:root {
  color-scheme: light dark;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #526074;
  --border: #d8e0ea;
  --navy: #0f4c81;
  --blue: #1565c0;
  --gold: #b7791f;
  --profit: #0f766e;
  --loss: #b4233a;
  --warning: #9a4d00;
  --shadow: 0 14px 34px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { overflow-x: hidden; scroll-behavior: smooth; }
body {
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: radial-gradient(circle at 10% 0, rgba(21, 101, 192, .1), transparent 28rem), var(--bg);
  font-family: "Segoe UI", "Hiragino Sans", Meiryo, sans-serif;
  line-height: 1.7;
}
a { color: inherit; }
button, input, select { font: inherit; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 8px 12px; color: #fff; background: #111827; transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.research-topbar { border-bottom: 1px solid rgba(15, 76, 129, .14); background: color-mix(in srgb, var(--surface) 94%, transparent); }
.research-topbar__inner, .research-shell { width: min(1220px, calc(100% - 32px)); min-width: 0; margin-inline: auto; }
.research-topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 68px; }
.research-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 900; text-decoration: none; }
.research-brand img { width: 42px; height: 42px; border-radius: 10px; object-fit: contain; }
.research-nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 16px; }
.research-nav a { color: var(--muted); font-size: .88rem; font-weight: 800; text-decoration: none; }
.research-nav a[aria-current="page"], .research-nav a:hover, .research-nav a:focus-visible { color: var(--navy); text-decoration: underline; }

.hero { padding: 42px 0 26px; }
.hero__panel { padding: clamp(25px, 5vw, 52px); color: #fff; background: linear-gradient(135deg, #092f52, #0f4c81 58%, #1565c0); border-radius: 28px; box-shadow: 0 22px 50px rgba(15, 76, 129, .24); }
.eyebrow { margin: 0 0 8px; color: #bae6fd; font-size: .78rem; font-weight: 900; letter-spacing: .12em; }
.hero h1 { max-width: 900px; margin: 0; overflow-wrap: anywhere; font-size: clamp(2rem, 5vw, 3.8rem); line-height: 1.08; }
.hero h1 span { display: block; margin-top: 10px; color: #dbeafe; font-size: clamp(1rem, 2.4vw, 1.45rem); font-weight: 700; }
.hero__lead { max-width: 820px; margin: 20px 0 0; color: #e2e8f0; font-size: clamp(.96rem, 1.6vw, 1.12rem); }
.disclaimer, .data-banner { margin: 16px 0 0; padding: 12px 15px; border-left: 4px solid var(--gold); color: var(--muted); background: var(--surface); border-radius: 0 12px 12px 0; }
.data-banner { border: 1px solid #f0c36a; border-left-width: 5px; background: #fff8e8; color: #6b3d00; font-weight: 800; }

.section { margin: 0 0 24px; padding: clamp(20px, 3vw, 34px); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; color: var(--navy); font-size: clamp(1.35rem, 2.6vw, 1.95rem); line-height: 1.25; }
.section-heading p { max-width: 720px; margin: 6px 0 0; color: var(--muted); }
h3 { color: var(--navy); }
.muted { color: var(--muted); }
.tag-row, .legend { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: var(--surface-soft); font-size: .78rem; font-weight: 800; }
.tag--safe { color: #075c51; border-color: #7bcabc; background: #ecfdf8; }
.tag--danger { color: #8f1830; border-color: #e8a4b2; background: #fff1f4; }
.tag--sample { color: #744200; border-color: #e8bd6a; background: #fff8e8; }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-size: .91rem; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--navy); background: var(--surface-soft); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }

.strategy-grid, .metric-grid, .glossary-grid, .link-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.strategy-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.strategy-card, .metric, .glossary-item, .link-card { min-width: 0; padding: 18px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 16px; }
.strategy-card h3, .glossary-item h3, .link-card h3 { margin: 0 0 7px; }
.strategy-card p, .glossary-item p, .link-card p { margin: 5px 0; }
.strategy-card--focus { border-color: #72a6d3; box-shadow: inset 0 4px 0 var(--blue); }
.strategy-card--danger { border-color: #e8a4b2; }
.link-card { display: block; text-decoration: none; }
.link-card:hover { border-color: var(--blue); }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr); gap: 20px; align-items: start; }
.definition-list { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 8px 14px; margin: 16px 0; }
.definition-list dt { color: var(--muted); font-weight: 800; }
.definition-list dd { margin: 0; }
.formula { padding: 14px 16px; overflow-x: auto; color: #dbeafe; background: #0b2944; border-radius: 12px; font-family: Consolas, monospace; white-space: pre-wrap; }
.warning-box { padding: 13px 15px; color: #7c2d12; background: #fff7ed; border: 1px solid #fdba74; border-radius: 12px; }

.simulator { padding: 18px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 5px; }
.field label { color: var(--muted); font-size: .82rem; font-weight: 800; }
.field input, .field select { width: 100%; min-height: 44px; padding: 9px 11px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.field input:focus, .field select:focus { outline: 3px solid rgba(21, 101, 192, .18); border-color: var(--blue); }
.input-suffix { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; min-width: 170px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; }
.input-suffix input { min-width: 0; border: 0; border-radius: 0; }
.input-suffix span { padding: 0 12px; color: var(--muted); font-weight: 900; }
.input-suffix:focus-within { outline: 3px solid rgba(21, 101, 192, .18); border-color: var(--blue); }
.input-suffix input:focus { outline: 0; }
.results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.result { padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.result span, .metric span { display: block; color: var(--muted); font-size: .75rem; font-weight: 800; }
.result strong, .metric strong { display: block; margin-top: 4px; font-size: clamp(1rem, 2vw, 1.35rem); }
.result--profit strong { color: var(--profit); }
.result--loss strong { color: var(--loss); }
.form-error { min-height: 1.5em; margin: 10px 0 0; color: var(--loss); font-weight: 800; }

.chart-card { min-width: 0; padding: 14px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 16px; }
.chart-card h3 { margin: 0 0 6px; font-size: 1rem; }
.chart-card canvas { display: block; width: 100%; max-width: 100%; background: var(--surface); border-radius: 10px; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.legend { margin: 8px 0; color: var(--muted); font-size: .78rem; }
.legend span::before { display: inline-block; width: 10px; height: 10px; margin-right: 5px; content: ""; background: var(--legend-color, #64748b); }

.manual-vi { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.verdict { margin-top: 14px; padding: 18px; background: #eef6ff; border: 1px solid #9fc5e8; border-radius: 14px; }
.verdict strong { display: block; color: var(--navy); font-size: 1.25rem; }
.vi-candidates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 16px 0 12px; }
.vi-candidate { padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.vi-candidate--top { border: 2px solid var(--gold); box-shadow: 0 5px 16px rgba(15, 76, 129, .1); }
.vi-candidate__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); }
.vi-candidate__head strong { color: var(--navy); font-size: 1.6rem; }
.vi-candidate h3 { margin: 8px 0; }
.vi-candidate p { margin: 8px 0 0; }
.vi-candidate__bar { height: 10px; overflow: hidden; background: #dbe7f1; border-radius: 999px; }
.vi-candidate__bar i { display: block; height: 100%; background: var(--navy); border-radius: inherit; }
.vi-candidate--top .vi-candidate__bar i { background: var(--gold); }
.verdict small { display: block; line-height: 1.65; color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; color: #fff; background: var(--navy); border: 0; border-radius: 10px; font-weight: 900; cursor: pointer; }
.button:hover { background: var(--blue); }
.button--secondary { color: var(--navy); background: var(--surface); border: 1px solid var(--border); }
.button--secondary:hover { color: #fff; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.decision-metrics { margin-top: 14px; }
.verdict--buy { background: #ecfdf8; border-color: #7bcabc; }
.verdict--buy strong { color: var(--profit); }
.verdict--skip { background: #fff1f4; border-color: #e8a4b2; }
.verdict--skip strong { color: var(--loss); }
.threshold-meter { height: 14px; margin-top: 16px; overflow: hidden; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 999px; }
.threshold-meter i { display: block; width: 0; height: 100%; border-radius: inherit; transition: width .2s ease; }
.threshold-meter__buy { background: var(--profit); }
.threshold-meter__skip { background: var(--loss); }

.checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.checklist h3 { margin-top: 0; }
.check-row { display: flex; gap: 9px; align-items: flex-start; padding: 7px 0; }
.check-row input { width: 20px; height: 20px; flex: 0 0 auto; }
.check-row label { cursor: pointer; }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.controls .field { min-width: 170px; }
.status { min-height: 1.6em; margin-top: 10px; color: var(--muted); font-weight: 700; }
.status--error { color: var(--loss); }
.trade-comment { max-width: 360px; }
.profit { color: var(--profit); font-weight: 900; }
.loss { color: var(--loss); font-weight: 900; }
.skip { color: var(--muted); font-weight: 900; }

.naked-compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; }
.naked-compare__arrow { color: var(--navy); font-size: 2rem; font-weight: 900; }
.risk-block { padding: 16px; border: 1px solid var(--border); border-radius: 14px; }
.risk-block strong { display: block; font-size: 1.15rem; }

.footer { width: min(1220px, calc(100% - 32px)); margin: 16px auto 0; padding: 24px 0 36px; color: var(--muted); text-align: center; }

@media (prefers-color-scheme: dark) {
  :root { --bg: #081321; --surface: #101e2f; --surface-soft: #15263a; --text: #e8eef7; --muted: #a8b6c9; --border: #30445c; --navy: #83baf0; --blue: #65aaf0; --gold: #e8b760; --profit: #72d5c4; --loss: #ff91a6; --warning: #f5b66d; --shadow: 0 14px 34px rgba(0, 0, 0, .25); }
  .hero__panel { background: linear-gradient(135deg, #071b2d, #0d3b64 58%, #155790); }
  .data-banner { color: #ffd98e; background: #37270e; border-color: #8d6523; }
  .tag--safe { color: #a9f1e4; border-color: #2f7f72; background: #123e38; }
  .tag--danger { color: #ffc0cc; border-color: #8f4051; background: #43222a; }
  .tag--sample { color: #ffda91; border-color: #8d6523; background: #37270e; }
  .warning-box { color: #ffd0aa; background: #3c2517; border-color: #8b5431; }
  .verdict { background: #102d48; border-color: #376d9c; }
  .verdict--buy { background: #123e38; border-color: #2f7f72; }
  .verdict--skip { background: #43222a; border-color: #8f4051; }
}

@media (max-width: 820px) {
  .research-topbar__inner { align-items: flex-start; flex-direction: column; padding-block: 12px; }
  .research-nav { justify-content: flex-start; }
  .detail-layout, .chart-grid { grid-template-columns: 1fr; }
  .strategy-grid, .strategy-grid--three, .metric-grid, .glossary-grid, .link-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .research-topbar__inner, .research-shell, .footer { width: auto; max-width: none; margin-right: 10px; margin-left: 10px; }
  .hero { padding-top: 20px; }
  .hero, .hero__panel, .section { width: 100%; max-width: 100%; min-width: 0; }
  .hero__panel, .section { border-radius: 16px; }
  .form-grid, .results, .manual-vi, .checklist, .vi-candidates { grid-template-columns: 1fr; }
  .definition-list { grid-template-columns: 1fr; gap: 2px; }
  .naked-compare { grid-template-columns: 1fr; }
  .naked-compare__arrow { transform: rotate(90deg); text-align: center; }
  .research-nav { display: grid; width: 100%; min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .research-nav a, .hero h1, .hero h1 span, .hero__lead, .data-banner, .disclaimer { min-width: 0; overflow-wrap: anywhere; word-break: break-all; }
}

@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --surface-soft: #fff; --text: #111; --muted: #444; --border: #aaa; --navy: #123c63; }
  body { background: #fff; }
  .research-topbar, .button, .controls, .checklist input { display: none !important; }
  .research-shell { width: 100%; }
  .hero { padding: 0 0 16px; }
  .hero__panel { color: #111; background: #fff; border: 2px solid #123c63; box-shadow: none; }
  .hero__lead, .eyebrow { color: #333; }
  .section { break-inside: avoid; box-shadow: none; }
  canvas { max-height: 260px; }
}
