:root {
  --bg: #fff;
  --text: #000;
  --muted: #999;
  --line: #e0e0e0;
  --font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

[data-theme='dark'] {
  --bg: #111;
  --text: #eee;
  --muted: #555;
  --line: #222;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* ── Header ── */

.header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 2.5rem;
}

.nav { display: flex; gap: 1.5rem; }

.nav-link {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  transition: color 0.2s;
}

.nav-link:hover, .nav-link.active { color: var(--text); }

/* ── Views ── */

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

/* ── Learn ── */

.learn-container {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 0 2rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 5rem);
}

/* ── Progress ── */

.progress-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0 1rem;
  margin-bottom: 2rem;
}

.progress-track {
  width: 90vw;
  height: 2px;
  background: var(--line);
  position: relative;
  margin-bottom: 0.75rem;
}

.progress-bar {
  height: 2px;
  background: var(--text);
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  transition: width 0.4s ease;
  width: 0%;
}

.counter {
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.counter strong {
  color: var(--text);
  font-weight: 700;
}

/* ── Word Area ── */

.word-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  width: 100%;
  padding: 2rem 0 8rem;
}

.pos {
  font-size: 0.8rem;
  text-transform: capitalize;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.word {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  cursor: pointer;
}

.phonetic {
  margin-top: 0.75rem;
  font-size: 1rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.hint {
  margin-top: 3rem;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  transition: opacity 0.3s;
  cursor: pointer;
}

/* ── Details (revealed on click/space) ── */

.details {
  width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease 0.05s;
  padding-bottom: 6rem;
}

.details.open {
  max-height: 500px;
  opacity: 1;
}

.detail-row {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1.5rem;
  align-items: baseline;
  text-align: left;
}

.detail-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding-top: 0.15rem;
}

.detail-text {
  font-size: 1rem;
  line-height: 1.6;
}

.pos-inline {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-right: 0.4rem;
}

.detail-example-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.detail-example-row p {
  font-style: italic;
  color: var(--muted);
}

.listen-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0.3rem;
  transition: color 0.15s;
  letter-spacing: 0;
}

.listen-btn:hover { color: var(--text); }
.listen-btn.playing { color: var(--text); }

/* ── Actions (always visible) ── */

.actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  position: fixed;
  bottom: 50px;
  left: 0;
}

.action {
  padding: 0.7rem 1.5rem;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: var(--font);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.action:hover {
  color: var(--text);
  border-color: var(--text);
}

.action .key {
  display: inline-block;
  margin-left: 0.25rem;
  opacity: 0.35;
  font-size: 0.65rem;
  vertical-align: super;
}

/* ── Done ── */

.done {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.done.hidden { display: none; }
.done h2 { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }
.done p { color: var(--muted); margin-top: 0.5rem; font-size: 0.85rem; }

/* ── Profile ── */

.profile {
  max-width: 600px;
  margin: 0 auto;
  padding: 4rem 2rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.stat {
  padding: 1.75rem 1.25rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-num {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.stat-name {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* ── Packs ── */

.packs-section { margin-top: 3rem; }

.section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.section-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.pack-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.pack-row:first-child { border-top: 1px solid var(--line); }

.pack-info { display: flex; flex-direction: column; gap: 0.15rem; }

.pack-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.pack-desc {
  font-size: 0.7rem;
  color: var(--muted);
}

.pack-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  background: var(--line);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.pack-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--bg);
  border-radius: 50%;
  transition: transform 0.2s;
}

.pack-toggle:checked { background: var(--text); }
.pack-toggle:checked::after { transform: translateX(16px); }

/* ── Add Word ── */

.add-form {
  display: flex;
  margin-top: 3rem;
  border: 1px solid var(--line);
}

.add-form input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  outline: none;
}

.add-form button {
  padding: 0.75rem 1.25rem;
  border: none;
  border-left: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font);
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.15s;
}

.add-form button:hover { color: var(--text); }

.add-status {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.add-status.error { color: #b00; }
.add-status.hidden { display: none; }

/* ── Transition Overlay ── */

.transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translateY(100%);
  z-index: 1000;
  pointer-events: none;
}

.transition-overlay.slide-up {
  animation: slideUp 0.6s ease-in-out forwards;
}

@keyframes slideUp {
  0%   { transform: translateY(100%); }
  40%  { transform: translateY(0); }
  60%  { transform: translateY(0); }
  100% { transform: translateY(-100%); }
}

/* ── Responsive ── */

@media (max-width: 600px) {
  .header { padding: 1.5rem; }

  .learn-container {
    padding: 0 1.5rem 3rem;
    align-items: flex-start;
  }

  .progress-section { align-items: flex-start; }

  .word-area {
    align-items: flex-start;
    text-align: left;
  }

  .word-row { justify-content: flex-start; }

  .word { font-size: 2.2rem; }

  .hint-desktop { display: none; }
  .hint-mobile { display: inline; }

  .detail-row { grid-template-columns: 1fr; gap: 0.3rem; }

  .actions { justify-content: flex-start; }

  .done { align-items: flex-start; text-align: left; }

  .stats { grid-template-columns: repeat(2, 1fr); }
  .profile { padding: 3rem 1.5rem; }
}

@media (min-width: 601px) {
  .hint-mobile { display: none; }
  .hint-desktop { display: inline; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #111;
    --text: #eee;
    --muted: #555;
    --line: #222;
  }
}
