/* ===== Tema değişkenleri ===== */
:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface2: #ece8de;
  --text: #22222a;
  --text-dim: #6b6b76;
  --accent: #7c4dbc;
  --accent-soft: #ede5f8;
  --ok: #2e8b57;
  --bad: #c0443c;
  --warn: #b8860b;
  --border: #ddd8cc;
  --shadow: 0 2px 10px rgba(0,0,0,.08);
}
:root[data-theme="dark"] {
  --bg: #15151f;
  --surface: #1f1f2e;
  --surface2: #2a2a3c;
  --text: #eae7f0;
  --text-dim: #9a97a8;
  --accent: #b08de0;
  --accent-soft: #322a44;
  --ok: #56b881;
  --bad: #e07a72;
  --warn: #d4a63a;
  --border: #34344a;
  --shadow: 0 2px 10px rgba(0,0,0,.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
}

/* ===== Üst bar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  padding-top: calc(.7rem + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1.05rem; flex: 1; text-align: center; font-weight: 600; }
.icon-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text);
  padding: .25rem .4rem;
  border-radius: 8px;
}
.icon-btn:active { background: var(--surface2); }

main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 2.5rem;
}
.foot {
  text-align: center;
  font-size: .75rem;
  color: var(--text-dim);
  padding: .5rem 0 calc(.5rem + env(safe-area-inset-bottom));
}
.loading { text-align: center; color: var(--text-dim); padding: 3rem 0; }

/* ===== Ana ekran ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
  margin-bottom: 1rem;
}
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .7rem .4rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-box .num { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.stat-box .lbl { font-size: .72rem; color: var(--text-dim); }

.countdown {
  text-align: center;
  font-size: .85rem;
  color: var(--warn);
  margin-bottom: 1rem;
  font-weight: 600;
}

.mode-grid { display: grid; gap: .7rem; margin-bottom: 1.2rem; }
.mode-btn {
  display: flex;
  align-items: center;
  gap: .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-size: 1rem;
  box-shadow: var(--shadow);
  transition: transform .1s;
}
.mode-btn:active { transform: scale(.98); }
.mode-btn .emoji { font-size: 1.7rem; }
.mode-btn .m-title { font-weight: 600; }
.mode-btn .m-desc { font-size: .8rem; color: var(--text-dim); }
.mode-btn .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .8rem;
  font-weight: 700;
}
.mode-btn .badge.zero { background: var(--surface2); color: var(--text-dim); }

/* Ustalık çubukları */
.mastery { margin-bottom: 1.2rem; }
.mastery h2, .section-title {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  margin-bottom: .5rem;
}
.m-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; font-size: .85rem; }
.m-row .m-axis { flex: 0 0 8.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-bar { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.m-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s; }
.m-pct { flex: 0 0 2.6rem; text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* Araçlar */
.tools { display: flex; flex-wrap: wrap; gap: .5rem; }
.tool-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: .5rem .8rem;
  font-size: .82rem;
  cursor: pointer;
}

/* ===== Kart görünümü ===== */
.session-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .8rem;
  font-size: .85rem;
  color: var(--text-dim);
}
.progressbar { height: 5px; background: var(--surface2); border-radius: 3px; margin-bottom: 1rem; overflow: hidden; }
.progressbar .p-fill { height: 100%; background: var(--accent); transition: width .3s; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.3rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  min-height: 180px;
}
.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .8rem;
  font-size: .72rem;
}
.chip {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: .12rem .55rem;
  font-weight: 600;
}
.chip.type-tuzak { background: #f8e2e0; color: var(--bad); }
:root[data-theme="dark"] .chip.type-tuzak { background: #442e2c; }
.chip.diff { background: var(--surface2); color: var(--text-dim); }
.card .front { font-size: 1.05rem; font-weight: 600; white-space: pre-wrap; }
.card .back { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); font-size: .95rem; }
.back p { margin-bottom: .55rem; }
.back .premise {
  padding-left: .8rem;
  border-left: 3px solid var(--accent);
  margin-bottom: .45rem;
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  padding-top: .2rem; padding-bottom: .2rem; padding-right: .4rem;
}
.back .conclusion { font-weight: 700; }
.pnote {
  margin-top: 1rem;
  background: var(--accent-soft);
  border-left: 4px solid var(--warn);
  border-radius: 0 8px 8px 0;
  padding: .7rem .9rem;
  font-size: .88rem;
}
.pnote .pnote-title { font-weight: 700; color: var(--warn); font-size: .78rem; margin-bottom: .2rem; }
.tagline { margin-top: .9rem; font-size: .72rem; color: var(--text-dim); }

/* Cevap butonları */
.answer-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.answer-row.single { grid-template-columns: 1fr; }
.big-btn {
  border: none;
  border-radius: 12px;
  padding: .95rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
}
.big-btn.show { background: var(--accent); }
.big-btn.ok { background: var(--ok); }
.big-btn.bad { background: var(--bad); }
.big-btn.neutral { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.big-btn:active { filter: brightness(.9); }

/* ===== Formlar (sınav kurulumu vb.) ===== */
.setup { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.1rem; box-shadow: var(--shadow); }
.setup label { display: block; font-size: .82rem; color: var(--text-dim); margin: .8rem 0 .3rem; }
.setup label:first-child { margin-top: 0; }
.setup select, .setup input[type=number] {
  width: 100%;
  padding: .6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
}
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg button {
  flex: 1;
  min-width: 3rem;
  padding: .55rem 0;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 10px;
  font-size: .95rem;
  cursor: pointer;
}
.seg button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.setup .big-btn { width: 100%; margin-top: 1.1rem; }

/* ===== Sonuç ekranı ===== */
.result-score { text-align: center; padding: 1.2rem 0; }
.result-score .big { font-size: 2.6rem; font-weight: 800; color: var(--accent); }
.result-score .sub { color: var(--text-dim); font-size: .9rem; }
.wrong-list .card { min-height: 0; padding: 1rem; }

/* ===== Serbest gezinme ===== */
.filter-bar { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.filter-bar select {
  padding: .55rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .95rem;
}
.browse-card { cursor: pointer; }
.browse-card .back.hidden, .hidden { display: none; }
.hint { font-size: .78rem; color: var(--text-dim); text-align: center; margin-bottom: .8rem; }

/* Kutu rozetleri */
.boxtag { font-size: .7rem; color: var(--text-dim); }

/* Sınav zamanlayıcı */
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }

.empty-msg { text-align: center; color: var(--text-dim); padding: 2.5rem 1rem; }
.empty-msg .emoji { font-size: 2.5rem; display: block; margin-bottom: .6rem; }

@media (min-width: 560px) {
  .mode-grid { grid-template-columns: 1fr 1fr; }
}
