:root {
  --bg: #eef0f8;
  --card: #ffffff;
  --ink: #1b1e33;
  --muted: #6b7091;
  --line: #dde0f0;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #e8e7fd;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn-soft: #fef3c7;
  --shadow: 0 6px 24px rgba(40, 45, 110, .10);
  --radius: 18px;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1020;
    --card: #1a1d36;
    --ink: #eceefb;
    --muted: #9a9fc4;
    --line: #2b2f52;
    --accent: #818cf8;
    --accent-ink: #0e1020;
    --accent-soft: #272a55;
    --ok: #4ade80;
    --ok-soft: #12351f;
    --bad: #f87171;
    --bad-soft: #3d1a1f;
    --warn-soft: #3b3010;
    --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Üst çubuk + gezinme ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 800;
}
.ver { font-weight: 500; font-size: .7rem; color: var(--muted); }
.icon-btn { margin-left: auto; background: none; border: 0; font-size: 22px; padding: 6px 8px; border-radius: 10px; }
.icon-btn:hover { background: var(--accent-soft); }

#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
#nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
#nav a .ic { font-size: 22px; filter: grayscale(.6); }
#nav a.on { color: var(--accent); }
#nav a.on .ic { filter: none; }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  #nav { position: static; height: auto; border: 0; padding: 0; background: none; margin-left: 24px; gap: 4px; }
  #nav a { flex: none; flex-direction: row; gap: 8px; padding: 8px 14px; border-radius: 12px; font-size: 15px; }
  #nav a .ic { font-size: 18px; }
  #nav a.on { background: var(--accent-soft); }
  main { padding-bottom: 48px; }
}

/* ---------- Ortak bileşenler ---------- */
h1 { font-size: 1.35rem; margin: 4px 0 12px; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; border: 1px solid var(--line);
}
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 12px 18px; font-weight: 600; min-height: 48px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.btn.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn.ghost { background: none; }
.btn.sm { padding: 6px 12px; min-height: 36px; font-size: .9rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.wide { width: 100%; }

input[type=text], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); min-height: 44px;
}
textarea { min-height: 140px; resize: vertical; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; }
label.field > select, label.field > input { margin-top: 4px; color: var(--ink); font-weight: 400; }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.seg { display: inline-flex; background: var(--accent-soft); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 8px 14px; border-radius: 10px; font-weight: 600; color: var(--muted); min-height: 38px; }
.seg button.on { background: var(--card); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.seg.full { display: flex; flex-wrap: nowrap; }
.seg.full button { flex: 1; padding: 8px 6px; font-size: .92rem; white-space: nowrap; }

.scope { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (max-width: 340px) { .scope { grid-template-columns: 1fr; } }
.scope select { padding: 10px 8px; font-size: .92rem; }

.bar { height: 8px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }

.empty { text-align: center; padding: 40px 20px; }
.empty .big-ic { font-size: 48px; }

.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: #92400e; }
@media (prefers-color-scheme: dark) { .tag.warn { color: #fcd34d; } }

/* ---------- Çalışma kartı ---------- */
.flash {
  text-align: center; padding: 28px 20px 24px; min-height: 270px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; user-select: none;
}
.flash .lab { font-size: .72rem; letter-spacing: 1.5px; font-weight: 700; color: var(--muted); }
.flash .word { font-size: clamp(2rem, 8vw, 2.9rem); font-weight: 800; line-height: 1.15; word-break: break-word; }
.flash .meaning { font-size: clamp(1.25rem, 5vw, 1.7rem); font-weight: 600; color: var(--accent); min-height: 2em; }
.flash .hint { color: var(--muted); font-size: .9rem; }
.speak { border: 0; background: var(--accent-soft); color: var(--accent); width: 46px; height: 46px; border-radius: 50%; font-size: 20px; }
.speak.sm { width: 34px; height: 34px; font-size: 15px; flex: none; }
.counter { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin: 6px 2px 10px; }
.actions { display: grid; grid-template-columns: 52px 1fr 1fr 52px; gap: 10px; margin-top: 14px; }
.actions .btn { padding: 12px 6px; }
.kbd { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 12px; }
@media (hover: none) { .kbd { display: none; } }

/* ---------- Quiz ---------- */
.q-label { font-size: .72rem; letter-spacing: 1.5px; font-weight: 700; color: var(--muted); text-align: center; }
.q-word { text-align: center; font-size: clamp(1.7rem, 7vw, 2.4rem); font-weight: 800; margin: 8px 0 4px; word-break: break-word; }
.opts { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  text-align: left; padding: 14px 16px; min-height: 56px; border-radius: 14px; border: 2px solid var(--line);
  background: var(--card); font-weight: 600; display: flex; gap: 12px; align-items: center;
}
.opt b { flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: .85rem; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.verdict { margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-weight: 600; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.score { font-size: 3.2rem; font-weight: 800; text-align: center; color: var(--accent); line-height: 1.1; }
.wrong-list { display: grid; gap: 8px; margin-top: 8px; }
.wrong-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--bad-soft); }

/* ---------- Dinle ---------- */
.now { text-align: center; padding: 28px 16px; }
.now .w { font-size: clamp(2rem, 8vw, 2.8rem); font-weight: 800; }
.now .m { font-size: 1.3rem; color: var(--accent); font-weight: 600; margin-top: 6px; min-height: 1.6em; }
.transport { display: flex; justify-content: center; gap: 16px; align-items: center; margin: 18px 0 8px; }
.transport .btn { border-radius: 50%; width: 56px; height: 56px; padding: 0; font-size: 20px; }
.transport .btn.play { width: 76px; height: 76px; font-size: 30px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .settings-grid { grid-template-columns: 1fr; } }
input[type=range] { width: 100%; accent-color: var(--accent); }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); font-size: .9rem; }

#dim { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; cursor: pointer; }
.dim-word { color: #3a3a4a; font-size: 2rem; font-weight: 700; text-align: center; padding: 0 20px; }
.dim-hint { color: #2a2a35; font-size: .8rem; }

/* ---------- Kelimeler ---------- */
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.wrow { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer; }
.wrow + .wrow { margin-top: 8px; }
.wrow .t { flex: 1; min-width: 0; }
.wrow .en { font-weight: 700; }
.wrow .tr { color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.wrow.known .en { color: var(--ok); }

/* ---------- Ekle ---------- */
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; text-align: center; background: var(--card);
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.review-row { display: grid; grid-template-columns: 28px 1fr 1.4fr 36px; gap: 8px; align-items: center; padding: 8px; border-radius: 12px; }
.review-row + .review-row { margin-top: 6px; }
.review-row.guess { background: var(--warn-soft); }
.review-row.dup { opacity: .55; }
.review-row.low { background: var(--bad-soft); }
.review-row input[type=text] { min-height: 40px; padding: 8px 10px; }
.review-row input.missing { border-color: var(--bad); }
.review-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.rm { border: 0; background: none; font-size: 18px; color: var(--muted); }
@media (max-width: 520px) {
  .review-row { grid-template-columns: 24px 1fr 30px; background: var(--card); border: 1px solid var(--line); }
  .review-row.guess { background: var(--warn-soft); }
  .review-row .rm { grid-column: 3; grid-row: 1; }
  .review-row .tr-cell { grid-column: 2 / 4; grid-row: 2; }
}
.progress-text { font-weight: 600; }
details summary { cursor: pointer; font-weight: 600; margin: 10px 0; }

/* ---------- Modal / bildirim ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(10, 12, 30, .55); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 22px; } }
.sheet h2:first-child { margin-top: 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #1b1e33; color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 80; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { #toast { bottom: 28px; } }

/* ---------- Eşleştirme ---------- */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mcol { display: grid; gap: 10px; align-content: start; }
.mbtn { text-align: left; padding: 12px; min-height: 54px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font-weight: 600; overflow-wrap: anywhere; }
.mbtn:hover:not(:disabled) { border-color: var(--accent); }
.mbtn.sel { border-color: var(--accent); background: var(--accent-soft); }
.mbtn.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); opacity: .65; }
.mbtn.bad { border-color: var(--bad); background: var(--bad-soft); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- Erişim kapısı ---------- */
.gate { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.gate-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 22px; text-align: center; display: grid; gap: 12px; }
.logo.big { width: 56px; height: 56px; border-radius: 16px; font-size: 24px; margin: 0 auto; }
.gate-card h1 { margin: 0; }
.gate-card p { margin: 0; }
.gate-err { color: var(--bad); font-weight: 600; font-size: .9rem; }
