/* The « Studio » look, chosen by the owner. light-dark() picks the colour for the
   phone's light or dark setting (or data-theme when set). */
:root { color-scheme: light dark; }
[data-theme="light"] { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

:root {
  --bg: light-dark(#f2efe8, #0c0e13);
  --card: light-dark(#fbf9f4, #151821);
  --fg: light-dark(#1b1813, #f1ece2);
  --muted: light-dark(#6e6658, #a59d8e);
  --line: light-dark(#e3ddd0, #262a35);
  --accent: light-dark(#946414, #d9a85b);
  --on-accent: light-dark(#ffffff, #0c0e13);
  --soft: light-dark(#f1e7d3, #221f1a);
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: "Literata", Georgia, serif;
  --font-title: "Literata", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  min-height: 100dvh;
  font-size: 18px;
  line-height: 1.6;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
:lang(ar), :lang(fa), :lang(ur) { font-family: "Noto Naskh Arabic", var(--font-read); }
h1, h2 { font-family: var(--font-title); text-wrap: balance; letter-spacing: -.015em; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: max(2rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 4rem max(1rem, env(safe-area-inset-left));
}

.brand { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.logo {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; flex: none;
  border-radius: 14px; background: var(--accent); color: var(--on-accent);
}
h1 { margin: 0; font-size: 2rem; line-height: 1.1; }
.lead { margin: 0 0 2rem; color: var(--muted); font-size: 1.05rem; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  padding: 2.5rem 1.25rem; text-align: center; cursor: pointer;
  border: 2px dashed var(--line); border-radius: 22px; background: var(--card);
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--soft); }
.drop:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }
.drop-icon { color: var(--accent); }
.drop-title { font-family: var(--font-title); font-size: 1.35rem; font-weight: 600; }
.button {
  display: inline-block; padding: .85rem 1.6rem; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 1.05rem;
  transition: transform .15s;
}
.drop:hover .button { transform: translateY(-1px); }
.drop-hint { color: var(--muted); font-size: .95rem; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.code-form {
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  padding: 2rem 1.25rem; text-align: center; border: 1px solid var(--line); border-radius: 22px; background: var(--card);
}
.code-form input {
  width: min(100%, 18rem); padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); color: var(--fg); font: inherit; font-size: 1.1rem; text-align: center;
}
.code-form button { border: 0; cursor: pointer; font-family: inherit; }

.player {
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
  margin: 1.5rem 0; padding: 1.75rem 1.25rem 1.25rem; text-align: center;
  border: 1px solid var(--line); border-radius: 26px; background: var(--card);
}
.kicker { margin: 0; color: var(--accent); font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.player h2 { margin: 0 0 .5rem; font-size: 1.5rem; overflow-wrap: anywhere; }
.player input[type="range"] { width: 100%; height: 2.25rem; margin: 0; accent-color: var(--accent); cursor: pointer; }
.times { display: flex; justify-content: space-between; width: 100%; margin-top: -.5rem; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.controls { display: flex; align-items: center; justify-content: center; gap: 1.5rem; margin: .25rem 0; }
.round {
  display: grid; place-items: center; width: 3.75rem; height: 3.75rem; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  font: 600 1rem var(--font-ui); font-variant-numeric: tabular-nums; cursor: pointer;
}
.round.play { width: 5.5rem; height: 5.5rem; border: 0; background: var(--accent); color: var(--on-accent); }
.play .icon-pause, .playing .play .icon-play { display: none; }
.playing .play .icon-pause { display: block; }
.round:active { transform: scale(.96); }
.speed {
  padding: .5rem 1.1rem; border: 1px solid var(--line); border-radius: 999px; background: transparent;
  color: var(--fg); font: 600 .95rem var(--font-ui); font-variant-numeric: tabular-nums; cursor: pointer;
}
.player .status { margin: 0; min-height: 0; }

.library h2 { font-size: 1.35rem; margin: 2rem 0 .75rem; }
.library ul { margin: 0; padding: 0; list-style: none; display: grid; gap: .5rem; }
.library .book {
  width: 100%; font: inherit; color: inherit; text-align: start;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .85rem 1.1rem; border: 1px solid var(--line); border-radius: 16px; background: var(--card);
}
button.book { cursor: pointer; }
button.book:hover { border-color: var(--accent); }
button.book .state { color: var(--accent); font-weight: 600; }
.library .name { overflow-wrap: anywhere; font-weight: 600; }
.library .state { flex: none; color: var(--muted); font-size: .9rem; }

.status { min-height: 1.6em; margin: 1rem 0; color: var(--muted); text-align: center; }
.status.error { color: light-dark(#b42318, #ff8a80); }

#result:focus { outline: none; }
.doc-head h2 { margin: 0 0 .5rem; font-size: 1.5rem; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.25rem; padding: 0; list-style: none; font-size: .95rem; }
.chip { padding: .3rem .8rem; border-radius: 999px; background: var(--soft); color: var(--fg); }

details { margin-bottom: 1.5rem; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
summary { padding: .8rem 1.1rem; cursor: pointer; color: var(--muted); font-size: .95rem; }
details ul { margin: 0; padding: 0 1.1rem 1rem 2.2rem; max-height: 16rem; overflow: auto; overflow-wrap: anywhere; font-size: .9rem; color: var(--muted); }
details bdi { color: var(--fg); }

.text {
  padding: clamp(1.25rem, 4vw, 2.25rem); border-radius: 22px;
  background: var(--card); border: 1px solid var(--line);
  font-family: var(--font-read); font-size: 1.1rem; line-height: 1.75;
}
.text p {
  margin: 0 0 1.1em; text-align: start; overflow-wrap: break-word;
  content-visibility: auto; contain-intrinsic-size: auto 6em;
}
.text p:last-child { margin-bottom: 0; }
.text p:lang(ar), .text p:lang(fa), .text p:lang(ur) { font-size: 1.3rem; line-height: 2; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
