@font-face { font-family: 'KFGQPC Hafs'; src: url('./fonts/kfgqpc-hafs-v18.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Nunito'; font-weight: 400; src: url('./fonts/nunito-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Nunito'; font-weight: 700; src: url('./fonts/nunito-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Nunito'; font-weight: 800; src: url('./fonts/nunito-latin-800-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Nunito'; font-weight: 400; src: url('./fonts/nunito-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-02AF, U+1E00-1EFF; }
@font-face { font-family: 'Nunito'; font-weight: 700; src: url('./fonts/nunito-latin-ext-700-normal.woff2') format('woff2'); unicode-range: U+0100-02AF, U+1E00-1EFF; }
@font-face { font-family: 'Nunito'; font-weight: 800; src: url('./fonts/nunito-latin-ext-800-normal.woff2') format('woff2'); unicode-range: U+0100-02AF, U+1E00-1EFF; }

:root {
  color-scheme: light;
  --turquoise: #60CAD4; --turquoise-soft: #E3F6F9;
  --petrol: #36788F; --petrol-dark: #2A6073;
  --ink: #1F2A2E; --muted: #4F5D63; --line: #D5E0E2;
  --bg: #F6F9F9; --paper: #fff;
  --ok: #1D6B4F; --ok-bg: #E8F5EE;
  --rec: #C0362C; --rec-bg: #FCEEEA;
  --focus: #F2A900;
  --ar: 'KFGQPC Hafs', 'Noto Naskh Arabic', 'Geeza Pro', serif;
}
* { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; line-height: 1.5; }
body.modal-open { overflow: hidden; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.heavy { text-decoration: underline; text-decoration-thickness: .12em; text-underline-offset: .18em; }
code { font-size: .9em; background: var(--turquoise-soft); padding: 1px 6px; border-radius: 6px; }

/* Header */
.top { position: sticky; top: 0; z-index: 5; background: var(--turquoise); box-shadow: 0 2px 0 rgba(31,42,46,.08); }
.top-inner { width: min(100% - 32px, 1040px); margin: 0 auto; padding: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: #fff; font-family: var(--ar); font-size: 32px; line-height: 1; color: var(--petrol-dark); padding-bottom: 8px; }
.brand h1 { margin: 0; font-size: 1.45rem; font-weight: 800; line-height: 1.1; }
.brand p { margin: 2px 0 0; font-weight: 700; font-size: .9rem; }
.progress-box { min-width: 150px; text-align: right; font-weight: 700; font-size: .9rem; }
.progress-box strong { font-size: 1.3rem; font-weight: 800; margin-right: 4px; }
.progress-bar { height: 8px; margin-top: 4px; border-radius: 99px; background: rgba(255,255,255,.6); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--petrol-dark); transition: width .3s ease; }

.shell { width: min(100% - 32px, 1040px); margin: 0 auto; padding: 18px 0 48px; }
.intro { padding: 14px 18px; border-radius: 14px; background: var(--paper); border: 1.5px solid var(--line); }
.intro p { margin: 4px 0; }
.warning { color: var(--rec); font-weight: 800; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0; }
.filters-label { font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--paper); font-weight: 700; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--petrol); background: var(--turquoise-soft); }
.chip input { width: 18px; height: 18px; margin: 0; accent-color: var(--petrol); }
.chip small { font-weight: 400; color: var(--muted); }

/* Letters */
.letters { display: grid; gap: 14px; }
.letter-card { padding: 12px; border-radius: 16px; background: var(--paper); border: 1.5px solid var(--line); }
.letter-card.complete { border-color: #9FD3B8; }
.letter-card header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.letter-ar { font-family: var(--ar); font-size: 2.4rem; line-height: 1.3; min-width: 48px; text-align: center; }
.letter-name { display: grid; flex: 1; }
.letter-name strong { font-size: 1.15rem; font-weight: 800; }
.letter-name small { color: var(--muted); }
.letter-count { font-weight: 800; color: var(--muted); }
.letter-card.complete .letter-count { color: var(--ok); }
.cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.cell { position: relative; display: grid; justify-items: center; align-content: center; min-height: 112px; padding: 6px 4px 8px; border-radius: 12px; border: 2px dashed var(--line); background: var(--bg); cursor: pointer; transition: transform .15s ease, border-color .15s ease; }
.cell:hover { border-color: var(--petrol); transform: translateY(-2px); }
.cell.done { border-style: solid; border-color: #9FD3B8; background: var(--ok-bg); }
.cell-ar { font-family: var(--ar); font-size: 2.2rem; line-height: 1.7; }
.cell-sign { font-size: .8rem; font-weight: 700; color: var(--muted); }
.cell-done { font-size: .8rem; font-weight: 800; color: var(--ok); }

/* Export */
.export { margin-top: 28px; padding: 18px; border-radius: 16px; background: var(--paper); border: 1.5px solid var(--line); }
.export h2 { margin: 0 0 6px; font-size: 1.2rem; font-weight: 800; }
.export p { margin: 0 0 12px; color: var(--muted); }
.export-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.status { min-height: 1.5em; margin-top: 10px !important; font-weight: 700; color: var(--ink) !important; }
.credits { margin-top: 24px; text-align: center; color: var(--muted); font-size: .85rem; }
.credits a { color: var(--petrol-dark); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 18px; border-radius: 12px; border: 2px solid var(--petrol); background: var(--paper); color: var(--petrol-dark); font-weight: 800; cursor: pointer; }
.btn.primary { background: var(--petrol); color: #fff; }
.btn.danger { border-color: var(--rec); color: var(--rec); }
.btn:disabled { opacity: .4; cursor: default; }

/* Recorder dialog */
.recorder { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px; background: rgba(31,42,46,.55); }
.recorder[hidden] { display: none; }
.recorder-card { position: relative; width: min(100%, 520px); max-height: 100%; overflow-y: auto; padding: 22px 22px 18px; border-radius: 22px; background: var(--paper); text-align: center; animation: pop .2s ease-out; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.close { position: absolute; top: 10px; right: 10px; width: 48px; height: 48px; border: 0; border-radius: 12px; background: var(--bg); font-size: 1.6rem; cursor: pointer; }
.rec-meta { margin: 0; font-weight: 800; color: var(--muted); }
.rec-syllable { margin: 0; font-family: var(--ar); font-size: 6.5rem; line-height: 1.8; }
.rec-hint { margin: -10px 0 6px; color: var(--muted); }
.rec-file { margin: 0 0 12px; }
.meter { height: 10px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--petrol), var(--turquoise)); transition: width .06s linear; }
.rec-state { min-height: 1.5em; margin: 10px 0; font-weight: 700; }
.rec-state.live { color: var(--rec); }
.rec-state.ok { color: var(--ok); }
.rec-state.error { color: var(--rec); }
.rec-main { margin: 6px 0 14px; }
.rec-btn { display: inline-flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px 36px; border-radius: 99px; border: 0; background: var(--rec); color: #fff; font-size: 1.3rem; font-weight: 800; cursor: pointer; box-shadow: 0 6px 18px rgba(192,54,44,.25); }
.rec-btn .dot { width: 18px; height: 18px; border-radius: 50%; background: #fff; }
.rec-btn.is-recording .dot { border-radius: 4px; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.rec-actions { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 8px; }
.shortcuts { margin: 12px 0 0; color: var(--muted); font-size: .8rem; }
kbd { font-family: inherit; font-size: .8rem; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--bg); }

@media (max-width: 560px) {
  .top-inner { flex-direction: column; align-items: stretch; gap: 8px; }
  .progress-box { text-align: left; }
  .rec-actions { grid-template-columns: 1fr 1fr; }
  .rec-actions .primary { grid-column: 1 / -1; }
  .rec-syllable { font-size: 5rem; }
  .shortcuts { display: none; }
  .cells { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .cell { min-height: 96px; }
  .cell-ar { font-size: 1.9rem; }
  .top { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
