/* Rouz beh Rouz — app styles */
:root {
  --bg: #f6f1e7;
  --bg-2: #efe7d8;
  --card: #fffdf8;
  --ink: #1f2a2e;
  --ink-2: #4b5a60;
  --ink-3: #7a878c;
  --line: #e2d9c8;
  --teal: #0f6e6a;
  --teal-2: #0b5553;
  --teal-soft: #d7ebe8;
  --saffron: #d9892b;
  --saffron-soft: #fbe9d2;
  --rose: #b84a5a;
  --rose-soft: #f6dde1;
  --green: #2f8f5b;
  --green-soft: #dcf0e4;
  --shadow: 0 1px 2px rgba(31,42,46,.06), 0 8px 24px -12px rgba(31,42,46,.18);
  --r: 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --font-fa: "Vazirmatn", "Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif;
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15201f; --bg-2: #1b2928; --card: #1f2d2c; --ink: #eef0e9; --ink-2: #b9c3c0; --ink-3: #87948f;
    --line: #2c3c3a; --teal: #4fb8b1; --teal-2: #7fd3cc; --teal-soft: #1f3f3d; --saffron: #e9a152; --saffron-soft: #3f2d17;
    --rose: #e07b8a; --rose-soft: #3f2227; --green: #5fc48a; --green-soft: #1e3a2b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #15201f; --bg-2: #1b2928; --card: #1f2d2c; --ink: #eef0e9; --ink-2: #b9c3c0; --ink-3: #87948f;
  --line: #2c3c3a; --teal: #4fb8b1; --teal-2: #7fd3cc; --teal-soft: #1f3f3d; --saffron: #e9a152; --saffron-soft: #3f2d17;
  --rose: #e07b8a; --rose-soft: #3f2227; --green: #5fc48a; --green-soft: #1e3a2b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.5;
  background-image: radial-gradient(1200px 500px at 50% -200px, var(--teal-soft), transparent 70%);
}
a { color: var(--teal); text-decoration: none; }
button { font: inherit; }
[lang="fa"], .fa { font-family: var(--font-fa); direction: rtl; unicode-bidi: isolate; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: 2rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--ink-2); } .small { font-size: .875rem; } .tiny { font-size: .78rem; color: var(--ink-3); }
.hide-tr .tr, .hide-fa .fa-text { display: none !important; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 10px; color: var(--ink); }
.brand-fa { font-family: var(--font-fa); font-size: 1.3rem; font-weight: 700; color: var(--teal); }
.brand-en { font-family: var(--font-display); font-size: 1rem; color: var(--ink-2); }
.topnav { display: none; gap: 18px; }
.topnav a { color: var(--ink-2); font-weight: 500; padding: 6px 2px; border-bottom: 2px solid transparent; }
.topnav a.active { color: var(--teal); border-color: var(--teal); }
@media (min-width: 760px) { .topnav { display: flex; } .tabbar { display: none; } }

/* Tab bar (mobile) */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .7rem; color: var(--ink-3); }
.tabbar a .ico { font-size: 1.25rem; line-height: 1; }
.tabbar a.active { color: var(--teal); }
@media (min-width: 760px) { .tabbar { display: none; } }

/* Layout */
.app { max-width: 860px; margin: 0 auto; padding: 20px 16px calc(var(--tabbar-h) + 32px); }
@media (min-width: 760px) { .app { padding: 28px 24px 48px; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.stack > * + * { margin-top: 12px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: 12px; padding: 10px 16px; font-weight: 500; cursor: pointer; transition: transform .05s, background .15s; min-height: 44px; }
.btn:hover { background: var(--bg-2); } .btn:active { transform: scale(.98); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-2); }
.btn-accent { background: var(--saffron); border-color: var(--saffron); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--teal); }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: .9rem; border-radius: 10px; }
.btn-round { width: 44px; height: 44px; padding: 0; border-radius: 50%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-block { width: 100%; }

/* Pills, progress */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.pill-teal { background: var(--teal-soft); color: var(--teal); }
.pill-saffron { background: var(--saffron-soft); color: var(--saffron); }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-grey { background: var(--bg-2); color: var(--ink-2); }
.progress { height: 8px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), #3aa39c); border-radius: 999px; transition: width .4s; }

/* Hero */
.hero { padding: 24px 20px; border-radius: 22px; background: linear-gradient(135deg, var(--teal) 0%, #1a8a84 60%, #35a39b 100%); color: #fff; position: relative; overflow: hidden; }
.hero::after { content: "روز به روز"; position: absolute; right: -10px; bottom: -30px; font-family: var(--font-fa); font-size: 7rem; font-weight: 700; opacity: .08; direction: rtl; }
.hero h1 { color: #fff; margin-bottom: 4px; }
.hero .muted { color: rgba(255,255,255,.8); }
.hero .btn { background: #fff; color: var(--teal); border-color: #fff; }
.hero .btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.hero .btn-outline:hover { background: rgba(255,255,255,.12); }
.hero .progress { background: rgba(255,255,255,.25); } .hero .progress > span { background: #fff; }
.stat { text-align: center; } .stat b { display: block; font-family: var(--font-display); font-size: 1.6rem; }

/* Week list */
.week-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.week-item:hover { border-color: var(--teal); }
.week-num { width: 48px; height: 48px; border-radius: 12px; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.week-item.outline .week-num { background: var(--bg-2); color: var(--ink-3); }
.week-item.done .week-num { background: var(--green-soft); color: var(--green); }
.block-head { margin: 22px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.block-head h2 { margin: 0; }

/* Word/sentence display */
.word { text-align: center; padding: 10px; }
.word .fa-text { font-family: var(--font-fa); font-size: 2.4rem; font-weight: 700; direction: rtl; line-height: 1.5; color: var(--ink); }
.word .tr { font-family: var(--font-display); font-size: 1.5rem; color: var(--teal); }
.word .en { font-size: 1.05rem; color: var(--ink-2); }
.sent { padding: 12px 14px; border-radius: 12px; background: var(--bg-2); }
.sent .fa-text { font-family: var(--font-fa); font-size: 1.35rem; direction: rtl; text-align: right; }
.sent .tr { font-family: var(--font-display); font-size: 1.1rem; color: var(--teal); }
.sent .en { color: var(--ink-2); font-size: .95rem; }
.lvl { float: right; }
.note { padding: 14px 16px; border-left: 4px solid var(--saffron); background: var(--saffron-soft); border-radius: 10px; }
.note h3 { margin-bottom: .3em; }
.vocab-table { width: 100%; border-collapse: collapse; }
.vocab-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.vocab-table .fa-text { font-family: var(--font-fa); font-size: 1.3rem; direction: rtl; text-align: right; }
.vocab-table .tr { color: var(--teal); font-weight: 500; }

/* Flashcard */
.flash { perspective: 1200px; cursor: pointer; user-select: none; }
.flash-inner { position: relative; min-height: 260px; transition: transform .5s; transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 20px;
  border-radius: var(--r); background: var(--card); border: 1px solid var(--line); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.flash-back { transform: rotateY(180deg); }
.flash .hint { position: absolute; bottom: 12px; font-size: .75rem; color: var(--ink-3); }

/* Choices */
.choices { display: grid; gap: 10px; }
.choice { text-align: left; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 1rem; }
.choice:hover { border-color: var(--teal); }
.choice.correct { background: var(--green-soft); border-color: var(--green); }
.choice.wrong { background: var(--rose-soft); border-color: var(--rose); }
.choice[disabled] { cursor: default; }

/* Tiles (sentence builder / word bank) */
.tiles { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; padding: 10px; border-radius: 12px; border: 1px dashed var(--line); }
.tiles.answer { background: var(--bg-2); border-style: solid; }
.tile { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-family: var(--font-display); font-size: 1.05rem; }
.tile:hover { border-color: var(--teal); }
.tile[disabled] { opacity: .35; cursor: default; }

/* Inputs */
.input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 1.05rem; }
.input:focus { outline: 2px solid var(--teal); border-color: transparent; }
.feedback { padding: 12px 14px; border-radius: 12px; margin-top: 12px; }
.feedback.ok { background: var(--green-soft); color: var(--green); }
.feedback.bad { background: var(--rose-soft); color: var(--rose); }

/* Exercise frame */
.ex-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.ex-title { font-weight: 600; }
.ex-progress { flex: 1; }
.ex-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.session-steps { display: flex; gap: 6px; margin: 8px 0 16px; }
.session-steps span { flex: 1; height: 6px; border-radius: 3px; background: var(--bg-2); }
.session-steps span.done { background: var(--teal); } .session-steps span.cur { background: var(--saffron); }

/* Conversation */
.convo { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 85%; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.bubble.them { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.you { align-self: flex-end; background: var(--teal-soft); border-color: transparent; border-bottom-right-radius: 4px; }
.bubble .who { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin-bottom: 2px; }
.bubble .fa-text { font-family: var(--font-fa); font-size: 1.25rem; direction: rtl; text-align: right; }
.bubble .tr { font-family: var(--font-display); font-size: 1.05rem; color: var(--teal); }
.bubble .en { font-size: .9rem; color: var(--ink-2); }

/* Recorder */
.recorder { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.rec-btn { width: 72px; height: 72px; border-radius: 50%; border: 0; background: var(--rose); color: #fff; font-size: 1.4rem; cursor: pointer; box-shadow: var(--shadow); }
.rec-btn.recording { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(184,74,90,.5); } 50% { box-shadow: 0 0 0 14px rgba(184,74,90,0); } }

/* Alphabet */
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.letter { padding: 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); text-align: center; }
.letter .glyph { font-family: var(--font-fa); font-size: 2.2rem; direction: rtl; }
.letter .forms { font-family: var(--font-fa); font-size: 1.1rem; color: var(--ink-2); direction: rtl; }

.alpha-table th { text-align: left; padding: 8px 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); border-bottom: 1px solid var(--line); }
.alpha-table .glyph-cell { font-size: 1.9rem; text-align: center; direction: rtl; }
.alpha-table .forms-cell { font-size: 1.1rem; color: var(--ink-2); white-space: nowrap; text-align: right; }

/* In-lesson navigation */
.ex-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; }
.ex-nav .btn { min-height: 36px; padding: 6px 12px; font-size: .85rem; color: var(--ink-2); }

/* Settings */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.switch { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: left .15s; }
.switch.on { background: var(--teal); border-color: var(--teal); } .switch.on::after { left: 23px; }
select.input { appearance: auto; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; font-size: .9rem; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 760px) { .toast { bottom: 24px; } }

.fade-in { animation: fade .25s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.center { text-align: center; }
.speak-btn { background: var(--teal-soft); color: var(--teal); border: 0; }

/* Recording studio */
.studio tr.cur td { background: var(--teal-soft); }
.studio td.st { font-size: 1rem; width: 28px; text-align: center; }
.studio code { font-size: .8rem; }
.studio .rec.btn-accent { background: var(--rose); border-color: var(--rose); }
kbd { font: .8em var(--font); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--card); }
