:root {
  color-scheme: dark light;
  --bg: #0f1512; --surface: #171f1b; --raised: #1e2822; --line: #2a3830;
  --text: #e9f0ea; --muted: #94a69a; --accent: #7bd89a; --accent-ink: #0b1a11;
  --warn: #f0b45a; --danger: #ef7a6b; --info: #7fb4e8;
  --radius: 14px; --tap: 46px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f6f3; --surface: #ffffff; --raised: #eef3ee; --line: #d9e2da;
    --text: #17211b; --muted: #5c6c61; --accent: #1d7a45; --accent-ink: #ffffff;
    --warn: #a4620a; --danger: #b5392b; --info: #1f5fa3;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.75 "Vazirmatn", Tahoma, system-ui, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
main { max-width: 680px; margin: 0 auto; padding: 14px 16px 24px; }
body.login { padding: 0; }
body.login main { padding-top: 12vh; }
h1 { font-size: 19px; margin: 0; line-height: 1.5; }
h2 { font-size: 15px; color: var(--accent); margin: 22px 0 8px; display: flex; gap: 8px; align-items: center; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); font-size: 13px; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 6px; }
.top p { margin: 0; }
section { margin: 0; }

/* دکمه و فرم */
.btn, button, summary.btn {
  font: inherit; color: var(--text); background: var(--raised);
  border: 1px solid var(--line); border-radius: 12px;
  min-height: var(--tap); padding: 8px 16px; cursor: pointer; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.btn.wide { width: 100%; }
.btn.small { min-height: 36px; padding: 2px 12px; font-size: 14px; }
button:disabled { opacity: .55; }
.link-danger { background: none; border: 0; color: var(--danger); min-height: 36px; font-size: 14px; }
input, select, textarea {
  font: inherit; width: 100%; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: var(--tap);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
label { display: block; margin: 10px 0; font-size: 14px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; color: var(--text); font-size: 16px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 8px 0 0; }
.check input { width: 20px; min-height: 20px; margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.err { color: var(--danger); margin: 0 0 8px; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 2px; margin: 0; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.card > summary { font-weight: 700; }
details.card[open] > summary { margin-bottom: 8px; }

/* ثبت سریع */
.capture { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 12px 0; }
.capture-target { font-size: 14px; margin-bottom: 10px; }
.capture-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.capture-grid button {
  flex-direction: column; gap: 2px; padding: 10px 2px; min-height: 66px; font-size: 12.5px; line-height: 1.4;
}
.capture-grid svg { width: 24px; height: 24px; }
.capture-grid button.recording { background: var(--danger); color: #fff; border-color: transparent; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sheet { margin-top: 10px; }
.sheet .row { display: flex; gap: 8px; margin-top: 8px; }
.sheet .row .btn { flex: 1; }
.active-picker label { margin: 12px 0 0; }

/* فهرست‌ها */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: block; padding: 11px 14px; }
.list b { display: block; font-weight: 600; line-height: 1.6; }
.list.compact a { padding: 8px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  display: inline-block; font-style: normal; font-size: 12.5px; line-height: 1.5; min-height: 0;
  padding: 2px 10px; border-radius: 99px; background: var(--raised); border: 1px solid var(--line); color: var(--muted);
}
a.chip, button.chip { padding: 6px 12px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.over { color: var(--danger); border-color: var(--danger); }
.chip.soon { color: var(--warn); border-color: var(--warn); }
.chip.stale { color: var(--warn); border-color: var(--warn); }
.chip.follow { color: var(--info); border-color: var(--info); }
.chip.new { color: var(--info); border-color: var(--info); }
.count { background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: 12px; padding: 0 9px; }
.banner { display: block; background: var(--raised); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-top: 14px; }
.recent { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.recent b { color: var(--accent); font-weight: 600; }
.recent .muted { width: 100%; }
.summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.pill { font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 2px 12px; color: var(--muted); }
.pill b { color: var(--text); }
.search { margin: 12px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.bulk { margin: 12px 0; }

/* مورد ثبت‌شده */
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 8px 0; overflow-wrap: anywhere; }
.card .item { background: transparent; border: 0; padding: 0; margin: 0 0 10px; }
.item time { display: block; font-size: 12px; color: var(--muted); }
.item .text { margin: 4px 0 0; white-space: pre-wrap; }
.item img { display: block; width: 100%; max-height: 320px; object-fit: contain; background: var(--bg); border-radius: 10px; margin-top: 6px; }
.item audio { width: 100%; margin-top: 6px; }
.item .geo, .item .filelink { display: inline-block; margin-top: 6px; color: var(--accent); font-size: 14px; }
.item.event { background: none; border: 0; border-inline-start: 2px solid var(--line); border-radius: 0; padding: 2px 12px; margin: 8px 8px; color: var(--muted); font-size: 14px; }
.item.event .dot { display: none; }
.inbox-card .filing { display: flex; gap: 8px; flex-wrap: wrap; }
.inbox-card .filing select { flex: 1 1 180px; width: auto; }
.inbox-card .filing .new-title { flex: 1 1 100%; }
.inbox-card .del { text-align: left; margin-top: 4px; }

/* پایین صفحه */
.tabs {
  position: fixed; inset-inline: 0; bottom: 0; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 7px 0 6px; font-size: 12px; color: var(--muted); position: relative; line-height: 1.5; }
.tabs a.on { color: var(--accent); }
.tabs svg { width: 24px; height: 24px; }
.badge { position: absolute; top: 3px; inset-inline-start: calc(50% + 8px); background: var(--danger); color: #fff; font-style: normal; font-size: 11px; border-radius: 99px; min-width: 18px; text-align: center; padding: 0 5px; line-height: 1.6; }
.queue-bar { position: fixed; inset-inline: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 6; padding: 0 16px; }
.queue-bar[hidden] { display: none; }
.queue-bar.fail { bottom: calc(112px + env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.queue-bar.fail[hidden] { display: none; }
.queue-bar.fail button { background: var(--danger); color: #fff; }
.queue-bar.fail #failDiscard { width: auto; flex: none; }
.queue-bar button { width: 100%; background: var(--warn); color: #1a1100; border: 0; font-weight: 700; }
#toast {
  position: fixed; inset-inline: 16px; bottom: calc(112px + env(safe-area-inset-bottom)); z-index: 9;
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 520px; margin: 0 auto;
}
#toast.show { opacity: 1; }
#toast.ok { border-color: var(--accent); }
#toast.warn { border-color: var(--warn); }
#toast.err { border-color: var(--danger); color: var(--danger); }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
