:root {
  --orange: #DB9558;
  --cream: #FCF9EA;
  --green: #97A87A;
  --sage: #A8BBA3;
  --ink: #3a3630;
  --fs-base: 1rem;
  --fs-h4: 1.25rem;
  --fs-h3: 1.5625rem;
  --fs-h2: 1.953rem;
  --fs-h1: 2.441rem;
}

* { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }

body {
  margin: 0;
  font-family: 'Lexend', sans-serif;
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  text-align: left;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

h1, h2, h3, h4 { font-family: 'Sora', sans-serif; font-weight: 700; margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }

button { font-family: inherit; font-size: 1rem; cursor: pointer; border: none; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* --- App shell --- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 15rem; flex-shrink: 0;
  background: #fff; border-right: 1px solid var(--sage);
  padding: 1.5em 1.25em;
}
.brand { font-size: var(--fs-h4); font-family: 'Sora', sans-serif; font-weight: 700; margin-bottom: 1.5em; line-height: 1.25; }
.navgroup-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: #7E8C7A; margin: 1.4em 0 .5em; }
.brand + .navgroup-label { margin-top: 0; }

.navitem {
  display: flex; align-items: center; gap: .6em;
  padding: .55em .6em; border-radius: .5em;
  color: var(--ink); text-decoration: none; margin-bottom: .2em; font-size: .95rem;
}
.navitem::before { content: ""; width: .4em; height: .4em; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.navitem.active { background: var(--cream); color: var(--green); font-weight: 600; }
.navitem.-soft { color: var(--sage); }

.main { flex: 1; min-width: 0; }

.topbar { background: var(--green); color: #fff; padding: 2em 2em 2.5em; }
.topbar p { margin: 0; opacity: .9; }

.content { padding: 2em; max-width: 40rem; margin: 0 auto; }
.content.-narrow { max-width: 34rem; }
.view { display: none; }
.view.active { display: block; }

/* --- Future phase toggle --- */
.future-only { display: none; }
body.future-phase .future-only { display: block; }

/* --- Dashboard --- */
.stat-row { display: flex; gap: 1em; flex-wrap: wrap; margin: 1.5em 0; }
.stat { background: #fff; border: 1px solid var(--sage); border-radius: .75em; padding: 1em 1.25em; flex: 1; min-width: 9rem; }
.stat .num { font-family: 'Sora', sans-serif; font-size: var(--fs-h3); color: var(--green); }
.stat .label, .deck-row .label { color: var(--ink); opacity: .75; font-size: .9rem; }

.cta {
  background: var(--orange); color: #fff; padding: .8em 1.6em; border-radius: .6em;
  font-weight: 600; margin-top: 1em; display: inline-block; text-decoration: none;
}
.decks { margin-top: 2em; }
.decks h3 { font-size: var(--fs-h4); }
.deck-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1em; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--sage); border-radius: .75em; padding: 1em 1.25em;
}
.soon { color: var(--sage); font-size: .85rem; }

/* --- Study card --- */
.card-wrap { margin-top: -1.25em; }
.card {
  position: relative; background: #fff; border: 1px solid var(--sage);
  border-radius: 1em; overflow: hidden; box-shadow: 0 .5em 1.5em rgba(58,54,48,.08);
}
.card-tab {
  position: absolute; top: 0; z-index: 1; font-size: .85rem; padding: .5em 1em;
  background: #fff; border-bottom: 1px solid var(--sage);
}
.card-tab-right { right: 0; color: var(--ink); opacity: .8; border-left: 1px solid var(--sage); border-bottom-left-radius: .6em; }
.card-tab-left { left: 0; color: var(--green); font-weight: 600; border-right: 1px solid var(--sage); border-bottom-right-radius: .6em; display: none; }
.card-tab-left.show { display: block; }

.card-body {
  padding: 3.5em 1.5em 3em; text-align: center; min-height: 14rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5em;
}
.word { font-family: 'Sora', sans-serif; font-size: clamp(2rem, 8vw, var(--fs-h1)); color: var(--green); overflow-wrap: anywhere; }
.answer { font-family: 'Sora', sans-serif; font-size: clamp(1.75rem, 7vw, var(--fs-h2)); color: var(--orange); overflow-wrap: anywhere; }
.subword { color: var(--ink); opacity: .65; }

/* --- Pronunciation (Web Speech API) --- */
.listen-btn {
  display: inline-flex; align-items: center; gap: .5em;
  margin-top: .75em; padding: .55em 1.3em;
  background: var(--cream); color: var(--green);
  border: 1px solid var(--sage); border-radius: 2em;
  font-weight: 600; font-size: .9rem;
  transition: background .15s ease, color .15s ease, transform .1s ease;
}
.listen-btn:hover { background: var(--sage); color: #fff; }
.listen-btn:active { transform: scale(.96); }
.listen-btn[disabled] { opacity: .5; cursor: not-allowed; }
.listen-icon { font-size: 1.05em; line-height: 1; }

.card-actions { display: flex; border-top: 1px solid var(--sage); }
.card-actions button { flex: 1; min-height: 3.25rem; padding: 1em; background: #fff; font-weight: 600; }
.card-actions button.show-answer { background: var(--sage); color: #fff; }
.card-actions button.correct { background: var(--green); color: #fff; }
.card-actions button.wrong { background: var(--orange); color: #fff; }
.card-actions.-hidden { display: none; }
.card-actions button + button { border-left: 1px solid #fff; }

.session-tally { text-align: center; margin-top: 1em; color: var(--ink); opacity: .7; font-size: .9rem; }

/* --- Mobile: hamburger + slide-in drawer --- */
.menu-btn { display: none; }
.backdrop { display: none; }

@media (max-width: 48rem) {
  .menu-btn {
    display: flex; flex-direction: column; justify-content: center; gap: .3rem;
    width: 2.75rem; height: 2.75rem; padding: .7rem; margin: 0 0 1em -.7rem;
    background: transparent; border-radius: .5em;
  }
  .menu-btn span { display: block; height: 2px; background: #fff; border-radius: 1px; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 20;
    width: min(16rem, 82vw); overflow-y: auto;
    padding-top: calc(1.5em + env(safe-area-inset-top, 0px));
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 2rem rgba(58,54,48,.25); }
  .backdrop.open { display: block; position: fixed; inset: 0; z-index: 10; background: rgba(58,54,48,.4); }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  .topbar { padding: 1.25em 1.25em 2.25em; }
  .content { padding: 1.25em; }
  .stat { min-width: 7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
