:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #cbd5e1;
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  --accent: #0284c7;
  --ok: #059669;
  --danger: #dc2626;
  --text: #0f172a;
  --text-muted: #475569;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.55; padding: 20px 16px; }
.container { max-width: 1480px; margin: 0 auto; }
a { color: var(--primary); }

/* ---- 共通ヘッダー・フッター ---- */
header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--card-border); margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.header-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.portal-link { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; background: #0f172a; color: #fff; padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; font-family: ui-monospace, monospace; }
.logo { font-size: 1.25rem; font-weight: 800; }
.logo a { color: var(--text); text-decoration: none; }
.site-nav { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; font-weight: 700; }
.site-nav a { color: var(--text); text-decoration: none; }
.site-nav a:hover { color: var(--primary); }
.site-footer { padding: 28px 0 8px; color: var(--text); font-size: 0.82rem; border-top: 1px solid var(--card-border); margin-top: 40px; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 20px; }
.footer-cols h3 { font-size: 0.82rem; font-weight: 800; margin-bottom: 8px; }
.footer-cols ul { list-style: none; line-height: 1.9; }
.footer-cols a { color: var(--text); text-decoration: none; font-weight: 600; }
.footer-cols a:hover { color: var(--primary); text-decoration: underline; }
.copyright { text-align: center; font-weight: 600; }

/* ---- 広告枠（プレースホルダ）: 広告ユニットのコードを入れるまでは何も表示しない ---- */
.ad-slot { margin: 24px 0; }
.ad-slot:empty { margin: 0; }

/* ---- シミュレーター ---- */
.hero-section { background: #fff; border: 1px solid var(--card-border); border-radius: 12px; padding: 20px 24px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.hero-title { font-size: 1.35rem; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.3px; }
.hero-lead { font-size: 1rem; font-weight: 600; line-height: 1.75; margin-bottom: 10px; }
.hero-desc { font-size: 0.86rem; line-height: 1.75; font-weight: 500; margin-bottom: 14px; color: #1e293b; }
.hero-desc strong { color: var(--primary); font-weight: 700; }
.hero-links { margin-top: 12px; font-size: 0.88rem; font-weight: 700; }
.feature-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tech-tag { background: #f8fafc; border: 1px solid var(--card-border); font-size: 0.75rem; font-weight: 600; padding: 4px 10px; border-radius: 6px; font-family: ui-monospace, monospace; }
.tech-tag span { color: var(--primary); font-weight: 700; margin-right: 4px; }

.mode-tab-bar { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 2px solid var(--card-border); padding-bottom: 2px; flex-wrap: wrap; }
.tab-btn { padding: 10px 18px; font-size: 0.9rem; font-weight: 800; border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0; background: #e2e8f0; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tab-btn:hover { background: #cbd5e1; color: var(--text); }
.tab-btn.active { background: #fff; color: var(--primary); border-color: var(--card-border); border-bottom: 3px solid var(--primary); margin-bottom: -2px; }
.tab-badge { font-size: 0.7rem; padding: 1px 6px; border-radius: 10px; background: rgba(37, 99, 235, 0.15); color: var(--primary); }

.grid { display: grid; grid-template-columns: 480px 1fr; gap: 20px; }
@media (max-width: 1180px) { .grid { grid-template-columns: 1fr; } }
.grid > *, .theory-grid > * { min-width: 0; }

.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px; padding: 18px; box-shadow: var(--shadow-sm); }
h2 { font-size: 0.92rem; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
h2::before { content: ""; display: inline-block; width: 4px; height: 14px; background: var(--primary); border-radius: 2px; }

.control-group { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid #f1f5f9; }
.label-row { display: flex; justify-content: space-between; gap: 8px; font-size: 0.82rem; font-weight: 700; margin-bottom: 6px; }
.val-display { font-family: ui-monospace, monospace; color: var(--primary); font-weight: 800; }
select, input[type="number"] { width: 100%; background: #fff; border: 1px solid var(--card-border); color: var(--text); padding: 7px 10px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; outline: none; }
select:focus, input[type="number"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.slider-row { display: flex; gap: 10px; align-items: center; }
input[type="range"] { flex: 1; accent-color: var(--primary); cursor: pointer; height: 6px; }
.hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 700; margin-bottom: 8px; cursor: pointer; }

.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.btn { background: #f1f5f9; border: 1px solid var(--card-border); color: var(--text); padding: 6px 12px; border-radius: 6px; font-size: 0.78rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.btn:hover { background: var(--primary-light); border-color: var(--primary-border); color: var(--primary); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: #1d4ed8; }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { background: #fef2f2; border-color: #fecaca; color: var(--danger); padding: 3px 6px; font-size: 0.7rem; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.wide { width: 100%; justify-content: center; padding: 9px; font-size: 0.85rem; }

.math-line { font-size: 0.75rem; margin-bottom: 6px; overflow-x: auto; }
.matrix-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 8px; border: 1px solid var(--card-border); border-radius: 6px; background: #fff; }
table.matrix-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; font-family: ui-monospace, monospace; }
table.matrix-table th { background: #f1f5f9; padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--card-border); border-right: 1px solid var(--card-border); font-weight: 700; white-space: nowrap; }
table.matrix-table td { border-bottom: 1px solid var(--card-border); border-right: 1px solid var(--card-border); padding: 4px; text-align: center; }
table.matrix-table tr:last-child td { border-bottom: none; }
table.matrix-table td.row-head { font-weight: bold; background: #f8fafc; }
table.matrix-table input.param-input { width: 58px; padding: 4px 2px; border: 1px solid #cbd5e1; border-radius: 4px; background: #f8fafc; text-align: center; font-family: ui-monospace, monospace; font-size: 0.78rem; font-weight: 700; }

.canvas-container { position: relative; width: 100%; height: 580px; background: #fff; border: 1px solid var(--card-border); border-radius: 8px; overflow: hidden; }
canvas.viewport-canvas { width: 100%; height: 100%; display: block; }
.canvas-stats { position: absolute; bottom: 10px; left: 12px; background: rgba(255, 255, 255, 0.92); border: 1px solid var(--card-border); padding: 4px 10px; border-radius: 6px; font-family: ui-monospace, monospace; font-size: 0.75rem; font-weight: 700; }
@media (max-width: 600px) { .canvas-container { height: 380px; } }

.transform-legend-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 0.75rem; font-weight: 700; font-family: ui-monospace, monospace; }
.legend-chip { display: flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 4px; background: #f1f5f9; border: 1px solid var(--card-border); }
.legend-color-box { width: 10px; height: 10px; border-radius: 2px; }

.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.metric-card { background: #f8fafc; border: 1px solid var(--card-border); border-radius: 8px; padding: 10px; text-align: center; }
.metric-title { font-size: 0.72rem; font-weight: 700; }
.metric-val { font-size: 1.15rem; font-weight: 800; margin-top: 2px; font-family: ui-monospace, monospace; }
.metric-sub { font-size: 0.7rem; color: var(--primary); font-weight: 600; margin-top: 1px; }
.dim-note { font-size: 0.78rem; margin-top: 10px; color: #334155; }
.dim-note a { font-weight: 700; margin-left: 6px; }

details.dim-detail, details.export-box { margin-top: 14px; border: 1px solid var(--card-border); border-radius: 8px; background: #f8fafc; }
details > summary { cursor: pointer; padding: 10px 14px; font-size: 0.85rem; font-weight: 800; }
.dim-detail-body, .export-box > :not(summary) { padding: 0 14px 12px; }
.dim-detail-body { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.dim-detail-body .note { flex: 1 1 240px; }
.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; font-size: 0.8rem; font-weight: 700; }
.export-grid label:not(.check) { display: flex; flex-direction: column; gap: 4px; }
.export-grid label.check { grid-column: 1 / -1; margin: 0; }
.share-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--card-border); }
.share-msg { font-size: 0.78rem; font-weight: 700; color: var(--ok); }
svg.loglog { max-width: 100%; height: auto; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; }
.note { font-size: 0.8rem !important; color: #334155; line-height: 1.7; }

.mode-panel { display: none; }
.mode-panel.active { display: block; }

.theory-section { margin-top: 28px; }
.theory-title { font-size: 1.2rem; }
.theory-intro { font-size: 0.9rem; font-weight: 500; margin-bottom: 16px; line-height: 1.7; }
.theory-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.theory-card { background: #fff; border: 1px solid var(--card-border); border-radius: 10px; padding: 18px; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.theory-grid .theory-card { margin-bottom: 0; }
.theory-card h3 { font-size: 1rem; font-weight: 800; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid #e2e8f0; }
.theory-card p { font-size: 0.88rem; margin-bottom: 10px; line-height: 1.75; }
.theory-card ul { font-size: 0.86rem; margin-left: 18px; margin-bottom: 10px; line-height: 1.7; }
.math-box { background: #f8fafc; border: 1px solid var(--card-border); border-radius: 8px; padding: 12px; margin: 12px 0; font-size: 0.92rem; text-align: center; overflow-x: auto; }
.math-box .katex-display { overflow-x: auto; overflow-y: hidden; }

/* ---- 静的ページ ---- */
.page { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; padding: 28px 24px; box-shadow: var(--shadow-sm); max-width: 980px; margin: 0 auto; }
.page h1 { font-size: 1.5rem; font-weight: 800; line-height: 1.4; margin-bottom: 14px; }
.page h2 { margin-top: 32px; margin-bottom: 12px; font-size: 1.1rem; }
.page p, .page li { font-size: 0.92rem; line-height: 1.85; }
.page p { margin-bottom: 12px; }
.page ul, .page ol { padding-left: 1.4em; margin-bottom: 12px; }
.lead { font-size: 0.95rem; }
.crumbs { font-size: 0.78rem; margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 4px; list-style: none; padding: 0 !important; }
.crumbs li:not(:last-child)::after { content: "›"; margin-left: 6px; color: #94a3b8; }
.crumbs a { color: var(--text); }
.hero-figure { text-align: center; margin: 10px 0 16px; }
.hero-figure img { width: 100%; max-width: 560px; height: auto; border: 1px solid #e2e8f0; border-radius: 10px; }
.cta { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.cta .btn { font-size: 0.9rem; padding: 10px 16px; }
.facts { list-style: none; padding: 0 !important; display: flex; gap: 8px 20px; flex-wrap: wrap; font-weight: 700; font-size: 0.88rem; }
.step-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 600px) { .step-grid { grid-template-columns: repeat(2, 1fr); } }
.step-grid figure { margin: 0; text-align: center; }
.step-grid img { width: 100%; height: auto; border: 1px solid #e2e8f0; border-radius: 8px; }
.step-grid figcaption { font-size: 0.8rem; font-weight: 700; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px 0 18px; border: 1px solid var(--card-border); border-radius: 8px; max-width: 100%; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
.table-wrap th, .table-wrap td { padding: 8px 10px; border-bottom: 1px solid #e2e8f0; text-align: left; }
.table-wrap thead th { background: #f1f5f9; font-weight: 800; white-space: nowrap; }
.table-wrap tbody th { white-space: nowrap; }
.table-wrap td.num { font-family: ui-monospace, monospace; white-space: nowrap; text-align: right; }
.table-wrap tbody tr:last-child td, .table-wrap tbody tr:last-child th { border-bottom: none; }
.figure-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.figure-row > .figure { flex: 0 1 320px; }
.figure-row > .table-wrap { flex: 1 1 240px; margin-top: 0; }
.thumb-list { list-style: none; padding: 0 !important; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.thumb-list a { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 0.85rem; border: 1px solid var(--card-border); border-radius: 8px; padding: 8px; background: #fff; height: 100%; }
.thumb-list a:hover { border-color: var(--primary); }
.thumb-list img { width: 100%; height: auto; border-radius: 4px; }
.thumb-list small { font-weight: 500; font-size: 0.75rem; color: #334155; line-height: 1.5; }
.pending { background: #fffbeb; border: 1px dashed #f59e0b; border-radius: 8px; padding: 12px 14px; font-size: 0.85rem; }
@media (max-width: 480px) {
  body { padding: 16px 12px; }
  .page { padding: 20px 14px; }
  .page h1 { font-size: 1.2rem; }
  .card { padding: 14px; }
  .hero-section { padding: 16px; }
}
