:root {
  --bg: #f6f4ff;
  --surface: #ffffff;
  --surface-2: #efecfa;
  --text: #1c1830;
  --muted: #6c6785;
  --border: #e2ddf2;
  --accent: #6d4aff;
  --accent-2: #9b7bff;
  --accent-soft: #ebe5ff;
  --good: #1f9d63;
  --good-soft: #dff5ea;
  --bad: #e0445a;
  --bad-soft: #fde4e8;
  --warn: #d98a00;
  --lv-a1: #2fa36b;
  --lv-a2: #1b9aaa;
  --lv-b1: #3f6ee8;
  --lv-b2: #a34be0;
  --shadow: 0 6px 24px rgba(60, 40, 140, .08);
  --hero-1: #6d4aff;
  --hero-2: #9b7bff;
  --radius: 18px;
  --tabbar-h: 62px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e0d14;
  --surface: #1a1824;
  --surface-2: #252232;
  --text: #f2f0fa;
  --muted: #a39fb8;
  --border: #2d2940;
  --accent: #9a80ff;
  --accent-2: #b8a4ff;
  --accent-soft: #2c2547;
  --good: #3ccf8e;
  --good-soft: #163527;
  --bad: #ff6b7f;
  --bad-soft: #3d1c24;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --hero-1: #3d2a99;
  --hero-2: #5a3fc4;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; font-size: 17px; color: inherit; }

#app { min-height: 100dvh; }
#view {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}
body.quiz-mode #view { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
body.quiz-mode #tabbar { display: none; }

/* Tab bar */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 4px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
}
#tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; font-size: 11px; color: var(--muted); font-weight: 600;
}
#tabbar .ti { font-size: 22px; filter: grayscale(1); opacity: .7; }
#tabbar button.active { color: var(--accent); }
#tabbar button.active .ti { filter: none; opacity: 1; }

/* Typography */
h1 { font-size: 30px; line-height: 1.15; margin: 6px 0 4px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 26px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 17px; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card + .card { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 > .card + .card { margin-top: 0; }
.stack > * + * { margin-top: 12px; }

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--hero-1), var(--hero-2));
  color: #fff; border: 0;
}
.hero .muted { color: rgba(255,255,255,.85); }
.hero h3 { color: #fff; }
.ring-wrap { display: flex; align-items: center; gap: 16px; }
.ring { width: 76px; height: 76px; flex: none; }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: rgba(255,255,255,.25); }
.ring .val { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring text { fill: #fff; font-weight: 700; font-size: 20px; }
.streak { font-size: 15px; font-weight: 600; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 12px 18px;
  border-radius: 16px; font-weight: 700; font-size: 17px;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.secondary { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: none; min-height: 44px; }
.btn.white { background: #fff; color: var(--hero-1); box-shadow: none; }
.btn:disabled { opacity: .45; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); font-size: 20px; flex: none;
}

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: 15px;
  border: 2px solid transparent; min-height: 40px;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.lv { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 8px; color: #fff; letter-spacing: .03em; }
.lv-a1 { background: var(--lv-a1); } .lv-a2 { background: var(--lv-a2); }
.lv-b1 { background: var(--lv-b1); } .lv-b2 { background: var(--lv-b2); }
.pos { font-size: 13px; color: var(--muted); font-style: italic; }

/* Mode list */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode {
  text-align: left; padding: 14px; border-radius: 16px; background: var(--surface);
  border: 2px solid var(--border); min-height: 86px;
}
.mode .mi { font-size: 22px; }
.mode b { display: block; font-size: 15px; margin-top: 4px; }
.mode span.d { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.mode.on { border-color: var(--accent); background: var(--accent-soft); }

/* Progress bars */
.bar { height: 10px; border-radius: 10px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }
.bar .learned { background: var(--good); }
.bar .learning { background: var(--warn); opacity: .75; }
.lvl-row { margin: 14px 0; }
.lvl-row .row { margin-bottom: 6px; }
.stat { text-align: center; padding: 14px 8px; }
.stat b { display: block; font-size: 26px; letter-spacing: -.02em; }
.stat span { font-size: 13px; color: var(--muted); }

/* Quiz */
.qtop { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.qprog { flex: 1; height: 10px; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.qprog i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s ease; }
.qcount { font-size: 14px; color: var(--muted); font-weight: 600; min-width: 46px; text-align: right; }
.qtype { font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.prompt { padding: 22px 18px; text-align: center; }
.prompt .big { font-size: 36px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; word-break: break-word; }
.prompt .mid { font-size: 22px; font-weight: 700; line-height: 1.3; }
.prompt .sentence { font-size: 21px; line-height: 1.45; font-weight: 500; text-align: left; }
.prompt .hint { margin-top: 10px; color: var(--muted); font-size: 15px; }
.blank { display: inline-block; min-width: 80px; border-bottom: 3px solid var(--accent); color: var(--accent); font-weight: 700; text-align: center; }
.blank.filled-good { color: var(--good); border-color: var(--good); }
.blank.filled-bad { color: var(--bad); border-color: var(--bad); }
.phon { color: var(--muted); font-size: 16px; margin-top: 6px; }
.listen-btn {
  width: 96px; height: 96px; border-radius: 48px; font-size: 42px;
  background: var(--accent-soft); color: var(--accent); margin: 6px auto;
  display: flex; align-items: center; justify-content: center;
}
.listen-btn:active { transform: scale(.96); }

.options { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  width: 100%; min-height: 58px; padding: 12px 16px; text-align: left;
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px;
  font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 12px;
  transition: transform .08s ease, background .2s, border-color .2s;
}
.opt:active { transform: scale(.985); }
.opt .k {
  width: 28px; height: 28px; border-radius: 9px; background: var(--surface-2); flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); font-weight: 700;
}
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.correct .k { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .k { background: var(--bad); color: #fff; }
.opt.dim { opacity: .5; }
.opt:disabled { cursor: default; }

.type-box { margin-top: 16px; }
.type-box input {
  width: 100%; height: 58px; border-radius: 16px; border: 2px solid var(--border);
  background: var(--surface); padding: 0 16px; font-size: 20px; font-weight: 600; outline: none;
}
.type-box input:focus { border-color: var(--accent); }
.type-box input.good { border-color: var(--good); background: var(--good-soft); }
.type-box input.bad { border-color: var(--bad); background: var(--bad-soft); }
.type-box .btn { margin-top: 10px; }
.letters { letter-spacing: .25em; font-family: ui-monospace, Menlo, monospace; font-size: 18px; color: var(--muted); margin-top: 8px; }

.feedback { margin-top: 16px; animation: up .25s ease; }
.feedback .verdict { font-weight: 800; font-size: 18px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.feedback .verdict.good { color: var(--good); }
.feedback .verdict.bad { color: var(--bad); }
.word-detail .w { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.word-detail .tr { font-size: 18px; font-weight: 600; margin-top: 2px; }
.word-detail .def { margin-top: 10px; }
.word-detail .ex { margin-top: 10px; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; }
.word-detail .ex em { font-style: normal; font-weight: 700; color: var(--accent); }
.word-detail .ex .extr { color: var(--muted); font-size: 15px; margin-top: 4px; }
.next-bar {
  position: sticky; bottom: 0; padding: 14px 0 calc(env(safe-area-inset-bottom) + 6px);
  background: linear-gradient(to bottom, transparent, var(--bg) 30%);
}
@keyframes up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 30%, 70% { transform: translateX(4px); } 50% { transform: translateX(-4px); } }
.shake { animation: shake .4s ease; }

/* Result */
.result-hero { text-align: center; padding: 26px 18px; }
.result-hero .emoji { font-size: 56px; }
.result-hero .score { font-size: 44px; font-weight: 800; letter-spacing: -.03em; }
.missed-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.missed-item:last-child { border-bottom: 0; }

/* Word list */
.search {
  position: sticky; top: 0; z-index: 5; padding: calc(env(safe-area-inset-top) + 8px) 0 10px; margin-top: calc(-1 * env(safe-area-inset-top) - 14px);
  background: var(--bg);
}
.search input {
  width: 100%; height: 46px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); padding: 0 14px; outline: none; font-size: 17px;
}
.search .chips { margin-top: 10px; }
.search .chip { padding: 6px 12px; min-height: 34px; font-size: 14px; }
.wlist { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.witem { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); width: 100%; text-align: left; }
.witem:last-child { border-bottom: 0; }
.witem .wm { flex: 1; min-width: 0; }
.witem .wm b { font-size: 17px; }
.witem .wm div { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex: none; background: var(--surface-2); border: 1px solid var(--border); }
.dot.s1 { background: var(--warn); border-color: var(--warn); }
.dot.s2 { background: var(--good); border-color: var(--good); }
.dot.s0 { background: var(--bad); border-color: var(--bad); }

/* Settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: 0; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.seg button { padding: 7px 12px; border-radius: 9px; font-weight: 600; font-size: 15px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.switch { width: 52px; height: 32px; border-radius: 16px; background: var(--surface-2); position: relative; flex: none; border: 1px solid var(--border); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .2s; }
.switch.on { background: var(--good); border-color: var(--good); }
.switch.on::after { left: 23px; }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet.hidden { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 8, 20, .45); animation: fade .2s ease; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 20px);
  animation: slide .25s ease; max-width: 560px; margin: 0 auto;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateY(40px); opacity: .4; } }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
  z-index: 60; animation: up .2s ease; max-width: 90vw; text-align: center;
}
.loading { min-height: 70dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--surface-2); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tip { font-size: 14px; color: var(--muted); background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }

/* Açık temada iPhone durum çubuğu (beyaz yazı) okunabilsin diye üstte koyu şerit */
:root:not([data-theme="dark"]) body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top);
  background: var(--accent); z-index: 100;
}
