/* Tarifit platform. Amazigh flag colors: sea blue, mountain green, sun yellow. */
:root {
  --bg: #f4f6f5; --surface: #ffffff; --fg: #16231f; --muted: #5a6a64; --line: #d6dfdb;
  --blue: #1f5fa8; --blue-soft: #e3edf8; --green: #2f7d4f; --green-soft: #e2f1e7;
  --sun: #a86f00; --sun-soft: #fbf0d4; --red: #b23a2e; --red-soft: #f8e4e1;
  --orange: #b4530f; --orange-soft: #fbe6d6;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Inter Tight", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1614; --surface: #17211e; --fg: #e6eeea; --muted: #9db0a8; --line: #2a3833;
    --blue: #7fb2ec; --blue-soft: #18283a; --green: #7fcf9d; --green-soft: #16291e;
    --sun: #f0c25a; --sun-soft: #2e2611; --red: #f08b80; --red-soft: #33191a;
    --orange: #f3a464; --orange-soft: #33220f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 400 15px/1.55 var(--body); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 1.7rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
.mono, code { font-family: var(--mono); font-size: 0.85em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* layout */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; }
.top-inner { max-width: 1180px; margin: 0 auto; padding-inline: 16px; display: flex; align-items: center; gap: 18px; min-height: 56px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 800; font-size: 1.05rem; color: var(--fg); display: flex; gap: 8px; align-items: center; }
.brand .tif { color: var(--blue); font-weight: 600; }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
nav a:hover { background: var(--bg); text-decoration: none; color: var(--fg); }
nav a.on { background: var(--blue-soft); color: var(--blue); }
.count { font: 600 0.7rem/1 var(--mono); background: var(--sun-soft); color: var(--sun); padding: 3px 6px; border-radius: 99px; }
.who { color: var(--muted); font-size: 0.85rem; }
main { max-width: 1180px; margin: 0 auto; padding-inline: 16px; padding-block: 28px 80px; display: grid; gap: 24px; }
.head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 4px; }

/* blocks */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: grid; gap: 14px; min-width: 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.cols { display: grid; gap: 20px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 2px; }
.stat b { font: 700 1.6rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.82rem; }
.stat.hl { background: var(--green-soft); border-color: transparent; }
.stat.hl b { color: var(--green); }

.flash { background: var(--green-soft); color: var(--green); padding: 10px 14px; border-radius: 10px; font-weight: 600; }

/* tables */
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th { font: 600 0.7rem/1.2 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: var(--bg); }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* pills */
.pill { display: inline-block; font: 600 0.7rem/1 var(--mono); padding: 4px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; letter-spacing: 0.02em; }
.st-done, .st-approved, .st-yes, .st-corrected { background: var(--green-soft); color: var(--green); }
.st-running, .st-processing, .st-queued, .st-open { background: var(--blue-soft); color: var(--blue); }
.st-found, .st-permission_asked, .st-asked, .st-candidate, .st-pending, .st-unknown { background: var(--sun-soft); color: var(--sun); }
.st-failed, .st-rejected, .st-no, .st-needs_admin { background: var(--red-soft); color: var(--red); }
.lic-creativeCommon, .lic-own { background: var(--green-soft); color: var(--green); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; background: var(--surface); }
.tabs a.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* forms */
label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
  font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.btn { font: 600 0.9rem/1 var(--body); border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 10px 14px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.ok { background: var(--green); border-color: var(--green); color: #fff; }
.btn.bad { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn.big { padding: 14px 20px; font-size: 1rem; }
.btn.sm { padding: 6px 10px; font-size: 0.8rem; }
form.inline { display: inline; }

/* review */
.review-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: grid; gap: 16px; }
.audio-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
audio { width: 100%; max-width: 520px; }
.textbox { font: 500 1.15rem/1.5 var(--mono); min-height: 110px; }
.line-label { font: 600 0.7rem/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.raw { font-family: var(--mono), "Noto Sans Tifinagh"; font-size: 0.9rem; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; }
.suggest { font-family: var(--mono); font-size: 0.95rem; background: var(--sun-soft); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; }
.meaning { background: var(--blue-soft); border-radius: 8px; padding: 10px 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 140px; }
.words { display: flex; flex-wrap: wrap; gap: 6px; }
.word { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-family: var(--mono); font-size: 0.85rem; cursor: pointer; background: var(--surface); color: var(--fg); }
.word.low { border-color: var(--sun); background: var(--sun-soft); }
.word:hover { border-color: var(--blue); }
/* languages: Tarifit plain, Darija orange, Spanish red, French blue, Arabic green */
.lw { border-radius: 4px; padding: 0 4px; font-weight: 600; }
.lw-rif { border: 1px solid var(--line); font-weight: 500; }
.lw-ary { background: var(--orange-soft); color: var(--orange); }
.lw-es { background: var(--red-soft); color: var(--red); }
.lw-fr { background: var(--blue-soft); color: var(--blue); }
.lw-ar { background: var(--green-soft); color: var(--green); }
.lang-legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.75rem; }
.chips-wrap { display: grid; gap: 8px; }
.chips-wrap .head { align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: grid; gap: 2px; justify-items: start; text-align: left; border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 9px; background: var(--surface); color: var(--fg); cursor: pointer; font: inherit; max-width: 100%; }
.chip:hover { border-color: var(--fg); }
.chip .cw { font: 600 0.9rem/1.2 var(--mono); overflow-wrap: anywhere; }
.chip .cl { font: 700 0.6rem/1 var(--mono); letter-spacing: 0.04em; vertical-align: 1px; }
.chip .cg { font-size: 0.75rem; line-height: 1.2; color: var(--muted); }
.chip.lang-ary { background: var(--orange-soft); border-color: transparent; color: var(--orange); }
.chip.lang-es { background: var(--red-soft); border-color: transparent; color: var(--red); }
.chip.lang-fr { background: var(--blue-soft); border-color: transparent; color: var(--blue); }
.chip.lang-ar { background: var(--green-soft); border-color: transparent; color: var(--green); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); }
.kbd { font: 600 0.7rem/1 var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; color: var(--muted); }
.btn .kbd { color: inherit; border-color: currentColor; opacity: 0.7; }

.log { font: 0.82rem/1.5 var(--mono); background: #0f1614; color: #cfe3da; padding: 14px; border-radius: 10px; white-space: pre-wrap; overflow-x: auto; max-height: 520px; overflow-y: auto; }
.events { display: grid; gap: 6px; font-size: 0.88rem; }
.events div { display: flex; gap: 10px; }
.events time { color: var(--muted); font-family: var(--mono); font-size: 0.75rem; flex: none; padding-top: 2px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty b { font-family: var(--display); font-size: 1.2rem; color: var(--fg); }
.tif-big { font-family: var(--display); font-size: 1.4rem; color: var(--blue); }
h1.mono { font-size: 2rem; }
.check { display: flex; gap: 8px; align-items: center; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--green); } .dot.off { background: var(--line); }
pre.copy { white-space: pre-wrap; background: var(--bg); padding: 12px; border-radius: 8px; font: 0.85rem/1.5 var(--mono); margin: 0; overflow-wrap: anywhere; }
.login { max-width: 380px; margin: 10vh auto; }

.head > .row { flex-wrap: nowrap; }
.head > .row > * { flex: 0 0 auto; }
@media (max-width: 760px) {
  .top-inner { gap: 6px 12px; padding-block: 8px; }
  .brand { flex: 1; }
  nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav a { white-space: nowrap; }
  .head > .row { flex-wrap: wrap; }
}

.brand img { display: block; }
.brand .tif { font-weight: 500; font-size: 0.9rem; }

/* scripts: Latin / Tifinagh */
.script-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; background: var(--surface); }
.script-switch button { font: 600 0.8rem/1 var(--body); border: 0; background: none; color: var(--muted); padding: 7px 12px; cursor: pointer; }
.script-switch button.on { background: var(--blue); color: #fff; }
.tif-view { background: var(--bg); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.tif-text { font-family: "Noto Sans Tifinagh", var(--body); font-size: 1.25rem; line-height: 1.7; color: var(--blue); overflow-wrap: anywhere; margin: 0; }
.tif-text.sm { font-size: 1rem; line-height: 1.5; }
.ai-flag { background: var(--sun-soft); color: var(--sun); border-radius: 10px; padding: 10px 14px; }
.meaning .head { align-items: center; }
.meaning p + p { margin-top: 4px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

/* record */
.read-text { font: 600 1.5rem/1.5 var(--mono); overflow-wrap: anywhere; margin: 0; }
.read-tif { font-size: 1.5rem; }
.rec-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.rec-btn { display: inline-flex; align-items: center; gap: 12px; font: 700 1.05rem/1 var(--body); padding: 16px 24px; border-radius: 99px;
  border: 2px solid var(--red); background: var(--surface); color: var(--red); cursor: pointer; min-height: 56px; }
.rec-btn .rec-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--red); }
.rec-btn.on { background: var(--red); color: #fff; }
.rec-btn.on .rec-dot { background: #fff; animation: pulse 1s infinite; }
.rec-btn:disabled { opacity: .45; cursor: not-allowed; }
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .rec-btn.on .rec-dot { animation: none; } }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--blue); flex: none; }
input[type=file] { font: inherit; color: var(--fg); }

/* izran */
.izran-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.izra-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 8px; color: var(--fg); }
.izra-card:hover { border-color: var(--blue); text-decoration: none; }
.izra-card .lyr { overflow-wrap: anywhere; }
.verses { display: grid; gap: 12px; }
.verse { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.verse:last-child { border-bottom: 0; padding-bottom: 0; }

/* pronunciation */
.ipa { font: 600 1.3rem/1.2 "Noto Sans", var(--body); color: var(--blue); }
.ipa.sm { font-size: 1rem; }
.sounds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sounds li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
