:root {
  --bg: #13111d;
  --bg-grad: radial-gradient(120% 90% at 0% 100%, #3a2140 0%, #1b1730 45%, #13111d 100%);
  --bar: #07060b;
  --panel: #1e1b2e;
  --tile: #37355a;
  --tile-2: #2b2946;
  --tile-hi: #45436c;
  --text: #f3f1fa;
  --muted: #a9a4c7;
  --accent: #f08aa8;
  --accent-2: #c9a3ff;
  --ok: #7fd6a4;
  --bad: #ff8080;
  --radius: 14px;
  --gap: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Vazirmatn", "Inter", system-ui, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.fa { direction: rtl; font-family: "Vazirmatn", sans-serif; }

/* ---------- Frame ---------- */
.frame {
  width: min(1280px, 100%);
  height: min(800px, calc(100vh - 32px));
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: 40px 1fr 64px;
  overflow: hidden;
}

/* ---------- Status bar ---------- */
.status {
  background: var(--bar);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  font-size: 13px;
}
.status .brand { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .5px; }
.status .dot { width: 14px; height: 14px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.status .clock { font-weight: 600; }
.status .right { display: flex; justify-content: flex-end; align-items: center; gap: 12px; color: var(--muted); }
.mini-player { display: flex; align-items: center; gap: 8px; }
.mini-player .title { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: var(--text); }
.icon-btn:hover { background: var(--tile-2); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- Main ---------- */
main { position: relative; overflow: hidden; }
.screen { position: absolute; inset: 0; padding: 14px 16px; display: none; flex-direction: column; gap: var(--gap); overflow: auto; }
.screen.active { display: flex; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen-head { display: flex; align-items: center; gap: 24px; }
.screen-head h1 { font-size: 20px; margin: 0; flex: 1; }
.screen-head h1 small { color: var(--muted); font-weight: 400; font-size: 14px; margin-inline-start: 8px; }
.tabs { display: flex; gap: 4px; }
.tabs button { padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.tabs button.on { background: var(--tile); color: var(--text); }

.tile {
  background: var(--tile);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 0;
  position: relative;
}
.tile.dark { background: transparent; }
.tile h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .6px; }
.tile .big { font-size: 22px; font-weight: 700; }
.tile.click { cursor: pointer; transition: background .2s; }
.tile.click:hover { background: var(--tile-hi); }

/* Home */
.home-top { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: var(--gap); flex: 1; }
.home-bottom { flex: 1.1; display: grid; grid-template-columns: 1fr; }
.clock-tile { display: flex; flex-direction: column; justify-content: center; align-items: center; }
.clock-tile .time { font-size: 48px; font-weight: 600; }
.clock-tile .date { color: var(--accent); margin-top: 4px; }
.pager { display: flex; justify-content: center; gap: 6px; }
.pager span { width: 6px; height: 6px; border-radius: 50%; background: var(--tile); }
.pager span.on { background: var(--muted); }
.ring { width: 90px; height: 90px; }
.continue { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; }
.continue .cover {
  width: 120px; height: 120px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #6f5bd6);
  display: grid; place-items: center; font-size: 42px; font-weight: 800;
}
.play-lg { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #1b1024; display: grid; place-items: center; }
.play-lg svg { width: 26px; height: 26px; }
.progress { height: 6px; border-radius: 3px; background: var(--tile-2); overflow: hidden; margin-top: 12px; cursor: pointer; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); }

/* Lesson */
.lesson-grid { flex: 1; display: grid; grid-template-columns: 1.1fr 1fr 1fr; grid-template-rows: 1fr 1fr; gap: var(--gap); min-height: 0; }
.lesson-grid .intro { grid-row: span 2; display: flex; flex-direction: column; gap: 10px; }
.lesson-grid .phr { grid-column: span 2; grid-row: span 2; overflow: auto; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--tile-2); font-size: 12px; color: var(--accent); }
.phrase { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid rgba(255,255,255,.06); }
.phrase .de { font-weight: 600; }
.phrase .note { font-size: 11px; color: var(--muted); }
.say { width: 30px; height: 30px; border-radius: 50%; background: var(--tile-2); display: grid; place-items: center; }
.say:hover { background: var(--accent); color: #1b1024; }
.say svg { width: 14px; height: 14px; }

/* Audio */
.audio-grid { flex: 1; display: grid; grid-template-columns: 1fr 2fr; gap: var(--gap); min-height: 0; }
.player { display: flex; flex-direction: column; gap: 14px; }
.player-ctrls { display: flex; justify-content: center; align-items: center; gap: 14px; }
.player-ctrls .icon-btn { width: 44px; height: 44px; background: var(--tile-2); border-radius: 12px; }
.player-ctrls .icon-btn svg { width: 20px; height: 20px; }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.speakers { display: flex; gap: 10px; }
.speakers label { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.transcript { overflow: auto; padding: 8px; }
.line { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; line-height: 1.55; }
.line:hover { background: var(--tile-2); }
.line .who { font-size: 12px; font-weight: 700; padding-top: 3px; }
.line.anna .who { color: var(--accent); }
.line.ben .who { color: var(--accent-2); }
.line.now { background: var(--tile-hi); box-shadow: inset 3px 0 0 var(--accent); }
.line.hide { display: none; }
.notice { font-size: 12px; color: var(--muted); }

/* Vocab */
.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--gap); }
.card { perspective: 800px; height: 130px; cursor: pointer; }
.card .in { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.card.flip .in { transform: rotateY(180deg); }
.card .face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: var(--radius); background: var(--tile); display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 12px; text-align: center; gap: 6px; }
.card .back { transform: rotateY(180deg); background: var(--tile-hi); }
.card .de { font-size: 18px; font-weight: 700; }
.card .en { font-size: 12px; color: var(--muted); }
.card .say { position: absolute; top: 8px; right: 8px; }
.card.known .front { box-shadow: inset 0 0 0 2px var(--ok); }

/* Practice */
.practice-grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); min-height: 0; }
.quiz-q { font-size: 18px; margin: 10px 0 16px; line-height: 1.7; }
.opts { display: grid; gap: 8px; }
.opts button { text-align: start; padding: 12px 14px; border-radius: 10px; background: var(--tile-2); }
.opts button:hover:not(:disabled) { background: var(--tile-hi); }
.opts button.ok { background: rgba(127,214,164,.25); box-shadow: inset 0 0 0 2px var(--ok); }
.opts button.bad { background: rgba(255,128,128,.2); box-shadow: inset 0 0 0 2px var(--bad); }
.quiz-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); font-size: 13px; }
.btn { padding: 9px 16px; border-radius: 10px; background: var(--accent); color: #1b1024; font-weight: 600; }
.btn.ghost { background: var(--tile-2); color: var(--text); }
.builder { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.builder .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.builder input { background: var(--tile-2); border: 1px solid transparent; color: var(--text); border-radius: 8px; padding: 7px 10px; font: inherit; min-width: 120px; flex: 1; }
.builder input:focus { outline: none; border-color: var(--accent); }
.output { background: var(--tile-2); border-radius: 10px; padding: 12px; line-height: 1.7; }

/* Lessons list */
.lessons-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Bottom bar ---------- */
.dock {
  background: var(--panel);
  border-top: 1px solid rgba(255,255,255,.05);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}
.stepper { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.stepper .label { color: var(--muted); font-weight: 400; font-size: 13px; }
.nav { display: flex; background: var(--tile-2); border-radius: 12px; padding: 4px; gap: 2px; }
.nav button { width: 58px; height: 44px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); position: relative; }
.nav button svg { width: 22px; height: 22px; }
.nav button.on { color: var(--accent); }
.nav button.on::after { content: ""; position: absolute; bottom: 5px; width: 18px; height: 2px; border-radius: 2px; background: var(--accent); }
.nav button:hover { color: var(--text); }
.dock .right { display: flex; justify-content: flex-end; align-items: center; gap: 16px; }

.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: var(--bar); padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.on { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  body { padding: 0; align-items: stretch; }
  .frame { height: 100vh; height: 100dvh; border-radius: 0; grid-template-rows: 40px 1fr auto; }
  .status .mini-player .title { display: none; }
  /* Home fits one screen on mobile: no page scroll */
  #home { overflow: hidden; gap: 10px; padding: 12px; }
  .home-top { flex: 1; min-height: 0; grid-template-columns: repeat(3, 1fr); grid-template-rows: auto 1fr; gap: 10px; }
  .clock-tile { grid-column: span 3; flex-direction: row; justify-content: space-between; padding: 4px 4px 0; }
  .clock-tile .time { font-size: 34px; }
  .home-top .tile:not(.clock-tile) { padding: 10px; overflow: hidden; }
  .home-top .tile h3 { font-size: 10px; margin-bottom: 6px; }
  .home-top .big { font-size: 15px; }
  .home-top .fa, .home-top .chip { font-size: 12px; }
  .ring { width: 58px; height: 58px; }
  #ringSub { font-size: 10px !important; text-align: center; }
  .home-bottom { flex: none; }
  .lesson-grid, .audio-grid, .practice-grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .lesson-grid .intro, .lesson-grid .phr { grid-row: auto; grid-column: auto; }
  .audio-grid .transcript { max-height: none; }
  .continue { grid-template-columns: auto 1fr auto; gap: 12px; padding: 12px; }
  .continue .cover { width: 56px; height: 56px; font-size: 20px; border-radius: 10px; }
  .continue .play-lg { width: 52px; height: 52px; }
  .continue .play-lg svg { width: 22px; height: 22px; }
  .continue h3 { font-size: 10px; margin-bottom: 4px; }
  #hNowLine { font-size: 15px !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .now-fa { font-size: 13px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  #home .pager { display: none; }
  .phrase { grid-template-columns: auto 1fr; }
  .phrase .fa, .phrase .note { grid-column: 2; }
  .dock { grid-template-columns: 1fr 1fr; padding: 8px 12px; row-gap: 8px; }
  .dock .nav { grid-column: span 2; order: -1; justify-content: space-between; }
  .nav button { flex: 1; width: auto; }
}
.now-fa { margin-top: 10px; color: var(--muted); line-height: 1.9; font-size: 15px; }
.player { overflow: auto; }
.now-box { background: var(--tile-2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.now-box[hidden] { display: none; }
.now-box h3 { margin: 0; color: var(--accent); }
.now-de { font-size: 16px; line-height: 1.6; }
.now-fa-lg { font-size: 16px; line-height: 2; color: var(--text); opacity: .85; }
