:root {
  --navy: #1F3A5F;
  --teal: #2E7D9A;
  --gold: #E0A800;
  --bg: #F3F7FB;
  --surface: #FFFFFF;
  --surface-2: #F7F9FB;
  --text: #1B2430;
  --muted: #5A6672;
  --border: #DCE3EA;
  --accent: var(--teal);
  --accent-soft: #E3F1F6;
  --link: #22708C;
  --warn-bg: #FFF6DB;
  --warn-text: #6B5200;
  --header-bg: var(--navy);
  --header-text: #FFFFFF;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 2px 8px rgba(16, 32, 56, .05);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E151F; --surface: #16202D; --surface-2: #1B2736; --text: #E6ECF2; --muted: #9AA8B6;
    --border: #2A3949; --accent: #4FB0CF; --accent-soft: #17394A; --link: #7CC7E0;
    --warn-bg: #3A3010; --warn-text: #F2D477; --header-bg: #13243B; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E151F; --surface: #16202D; --surface-2: #1B2736; --text: #E6ECF2; --muted: #9AA8B6;
  --border: #2A3949; --accent: #4FB0CF; --accent-soft: #17394A; --link: #7CC7E0;
  --warn-bg: #3A3010; --warn-text: #F2D477; --header-bg: #13243B; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  display: flex; flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--header-bg); color: var(--header-text);
}
.brand { display: flex; align-items: center; gap: 8px; color: inherit; font-weight: 650; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { font-size: .68rem; font-weight: 500; opacity: .75; letter-spacing: .02em; }

/* Security Checkup call to action */
.cta-top {
  flex: none; padding: 7px 12px; border-radius: 8px; background: var(--gold); color: #1B2430;
  font-weight: 650; font-size: .88rem; white-space: nowrap;
}
.cta-top:hover { text-decoration: none; filter: brightness(1.06); }
@media (max-width: 900px) { .cta-top { display: none; } }
.cta-box {
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  margin: 22px 0; padding: 16px 18px; border-radius: var(--radius);
  background: var(--navy); color: #fff; box-shadow: var(--shadow);
  border-left: 5px solid var(--gold);
}
.cta-box h2 { margin: 0 0 4px; font-size: 1.05rem; color: #fff; text-transform: none; letter-spacing: 0; }
.cta-box p { margin: 0; font-size: .9rem; color: rgba(255,255,255,.85); max-width: 60ch; }
.cta-box .by { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); font-weight: 700; margin-bottom: 4px; }
.btn-cta {
  display: inline-block; padding: 10px 16px; border-radius: 8px; background: var(--gold); color: #1B2430;
  font-weight: 700; white-space: nowrap;
}
.btn-cta:hover { text-decoration: none; filter: brightness(1.06); }
.cta-box.compact { padding: 12px 14px; }
.cta-box.compact h2 { font-size: .95rem; }
.brandfoot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--muted); }
.search { flex: 1; min-width: 0; }
.search input {
  width: 100%; max-width: 460px; display: block; margin-left: auto;
  padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.12); color: #fff; font-size: 16px;
}
.search input::placeholder { color: rgba(255,255,255,.7); }
.search input:focus { outline: 2px solid var(--gold); background: rgba(255,255,255,.18); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }
@media (max-width: 560px) { .brand-text { display: none; } }

main { flex: 1; min-height: 0; outline: none; }
.loading, .empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }

/* home */
.hero h1 { margin: 6px 0 4px; font-size: 1.6rem; color: var(--text); }
.hero p { margin: 0 0 20px; color: var(--muted); max-width: 60ch; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  display: block; padding: 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); color: inherit; position: relative;
  border-top: 4px solid var(--accent);
}
.card:hover { text-decoration: none; border-color: var(--accent); }
.card h2 { margin: 0 0 4px; font-size: 1.1rem; }
.card .count { color: var(--muted); font-size: .9rem; }
.card p { margin: 8px 0 0; font-size: .9rem; color: var(--muted); }
.tag {
  display: inline-block; font-size: .72rem; font-weight: 650; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: middle;
}
.tag.gold { background: var(--warn-bg); color: var(--warn-text); }
.tag.gray { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.foot { margin-top: 28px; font-size: .85rem; color: var(--muted); }
.foot li { margin: 4px 0; }

/* framework browse: list + detail */
.split { display: grid; grid-template-columns: minmax(300px, 400px) 1fr; height: calc(100dvh - 52px - env(safe-area-inset-top)); }
.pane { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
.list-pane { border-right: 1px solid var(--border); background: var(--surface); }
.detail-pane { background: var(--bg); }
@media (max-width: 820px) {
  .split { display: block; height: auto; }
  .split.has-detail .list-pane { display: none; }
  .split:not(.has-detail) .detail-pane { display: none; }
  .list-pane { border-right: 0; }
  .pane { overflow: visible; }
}

.list-head {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  padding: 12px 16px 10px; border-bottom: 1px solid var(--border);
}
@media (max-width: 820px) { .list-head { position: static; } }
.list-head h1 { margin: 0; font-size: 1.15rem; }
.list-head .sub { color: var(--muted); font-size: .85rem; }
.filters { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.filters input[type=search] {
  flex: 1; min-width: 140px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 16px;
}
.filters select {
  padding: 7px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 15px; max-width: 100%;
}
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: .85rem; color: var(--muted); cursor: pointer; }

.fam-h {
  position: sticky; top: var(--fam-top, 0); z-index: 1;
  padding: 6px 16px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.row {
  display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border);
  color: var(--text); align-items: baseline; content-visibility: auto; contain-intrinsic-size: auto 52px;
}
.row:hover { background: var(--surface-2); text-decoration: none; }
.row.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.row .cid { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 74px; color: var(--accent); }
.row .ct { flex: 1; min-width: 0; }
.row.enh .cid { padding-left: 10px; font-weight: 600; }
.row.wd { opacity: .55; }
.row .mini { font-size: .72rem; color: var(--muted); white-space: nowrap; }

/* detail */
.detail { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.detail h1 { margin: 0 0 8px; font-size: 1.45rem; line-height: 1.25; }
.detail h1 .id { color: var(--accent); margin-right: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; box-shadow: var(--shadow); }
.box h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.stmt p { margin: 0 0 8px; }
.stmt ol { list-style: none; padding-left: 0; margin: 4px 0; }
.stmt ol ol { padding-left: 22px; }
.stmt li { margin: 5px 0; display: flex; gap: 8px; }
.stmt li > .lab { font-weight: 650; color: var(--muted); min-width: 22px; flex: none; }
.stmt li > div { flex: 1; min-width: 0; }
.guid p { margin: 0 0 10px; color: var(--text); }
details > summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details > summary h2 { margin: 0; }
.notice { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 10px 12px; font-size: .88rem; margin: 10px 0; }

.map-fw { margin: 10px 0 14px; }
.map-fw h3 { font-size: .95rem; margin: 0 0 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; gap: 6px; align-items: baseline; padding: 5px 10px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: .88rem; max-width: 100%;
}
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip b { color: var(--accent); white-space: nowrap; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.wd { opacity: .6; }
.chips.collapsed .chip.extra { display: none; }
.chip.more { cursor: pointer; font-weight: 650; color: var(--accent); border-style: dashed; }
.src { font-size: .75rem; color: var(--muted); font-weight: 400; }
.via { font-size: .75rem; color: var(--muted); }

.cci { border-top: 1px solid var(--border); padding: 8px 0; font-size: .92rem; }
.cci:first-of-type { border-top: 0; }
.cci b { color: var(--accent); margin-right: 6px; }
.cci .meta { font-size: .76rem; color: var(--muted); }

.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.pager a { padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: .9rem; max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* search results */
.results .row { border: 1px solid var(--border); border-radius: 8px; margin: 6px 0; background: var(--surface); }
.results .fwname { font-size: .72rem; color: var(--muted); }
mark { background: color-mix(in srgb, var(--gold) 35%, transparent); color: inherit; border-radius: 2px; }

#toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; pointer-events: auto; }
#toast button { margin-left: 10px; background: var(--gold); color: #1B2430; border: 0; border-radius: 6px; padding: 4px 10px; font-weight: 650; cursor: pointer; }
