:root {
  --bg: #f4f6f3;
  --card: #ffffff;
  --text: #17211b;
  --muted: #6a756e;
  --line: #e2e7e3;
  --brand: #1f7a4d;
  --brand-soft: #e3f2ea;
  --danger: #c0392b;
  --warn: #b7791f;
  --rec: #d64545;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1411;
    --card: #18201b;
    --text: #e8eee9;
    --muted: #98a59d;
    --line: #26312a;
    --brand: #3fbf7f;
    --brand-soft: #1b3326;
    --danger: #ff6b5b;
    --warn: #f0b44c;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Geeza Pro", sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.screen { max-width: 640px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 16px; }
header { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
h1 { font-size: 1.5rem; margin: 0; }
pre { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; unicode-bidi: plaintext; }
[dir="auto"] { unicode-bidi: plaintext; text-align: start; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card summary { cursor: pointer; font-weight: 600; }
.card textarea { width: 100%; margin: 10px 0; padding: 10px; font: inherit; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--brand-soft); color: var(--brand); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.small { padding: 6px 10px; font-size: .9rem; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Login */
.login-box { max-width: 320px; margin: 18vh auto 0; text-align: center; }
.login-box .logo { width: 72px; height: 72px; border-radius: 18px; }
.login-box input { width: 100%; padding: 14px; font-size: 1.3rem; text-align: center; letter-spacing: .3em;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); margin: 16px 0 10px;
  letter-spacing: .15em; }
.login-box .btn { width: 100%; padding: 14px; }
.error { color: var(--danger); min-height: 1.4em; }

/* Record */
.rec-wrap { display: flex; flex-direction: column; align-items: center; padding: 28px 0 18px; }
.rec-btn { width: 180px; height: 180px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); box-shadow: 0 10px 30px rgba(31,122,77,.35); transition: transform .15s, background .2s; }
.rec-btn:active { transform: scale(.96); }
.rec-btn .rec-icon { font-size: 64px; }
.rec-btn.recording { background: var(--rec); animation: pulse 1.4s infinite; }
.rec-btn.busy { background: var(--muted); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(214,69,69,.5); } 100% { box-shadow: 0 0 0 30px rgba(214,69,69,0); } }
.rec-timer { margin-top: 18px; font-size: 1.3rem; font-variant-numeric: tabular-nums; font-weight: 600; }
.hint { color: var(--muted); font-size: .9rem; text-align: center; }
.result pre { font-size: 1.02rem; margin-bottom: 8px; }
.banner { background: var(--brand-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }

/* Notes */
.note-head { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .85rem; margin-bottom: 6px; }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.badge.pending, .badge.queued, .badge.processing { background: #fff3d6; color: var(--warn); }
.badge.failed, .badge.budget { background: #fde2df; color: var(--danger); }
.badge.cancelled { background: var(--line); color: var(--muted); }
.transcript { color: var(--muted); font-size: .92rem; border-inline-start: 3px solid var(--line); padding-inline-start: 10px; margin: 8px 0; }
.item { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.item.archived { opacity: .45; }
.item .title { font-weight: 600; }
.item .meta { color: var(--muted); font-size: .85rem; margin: 2px 0 6px; }
.item select, .item input[type=date] { font: inherit; font-size: .9rem; padding: 6px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* Today */
.task { display: flex; gap: 10px; align-items: flex-start; }
.task .body { flex: 1; min-width: 0; }
.task.overdue .meta { color: var(--danger); }
.section-title { font-weight: 700; color: var(--muted); margin: 18px 0 8px; font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }

/* Status */
.stat { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat:last-child { border-bottom: 0; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; background: var(--brand); }
.bar.warn > div { background: var(--warn); }
.bar.full > div { background: var(--danger); }
.digest pre { font-size: .9rem; color: var(--muted); margin-top: 6px; }

/* Tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 8px 0 10px; color: var(--muted); text-decoration: none; font-size: .72rem; }
.tabs a span { display: block; font-size: 1.35rem; }
.tabs a.active { color: var(--brand); font-weight: 700; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); max-width: 600px; margin: 0 auto;
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; white-space: pre-wrap; z-index: 10; }
