:root {
  --paper: #F3F2EC; --paper-2: #E8E7DE; --ink: #121410; --ink-2: #55584F; --line: #D3D2C8;
  --lime: #C6F24E; --lime-2: #DDF7A0; --forest: #0E3A2B; --on-forest: #EAF1E6; --white: #fff;
  --warn: #B4530F; --warn-bg: #F7E3CF;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.55 var(--body); }
::selection { background: var(--lime); }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.03em; line-height: 1.05; margin: 0; }
h1 { font-size: clamp(30px, 6vw, 44px); font-weight: 800; }
h2 { font-size: 22px; font-weight: 700; margin: 36px 0 12px; display: flex; align-items: center; gap: 10px; }
h2::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 1px var(--ink) inset; }
h3 { font-size: 19px; font-weight: 700; }
p { margin: 0 0 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }

.top { position: sticky; top: 0; z-index: 5; background: var(--paper); display: flex; align-items: center;
  justify-content: space-between; gap: 16px; padding: 14px max(20px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); }
.mark { font: 800 22px var(--display); letter-spacing: -0.04em; text-decoration: none; }
.mark span { color: var(--ink); background: var(--lime); border-radius: 4px; padding: 0 2px; margin-left: 1px; }
nav { display: flex; align-items: center; gap: 4px; }
nav a, .link { font: 500 15px var(--body); text-decoration: none; padding: 10px 12px; border-radius: 10px; color: var(--ink);
  background: none; border: 0; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
nav a.on { background: var(--paper-2); }
nav b { background: var(--lime); border-radius: 99px; font-size: 12px; padding: 0 7px; line-height: 20px; }
nav b:empty { display: none; }

main { max-width: 880px; margin: 0 auto; padding: 28px 20px 96px; }
.lede { margin-top: 8px; color: var(--ink-2); max-width: 60ch; }

.btn { font: 600 15px var(--body); border: 0; border-radius: 12px; padding: 0 18px; min-height: 44px; cursor: pointer;
  background: var(--ink); color: var(--paper); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.lime { background: var(--lime); color: var(--ink); }
.btn.quiet { background: var(--paper-2); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

input, textarea, select { font: 400 16px var(--body); color: var(--ink); background: var(--white); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px; width: 100%; min-height: 44px; }
textarea { resize: vertical; min-height: 88px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }

.item { background: var(--white); border-radius: var(--radius); padding: 20px; margin-bottom: 12px; }
.item.warn { background: var(--warn-bg); }
.tag { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--paper-2); color: var(--ink-2); }
.tag.lime { background: var(--lime-2); color: var(--ink); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.forest { background: var(--forest); color: var(--on-forest); }
ul.crit { margin: 8px 0 12px; padding-left: 20px; }
ul.crit li { margin: 2px 0; }
.areas code { font-size: 13px; background: var(--paper); padding: 1px 6px; border-radius: 6px; }
details summary { cursor: pointer; color: var(--ink-2); font-size: 14px; min-height: 32px; }
.empty { padding: 28px 20px; border-radius: var(--radius); background: var(--paper-2); color: var(--ink-2); }

.list { border-top: 1px solid var(--line); }
.list > a, .list > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 16px 4px;
  border-bottom: 1px solid var(--line); text-decoration: none; flex-wrap: wrap; }
.list > a:hover { background: var(--paper-2); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--white); border-radius: 14px; padding: 14px 16px; }
.stat b { display: block; font: 800 28px/1.1 var(--display); letter-spacing: -0.03em; }
.stat span { font-size: 13px; color: var(--ink-2); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; background: var(--white); border-radius: 14px; padding: 14px 14px 0; }
.bars div { flex: 1; background: var(--ink); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars div.zero { background: var(--line); }
.barlabels { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); padding: 4px 14px 0; }

.chat { background: var(--paper-2); border-radius: var(--radius); padding: 14px; max-height: 460px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--lime-2); }
.msg.assistant { align-self: flex-start; background: var(--white); }
.doc { white-space: pre-wrap; background: var(--white); border-radius: var(--radius); padding: 16px 18px; font-size: 15px; overflow-wrap: anywhere; }
.dark { background: var(--forest); color: var(--on-forest); border-radius: var(--radius); padding: 22px; }
.dark .btn.lime { margin-top: 4px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 12px 18px; border-radius: 12px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.on { opacity: 1; }
.login { max-width: 380px; margin: 10vh auto 0; }
@media (max-width: 560px) {
  .item { padding: 16px; }
  nav a, .link { padding: 10px 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.item code { font-size: .88em; background: var(--paper); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
