/* R0 research app. Tool-like, card images first, restrained borders (PRD 29.3 / 29.6). */
:root {
  --bg: #f5f6f8; --surface: #fff; --surface-2: #f9fafb; --ink: #1c2737; --muted: #5f6b7b; --line: #e3e7ed; --line-strong: #cfd6de;
  --accent: #256d66; --accent-ink: #1b5e58; --accent-soft: #e9f4f0; --warn: #8f5a1f; --warn-soft: #faf4e8; --warn-line: #e7dcc8;
  --danger: #a63d3d; --good: #2c7a4b; --radius: 12px; --shadow: 0 10px 35px #1627370d; --focus: #4caca2;
  --top: 64px; --gutter: 24px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.6 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-synthesis: none; }
body.has-tray { padding-bottom: 88px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }
h1, h2, h3, p, dl, dd, figure { margin: 0; }
h1 { font-size: 28px; line-height: 1.3; letter-spacing: -.5px; font-weight: 650; }
h2 { font-size: 20px; font-weight: 630; }
h3, .h3 { font-size: 16px; font-weight: 620; }
.h-sub { font-size: 18px; font-weight: 500; }
.muted { color: var(--muted); } .small { font-size: 12px; } .good { color: var(--good); } .warn-text { color: var(--warn); }
.num { font-variant-numeric: tabular-nums; } .strong { font-weight: 650; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; top: -80px; left: 16px; background: #fff; padding: 12px; z-index: 300; border-radius: 8px; }
.skip:focus { top: 8px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.container { max-width: 1408px; margin: 0 auto; padding: 0 var(--gutter); }
.page { padding-top: 24px; padding-bottom: 64px; min-height: 60vh; }
.boot, .noscript { padding: 80px 0; text-align: center; color: var(--muted); }

/* C01 AppShell */
.topbar { height: var(--top); background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.top-inner { height: 100%; display: flex; align-items: center; gap: 36px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; white-space: nowrap; }
.brand-mark { width: 32px; height: 32px; background: var(--ink); color: #fff; display: grid; place-items: center; border-radius: 8px; transform: rotate(-6deg); }
.brand-mark .icon { width: 20px; height: 20px; }
.nav { display: flex; gap: 26px; height: 100%; }
.nav a { display: flex; align-items: center; gap: 6px; height: 100%; border-bottom: 3px solid transparent; padding-top: 3px; color: #56616f; white-space: nowrap; }
.nav a.active { color: var(--accent); border-color: var(--accent); font-weight: 650; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 650; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip-status { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip-status.offline { background: var(--surface-2); }
.menu-btn, .mobile-only { display: none; }
.mode-bar { border-bottom: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 12px; }
.mode-bar strong { color: var(--accent); }
.mode-bar.demo { background: #eef1fb; border-color: #d8def2; color: #3b4a7a; }
.mode-inner { min-height: 36px; display: flex; gap: 12px; align-items: center; justify-content: space-between; padding-top: 6px; padding-bottom: 6px; }

/* buttons & fields */
.btn { min-height: 42px; padding: 9px 15px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 560; line-height: 1.35; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #b4c4c0; background: #f8fbfa; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-ink); color: #fff; }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.iconbtn { padding: 10px; min-width: 44px; min-height: 44px; }
.btn.compact { min-height: 36px; padding: 6px 11px; font-size: 12px; }
.linkbtn { background: none; border: 0; padding: 4px 2px; min-height: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; font-size: 12px; }
.textbutton { color: var(--accent); font-weight: 600; font-size: 13px; padding: 10px 2px; min-height: 44px; }
.field { display: block; margin-bottom: 16px; }
.field > span, .field-label { display: block; font-size: 12px; font-weight: 620; margin-bottom: 7px; color: #4f5b6b; }
.field.flush { margin: 0; }
.field input, .field select, .field textarea, .select, .search-input { display: block; width: 100%; border: 1px solid #d6dde4; border-radius: 7px; background: #fff; padding: 9px 11px; min-height: 42px; }
.field textarea { resize: vertical; min-height: 72px; }
.field input:invalid { border-color: var(--danger); }
.hint { display: block; margin-top: 6px; font-weight: 400; font-size: 12px; line-height: 1.5; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.tag { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 2px 8px; font-size: 12px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag.neutral { background: #eef1f4; color: #4f5b6b; }
.tag .icon { width: 13px; height: 13px; }
.level { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.level.D2 { background: var(--accent-soft); color: var(--accent); }
.level.D1 { background: #eaf0fb; color: #33558f; }
.level.limited { background: var(--warn-soft); color: var(--warn); }
.level.D0, .level.unselected { background: #eef1f4; color: #5b6573; }
.notice { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 11px 14px; font-size: 13px; color: #465262; margin-bottom: 16px; }
.notice.warn { border-color: var(--warn-line); background: var(--warn-soft); color: #6f5230; }
.notice.good { border-color: #cfe5d7; background: #eef7f1; color: var(--good); }
.notice .btn { margin-left: 8px; }

/* page head */
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.breadcrumb .icon { width: 13px; height: 13px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.pagehead p { margin-top: 6px; color: var(--muted); }
.pagehead .tag { margin-bottom: 8px; }
.pagehead-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* L02 layout */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.sidebar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 18px; position: sticky; top: calc(var(--top) + 16px); max-height: calc(100vh - var(--top) - 32px); overflow: auto; }
.side-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.filter-actions { display: grid; gap: 8px; }
.filter-status { color: var(--warn); font-size: 12px; margin-top: 10px; min-height: 1em; }
.result-panel { min-width: 0; }
.searchbox { position: relative; display: flex; gap: 10px; margin-bottom: 14px; }
.searchbox > .icon { position: absolute; top: 14px; left: 14px; color: var(--muted); }
.search-input { padding-left: 42px; min-height: 46px; }
.cohort-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.cohort-quick > span { margin-right: 4px; }
.pill { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 13px; min-height: 36px; font-size: 13px; }
.pill.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.resultbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.result-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.select { width: auto; min-height: 40px; padding-right: 26px; }
.segmented { display: inline-flex; background: #e9edf1; padding: 3px; border-radius: 8px; }
.segmented button { min-height: 36px; padding: 5px 12px; border-radius: 6px; font-size: 13px; display: flex; align-items: center; gap: 6px; color: #5d6876; }
.segmented button.active { background: #fff; color: var(--ink); font-weight: 620; box-shadow: 0 1px 3px #1627371f; }
.segmented.wide { display: flex; width: 100%; }
.segmented.wide button { flex: 1; justify-content: center; }
.mobile-filter { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid #d5e5df; background: var(--accent-soft); color: var(--accent); border-radius: 7px; padding: 4px 8px; font-size: 12px; min-height: 30px; }
.chip .icon { width: 12px; height: 12px; }
.endnote { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }

/* C05 cards */
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.card-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; transition: box-shadow .15s, border-color .15s; }
.card-item:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.card-image-link { display: block; padding: 14px 14px 0; background: linear-gradient(#f2f4f7, #fff); }
.card-body { padding: 12px 14px 4px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.card-title { font-weight: 650; font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 12px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.card-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.card-price { margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.card-price small { display: block; font-size: 11px; color: var(--muted); }
.card-price strong { font-size: 17px; }
.card-price > small { text-align: right; }
.card-price.empty small { color: var(--muted); }
.card-footer { display: flex; justify-content: space-between; align-items: center; padding: 0 14px 4px; gap: 8px; min-height: 48px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; min-height: 44px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

/* card art: 5:7 container, contain, never crop numbers */
.art { aspect-ratio: 5 / 7; width: 100%; display: grid; place-items: center; }
.art img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 14px #16273726); }
.art.placeholder { background: repeating-linear-gradient(135deg, #eef2f0 0 10px, #e7ece9 10px 20px); border: 1px solid #d7dfdb; border-radius: 10px; grid-template-rows: auto 1fr auto; padding: 10px; color: #4f6159; place-items: stretch; }
.ph-top { font-size: 10px; letter-spacing: 1.5px; }
.ph-num { align-self: center; justify-self: center; font: 600 40px/1 Georgia, serif; }
.ph-name { font-size: 12px; font-weight: 650; }
.ph-name small { display: block; font-weight: 400; font-size: 10px; }
.art.mini { width: 44px; flex: none; }
.art.mini.placeholder, .art.thumb.placeholder { padding: 3px; }
.art.mini .ph-top, .art.mini .ph-name, .art.thumb .ph-top, .art.thumb .ph-name { display: none; }
.art.mini .ph-num, .art.thumb .ph-num { font-size: 14px; }
.art.thumb { width: 54px; }
.art.large { max-width: 400px; margin: 0 auto; }
.art.zoomed { max-width: min(520px, 100%); margin: 0 auto; }

/* research table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.research-table, .records, .compare-table { width: 100%; border-collapse: collapse; }
.research-table th, .research-table td, .records th, .records td, .compare-table th, .compare-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.research-table th, .records th { font-size: 12px; font-weight: 620; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.research-table tr:last-child td, .records tr:last-child td { border-bottom: 0; }
.mini-identity { display: flex; gap: 10px; align-items: flex-start; min-width: 240px; }
.mini-identity small { display: block; color: var(--muted); font-size: 12px; line-height: 1.45; }
.row-actions { white-space: nowrap; }
.row-actions .check, .row-actions .textbutton { display: flex; min-height: 36px; padding: 4px 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 18px; }
.skeleton { background: linear-gradient(90deg, #eceff3, #f7f8fa, #eceff3); background-size: 200% 100%; animation: sh 1.2s linear infinite; border-radius: var(--radius); height: 260px; display: grid; place-items: center; color: var(--muted); }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition: none !important; } }
.empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 44px 20px; text-align: center; display: grid; justify-items: center; gap: 10px; }
.empty > .icon { width: 28px; height: 28px; color: var(--muted); }
.empty p { color: var(--muted); max-width: 520px; }
.empty.compact { padding: 22px 16px; }
.empty.failed { border-color: #e8c9c9; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.section-head { margin: 28px 0 14px; }
.section-head p { margin-top: 4px; }

/* L05 detail */
.detail-grid { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 24px; align-items: start; }
.detail-left { position: sticky; top: calc(var(--top) + 16px); }
.art-button { display: block; width: 100%; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: zoom-in; }
.caption { font-size: 12px; color: var(--muted); text-align: center; margin: 8px 0 14px; }
.actions { display: grid; gap: 8px; margin-bottom: 14px; }
.actions > .btn { width: 100%; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cohort-controls { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; }
.cohort-controls .field { margin: 0; }
.panel.condition { padding: 14px 16px; }
.mobile-condition { display: none; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.metric { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.metric .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.metric .value { font-size: 22px; font-weight: 650; margin: 2px 0; }
.metric .sub { font-size: 12px; color: var(--muted); line-height: 1.5; }
.metric.muted-box .value { color: #7a8594; font-size: 18px; }
.latest { font-size: 13px; margin-top: 12px; }
.chart-wrap { margin-top: 14px; }
.chart { width: 100%; height: auto; }
.chart text { font-size: 10px; fill: var(--muted); }
.chart .grid { stroke: var(--line); }
.chart circle { fill: var(--accent); fill-opacity: .75; }
.chart .band { fill: var(--accent); fill-opacity: .1; }
.chart .median { stroke: var(--accent); stroke-width: 2; }
.chart-note { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin-top: 14px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { font-weight: 560; overflow-wrap: anywhere; }
.facts dd small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.facts.inline { margin: 0; }
.story h3 { margin-bottom: 4px; }
.story p { color: #3e4a59; margin-bottom: 8px; }
.related { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.related-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.related-item small { display: block; color: var(--muted); font-size: 12px; }
.evidence-list { list-style: none; padding: 0; margin: 12px 0 18px; display: grid; gap: 10px; }
.evidence-list li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; }
.evidence-list a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.evidence-list small { color: var(--muted); }
.plain { padding-left: 18px; color: #465262; }
.zoom { padding: 8px; }

/* directories */
.dir-section { margin-bottom: 8px; }
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.dir-grid.compact { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.dir-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 24px 0; }
.dir-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; transition: box-shadow .15s; }
.dir-card:hover { box-shadow: var(--shadow); color: inherit; }
.dir-card .count { margin-top: auto; display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--accent); font-weight: 600; }
.dir-card .count .icon { width: 14px; height: 14px; }
.dir-card.entry .icon { width: 26px; height: 26px; color: var(--accent); }
.dir-thumbs { display: flex; gap: 6px; margin-bottom: 4px; }
.dir-card .tag { align-self: flex-start; }
.home-intro { padding: 36px 0 8px; max-width: 760px; }
.home-title { font-size: 34px; line-height: 1.3; margin-bottom: 10px; }
.home-search { margin-top: 22px; }
.featured { margin-top: 12px; }
.continue { margin-top: 12px; }
.capability-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.capability-strip p { grid-column: 1 / -1; }
.cap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; }
.cap strong { font-size: 22px; }
.cap span { font-size: 12px; color: var(--muted); }
.cap.D2 { border-top: 3px solid var(--accent); } .cap.D1 { border-top: 3px solid #33558f; } .cap.limited { border-top: 3px solid #c79a55; } .cap.D0 { border-top: 3px solid #aab3be; }
.market-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding-bottom: 2px; }
.market-controls .field { margin-bottom: 14px; }
.tools { margin-top: 20px; }
.tool-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tool-links a { border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-weight: 560; }

/* L07 / L08 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; border-bottom: 3px solid transparent; white-space: nowrap; color: #56616f; min-height: 44px; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 650; }
.plans-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.plan-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.plan-row small { display: block; color: var(--muted); font-size: 12px; }
.plan-row.draft { border-style: dashed; }
.saved-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.saved-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.saved-list small { display: block; color: var(--muted); }
.saved-list li > div:last-child { display: flex; gap: 4px; align-items: center; }
.plan-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.plan-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.plan-item.paused, .plan-item.excluded { background: var(--surface-2); }
.plan-item.excluded .plan-item-title h3 { text-decoration: line-through; color: var(--muted); }
.plan-item-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.plan-item-title { flex: 1; min-width: 0; }
.item-fields { display: grid; grid-template-columns: 110px 140px minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.item-fields .field { margin-bottom: 8px; }
.budget { position: sticky; top: calc(var(--top) + 16px); }
.budget-total { font-size: 26px; font-weight: 650; margin: 2px 0 10px; }
.budget-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; }
.budget .notice { margin: 14px 0 8px; }
.budget-actions { display: grid; gap: 8px; margin-top: 14px; }
.save-state { font-size: 12px; margin-top: 12px; color: var(--muted); }
.save-state.good { color: var(--good); } .save-state.error { color: var(--danger); } .save-state.warn { color: var(--warn); }
.save-state .btn { margin-top: 6px; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }

/* dialogs & tray */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 24px 80px #16273740; color: var(--ink); }
dialog.wide { width: min(980px, calc(100vw - 32px)); }
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; border-radius: 0; width: min(440px, 100vw); }
dialog::backdrop { background: #16273766; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.dialog-body { padding: 18px; }
.dialog-body > p { margin-bottom: 12px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.compare-table th[scope="col"] { vertical-align: bottom; min-width: 180px; }
.compare-table th[scope="col"] strong { display: block; margin-top: 6px; }
.compare-table th[scope="row"] { color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.comparebar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 60; width: min(760px, calc(100vw - 32px)); background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 12px 10px 18px; display: flex; align-items: center; gap: 10px; box-shadow: 0 16px 40px #16273755; }
.comparebar .summary { flex: 1; min-width: 0; font-size: 13px; }
.comparebar .names { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comparebar .btn.ghost { color: #fff; }
.comparebar .btn.ghost:hover { background: #ffffff1a; color: #fff; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 10px 16px; z-index: 400; transition: .2s; max-width: calc(100vw - 32px); font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.auth-form { display: grid; }
.app-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.app-footer a { text-decoration: underline; text-underline-offset: 3px; }

/* ≥1280 uses defaults. Medium 768–1279: filters become a drawer. */
@media (max-width: 1279px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .mobile-filter { display: inline-flex; }
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nav { gap: 18px; }
  .top-inner { gap: 22px; }
  .plan-layout { grid-template-columns: minmax(0, 1fr) 290px; }
  .item-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-left { position: static; }
  .art.large { max-width: 320px; }
  .desktop-condition { display: none; }
  .mobile-condition { display: block; }
  .plan-layout { grid-template-columns: minmax(0, 1fr); }
  .budget { position: static; }
  .card-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .market-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  :root { --top: 56px; }
  .nav { display: none; position: fixed; top: var(--top); left: 0; right: 0; bottom: 0; height: auto; background: #fff; flex-direction: column; gap: 0; padding: 8px 16px; z-index: 70; overflow: auto; }
  .nav.open { display: flex; }
  .nav a { height: auto; min-height: 52px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; padding: 0 12px; }
  .nav a.active { border-bottom-color: var(--line); border-left-color: var(--accent); }
  .menu-btn, .mobile-only { display: inline-flex; }
  .top-actions .chip-status { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 767px) {
  :root { --gutter: 16px; }
  h1 { font-size: 23px; }
  .home-title { font-size: 25px; }
  .pagehead { flex-direction: column; gap: 10px; margin-bottom: 16px; }
  .hide-mobile { display: none; }
  .card-grid, .card-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-image-link { padding: 10px 10px 0; }
  .card-body { padding: 10px 10px 2px; }
  .card-footer { padding: 0 10px 2px; flex-wrap: wrap; }
  .card-price { flex-direction: column; align-items: flex-start; }
  .card-price > small { text-align: left; }
  .resultbar { align-items: flex-start; }
  .result-controls .select { max-width: 150px; }
  .dir-grid.three { grid-template-columns: minmax(0, 1fr); }
  .capability-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics, .facts, .related, .cohort-controls { grid-template-columns: minmax(0, 1fr); }
  .market-controls { grid-template-columns: minmax(0, 1fr); }
  .item-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  /* Research table becomes summary rows; identity and basis stay visible. */
  .research-table thead { display: none; }
  .research-table, .research-table tbody, .research-table tr, .research-table td { display: block; width: 100%; }
  .research-table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .research-table td { border: 0; padding: 4px 12px; }
  .research-table td[data-col]::before { content: attr(data-col); display: block; font-size: 11px; color: var(--muted); }
  .mini-identity { min-width: 0; }
  .row-actions { display: flex !important; gap: 16px; }
  .searchbox .btn { padding: 9px 12px; }
  .comparebar { bottom: 8px; padding: 8px 8px 8px 12px; gap: 6px; }
  .comparebar .names { display: none; }
  .mode-inner { flex-wrap: wrap; }
  dialog.drawer { width: 100vw; }
}
@media (max-width: 359px) {
  .card-grid, .card-grid.four { grid-template-columns: minmax(0, 1fr); }
  .item-fields { grid-template-columns: minmax(0, 1fr); }
  .brand span:last-child { display: none; }
}

/* COL-004 not-now, registry notices */
.notnow { padding: 0 14px 10px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; min-height: 32px; }
.notnow .linkbtn { color: var(--muted); min-height: 32px; }
.notnow.on { color: var(--warn); }
.notnow.big { padding: 0 0 12px; justify-content: center; }
.notice.slim { padding: 7px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.radio-list { display: grid; gap: 4px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.check-row input { accent-color: var(--accent); width: 17px; height: 17px; }
.row-level { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.nav a.nav-sim::before { content: ''; width: 1px; height: 16px; background: var(--line-strong); margin-right: 12px; }
@media (max-width: 860px) { .nav a.nav-sim::before { display: none; } }

/* COL-002 match reasons */
.match { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 0 14px 8px; font-size: 11.5px; line-height: 1.5; }
.match .ok { color: var(--accent); }
.match .no { color: #7a6a52; }
.match.fail .no { color: var(--danger); }
/* C02 grouped suggestions */
.searchbox { position: relative; }
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 420px; overflow: auto; padding: 6px 0; text-align: left; }
.suggest-title { font-size: 11px; font-weight: 650; color: var(--muted); padding: 8px 14px 4px; }
.suggest-item { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; cursor: pointer; min-height: 40px; align-items: center; }
.suggest-item small { color: var(--muted); font-size: 12px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item:hover, .suggest-item[aria-selected="true"] { background: var(--accent-soft); }
/* COL-001 preference form */
.prefs-form h2 { margin: 22px 0 8px; }
.prefs-form h2:first-of-type { margin-top: 14px; }
.pref-group { border: 0; padding: 0; margin: 0 0 14px; }
.pref-group legend { font-size: 12px; font-weight: 620; color: #4f5b6b; margin-bottom: 8px; }
.pref-options { display: flex; flex-wrap: wrap; gap: 6px; }
.pref-pill { position: relative; }
.pref-pill input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.pref-pill span { display: inline-flex; align-items: center; min-height: 34px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; }
.pref-pill input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.pref-pill input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.pref-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.toggle { font-weight: 600; }
.inferred .saved-list li { background: var(--surface-2); }
@media (max-width: 767px) { .pref-row { grid-template-columns: minmax(0, 1fr); } .suggest-item small { max-width: 50%; } }
