:root {
  color-scheme: light;
  --bg: #eef3ff;
  --bg-2: #fdf3ff;
  --surface: #ffffff;
  --ink: #1f2140;
  --ink-2: #5b5f86;
  --line: #e2e6f5;
  --primary: #6c5ce7;
  --primary-2: #8e7cff;
  --primary-ink: #ffffff;
  --accent: #ff9f43;
  --good: #1fae6b;
  --good-bg: #e3f8ee;
  --warn: #e0a100;
  --warn-bg: #fff5d6;
  --bad: #e64a61;
  --bad-bg: #fde8ec;
  --az-face: linear-gradient(160deg, #fff7e0, #ffe6c7);
  --en-face: linear-gradient(160deg, #ffffff, #f1efff);
  --radius: 22px;
  --shadow: 0 10px 30px rgba(60, 50, 150, 0.12), 0 2px 6px rgba(60, 50, 150, 0.08);
  --font: ui-rounded, 'SF Pro Rounded', 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(1200px 600px at 10% -10%, #dfe8ff, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #ffe3f3, transparent 60%), var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  padding: max(14px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- ümumi ---------- */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.topbar h1 { font-size: 1.25rem; margin: 0; flex: 1; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0;
  background: var(--surface); box-shadow: var(--shadow); font-size: 1.2rem;
  display: inline-grid; place-items: center; flex: none;
}
.btn {
  border: 0; border-radius: 16px; padding: 14px 20px; font-weight: 700; font-size: 1.05rem;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  transition: transform 0.12s ease, filter 0.12s ease; touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink); }
.btn.good { background: var(--good); color: #fff; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn.big { padding: 18px 24px; font-size: 1.25rem; border-radius: 20px; width: 100%; }
.btn.small { padding: 9px 14px; font-size: 0.92rem; border-radius: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.center { text-align: center; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel h2 { margin: 0 0 10px; font-size: 1.05rem; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: #f1f0ff; color: var(--primary); font-weight: 700; font-size: 0.85rem; border: 0;
}
.chip.on { background: var(--primary); color: #fff; }
input[type='text'], input[type='search'], select, textarea {
  width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px;
  background: #fff; font-size: 1.05rem; outline: none; transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-2); }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 0.92rem; }
label.field small { font-weight: 500; color: var(--ink-2); }

/* ---------- profillər ---------- */
.hero-title { font-size: 1.8rem; margin: 18px 0 2px; text-align: center; }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.profile-card {
  border: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.profile-card .avatar { font-size: 3rem; line-height: 1; }
.profile-card strong { font-size: 1.1rem; }
.profile-card.add { border: 2px dashed #c9c3ff; background: transparent; box-shadow: none; color: var(--primary); }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.avatars button { font-size: 1.6rem; border: 2px solid transparent; background: #f6f5ff; border-radius: 12px; padding: 6px 0; }
.avatars button.on { border-color: var(--primary); background: #ebe8ff; }

/* ---------- ana ekran ---------- */
.hello { display: flex; align-items: center; gap: 12px; }
.hello .avatar { font-size: 2.6rem; }
.hello h1 { margin: 0; font-size: 1.4rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 1.4rem; }
.stat span { font-size: 0.8rem; color: var(--ink-2); }
.level { display: flex; align-items: center; gap: 12px; }
.level .icon { font-size: 2rem; }
.bar { height: 10px; background: #edebff; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: inherit; transition: width 0.4s ease; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode {
  border: 2px solid transparent; background: var(--surface); border-radius: 16px; padding: 12px 6px;
  box-shadow: var(--shadow); font-weight: 800; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.mode small { font-weight: 600; color: var(--ink-2); font-size: 0.75rem; }
.mode.on { border-color: var(--primary); background: #f3f1ff; }
.banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px;
  background: var(--warn-bg); color: #6b4e00; font-weight: 700;
}
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history li { display: flex; justify-content: space-between; font-size: 0.92rem; }

/* ---------- dərs ---------- */
.session-top { display: flex; align-items: center; gap: 10px; }
.session-top .bar { flex: 1; height: 14px; }
.score-pill {
  position: relative; background: var(--surface); box-shadow: var(--shadow); border-radius: 999px;
  padding: 8px 14px; font-weight: 800; min-width: 74px; text-align: center;
}
.float-pts {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, 0); font-weight: 900; color: var(--good);
  animation: floatUp 1s ease-out forwards; pointer-events: none; white-space: nowrap;
}
.float-pts.low { color: var(--warn); }
@keyframes floatUp { to { transform: translate(-50%, -42px); opacity: 0; } }

.card-scene { perspective: 1400px; }
.card {
  position: relative; height: clamp(190px, 34vh, 300px); transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.card.no-anim { transition: none; }
.face {
  position: absolute; inset: 0; border-radius: 26px; box-shadow: var(--shadow);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 44px 18px 18px; text-align: center; border: 3px solid transparent; transition: border-color 0.3s;
}
.face.en { background: var(--en-face); }
.face.az { background: var(--az-face); transform: rotateY(180deg); }
.face .word { font-size: clamp(2rem, 9vw, 3rem); font-weight: 900; line-height: 1.1; word-break: break-word; }
.face.en .word { color: var(--primary); }
.face.az .word { color: #b4570b; }
.face .tr { font-size: 1.25rem; color: var(--ink-2); font-style: italic; }
.face .lang { position: absolute; top: 14px; left: 16px; font-weight: 800; font-size: 0.8rem; color: var(--ink-2); letter-spacing: 0.04em; }
.face .tags { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.tag { font-size: 0.72rem; font-weight: 800; padding: 4px 8px; border-radius: 999px; background: rgba(108, 92, 231, 0.12); color: var(--primary); }
.tag.past { background: rgba(255, 159, 67, 0.2); color: #b4570b; }
.tag.new { background: #20bf6b; color: #fff; }
.tag.review { background: #4b7bec; color: #fff; }
.speak { border: 0; background: rgba(108, 92, 231, 0.12); color: var(--primary); border-radius: 999px; padding: 8px 14px; font-weight: 800; }
.card.good .face { border-color: var(--good); }
.card.warn .face { border-color: var(--warn); }
.card.bad .face { border-color: var(--bad); }
.card-scene.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.feedback { min-height: 26px; text-align: center; font-weight: 800; font-size: 1.05rem; }
.feedback.good { color: var(--good); }
.feedback.warn { color: var(--warn); }
.feedback.bad { color: var(--bad); }
.feedback small { display: block; font-weight: 600; color: var(--ink-2); font-size: 0.9rem; margin-top: 2px; }
.answer-row { display: flex; gap: 8px; }
.answer-row input { font-size: 1.2rem; padding: 14px 16px; border-radius: 16px; }
.answer-row input.good { border-color: var(--good); background: var(--good-bg); }
.answer-row input.warn { border-color: var(--warn); background: var(--warn-bg); }
.answer-row input.bad { border-color: var(--bad); background: var(--bad-bg); }
.answer-row .btn { flex: none; }
.letters { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.letters button { width: 42px; height: 40px; border: 0; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); font-weight: 800; font-size: 1.1rem; }

.reinforce { background: #fffdf3; border: 2px dashed #ffd27a; border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.reinforce h3 { margin: 0; font-size: 1rem; }
.reinforce .r-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.reinforce .r-prompt { grid-column: 1 / -1; font-weight: 700; color: var(--ink-2); font-size: 0.92rem; }
.reinforce .r-row.done input { border-color: var(--good); background: var(--good-bg); }
.reinforce .r-row.retry input { border-color: var(--bad); }

/* ---------- nəticə ---------- */
.result-hero { text-align: center; padding: 22px 16px; }
.result-hero .stars { font-size: 3rem; letter-spacing: 6px; }
.result-hero .stars .off { filter: grayscale(1); opacity: 0.3; }
.result-hero .big-score { font-size: 3.2rem; font-weight: 900; color: var(--primary); line-height: 1; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.learned-list { display: flex; flex-wrap: wrap; gap: 6px; }
.learned-list span { background: var(--good-bg); color: var(--good); font-weight: 800; padding: 6px 10px; border-radius: 999px; }
.review-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.review-list li { display: flex; gap: 8px; align-items: baseline; font-size: 0.95rem; }

/* ---------- sözlər ---------- */
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.filters .chip { flex: none; }
.word-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.word-item { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; }
.word-item .main { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 0; text-align: left; }
.word-item .en { font-weight: 800; color: var(--primary); }
.word-item .az { color: #b4570b; font-weight: 700; }
.word-item .tr { color: var(--ink-2); font-style: italic; font-size: 0.9rem; }
.word-item .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.dots { display: inline-flex; flex-direction: column; gap: 3px; font-size: 0.7rem; color: var(--ink-2); flex: none; text-align: right; }
.dots i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e3e1f7; margin-left: 2px; }
.dots i.on { background: var(--good); }
.status-learned { font-size: 1.3rem; flex: none; }
.count-line { font-size: 0.9rem; color: var(--ink-2); }

dialog {
  border: 0; border-radius: var(--radius); padding: 18px; width: min(520px, calc(100vw - 24px));
  box-shadow: 0 30px 80px rgba(20, 20, 60, 0.35); color: var(--ink);
}
dialog::backdrop { background: rgba(25, 22, 60, 0.45); }
dialog h2 { margin: 0 0 12px; }
textarea { min-height: 180px; font-size: 0.95rem; resize: vertical; }

/* ---------- parametrlər ---------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting select { width: auto; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #d9d7ee; transition: background 0.2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform 0.2s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(22px); }
.note { font-size: 0.88rem; color: var(--ink-2); line-height: 1.45; }
.note.warn { background: var(--warn-bg); color: #6b4e00; padding: 10px 12px; border-radius: 12px; }
input[type='range'] { width: 150px; accent-color: var(--primary); }

/* ---------- toast & konfetti ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #26234a; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700;
  box-shadow: var(--shadow); z-index: 50; animation: toastIn 0.25s ease; max-width: calc(100vw - 32px);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  .card { transition-duration: 0.01s; }
  .confetti { display: none; }
}
