/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #fff;
  color: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
}

/* ── Nav ──────────────────────────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  background: #fff;
  border-bottom: 1px solid #ddd;
  z-index: 100;
  padding-top: env(safe-area-inset-top);
}

nav.hidden { display: none; }

.nav-item {
  flex: 1;
  min-height: 48px;
  padding: 8px 0 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  color: #999;
  font-size: 0.82rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
}

.nav-item.active { color: #000; border-bottom-color: #000; }
.nav-gear { font-size: 1.3rem; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
main {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-top: calc(48px + env(safe-area-inset-top));
  padding-bottom: 24px;
}

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

/* ── Overlay / Login ──────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}

.overlay.hidden { display: none; }

.login-box {
  width: 90%; max-width: 360px;
  display: flex; flex-direction: column; gap: 12px;
}

.login-box h1 { font-size: 1.5rem; margin-bottom: 8px; }

.login-box input {
  padding: 12px; font-size: 1rem;
  border: 1px solid #ccc; border-radius: 8px;
}

.login-box button {
  padding: 12px; font-size: 1rem; font-weight: bold;
  background: #333; color: #fff;
  border: none; border-radius: 8px; cursor: pointer;
}

.error { color: #c00; font-size: 0.9rem; }
.hidden { display: none !important; }

/* ── Study page wrapper ───────────────────────────────────────────────────── */
.study-header {
  padding: 12px 16px 0;
  display: flex; align-items: center; gap: 10px;
}

.deck-select {
  flex: 1; padding: 9px 10px; font-size: 0.95rem;
  border: 1px solid #ccc; border-radius: 8px; background: #fff;
}

.due-badge {
  font-size: 0.8rem; color: #fff; background: #333;
  padding: 4px 8px; border-radius: 12px; white-space: nowrap;
}

/* ── Card view ────────────────────────────────────────────────────────────── */
.card-view {
  font-family: 'Lucida Console', monospace;
  padding: 16px 16px 80px;
  min-height: calc(100vh - 100px);
}

/* Front */
.card-front {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px;
  min-height: 55vh;
}

.card-front.hidden { display: none; }

.card-image {
  width: 55vw; max-width: 260px;
  height: 55vw; max-height: 260px;
  object-fit: cover; border-radius: 8px;
}

.card-english-front {
  font-size: 1.8rem; font-weight: bold; text-align: center;
}

.show-btn {
  padding: 14px 0; font-size: 1rem; font-weight: bold;
  background: #333; color: #fff;
  border: none; border-radius: 10px; cursor: pointer;
  width: 100%;
}

/* Back */
.card-back { display: none; }
.card-back.visible { display: block; }

.card-english-back {
  font-size: 1.4rem; font-weight: bold;
  margin-bottom: 16px;
}

.section-label {
  display: flex; align-items: center;
  color: grey; font-style: italic;
  margin: 18px 0 8px;
}

.section-label::before {
  content: ""; width: 10px; height: 1px;
  background: grey; margin-right: 8px;
}

.section-label::after {
  content: ""; flex: 1; height: 1px;
  background: grey; margin-left: 8px;
}

.conj-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, auto);
  grid-auto-flow: column;
  gap: 8px;
}

.field-row { display: flex; flex-direction: column; }

.verb-input {
  width: 100%; font-size: 1rem;
  font-family: 'Lucida Console', monospace;
  padding: 5px 7px;
  border: 1px solid #ccc; border-radius: 4px;
  color: navy; background: #fff;
}

.verb-input:focus { outline: 2px solid #333; border-color: transparent; }

.answer-span {
  font-family: 'Lucida Console', monospace;
  font-weight: bold;
  padding: 0.15em 0.35em;
  border-radius: 4px;
  display: none;
}

.answer-span.show { display: inline-block; }
.answer-span.correct-green  { background: #d4f8d4; color: #006400; }
.answer-span.correct-red    { background: #f8d4d4; color: #8b0000; }
.answer-span.correct-neutral { background: #ffe5b4; color: #ff8000; }

/* Check button */
.check-btn {
  display: block; width: 100%;
  margin-top: 20px; padding: 14px 0;
  font-size: 1rem; font-weight: bold;
  background: #333; color: #fff;
  border: none; border-radius: 10px; cursor: pointer;
}

/* Rating bar */
.rating-bar {
  display: none; gap: 12px;
  margin-top: 20px;
}

.rating-bar.visible { display: flex; }

.rating-btn {
  flex: 1; padding: 14px 0;
  font-size: 1rem; font-weight: bold;
  border: 2px solid; border-radius: 10px;
  cursor: pointer; background: #fff;
}

.rating-btn.again { border-color: #c00; color: #c00; }
.rating-btn.good  { border-color: #080; color: #080; }

/* ── Conjugation color classes ────────────────────────────────────────────── */
.separable  { color: #5bc8f5; font-weight: bold; }
.prafix     { color: #2a9d2a; font-weight: bold; }
.weak       { color: #888;    font-weight: bold; }
.sein       { color: #c00;    font-weight: bold; }
.prasens    { color: #aaa;    font-weight: bold; }
.prateritum { color: #7b00b0; font-weight: bold; }
.irregular  { color: #000;    font-weight: bold; }
.maskuline  { color: navy;    font-weight: bold; }
.feminine   { color: hotpink; font-weight: bold; }
.neuter     { color: #888;    font-weight: bold; }
.regular    { color: #000;    font-weight: bold; }

/* ── Empty / done states ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 80px 20px; color: #555;
}

.empty-state .icon { font-size: 3.5rem; margin-bottom: 14px; }
.empty-state p { font-size: 1.1rem; }

/* ── Browse page ──────────────────────────────────────────────────────────── */
.browse-top { padding: 14px 16px 0; }

.search-input {
  width: 100%; padding: 10px 12px; font-size: 1rem;
  border: 1px solid #ccc; border-radius: 8px; margin-bottom: 10px;
}

.deck-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }

.chip {
  padding: 4px 12px; font-size: 0.82rem;
  border: 1px solid #ccc; border-radius: 14px;
  cursor: pointer; background: #fff;
}

.chip.active { background: #333; color: #fff; border-color: #333; }

.card-list { list-style: none; }

.card-list-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-bottom: 1px solid #eee;
}

.type-badge {
  font-size: 0.75rem; background: #eee;
  padding: 3px 7px; border-radius: 4px;
  white-space: nowrap; flex-shrink: 0; margin-top: 2px;
}

.card-summary { font-size: 1rem; }
.card-due { font-size: 0.8rem; color: #888; margin-top: 3px; }
.card-due.overdue { color: #c00; }

/* ── Stats page ───────────────────────────────────────────────────────────── */
.stats-wrap { padding: 16px; }

.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 20px;
}

.stat-card {
  background: #f5f5f5; border-radius: 10px;
  padding: 16px; text-align: center;
}

.stat-value { font-size: 2.2rem; font-weight: bold; }
.stat-label { font-size: 0.8rem; color: #666; margin-top: 4px; }

.forecast-title { font-size: 0.9rem; color: #666; margin-bottom: 10px; }

.forecast-bar { display: flex; align-items: flex-end; gap: 6px; height: 110px; }

.bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; }

.bar-fill {
  width: 100%; background: #333; border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.bar-label { font-size: 0.72rem; color: #888; margin-top: 4px; }

/* ── Settings page ────────────────────────────────────────────────────────── */
.settings-wrap { padding: 16px; }
.settings-wrap h2 { font-size: 0.9rem; color: #888; text-transform: uppercase; letter-spacing: 0.04em; margin: 20px 0 10px; }
.settings-wrap h2:first-child { margin-top: 0; }

.settings-btn {
  width: 100%; padding: 12px; font-size: 1rem;
  border: 1px solid #ccc; border-radius: 8px;
  background: #fff; cursor: pointer; text-align: left;
}

.settings-btn.danger { color: #c00; border-color: #f5c0c0; }

.settings-info { font-size: 0.85rem; color: #666; line-height: 1.5; }
