@font-face { font-family: 'Onest'; src: url('/fonts/onest-latin-wght-normal.Dun_Rd-l.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Bricolage Grotesque'; src: url('/fonts/bricolage-grotesque-latin-wght-normal.DLoelf7F.woff2') format('woff2'); font-weight: 200 800; font-display: swap; }
@font-face { font-family: 'Azeret Mono'; src: url('/fonts/azeret-mono-latin-wght-normal.BhHwRSCm.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --brand: #0f5a3c;
  --brand-dark: #0b4630;
  --brand-light: #e7f3ec;
  --mint-strong: #bfe3cf;
  --ink: #14201b;
  --muted: #5b6b63;
  --border: #dfe7e2;
  --bg: #f6f8f7;
  --surface: #fff;
  --danger: #b02a2a;
  --radius: 10px;
  --font-body: 'Onest', system-ui, sans-serif;
  --font-display: 'Bricolage Grotesque', var(--font-body);
  --font-mono: 'Azeret Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body); color: var(--ink); background: var(--bg); line-height: 1.55; }
h1, h2, h3 { font-family: var(--font-display); margin: 0 0 .4em; line-height: 1.15; }
p { margin: 0 0 .75em; color: var(--muted); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 24px; }
[hidden] { display: none !important; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { display: block; height: 34px; width: auto; }
.brand-name { font-family: var(--font-display); font-weight: 700; }

.btn { display: inline-block; padding: 9px 16px; border-radius: 999px; font-family: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; border: 1px solid transparent; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand); }

/* Page head */
.page-head { padding: 44px 0 24px; text-align: center; }
.page-head h1 { font-size: 2.3rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-family: var(--font-mono); font-size: .78rem; color: var(--brand); font-weight: 600; margin-bottom: 10px; }
.sub { max-width: 560px; margin: 0 auto; }
.page-head-actions { margin-top: 18px; }

/* Toolbar */
.toolbar { position: sticky; top: 57px; z-index: 10; background: var(--bg); padding: 12px 0; }
.toolbar-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search { flex: 1; min-width: 220px; position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding: 11px 16px 11px 42px; border-radius: 999px; border: 1px solid var(--border); font: inherit; background: var(--surface); }
.search input:focus, .field input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; font: inherit; font-weight: 600; font-size: .88rem; padding: 8px 16px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.caret { display: inline-block; transition: transform .15s; }
.seg button.legend-open .caret { transform: rotate(180deg); }
.count { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); }

/* Legend */
.legend { margin-top: 10px; }
.legend-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 8px 24px rgba(15,90,60,.08); }
.legend-card h3 { font-size: 1rem; }
.legend-list { list-style: none; margin: 0; padding: 0; }
.legend-row { width: 100%; display: grid; grid-template-columns: 64px 1fr auto 60px; gap: 12px; align-items: center; text-align: left; background: none; border: 0; border-top: 1px solid var(--border); padding: 10px 4px; font: inherit; cursor: pointer; color: var(--ink); }
.legend-row:hover { background: var(--brand-light); }
.legend-code { font-family: var(--font-mono); font-weight: 600; font-size: .8rem; color: var(--brand); }
.legend-n { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); }
.legend-go { font-size: .8rem; color: var(--brand); font-weight: 600; }

/* Groups + entries */
.group { margin-top: 26px; }
.group-band { display: flex; align-items: center; gap: 12px; background: var(--brand); color: #fff; padding: 10px 16px; border-radius: var(--radius) var(--radius) 0 0; scroll-margin-top: 130px; }
.gcode { font-family: var(--font-mono); font-size: .78rem; background: rgba(255,255,255,.18); padding: 2px 8px; border-radius: 999px; }
.gname { font-family: var(--font-display); font-weight: 700; flex: 1; }
.gcount { font-family: var(--font-mono); font-size: .8rem; opacity: .85; }
.entry { background: var(--surface); border: 1px solid var(--border); border-top: 0; padding: 16px 18px; scroll-margin-top: 130px; }
.entry:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.entry-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.entry-id { font-family: var(--font-mono); font-weight: 600; font-size: .78rem; background: var(--brand-light); color: var(--brand-dark); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.entry-q { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.tag-updated { font-family: var(--font-mono); font-weight: 700; font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; background: #fdf1de; color: #8a5a00; border: 1px solid #f0dcb0; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.entry-meta { display: flex; align-items: center; gap: 10px; margin: 8px 0 6px; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .03em; color: var(--muted); flex-wrap: wrap; }
.xref { font-family: var(--font-mono); font-size: .72rem; font-weight: 600; background: none; border: 1px solid var(--border); color: var(--brand); border-radius: 999px; padding: 1px 9px; cursor: pointer; }
.xref:hover { border-color: var(--brand); background: var(--brand-light); }
.entry-a { color: var(--ink); margin: 0; white-space: pre-line; }
mark { background: var(--mint-strong); color: inherit; border-radius: 2px; }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--brand); background: var(--mint-strong); } 100% { box-shadow: 0 0 0 0 transparent; } }
.empty { text-align: center; padding: 48px 0; color: var(--muted); }

footer { margin: 48px 0 40px; padding-top: 20px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--muted); }
.foot-meta { margin-top: 8px; font-family: var(--font-mono); font-size: .75rem; }

/* Admin */
.narrow { max-width: 460px; margin: 56px auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.card h2 { font-size: 1.15rem; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: .88rem; font-weight: 600; }
.field input, .field textarea, .field select { font: inherit; font-weight: 400; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.field textarea { resize: vertical; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Ask-a-question modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,32,27,.55); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { max-width: 440px; width: 100%; position: relative; margin: 0; max-height: 90vh; overflow-y: auto; }
.modal-close { position: absolute; top: 14px; right: 14px; background: none; border: 0; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0; }
.modal-close:hover { color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 14px 0; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; text-align: center; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.6rem; color: var(--brand); }
.stat span { font-size: .78rem; color: var(--muted); }
.dropzone { display: block; margin-bottom: 14px; border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; background: var(--bg); cursor: pointer; }
.dropzone.over, .dropzone:hover { border-color: var(--brand); background: var(--brand-light); }
.dropzone input { display: none; }
.msg { padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-size: .9rem; }
.msg.ok { background: var(--brand-light); color: var(--brand-dark); }
.msg.err { background: #fbeaea; color: var(--danger); }
.msg.warn { background: #fff5db; color: #7a5b00; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.small { font-size: .85rem; }
code { background: var(--brand-light); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: .82em; }

/* Appearance & copy (admin) */
.small-h { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .05em; font-size: .74rem; color: var(--muted); margin: 18px 0 10px; }
.small-h:first-child { margin-top: 0; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 16px; }
.color-field input[type="color"] { padding: 2px; height: 34px; width: 48px; border-radius: 8px; cursor: pointer; flex-shrink: 0; }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-hex { font-weight: 400; }

/* Submitted questions (admin) */
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.sub-item { border-top: 1px solid var(--border); padding: 14px 0; }
.sub-item:first-child { border-top: 0; }
.sub-q { font-weight: 600; }
.sub-meta { color: var(--muted); margin-top: 2px; }
.sub-answer-form { margin-top: 12px; padding: 14px; background: var(--bg); border-radius: 8px; }
.sub-answer-form .field { margin-bottom: 10px; }

@media (max-width: 640px) {
  .page-head h1 { font-size: 1.7rem; }
  .legend-row { grid-template-columns: 54px 1fr auto; }
  .legend-go { display: none; }
  .toolbar { top: 57px; }
}
