:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #1f1d1a;
  --muted: #6b675f;
  --border: #e3dfd5;
  --accent: #0f6e56;
  --accent-ink: #ffffff;
  --accent-soft: #e1f5ee;
  --warn: #854f0b;
  --warn-soft: #faeeda;
  --danger: #a32d2d;
  --rec: #d85a30;
  --radius: 14px;
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --surface: #201f1c; --surface-2: #2a2925; --text: #f1efe8; --muted: #a8a59c;
    --border: #3a3833; --accent: #5dcaa5; --accent-ink: #04342c; --accent-soft: #0f3a2f;
    --warn: #fac775; --warn-soft: #412402; --danger: #f09595; --rec: #f0997b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --surface: #201f1c; --surface-2: #2a2925; --text: #f1efe8; --muted: #a8a59c;
  --border: #3a3833; --accent: #5dcaa5; --accent-ink: #04342c; --accent-soft: #0f3a2f;
  --warn: #fac775; --warn-soft: #412402; --danger: #f09595; --rec: #f0997b; color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.5; padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
h2 { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
button, input, select, textarea { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; max-width: 760px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 22px; font-weight: 600;
}
.brand-name { font-weight: 600; }
.brand-sub { font-size: 13px; color: var(--muted); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

main { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.view { display: none; }
.view.active { display: block; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 12px; }

/* mic */
.hero { display: flex; flex-direction: column; align-items: center; padding: 26px 0 18px; }
.mic {
  width: 112px; height: 112px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: 0 0 0 10px var(--accent-soft); transition: transform .15s, background .2s, box-shadow .2s;
}
.mic svg { width: 46px; height: 46px; fill: currentColor; }
.mic:active { transform: scale(.96); }
.mic.recording { background: var(--rec); box-shadow: 0 0 0 10px color-mix(in srgb, var(--rec) 25%, transparent); }
@media (prefers-reduced-motion: no-preference) {
  .mic.recording { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 0 18px color-mix(in srgb, var(--rec) 12%, transparent); } }
}
.mic.busy { opacity: .6; pointer-events: none; }
.mic-label { margin-top: 16px; color: var(--muted); font-size: 15px; text-align: center; }

.ask { display: flex; gap: 8px; margin-bottom: 16px; }
.ask input { flex: 1; min-width: 0; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }

.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 10px 16px; border-radius: 10px;
  cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.rec-btn.recording { background: var(--rec); border-color: var(--rec); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.row > input { flex: 1; min-width: 0; }

.field { display: block; margin: 10px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: end; }
.grid .wide, .grid textarea { grid-column: 1 / -1; }
.grid .field.wide { grid-column: 1 / -1; }
.grid > .btn { grid-column: 1 / -1; margin-top: 6px; }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }

.prompt {
  font-size: 22px; line-height: 1.6; padding: 16px; border-radius: 12px; background: var(--accent-soft);
  color: var(--text); text-align: center; margin: 12px 0;
}

/* result */
.result h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 4px; text-transform: none; }
.route { display: grid; gap: 10px; margin: 14px 0; }
.stop { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; margin-top: 22px; }
.dot.a { background: var(--accent-soft); color: var(--accent); }
.dot.b { background: var(--accent); color: var(--accent-ink); }
.said { font-size: 13px; color: var(--muted); margin-top: 3px; }
.alts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.alts > span { font-size: 13px; color: var(--muted); }
.unresolved input { border-color: var(--warn); background: var(--warn-soft); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.conf { height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 4px 0 12px; }
.conf > div { height: 100%; background: var(--accent); }
.translations { font-size: 14px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 6px; }
.translations p { margin: 2px 0; }
.meaning { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 6px; }
.meaning span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.meaning p { margin: 2px 0 0; font-size: 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions .btn.primary { flex: 1; }
.unknown { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); margin-top: 8px; }
.chip-btn { font-size: 13px; border: 1px dashed var(--warn); color: var(--warn); background: transparent; border-radius: 99px; padding: 2px 10px; cursor: pointer; }
.done { text-align: center; padding: 8px 0; }
.done strong { display: block; font-size: 18px; margin-bottom: 4px; }

/* queue + lists */
.qitem { border-top: 1px solid var(--border); padding: 12px 0; }
.qitem:first-child { border-top: none; }
.qitem audio { width: 100%; height: 36px; margin: 6px 0; }
.qtop { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 99px; padding: 4px 6px 4px 12px; font-size: 14px; }
.chip button, .li button { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 99px; }
.chip button:hover, .li button:hover { color: var(--danger); }
.list .li { display: flex; justify-content: space-between; gap: 10px; align-items: center; border-top: 1px solid var(--border); padding: 8px 0; font-size: 14px; }
.list .li:first-child { border-top: none; }
.li .k { font-size: 12px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.tile b { display: block; font-size: 26px; font-weight: 600; }
.tile span { font-size: 13px; color: var(--muted); }
.goal { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.goal-bar { height: 100%; background: var(--accent); width: 0; }
.goal-text { font-size: 14px; color: var(--muted); margin: 8px 0 0; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 4px;
  background: var(--surface); border-top: 1px solid var(--border); padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.tab { flex: 1; max-width: 200px; border: none; background: none; padding: 10px; border-radius: 10px; color: var(--muted); font-weight: 500; cursor: pointer; }
.tab.active { background: var(--accent-soft); color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: calc(100% - 32px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: #fff; }

/* roles: volunteers don't see the review queue (other people's recordings) or delete buttons */
body[data-role="volunteer"] .admin-only, body[data-role="app"] .admin-only, body[data-role="none"] .admin-only { display: none; }
.need-key { border-color: var(--warn, #b7791f); }
