:root {
  --navy: #082a5e;
  --navy-2: #0d3979;
  --blue: #1976d2;
  --teal: #087f6b;
  --ink: #12233f;
  --muted: #64748b;
  --line: #dce4ee;
  --soft: #f4f7fb;
  --paper: #ffffff;
  --amber: #a65305;
  --amber-bg: #fff8ed;
  --green: #188653;
  --red: #c34a1d;
  --shadow: 0 10px 30px rgba(15, 38, 70, 0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: #fbfcfe; color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { color: var(--blue); display: block; font-size: .69rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.quiet { color: var(--muted); font-size: .76rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; background: var(--paper); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 7px 25px; text-decoration: none; border-bottom: 1px solid var(--line); }
.brand-mark { width: 42px; height: 42px; border: 1.5px solid #3491eb; border-radius: 50%; display: grid; place-items: center; color: var(--navy); font-weight: 900; }
.brand strong { display: block; font-size: 1.45rem; line-height: 1; letter-spacing: -.04em; }
.brand small { color: var(--blue); display: block; font-weight: 700; margin-top: 4px; }
.sidebar nav { display: grid; gap: 6px; padding-top: 18px; }
.nav-link { display: flex; align-items: center; gap: 14px; padding: 13px 14px; border-radius: 8px; color: #36506f; font-weight: 700; text-decoration: none; }
.nav-link span { color: #8ba0b8; font-size: .68rem; letter-spacing: .08em; }
.nav-link.active { background: var(--navy); color: white; }
.nav-link.active span { color: #9ec3f5; }
.sidebar-note { margin-top: auto; padding: 16px 10px 4px; }
.sidebar-note p { color: var(--navy); font-weight: 750; line-height: 1.55; }
.sidebar-note small { color: var(--muted); }

main { min-width: 0; padding: 26px 28px 12px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.page-header h1 { margin: 4px 0 3px; font-size: clamp(1.8rem, 3vw, 2.35rem); letter-spacing: -.045em; color: var(--navy); }
.page-header p { margin: 0; color: var(--muted); }
.warning-badge { border: 1px solid #f0a23b; background: var(--amber-bg); color: var(--amber); padding: 13px 17px; border-radius: 8px; font-weight: 800; font-size: .84rem; }

.control-panel { display: grid; grid-template-columns: minmax(170px, 1.05fr) minmax(150px, .7fr) minmax(250px, 1.2fr) minmax(170px, .8fr); gap: 20px; align-items: end; padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.control-panel label, .control-panel legend { color: #183458; display: grid; gap: 8px; font-size: .78rem; font-weight: 800; }
.control-panel input[type="date"], .control-panel select { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid #bdcad9; border-radius: 7px; background: white; color: var(--ink); }
.control-panel fieldset { padding: 0; border: 0; margin: 0; min-width: 0; }
.control-panel legend { margin-bottom: 8px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; height: 46px; border: 1px solid #bdcad9; border-radius: 7px; padding: 3px; }
.segmented label { display: block; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { height: 38px; display: grid; place-items: center; border-radius: 5px; color: #42546b; font-weight: 700; }
.segmented input:checked + span { color: white; background: var(--navy); }
.segmented b { display: inline; font-weight: 600; }
#run-button { min-height: 46px; border: 0; border-radius: 7px; background: var(--navy); color: white; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; font-weight: 800; cursor: pointer; box-shadow: 0 6px 16px rgba(8, 42, 94, .16); }
#run-button:hover { background: var(--navy-2); }
#run-button:disabled { cursor: wait; opacity: .65; }

.status-strip { margin: 14px 0; border: 1px solid #d0e2f0; background: #f7fbff; border-radius: 8px; display: grid; grid-template-columns: 1fr 1fr; }
.status-strip > div { display: flex; align-items: center; gap: 10px; padding: 11px 16px; font-size: .78rem; }
.status-strip > div + div { border-left: 1px solid #d0e2f0; background: #f6fcf8; }
.status-strip span:last-child { color: var(--muted); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status-dot.blue { background: var(--blue); }
.status-dot.green { background: var(--green); }
.error-banner { margin: 14px 0; padding: 15px 18px; border: 1px solid #efb49f; border-radius: 8px; background: #fff7f3; color: #8f3515; font-weight: 700; }

.results { display: grid; gap: 14px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.taf-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 190px; gap: 14px; }
.taf-card { padding: 16px; min-width: 0; }
.card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 11px; }
.card-heading h2, .lineage-card h2 { margin: 2px 0 0; color: var(--navy); font-size: 1rem; }
.card-heading h2 small { color: var(--muted); font-size: .72rem; font-weight: 600; }
.chip { border-radius: 5px; padding: 4px 7px; font-size: .68rem; font-weight: 800; }
.blue-chip { color: #0d61b8; background: #e8f3ff; border: 1px solid #bfddfb; }
pre { white-space: pre-wrap; word-break: break-word; min-height: 118px; margin: 0; padding: 14px; background: #fbfcfe; border: 1px solid #d5deea; border-radius: 7px; color: #152033; font: 600 .81rem/1.65 "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: .72rem; margin-top: 9px; }
.text-button { padding: 4px 7px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-weight: 800; }
.similarity-card { display: grid; place-items: center; align-content: center; text-align: center; padding: 15px; }
.similarity-card h2 { margin: 8px 0 3px; color: var(--navy); font-size: .9rem; }
.similarity-card p { color: var(--muted); margin: 0; font-size: .72rem; }
.similarity-ring { --score: 0; width: 94px; height: 94px; border-radius: 50%; margin-top: 13px; display: grid; place-items: center; background: conic-gradient(var(--blue) calc(var(--score) * 1%), #e5ebf1 0); position: relative; }
.similarity-ring::after { content: ""; position: absolute; inset: 10px; background: white; border-radius: 50%; }
.similarity-ring strong { position: relative; z-index: 1; color: var(--navy); font-size: 1.35rem; }

.timeline-card { padding: 16px; overflow: hidden; }
.timeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; }
.timeline-column { min-width: 0; }
.timeline-column + .timeline-column { border-left: 1px solid var(--line); }
.timeline-time { padding: 10px 12px; background: var(--soft); border-bottom: 1px solid var(--line); color: var(--navy); font-size: .76rem; font-weight: 850; }
.timeline-value { padding: 9px 12px; min-height: 42px; border-bottom: 1px solid #edf1f5; }
.timeline-value:last-child { border-bottom: 0; }
.timeline-value small { display: block; color: var(--muted); font-size: .61rem; text-transform: uppercase; letter-spacing: .06em; }
.timeline-value strong { display: block; margin-top: 3px; color: #253b59; font-size: .76rem; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(270px, .65fr); gap: 14px; }
.differences-card, .lineage-card { padding: 16px; min-width: 0; }
.legend { display: flex; gap: 15px; font-size: .7rem; }
.legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; }
.legend .match::before { background: var(--green); }
.legend .changed::before { background: var(--red); }
.legend .unavailable::before { background: #aab5c2; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .75rem; }
th { background: var(--soft); color: #49617e; text-align: left; font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; }
th, td { padding: 9px 10px; border-bottom: 1px solid #e7edf3; }
.state { display: inline-block; padding: 3px 7px; border-radius: 4px; font-weight: 800; text-transform: capitalize; }
.state.match { background: #eaf8f1; color: var(--green); }
.state.changed { background: #fff0e9; color: var(--red); }
.state.unavailable { background: #eef2f5; color: #697687; }
.mode-guide { margin: -4px 2px 14px; color: #697687; font-size: 12px; }
.lineage-card dl { margin: 12px 0 0; }
.lineage-card dl > div { padding: 9px 0; border-bottom: 1px solid #e7edf3; }
.lineage-card dt { color: var(--muted); font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; }
.lineage-card dd { margin: 4px 0 0; color: #203754; font-size: .75rem; font-weight: 700; overflow-wrap: anywhere; }
.limitations { border: 1px solid #f0c181; background: var(--amber-bg); border-radius: 10px; padding: 16px 18px; display: grid; grid-template-columns: 220px 1fr; gap: 20px; }
.limitations h2 { color: #6f3b09; margin: 3px 0 0; font-size: 1rem; }
.limitations ul { margin: 0; padding-left: 18px; color: #714718; font-size: .75rem; line-height: 1.6; }
footer { display: flex; justify-content: flex-end; gap: 20px; color: #8291a5; font-size: .66rem; padding: 14px 4px 0; }

.methodology-page { max-width: 1450px; }
.method-hero { border: 1px solid var(--line); border-radius: 12px; background: white; padding: clamp(22px, 4vw, 42px); box-shadow: var(--shadow); }
.lead { max-width: 900px; margin: 0; color: #304966; font-size: 1.08rem; line-height: 1.75; }
.metric-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 28px 0 15px; }
.metric-row div { background: white; padding: 19px; }
.metric-row strong { display: block; color: var(--navy); font-size: 1.65rem; letter-spacing: -.04em; }
.metric-row span { display: block; color: var(--muted); font-size: .7rem; line-height: 1.4; margin-top: 4px; }
.metric-caveat { margin: 0; color: #795017; background: var(--amber-bg); border-left: 3px solid #d78921; padding: 12px 14px; font-size: .77rem; line-height: 1.55; }
.method-layout { display: grid; grid-template-columns: 215px minmax(0, 820px); justify-content: center; gap: 48px; padding: 42px 0; }
.method-toc { position: sticky; top: 22px; align-self: start; display: grid; }
.method-toc a { padding: 10px 0; border-bottom: 1px solid var(--line); color: #536981; text-decoration: none; font-size: .75rem; font-weight: 700; }
.method-toc a:hover { color: var(--blue); }
.method-content section { scroll-margin-top: 20px; padding: 8px 0 38px; }
.section-number { color: var(--blue); font-size: .72rem; font-weight: 850; letter-spacing: .1em; }
.method-content h2 { color: var(--navy); font-size: 1.42rem; letter-spacing: -.025em; margin: 6px 0 13px; }
.method-content p, .check-list { color: #425771; font-size: .89rem; line-height: 1.75; }
.callout { margin-top: 18px; padding: 16px 18px; border: 1px solid #cbdff2; background: #f6faff; border-radius: 8px; }
.callout strong { color: var(--navy); }
.callout p { margin: 4px 0 0; font-size: .78rem; }
.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; align-items: center; gap: 8px; margin: 22px 0; }
.flow div { min-height: 84px; border: 1px solid var(--line); background: white; border-radius: 7px; padding: 13px; }
.flow b { display: block; color: var(--navy); font-size: .76rem; }
.flow span { display: block; color: var(--muted); margin-top: 6px; font-size: .65rem; line-height: 1.4; }
.flow i { color: var(--blue); font-style: normal; }
.split-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.split-grid div { border-top: 3px solid var(--blue); background: white; padding: 15px; box-shadow: var(--shadow); }
.split-grid strong, .split-grid span { display: block; }
.split-grid strong { color: var(--navy); }
.split-grid span { color: var(--muted); margin-top: 5px; font-size: .72rem; }
.check-list li { margin-bottom: 7px; }
.source-list { list-style: none; padding: 0; }
.source-list li { display: grid; grid-template-columns: minmax(200px, 1fr) 1.4fr; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.source-list a { color: var(--blue); font-size: .8rem; font-weight: 800; }
.source-list span { color: var(--muted); font-size: .75rem; }
.repo-note code { color: var(--navy); background: #edf3f8; padding: 2px 4px; border-radius: 3px; }

@media (max-width: 1100px) {
  .control-panel { grid-template-columns: 1fr 1fr; }
  .taf-grid { grid-template-columns: 1fr 1fr; }
  .similarity-card { grid-column: 1 / -1; grid-template-columns: auto auto auto; gap: 18px; }
  .similarity-ring { margin: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 12px 16px; display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .brand { border: 0; padding: 0; }
  .sidebar nav { display: flex; padding: 0; }
  .nav-link { padding: 10px; }
  .nav-link span, .sidebar-note { display: none; }
  main { padding: 18px 14px 8px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .control-panel, .taf-grid, .status-strip, .limitations { grid-template-columns: 1fr; }
  .status-strip > div + div { border-left: 0; border-top: 1px solid #d0e2f0; }
  .similarity-card { grid-column: auto; grid-template-columns: 1fr; }
  .method-layout { display: block; padding-top: 25px; }
  .method-toc { position: static; margin-bottom: 28px; }
  .metric-row, .split-grid { grid-template-columns: 1fr; }
  .flow { grid-template-columns: 1fr; }
  .flow i { transform: rotate(90deg); text-align: center; }
  .source-list li { grid-template-columns: 1fr; gap: 5px; }
  footer { justify-content: flex-start; flex-wrap: wrap; }
}
