:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #09090b;
  --text-2: #3f3f46;
  --muted: #6b6b74;
  --accent: #3451d1;
  --accent-text: #2f49c2;
  --accent-soft: #eef1fd;
  --accent-line: #b9c5f4;
  --on-accent: #ffffff;
  --danger: #d0261d;
  --danger-soft: #fdf1f0;
  --ok: #1a7f4b;
  --warn: #a15c07;
  --shadow-sm: 0 1px 2px rgba(9, 9, 11, .05);
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 12px;
  --top: calc(52px + env(safe-area-inset-top));
  --tabs: calc(58px + env(safe-area-inset-bottom));
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0a0a0b;
    --surface: #121214;
    --surface-2: #19191c;
    --border: #26262a;
    --border-strong: #3a3a40;
    --text: #f4f4f5;
    --text-2: #c9c9cf;
    --muted: #9a9aa3;
    --accent: #7d93ff;
    --accent-text: #9aabff;
    --accent-soft: #161b33;
    --accent-line: #34407a;
    --on-accent: #0a0a0b;
    --danger: #f2655b;
    --danger-soft: #2a1412;
    --ok: #4cc38a;
    --warn: #e0a24a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
a { color: inherit; text-decoration: none; }
p { margin: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--top);
  padding: env(safe-area-inset-top) 16px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--text);
  display: grid; place-items: center;
}
.mark::after { content: ""; width: 10px; height: 7px; border-radius: 2px; background: #7d93ff; box-shadow: 0 0 0 2px var(--text), 0 0 0 3.4px var(--bg); }
.who { font: 500 13px var(--mono); color: var(--muted); }

main {
  max-width: 560px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabs) + 24px);
  display: flex; flex-direction: column; gap: 16px;
  outline: none;
}

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: var(--tabs); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--border);
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 500; color: var(--muted); }
.tabs a[aria-current] { color: var(--accent-text); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.compose { border-color: var(--accent-line); }
.compose-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); }

input:not([type=radio]):not([type=checkbox]), textarea, select {
  width: 100%; font: 16px/1.4 var(--sans); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; appearance: none; -webkit-appearance: none;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input::placeholder, textarea::placeholder { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; white-space: nowrap; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); font: 500 13px var(--mono); color: var(--text-2);
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  font: 600 15px var(--sans); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.btn:active { transform: scale(.98); }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.section { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 2px 8px; }
.section a { color: var(--accent-text); text-transform: none; letter-spacing: 0; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--border); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; }
.row-title { font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); font-weight: 400; }
.count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); font-size: 14px; padding: 12px 2px; }

.page-head { display: flex; flex-direction: column; gap: 4px; }
.row-between { flex-direction: row; justify-content: space-between; align-items: center; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg a { text-align: center; padding: 7px; border-radius: 7px; font-weight: 500; font-size: 14px; color: var(--muted); }
.seg a[aria-current] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.task { display: flex; gap: 10px; align-items: flex-start; padding: 12px 8px 12px 14px; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.task-title { font-weight: 500; }
.task-main .btn { align-self: flex-start; margin-top: 4px; }
.actions { display: flex; gap: 10px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.dev { gap: 0; }
.card .body { color: var(--text-2); white-space: pre-wrap; }
.state { font: 500 11px var(--mono); text-transform: uppercase; letter-spacing: .03em; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--text-2); }
.s-done { color: var(--ok); }
.s-blocked, .s-stale { color: var(--warn); }
.s-review, .s-confirm { color: var(--accent-text); background: var(--accent-soft); }
.tag { font: 500 11px var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); color: var(--text-2); }
.tag.accent { border-color: var(--accent-line); color: var(--accent-text); background: var(--accent-soft); }
.imp { font-size: 12px; font-weight: 600; }
.i2 { color: var(--accent-text); }
.i3 { color: var(--danger); }
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; margin-top: 2px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bell { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.bell[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); }
.bell[aria-pressed="true"] svg { fill: currentColor; }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.post summary { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.post .body { padding: 0 14px 14px; color: var(--text-2); white-space: pre-wrap; }
.agent summary { padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.agent-main { min-width: 0; }
.agent details[open] { padding-bottom: 12px; }
.agent .btn { margin: 8px 14px 0; }
.sub { list-style: none; margin: 0 14px; padding: 0; border: 1px solid var(--border); border-radius: 10px; }
.sub > li + li { border-top: 1px solid var(--border); }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 8px; background: var(--border-strong); }
.d-working { background: var(--ok); }
.d-blocked, .d-stale { background: var(--warn); }

.tree { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 1px solid var(--border); margin-left: 14px; }
.tree-root > li + li { border-top: 1px solid var(--border); }
.tree .row { padding-left: 12px; }

.seg-input { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg-input legend { font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; padding: 0; }
.seg-input input { position: absolute; opacity: 0; pointer-events: none; }
.seg-input span { display: block; text-align: center; padding: 9px; border-radius: 10px; border: 1px solid var(--border-strong); font-weight: 500; font-size: 14px; }
.seg-input input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.seg-input label:last-child input:checked + span { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.seg-input input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check, .switch-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.switch-row { justify-content: space-between; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
input[role=switch] {
  appearance: none; -webkit-appearance: none; flex: none; position: relative;
  width: 50px; height: 30px; border-radius: 15px; background: var(--border-strong); cursor: pointer; transition: background .15s;
}
input[role=switch]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
input[role=switch]:checked { background: var(--accent); }
input[role=switch]:checked::after { transform: translateX(20px); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs) + 12px); z-index: 10;
  max-width: 528px; margin: 0 auto; padding: 12px 14px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500;
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
select { padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238a8a93' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 12px 8px; }
