:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7684;
  --border: #e2e5ea;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --ok-bg: #e6f6ec;
  --ok-text: #1a7f43;
  --bad-bg: #fdecec;
  --bad-text: #c0392b;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --card: #1b2129;
    --text: #e7ebf0;
    --muted: #8a94a2;
    --border: #2b333d;
    --accent: #4f8bff;
    --ok-bg: #16311f;
    --ok-text: #6bd497;
    --bad-bg: #3a1e1e;
    --bad-text: #ff8f85;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 10px;
  /* iPhone főképernyőről indítva ne kerüljön a státuszsáv / notch alá */
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

header h1 { font-size: 1.4rem; margin: 0 0 12px; }

nav { display: flex; gap: 6px; flex-wrap: wrap; }

nav button {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: .9rem;
  cursor: pointer;
}

nav button.active { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

h2 { font-size: 1.1rem; margin: 0 0 12px; }

button.primary, a.primary {
  display: block;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
  text-align: center;
  text-decoration: none;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

/* ---------- tanulókártya ---------- */

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .2s; }

.meta { color: var(--muted); font-size: .85rem; margin-bottom: 18px; }
.meta .tag { background: var(--accent); color: #fff; padding: 1px 7px; border-radius: 999px; font-size: .75rem; }
.meta .tag.alt { background: #8b5cf6; }

.prompt {
  font-size: 1.9rem;
  font-weight: 600;
  text-align: center;
  margin: 24px 0;
  word-break: break-word;
}

#ans, .word-form input, .word-form select, textarea, #vocab-filter {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.choice {
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.05rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice.right { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-text); font-weight: 600; }
.choice.wrong { background: var(--bad-bg); color: var(--bad-text); border-color: var(--bad-text); }

#ans { text-align: center; margin-bottom: 14px; }
#ans:disabled { opacity: .7; }

#result { margin-bottom: 14px; }
#result .box {
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
#result.ok .box { background: var(--ok-bg); color: var(--ok-text); }
#result.bad .box { background: var(--bad-bg); color: var(--bad-text); }
#result .verdict { font-weight: 600; margin-bottom: 4px; }
#result .correct-answer { font-size: 1.2rem; font-weight: 600; }
#result .note { margin-top: 8px; font-size: .9rem; opacity: .85; }
#result .reveal-actions { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#result .reveal-actions .ghost { width: auto; }

.cloze-hint { text-align: center; color: var(--muted); font-size: .95rem; margin: -8px 0 18px; }
.cloze-filled { margin-top: 10px; font-size: 1.05rem; }

.start, .summary { text-align: center; padding: 20px 0; }
.start label { display: block; margin-bottom: 16px; color: var(--muted); }
.start select {
  display: block;
  margin: 8px auto 0;
  padding: 10px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.summary h2 { font-size: 1.4rem; }
.summary p { color: var(--muted); margin-bottom: 20px; }
.summary button, .start button { max-width: 240px; margin: 0 auto; }

/* ---------- szótár ---------- */

.word-form label { display: block; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
.word-form label input, .word-form label select { margin-top: 4px; }
.word-form small { display: block; margin-top: 4px; font-size: .78rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row.spread { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row .primary { width: auto; }
#vocab-filter { max-width: 200px; }
td.nowrap, th.nowrap { white-space: nowrap; }

.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 10px; }
.hint code, .word-form small code { background: var(--border); padding: 0 4px; border-radius: 4px; }

a.btn, button.btn { display: inline-block; text-decoration: none; text-align: center; width: auto; }
input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 10px;
  font-family: inherit;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: .82rem;
  cursor: pointer;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
details.card summary { cursor: pointer; font-weight: 600; }
details.card[open] summary { margin-bottom: 12px; }
textarea { margin-bottom: 10px; resize: vertical; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.c, th.c { text-align: center; }
.mini {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: .85rem;
  color: var(--text);
}
.boxpill {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--border);
  font-size: .78rem;
}
.boxpill.done { background: var(--ok-bg); color: var(--ok-text); }
.boxpill.leech { background: var(--bad-bg); color: var(--bad-text); }

/* ---------- statisztika ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .82rem; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.bar-row .lbl { width: 70px; color: var(--muted); }
.bar-row .track { flex: 1; background: var(--border); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-row .fill { display: block; height: 100%; background: var(--accent); min-width: 2px; }
.bar-row .val { width: 28px; text-align: right; color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .9rem;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }
