:root {
  --bg: #0b1220;
  --surface: #141e30;
  --surface2: #1c2a44;
  --text: #e8eef7;
  
  --muted: #9fb0c8;
  --accent: #3d9cf0;
  --accent-dim: #0f4c81;
  --good: #2ecc71;
  --hard: #f1c40f;
  --again: #e74c3c;
  --easy: #1abc9c;
  --border: #2a3b58;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  min-height: 100%;
}
body {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 0 88px;
}

header.app-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(11,18,32,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
header h1 {
  font-size: 1.05rem; margin: 0; font-weight: 650;
}
header .sub {
  font-size: .72rem; color: var(--muted); margin: 2px 0 0;
}
.badge {
  font-size: .7rem; padding: 4px 8px; border-radius: 999px;
  background: var(--surface2); color: var(--muted);
  border: 1px solid var(--border);
}

nav.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(560px, 100%);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 30;
}
nav.tabs button {
  background: transparent; border: 0; color: var(--muted);
  padding: 12px 8px 14px; font-size: .85rem; cursor: pointer;
}
nav.tabs button.active { color: var(--accent); font-weight: 600; }

main { padding: 16px; }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

.topic-pill {
  display: inline-block;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px;
  background: var(--accent-dim); color: #cfe6ff;
  margin-bottom: 10px;
}
.question {
  font-size: 1.12rem; line-height: 1.45; margin: 0 0 14px;
}
.options { display: grid; gap: 8px; }
.option, .tf-btn {
  width: 100%; text-align: left;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: .98rem; cursor: pointer;
}
.option:hover, .tf-btn:hover { border-color: var(--accent); }
.option.correct, .tf-btn.correct {
  border-color: var(--good); background: rgba(46,204,113,.15);
}
.option.wrong, .tf-btn.wrong {
  border-color: var(--again); background: rgba(231,76,60,.15);
}
.option:disabled, .tf-btn:disabled { opacity: .95; cursor: default; }

.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.explanation {
  margin-top: 14px; padding: 12px;
  background: rgba(61,156,240,.1);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: .92rem; line-height: 1.45;
}
.explanation .src {
  margin-top: 8px; font-size: .75rem; color: var(--muted);
}
.result-line {
  font-weight: 650; margin-bottom: 6px;
}
.result-line.ok { color: var(--good); }
.result-line.bad { color: var(--again); }

.ratings {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-top: 14px;
}
.ratings button {
  border: 0; border-radius: 10px; padding: 12px 4px;
  font-weight: 650; cursor: pointer; color: #0b1220;
}
.ratings .again { background: var(--again); color: #fff; }
.ratings .hard { background: var(--hard); }
.ratings .good { background: var(--good); color: #062; }
.ratings .easy { background: var(--easy); color: #043; }
.ratings button small { display: block; font-weight: 500; font-size: .65rem; opacity: .85; }

.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.stat {
  background: var(--surface2); border-radius: 12px; padding: 12px;
  border: 1px solid var(--border);
}
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { font-size: .75rem; color: var(--muted); }

.progress-bar {
  height: 8px; background: var(--surface2); border-radius: 999px; overflow: hidden;
  margin: 8px 0 4px;
}
.progress-bar > span {
  display: block; height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  width: 0%;
}

.topic-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem;
}
.topic-row:last-child { border-bottom: 0; }
.weak { color: var(--again); }
.okish { color: var(--hard); }
.strong { color: var(--good); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
button.primary, button.ghost, button.danger {
  border-radius: 10px; padding: 10px 14px; font-size: .9rem; cursor: pointer; border: 1px solid var(--border);
}
button.primary { background: var(--accent); color: #041018; border-color: transparent; font-weight: 650; }
button.ghost { background: var(--surface2); color: var(--text); }
button.danger { background: rgba(231,76,60,.15); color: #ffb4aa; border-color: #7a3030; }

.empty {
  text-align: center; color: var(--muted); padding: 28px 12px;
}
.select, .input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); margin-top: 6px;
}
label.field { display: block; font-size: .8rem; color: var(--muted); margin-top: 10px; }

.disclaimer {
  font-size: .72rem; color: var(--muted); line-height: 1.4; margin-top: 12px;
}

@media (min-width: 600px) {
  body { padding-bottom: 96px; }
  .question { font-size: 1.2rem; }
}
