/* Hikaya (حكاية) — identity: white, calm deep blue, a touch of mint */
:root {
  --blue-900: #0f2a66;
  --blue-700: #2050b8;
  --blue-600: #2a5fd0;
  --blue-500: #3b72e6;
  --blue-100: #e6eefc;
  --blue-50:  #f3f7fe;
  --mint-600: #23a983;
  --mint-500: #3ec6a0;
  --mint-100: #dcf6ee;
  --red-500:  #e5484d;

  --bg: #ffffff;
  --bg-soft: var(--blue-50);
  --surface: #ffffff;
  --border: #dfe6f3;
  --text: #13213f;
  --text-2: #50608a;
  --text-3: #5f6c88;
  --primary: var(--blue-700);
  --primary-hover: var(--blue-600);
  --primary-soft: var(--blue-100);
  --on-primary: #ffffff;
  --accent: var(--mint-500);
  --accent-strong: #0e7a5c;
  --accent-soft: var(--mint-100);
  --shadow: 0 1px 2px rgba(15, 42, 102, .06), 0 6px 20px rgba(15, 42, 102, .06);

  --radius: 14px;
  --radius-lg: 20px;
  --font: 'Tajawal', system-ui, sans-serif;
  --font-en: 'Nunito', 'Tajawal', system-ui, sans-serif;
  --tabbar-h: 68px;
}

[data-theme='dark'] {
  --bg: #0b1428;
  --bg-soft: #0f1b35;
  --surface: #132242;
  --border: #22345c;
  --text: #eef3ff;
  --text-2: #a9b7d9;
  --text-3: #8b9ac0;
  --primary: #5b8cff;
  --primary-hover: #77a0ff;
  --primary-soft: #1b2f5c;
  --on-primary: #0b1428;
  --accent: #4fd8b1;
  --accent-strong: #4fd8b1;
  --accent-soft: #123d37;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg-soft);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.en { font-family: var(--font-en); direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--text-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(14px, 4vw, 32px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.brand img { width: 34px; height: 34px; }
.brand .name { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; }
@media (max-width: 420px) {
  .topbar { gap: 8px; }
  .brand .name small { display: none; }
}
.brand .name b { font-family: var(--font-en); font-size: 17px; color: var(--primary); }
.brand .name small { font-size: 12px; color: var(--text-2); font-weight: 500; }
.topnav { display: none; gap: 4px; margin-inline-start: 24px; }
.topnav a { padding: 8px 14px; border-radius: 999px; color: var(--text-2); font-weight: 500; }
.topnav a.active { background: var(--primary-soft); color: var(--primary); }
.topbar .spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 20px; color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn.on { color: var(--primary); background: var(--primary-soft); border-color: transparent; }
.lang-btn { width: auto; padding: 0 12px; font-size: 14px; font-weight: 700; }
.streak-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong); font-weight: 800;
}
.streak-chip.off { background: var(--bg-soft); color: var(--text-3); }

/* ---------- layout ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 24px clamp(14px, 4vw, 32px) calc(var(--tabbar-h) + 32px); outline: none; }
.page-title { font-size: clamp(24px, 3.4vw, 32px); font-weight: 800; margin: 4px 0 4px; }
.page-sub { color: var(--text-2); margin: 0 0 22px; }
.section-title { font-size: 19px; font-weight: 800; margin: 30px 0 12px; display: flex; align-items: center; gap: 8px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 14px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 700; font-size: 16px; cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s, color .15s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-accent { background: var(--accent); color: #06352a; }
.btn-lg { padding: 15px 28px; font-size: 18px; border-radius: 16px; }
.btn-sm { padding: 8px 14px; font-size: 14px; border-radius: 11px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---------- tab bar (mobile) ---------- */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3); font-size: 12px; font-weight: 500;
}
.tabbar a i { font-size: 24px; }
.tabbar a.active { color: var(--primary); }
.tabbar.hidden, .topnav.hidden { display: none; }

@media (min-width: 860px) {
  .tabbar { display: none; }
  .topnav { display: flex; }
  .app { padding-bottom: 48px; }
}

/* ---------- landing ---------- */
.hero { display: grid; gap: 32px; align-items: center; padding: clamp(10px, 4vw, 40px) 0; }
@media (min-width: 860px) { .hero { grid-template-columns: 1.05fr 1fr; } }
.hero h1 { font-size: clamp(32px, 5.2vw, 52px); line-height: 1.15; margin: 0 0 14px; font-weight: 800; }
.hero h1 .hl { color: var(--primary); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; margin-bottom: 16px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 14px; }
.eyebrow img { width: 24px; height: 24px; }
.hero p.lead { font-size: 19px; color: var(--text-2); margin: 0 0 26px; max-width: 34ch; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-demo { padding: 28px; }
.hero-demo .demo-label { font-size: 13px; color: var(--text-3); margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }
.features { display: grid; gap: 14px; margin-top: 30px; }
@media (min-width: 700px) { .features { grid-template-columns: repeat(3, 1fr); } }
.feature i { font-size: 26px; color: var(--primary); background: var(--primary-soft); padding: 10px; border-radius: 14px; display: inline-block; }
.feature h3 { margin: 12px 0 4px; font-size: 18px; }
.feature p { margin: 0; color: var(--text-2); }

/* ---------- dashboard ---------- */
.dash-top { display: grid; gap: 14px; }
@media (min-width: 760px) { .dash-top { grid-template-columns: 1fr 1.4fr; } }
.streak-card { display: flex; align-items: center; gap: 18px; }
.streak-big {
  width: 84px; height: 84px; flex: none; border-radius: 24px;
  display: grid; place-items: center; text-align: center;
  background: var(--accent-soft); color: var(--accent-strong);
}
.streak-big b { font-size: 32px; line-height: 1; font-family: var(--font-en); }
.streak-big span { font-size: 12px; }
.streak-card.off .streak-big { background: var(--bg-soft); color: var(--text-3); }
.streak-card h3 { margin: 0 0 4px; font-size: 18px; }
.streak-card p { margin: 0; color: var(--text-2); font-size: 15px; }
.done-today { color: var(--accent-strong); font-weight: 700; display: inline-flex; gap: 6px; align-items: center; }
.continue-card { display: flex; align-items: center; gap: 16px; }
.continue-card .story-icon { width: 64px; height: 64px; font-size: 32px; }
.continue-card .info { flex: 1; min-width: 0; }
.continue-card h3 { margin: 0; font-size: 19px; }

.cats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cat {
  display: flex; align-items: center; gap: 10px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-weight: 700; font-size: 15px; cursor: pointer; text-align: start;
  transition: border-color .15s, transform .15s;
}
.cat:hover { border-color: var(--primary); transform: translateY(-1px); }
.cat i { font-size: 22px; color: var(--primary); }
.cat small { display: block; color: var(--text-3); font-weight: 500; font-size: 12px; }

/* ---------- library ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
/* On phones the category chips scroll sideways in one row, so the stories show right away. */
@media (max-width: 700px) {
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * clamp(14px, 4vw, 32px)); padding-inline: clamp(14px, 4vw, 32px); padding-bottom: 4px; scroll-snap-type: x proximity; }
  .filters::-webkit-scrollbar { display: none; }
  .filters .chip { flex: none; scroll-snap-align: start; }
}
.chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-2);
}
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip .en { font-weight: 700; }
.stories { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 16px; }
.story-card {
  display: flex; flex-direction: column; gap: 12px; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); cursor: pointer; text-align: start;
  transition: transform .15s, border-color .15s;
}
.story-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.story-card .row { display: flex; align-items: center; justify-content: space-between; }
.story-icon {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  font-size: 28px; background: var(--primary-soft); color: var(--primary);
}
.level { font-family: var(--font-en); font-weight: 800; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--bg-soft); color: var(--text-2); border: 1px solid var(--border); }
.story-card h3 { margin: 0; font-size: 18px; line-height: 1.3; }
.story-card .sub { color: var(--text-2); font-size: 14px; }
.progress { height: 8px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.progress-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.progress-row .progress { flex: 1; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty i { font-size: 42px; color: var(--text-3); }

/* ---------- story player ---------- */
.player { max-width: 860px; margin: 0 auto; }
.player-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.player-head .title { flex: 1; min-width: 0; }
.player-head h2 { margin: 0; font-size: 18px; line-height: 1.2; }
.player-head .count { font-size: 13px; color: var(--text-2); font-family: var(--font-en); }
.player .progress { height: 10px; margin-bottom: 18px; }

.history { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; max-height: 30vh; overflow-y: auto; mask-image: linear-gradient(to bottom, transparent, #000 40%); padding-top: 18px; }
.history p { margin: 0; font-family: var(--font-en); direction: ltr; text-align: left; color: var(--text-3); font-size: 16px; }

.stage { position: relative; padding: clamp(26px, 5vw, 48px) clamp(18px, 4vw, 40px); cursor: text; }
.sentence {
  font-family: var(--font-en); direction: ltr; text-align: left;
  font-size: clamp(24px, 4.4vw, 38px); font-weight: 700; line-height: 1.55;
  letter-spacing: .2px; word-spacing: 2px; user-select: none;
}
.sentence .w { display: inline-block; position: relative; border-radius: 8px; padding: 0 2px; cursor: pointer; transition: background .15s; }
.sentence .w:hover { background: var(--primary-soft); }
.sentence .sp { display: inline; white-space: pre-wrap; }
.ch { opacity: .5; transition: opacity .12s, color .2s; color: var(--text); }
.ch.on { opacity: 1; }
.ch.auto { opacity: .5; }
.ch.auto.on { opacity: 1; }
.ch.cur { position: relative; }
.ch.cur::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 3px;
  background: var(--primary); border-radius: 2px; animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.w.done .ch { color: var(--text); }
.w.pop { animation: pop .45s ease; }
.w.pop .ch { color: var(--accent-strong); }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); background: var(--accent-soft); }
  100% { transform: scale(1); }
}
.stage.shake { animation: shake .32s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}
.ch.bad { color: var(--red-500) !important; opacity: 1; }
.stage.complete .sentence { color: var(--text); }
.hidden-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; left: 50%; top: 50%; font-size: 16px; }
.tap-hint { margin-top: 18px; font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.controls .grow { flex: 1; }
.translation {
  margin-top: 14px; padding: 14px 18px; border-radius: var(--radius);
  background: var(--primary-soft); color: var(--text); font-size: 18px; font-weight: 500;
  direction: rtl; text-align: right;
}
.grammar-note {
  margin-top: 14px; padding: 14px 18px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--text); font-size: 16px;
  display: flex; gap: 10px; align-items: flex-start;
}
.grammar-note i { color: var(--accent-strong); font-size: 22px; flex: none; }
.btn-grammar.has { color: var(--accent-strong); border-color: var(--accent); }

/* hide mode (IELTS practice) */
.ielts-banner {
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px;
  padding: 12px 16px; border-radius: var(--radius); font-size: 15px; font-weight: 500;
  background: #fff4dc; color: #6b4a00; border: 1px solid #f2b33d;
}
.ielts-banner i { font-size: 22px; color: #c98a00; flex: none; }
[data-theme='dark'] .ielts-banner { background: #3a2c0a; color: #ffd98a; border-color: #8a6410; }
.ielts-banner[hidden] { display: none; }
.sentence.is-hidden .ch.hid { opacity: .55; color: var(--text-3); }
.sentence.is-hidden .w { cursor: default; }
.sentence.is-hidden .w.done { cursor: pointer; }
.ch.fmt { text-decoration: underline wavy #e0a020; text-underline-offset: 6px; }
.fmt-note { display: block; font-size: 12px; color: #c98a00; margin-top: 2px; }
#hideBtn.on { color: var(--primary); background: var(--primary-soft); border-color: transparent; }

/* word popover */
.pop-backdrop { position: fixed; inset: 0; z-index: 40; }
.word-pop {
  position: fixed; z-index: 41; width: min(320px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 16px 50px rgba(15, 42, 102, .22); padding: 16px;
  animation: popIn .16s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.word-pop .w-head { display: flex; align-items: center; gap: 10px; }
.word-pop .w-word { font-family: var(--font-en); font-size: 24px; font-weight: 800; direction: ltr; }
.word-pop .w-ipa { font-family: 'Nunito', sans-serif; color: var(--text-2); direction: ltr; font-size: 15px; }
.word-pop .w-pos { display: inline-block; margin-top: 8px; font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.word-pop .w-ar { font-size: 19px; font-weight: 700; margin: 8px 0 14px; }
.word-pop .w-actions { display: flex; gap: 8px; }
.word-pop .w-actions .btn { flex: 1; }

/* ---------- finish screen ---------- */
.finish { max-width: 640px; margin: 0 auto; text-align: center; }
.finish .badge-big {
  width: 96px; height: 96px; margin: 10px auto 16px; border-radius: 30px;
  display: grid; place-items: center; font-size: 50px;
  background: var(--accent-soft); color: var(--accent-strong);
  animation: pop .6s ease;
}
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 24px 0; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 16px 10px; }
.stat b { display: block; font-size: 26px; font-family: var(--font-en); color: var(--primary); }
.stat span { font-size: 13px; color: var(--text-2); }
.finish .list { text-align: start; }
.finish .list ul { margin: 0; padding-inline-start: 20px; }
.finish .list li { margin: 6px 0; }
.title-unlock { margin: 18px 0; padding: 18px; border-radius: var(--radius-lg); background: var(--accent-soft); color: var(--text); font-weight: 700; }
.title-unlock .t { font-size: 22px; color: var(--accent-strong); }
.word-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.word-tags span { font-family: var(--font-en); padding: 4px 12px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }

/* ---------- my words ---------- */
.words-list { display: grid; gap: 10px; }
.word-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.word-row .wr-main { flex: 1; min-width: 0; }
.word-row .wr-word { font-family: var(--font-en); font-weight: 800; font-size: 18px; direction: ltr; display: inline-block; }
.word-row .wr-ipa { color: var(--text-3); font-size: 14px; direction: ltr; display: inline-block; margin-inline-start: 6px; }
.word-row .wr-ar { color: var(--text-2); }
.word-row .wr-sent { font-family: var(--font-en); direction: ltr; text-align: left; font-size: 14px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex: none; }
.score-dot.s1 { background: #f2b33d; }
.score-dot.s2 { background: var(--accent); }

.flash-wrap { max-width: 520px; margin: 0 auto; }
.flashcard { perspective: 1200px; height: 300px; cursor: pointer; margin: 18px 0; }
.flashcard .inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border-radius: 24px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 24px; text-align: center;
}
.flashcard .back { transform: rotateY(180deg); background: var(--primary-soft); }
.flashcard .fc-word { font-family: var(--font-en); font-size: 40px; font-weight: 800; direction: ltr; }
.flashcard .fc-ar { font-size: 30px; font-weight: 800; }
.flashcard .fc-sent { font-family: var(--font-en); direction: ltr; color: var(--text-2); font-size: 15px; }
.flash-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-no { background: #fdecec; color: #b42328; }
.btn-yes { background: var(--accent-soft); color: var(--accent-strong); }
[data-theme='dark'] .btn-no { background: #3d1b20; color: #ff9da1; }

/* ---------- profile ---------- */
.profile-top { display: grid; gap: 14px; }
@media (min-width: 760px) { .profile-top { grid-template-columns: 1fr 1fr; } }
.title-card .t-label { font-size: 13px; color: var(--text-3); }
.title-card .t-name { font-size: 26px; font-weight: 800; margin: 4px 0; }
.title-card .t-name .en { color: var(--primary); }
.title-card.current { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.title-card.current .t-label, .title-card.current .muted { color: color-mix(in srgb, var(--on-primary) 75%, transparent); }
.title-card.current .t-name .en { color: var(--on-primary); }
.title-card .progress { margin-top: 12px; }
.ladder { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.rung { display: flex; align-items: center; gap: 12px; padding: 14px; }
.rung i { font-size: 26px; color: var(--text-3); }
.rung.got i { color: var(--accent-strong); }
.rung.got { border-color: var(--accent); }
.rung b { display: block; }
.rung small { color: var(--text-2); }
.settings { display: grid; gap: 4px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 700; color: var(--text-2); }
.seg button.on { background: var(--primary); color: var(--on-primary); }

/* ---------- accounts ---------- */
.auth-wrap { min-height: calc(100vh - 220px); display: grid; place-items: center; padding: 10px 0; }
.auth-card { width: min(440px, 100%); padding: clamp(22px, 5vw, 34px); display: grid; gap: 14px; }
.auth-card .page-title { margin: 0; }
.auth-card .page-sub { margin: -6px 0 4px; }
.auth-logo { width: 52px; height: 52px; }
.gate-badge { width: 84px; height: 84px; margin: 0 auto 6px; border-radius: 26px; display: grid; place-items: center; font-size: 42px; background: var(--accent-soft); color: var(--accent-strong); }
.field { display: grid; gap: 6px; font-weight: 700; font-size: 15px; }
.field small { font-weight: 500; font-size: 13px; }
.input-wrap { position: relative; display: block; }
.field input {
  width: 100%; padding: 13px 14px; font: inherit; font-family: var(--font-en); font-weight: 600; font-size: 16px;
  color: var(--text); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus { border-color: var(--primary); background: var(--surface); }
.field input[type='password'], .field input[data-pw] { padding-right: 46px; }
.eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer; color: var(--text-3); font-size: 20px; padding: 6px; }
.eye:hover { color: var(--primary); }
.link { color: var(--primary); font-weight: 700; font-size: 14px; justify-self: start; }
.link:hover { text-decoration: underline; }
.switch { margin: 0; text-align: center; color: var(--text-2); font-size: 15px; }
.note { margin: 0; font-size: 14px; display: flex; gap: 6px; align-items: flex-start; background: var(--accent-soft); color: var(--text); padding: 10px 12px; border-radius: 12px; }
.note i { color: var(--accent-strong); font-size: 18px; }
.form-msg { font-size: 14px; font-weight: 700; min-height: 0; }
.form-msg.err { color: var(--red-500); }
.form-msg.ok { color: var(--accent-strong); }
.signup-card { display: flex; align-items: center; gap: 14px; text-align: start; margin: 18px 0 0; border-color: var(--accent); }
.signup-card > i { font-size: 34px; color: var(--accent-strong); }
.signup-card p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.signup-card > div { flex: 1; }
@media (max-width: 520px) { .signup-card { flex-direction: column; text-align: center; } }

.pw-strength { display: grid; gap: 8px; margin-top: -4px; }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; direction: ltr; }
.pw-meter span { height: 6px; border-radius: 99px; background: var(--border); transition: background .2s; }
.pw-strength[data-level='1'] .pw-meter span.on { background: var(--red-500); }
.pw-strength[data-level='2'] .pw-meter span.on { background: #f2b33d; }
.pw-strength[data-level='3'] .pw-meter span.on { background: var(--primary); }
.pw-strength[data-level='4'] .pw-meter span.on { background: var(--accent); }
.pw-label { font-size: 13px; font-weight: 700; color: var(--text-2); min-height: 0; }
.pw-strength[data-level='4'] .pw-label { color: var(--accent-strong); }
.pw-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
@media (min-width: 420px) { .pw-rules { grid-template-columns: 1fr 1fr; } }
.pw-rules li { display: flex; align-items: center; gap: 6px; }
.pw-rules li.ok { color: var(--accent-strong); font-weight: 700; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 700;
  transition: opacity .2s, transform .2s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 860px) { .toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- avatar, account card, subscription ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.avatar { display: inline-grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 26px; border: 2px solid transparent; }
.avatar-sm { width: 36px; height: 36px; font-size: 19px; transition: transform .15s; }
.avatar-sm:hover { transform: scale(1.06); }
.avatar-lg { width: 72px; height: 72px; font-size: 36px; }
.avatar.is-premium { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.account-card { display: grid; grid-template-columns: auto 1fr; gap: 14px 16px; align-items: center; margin-top: 16px; }
.account-card .who { display: grid; gap: 2px; min-width: 0; }
.account-card .who b { font-size: 20px; }
.account-card .who .en { overflow: hidden; text-overflow: ellipsis; text-align: start; }
.account-card .actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
@media (min-width: 620px) { .account-card { grid-template-columns: auto 1fr auto; } .account-card .actions { grid-column: auto; } }
.edit-profile { grid-column: 1 / -1; display: grid; gap: 12px; padding-top: 14px; border-top: 1px solid var(--border); animation: popIn .2s ease-out; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }
.avatar-pick { width: 46px; height: 46px; font-size: 22px; cursor: pointer; background: var(--bg-soft); color: var(--text-2); border: 2px solid var(--border); transition: transform .12s, border-color .12s, background .12s; }
.avatar-pick:hover { transform: translateY(-2px); }
.avatar-pick.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); transform: scale(1.08); }
.sub-card { margin-top: 14px; display: grid; gap: 14px; }
.sub-card.is-premium { border-color: var(--accent); }
.sub-head { display: flex; gap: 12px; align-items: center; }
.sub-head b { font-size: 17px; }
.sub-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--bg-soft); color: var(--text-2); font-size: 22px; flex: none; }
.sub-card.is-premium .sub-icon { background: var(--accent-soft); color: var(--accent-strong); }
.sub-days { display: grid; gap: 6px; }
.sub-code { display: grid; gap: 8px; }
.code-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.code-form input { font-family: var(--font-en); letter-spacing: .06em; font-size: 16px; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); min-width: 0; transition: border-color .15s, box-shadow .15s; }
.code-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.code-form .form-msg { grid-column: 1 / -1; }
.code-form.shake { animation: shake .35s; }
.btn.is-loading { opacity: .7; cursor: progress; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 10px 0; }
.step-n { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--bg-soft); border: 1px solid var(--border); font-weight: 800; font-family: var(--font-en); color: var(--text-2); }
.step.done .step-n { background: var(--accent); border-color: transparent; color: #fff; }
.step-body { display: grid; gap: 6px; align-content: start; padding-top: 5px; min-width: 0; }
.step-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- light motion ---------- */
.app.page-in > * { animation: pageIn .28s ease-out both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } }
.btn:active:not(:disabled) { transform: scale(.97); }
.brand img { transition: transform .3s; }
.brand:hover img { transform: rotate(-6deg) scale(1.05); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.confetti i { position: absolute; top: 38%; width: 9px; height: 14px; border-radius: 3px; animation: confetti 1.3s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--x), 60vh) rotate(var(--r)); opacity: 0; }
}

/* ---------- free stories, locked stories and the subscribe page ---------- */
.story-card .row-end { display: inline-flex; align-items: center; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--text-2); }
.tag-free { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.tag-lock i { font-size: 13px; }
.story-card.is-locked .story-icon, .story-card.is-locked h3, .story-card.is-locked .progress-row { opacity: .55; }
.pay-card { width: min(480px, 100%); }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 14px 10px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-soft); }
.plan i { font-size: 26px; color: var(--accent-strong); }

/* The hidden attribute always wins over display rules above. */
[hidden] { display: none !important; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
