/* Quran Media — atelier sombre façon manuscrit : encre verte, or, papier */
:root {
  --ink: #0e1a17;
  --ink-2: #13231f;
  --ink-3: #1b2f2a;
  --line: #2a403a;
  --paper: #ece6d6;
  --muted: #9aa89f;
  --gold: #d6b56d;
  --gold-ink: #1d1708;
  --danger: #e58a7a;
  --ui: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Amiri", "Times New Roman", serif;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font: 15px/1.5 var(--ui);
  display: flex;
  flex-direction: column;
}
a { color: var(--gold); }
[hidden] { display: none !important; }

/* En-tête */
.topbar {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px max(20px, env(safe-area-inset-left)) 12px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--paper); text-decoration: none;
  font: 700 24px/1 var(--display);
  letter-spacing: .01em;
}
.brand-mark { width: 22px; height: 22px; fill: var(--gold); align-self: center; }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }

/* Mise en page */
.app {
  flex: 1;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}
.panel {
  border-right: 1px solid var(--line);
  background: var(--ink-2);
  overflow-y: auto;
  padding: 8px 20px 28px;
}
.group { padding: 16px 0; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.group:last-child { border-bottom: 0; }
.group h2 {
  margin: 0;
  font: 600 11px/1 var(--ui);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.field output { color: var(--paper); font-variant-numeric: tabular-nums; }

select, input[type="color"] {
  width: 100%;
  min-width: 0;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--ink-3);
  color: var(--paper);
  font: inherit;
  padding: 0 10px;
}
select:focus-visible, input:focus-visible, button:focus-visible, .file:focus-within .file-btn {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
input[type="color"] { padding: 4px; cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--gold); }

.file { position: relative; }
.file input { position: absolute; inset: auto 0 0 0; height: 40px; opacity: 0; cursor: pointer; }
.file-btn {
  height: 40px; display: grid; place-items: center;
  border: 1px dashed var(--line); border-radius: 8px;
  color: var(--paper); font-size: 14px;
}
.file:hover .file-btn { border-color: var(--gold); }

.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }
.note { margin: 0; font-size: 12.5px; color: var(--muted); }

/* Formats */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segmented button {
  display: grid; justify-items: center; gap: 4px;
  padding: 10px 4px 8px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--ink-3); color: var(--paper);
  font: 600 13px/1 var(--ui); cursor: pointer;
}
.segmented small { font-weight: 400; font-size: 11px; color: var(--muted); }
.segmented button[aria-checked="true"] { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.ratio { display: block; border: 1.5px solid currentColor; border-radius: 2px; margin-bottom: 4px; opacity: .8; }
.r916 { width: 12px; height: 20px; } .r11 { width: 18px; height: 18px; margin-top: 1px; } .r169 { width: 24px; height: 14px; margin-top: 3px; }

/* Thèmes */
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.swatch[aria-checked="true"] { border-color: var(--gold); outline: 2px solid var(--ink-2); outline-offset: -4px; }

/* Aperçu */
.preview {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px;
  padding: 22px max(16px, env(safe-area-inset-right)) 22px max(16px, env(safe-area-inset-left));
  min-width: 0; overflow-y: auto;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(214,181,109,.07), transparent 60%),
    var(--ink);
}
.stage-wrap {
  position: relative;
  display: grid; place-items: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}
#stage {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 290px);
  min-height: 260px;
  width: auto; height: auto;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.06);
  background: #000;
}
.stage-msg {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center; padding: 20px;
  font-size: 15px; color: var(--paper);
  background: rgba(14,26,23,.72);
  border-radius: 6px;
}

.transport { display: flex; align-items: center; gap: 12px; width: min(720px, 100%); }
.play {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--gold); color: var(--gold-ink); cursor: pointer;
  display: grid; place-items: center;
}
.play svg { width: 22px; height: 22px; fill: currentColor; }
.play .i-pause, .play.is-playing .i-play { display: none; }
.play.is-playing .i-pause { display: block; }
.play:disabled { opacity: .4; cursor: default; }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: min(720px, 100%); max-height: 76px; overflow-y: auto; }
.chip {
  min-width: 34px; height: 30px; padding: 0 8px;
  border-radius: 15px; border: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font: 500 13px/1 var(--ui); font-variant-numeric: tabular-nums; cursor: pointer;
}
.chip[aria-current="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--ink-3); color: var(--paper);
  font: 600 14px/1 var(--ui); cursor: pointer;
}
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.ghost { background: transparent; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:not(:disabled):hover { filter: brightness(1.08); }

.export { width: min(520px, 100%); display: grid; gap: 8px; }
.bar { height: 6px; border-radius: 3px; background: var(--ink-3); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s linear; }
.export-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; }

.status { margin: 0; min-height: 1.5em; font-size: 14px; color: var(--muted); text-align: center; }
.status.error { color: var(--danger); }

.foot {
  padding: 10px max(20px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}

/* Mobile et tablette */
@media (max-width: 860px) {
  body { height: auto; }
  .app { grid-template-columns: 1fr; grid-template-rows: auto; }
  .preview { order: -1; padding-top: 16px; }
  #stage { max-height: 62vh; }
  .panel { border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  .bar span { transition: none; }
}
