:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --ink: #1c1b18;
  --ink-2: #5d5a52;
  --ink-3: #8c887d;
  --line: #e2ded3;
  --accent: #1f5c4a;
  --accent-ink: #ffffff;
  --accent-soft: #e3eee9;
  --red: #b3412e;
  --red-soft: #f8e6e1;
  --amber: #9a6512;
  --amber-soft: #f7ecd6;
  --green: #2f7a4f;
  --green-soft: #e2f1e7;
  --blue: #2c5f9e;
  --blue-soft: #e3ecf7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 27, 24, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1d1c1a;
    --surface-2: #26251f;
    --ink: #ece9e1;
    --ink-2: #b5b1a6;
    --ink-3: #85817a;
    --line: #34322c;
    --accent: #6fbf9f;
    --accent-ink: #0f1f19;
    --accent-soft: #1d332b;
    --red: #e58a77;
    --red-soft: #3a211b;
    --amber: #e0b05a;
    --amber-soft: #3a2e17;
    --green: #7cc89a;
    --green-soft: #1b3324;
    --blue: #8db4e8;
    --blue-soft: #1c2a3d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  font-size: 16px; width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 120px; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 14px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
button:disabled { opacity: .55; cursor: default; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); font-size: 13px; }
.error { color: var(--red); }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { font-family: var(--serif); font-weight: 600; margin: 16px 0 6px; }
.login-card form { display: grid; gap: 10px; margin-top: 20px; }
.brand-mark { width: 52px; height: 52px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); display: inline-grid; place-items: center; font: 700 28px var(--serif); }
.brand-mark.small { width: 28px; height: 28px; border-radius: 8px; font-size: 16px; }

.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 980px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; }
.tabs { display: none; gap: 4px; }
.tabs a, .tabbar a { text-decoration: none; color: var(--ink-2); }
.tabs a { padding: 6px 12px; border-radius: 999px; font-size: 15px; }
.tabs a.on { background: var(--surface-2); color: var(--ink); font-weight: 600; }
#logout { font-size: 14px; padding: 6px 4px; }
.gear { margin-left: auto; color: var(--ink-2); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; }
.gear svg { width: 20px; height: 20px; }
.gear.on { color: var(--accent); background: var(--surface-2); }
#admin-link[hidden] + #logout { margin-left: auto; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; margin: 6px 0 16px; }
.seg a { padding: 6px 16px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-size: 14px; }
.seg a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.small-link { font-size: 14px; white-space: nowrap; }
.t-amber { color: var(--amber); }
.t-red { color: var(--red); }
.empty.big { padding: 28px 16px; font-size: 16px; }
.askbtn { display: inline-block; padding: 10px 16px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-decoration: none; font-weight: 600; }
.filters { grid-template-columns: 1fr 1fr !important; }
.filters .wide { grid-column: 1 / -1 !important; }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--accent); font-weight: 600; }

.view { max-width: 980px; margin: 0 auto; padding: 18px 16px 110px; }
@media (min-width: 760px) {
  .tabs { display: flex; }
  .tabbar { display: none; }
  .view { padding-bottom: 48px; }
}

h2.page { font-family: var(--serif); font-weight: 600; font-size: 28px; margin: 4px 0 4px; letter-spacing: -.01em; }
h3.section { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 26px 0 10px; font-weight: 600; }
.lede { margin: 0 0 16px; color: var(--ink-2); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 6px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-2); }
.stat.red b { color: var(--red); }
.stat.amber b { color: var(--amber); }
.stat.green b { color: var(--green); }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.list { display: grid; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.task { display: grid; gap: 4px; cursor: pointer; }
.task-top { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.task-title { font-weight: 550; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--ink-2); }
.task-more { display: none; font-size: 14px; color: var(--ink-2); border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; }
.task.open .task-more { display: grid; gap: 4px; }
.id { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink-3); white-space: nowrap; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.empty { padding: 14px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line); border-radius: var(--radius); }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.filters .wide { grid-column: 1 / -1; }
@media (min-width: 760px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr; } .filters .wide { grid-column: auto; } }

.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.unit { cursor: pointer; }
.unit b { display: block; font-size: 14px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.bar i { display: block; height: 100%; background: var(--accent); }

.meeting h4 { margin: 0 0 4px; font-size: 16px; }
.meeting ul { margin: 6px 0 0; padding-left: 18px; }
.meeting li { margin: 3px 0; }
details summary { cursor: pointer; color: var(--ink-2); font-size: 14px; }
pre.minutes { white-space: pre-wrap; font: 14px/1.55 var(--font); background: var(--surface-2); padding: 12px; border-radius: 10px; overflow-x: auto; }

.md { line-height: 1.6; overflow-wrap: anywhere; }
.md h1 { font-family: var(--serif); font-size: 26px; }
.md h2 { font-family: var(--serif); font-size: 21px; margin-top: 28px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.md h3 { font-size: 16px; margin-top: 20px; }
.md table { border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md ul { padding-left: 20px; }

.chat { display: grid; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; overflow-wrap: anywhere; }
.msg.user { justify-self: end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; white-space: pre-wrap; }
.msg.assistant { justify-self: start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.assistant .md > :first-child { margin-top: 0; }
.msg.assistant .md > :last-child { margin-bottom: 0; }
.msg.thinking { color: var(--ink-3); }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.suggest button { border-radius: 999px; font-size: 14px; padding: 7px 12px; }
.composer { position: sticky; bottom: 70px; display: flex; gap: 8px; padding: 10px 0; background: var(--bg); }
.composer textarea { min-height: 46px; max-height: 160px; }
@media (min-width: 760px) { .composer { bottom: 0; } }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; gap: 8px; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.linkbox { font: 13px ui-monospace, Menlo, monospace; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 14px; z-index: 20; }

.fold { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.fold > summary { font-weight: 600; color: var(--ink); font-size: 15px; }
.fold[open] > summary { margin-bottom: 10px; }
