/* Maneno — app styles, ported from docs/mockup.html.
   Class names, palette tokens and layout are kept exactly as approved in
   the mockup; only demo-only rules (the mockup disclaimer paragraph) were
   dropped. */

/* Outer page: presents the app as a centered device-style card on wide
   viewports (same pattern as the tracker it inherits from), edge-to-edge
   on narrow ones. Tokens only for the page ground. */
:root {
  --page-ground: #efece6;
}
@media (prefers-color-scheme: dark) {
  :root { --page-ground: #211d19; }
}
:root[data-theme="dark"]  { --page-ground: #211d19; }
:root[data-theme="light"] { --page-ground: #efece6; }

html, body { margin: 0; padding: 0; }
body {
  background: var(--page-ground);
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: 0;
}

/* ── App tokens — the tracker's warm paper palette ─────────────────── */
.m-frame {
  --ground:      #faf8f4;
  --surface:     #ffffff;
  --sunk:        #f4efe7;
  --border:      #e8e2d8;
  --border-soft: #f0ebe2;
  --text:        #1c1714;
  --ink-2:       #463d34;
  --muted:       #6f665a;
  --tint:        #fdf4e5;
  --accent:      #b45309;
  --on-accent:   #ffffff;
  --good:        #15803d;
  --good-tint:   #e8f4ec;
  --over:        #b3261e;
  --over-tint:   #fbeceb;
  --r:           10px;
  --shadow:      0 1px 2px rgba(40,28,12,.05), 0 8px 24px -12px rgba(40,28,12,.18);
  --serif:       Georgia, 'Times New Roman', serif;
  --sans:        ui-sans-serif, -apple-system, 'Helvetica Neue', sans-serif;

  width: 100%; max-width: 430px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  display: flex; flex-direction: column;
  height: 100dvh; max-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
@media (min-width: 460px) {
  body { padding: 1.2rem 0 0; }
  .m-frame {
    height: min(820px, calc(100dvh - 4.2rem));
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
  }
}
.m-frame [hidden] { display: none !important; }
.m-frame * { box-sizing: border-box; font-family: inherit; }
.m-frame button { color: inherit; }

/* ── PIN gate ──────────────────────────────────────────────────────── */
.m-gate {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 1.25rem; background: var(--ground);
}
.m-gate-card {
  width: 100%; max-width: 20rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  padding: 1.6rem 1.4rem; display: flex; flex-direction: column; gap: .6rem;
}
.m-gate-logo { font-size: .7rem; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.m-gate-h { font-family: var(--serif); font-size: 1.6rem; font-weight: 400; letter-spacing: -.02em; line-height: 1.1; margin: 0; }
.m-gate-p { font-size: .82rem; color: var(--muted); margin: 0 0 .3rem; }
.m-gate-form { display: flex; flex-direction: column; gap: .5rem; }
.m-gate-hint { font-size: .7rem; color: var(--muted); margin: .2rem 0 0; min-height: 1em; }

/* ── Shell ─────────────────────────────────────────────────────────── */
.m-status {
  display: flex; justify-content: space-between; align-items: center;
  padding: .65rem 1.35rem .1rem;
  font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.m-status .m-brand { font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-size: .68rem; }
.m-appbar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .6rem; padding: .5rem 1.15rem .7rem;
  border-bottom: 1px solid var(--border-soft);
}
.m-appbar .m-title { font-family: var(--serif); font-size: 1.22rem; letter-spacing: -.01em; }
.m-appbar .m-sub { font-size: .74rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.m-screen {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 1rem 1.15rem 1.4rem;
  display: none; flex-direction: column; gap: 1rem;
}
.m-screen.on { display: flex; }
.m-screen::-webkit-scrollbar { width: 0; }
@media (prefers-reduced-motion: no-preference) {
  .m-screen.on { animation: m-fade .18s ease-out; }
  @keyframes m-fade { from { opacity: 0 } to { opacity: 1 } }
}

/* ── Practice ──────────────────────────────────────────────────────── */
.m-card {
  background: var(--sunk); border: 1px solid var(--border-soft);
  border-radius: var(--r); padding: 1.1rem 1rem 1.15rem;
  display: flex; flex-direction: column; gap: .55rem;
}
.m-dir { font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 650; display: flex; justify-content: space-between; align-items: center; }
.m-dir .m-cat { letter-spacing: .04em; text-transform: none; font-weight: 600; color: var(--accent); }
.m-word { font-family: var(--serif); font-size: 1.85rem; line-height: 1.15; letter-spacing: -.01em; text-wrap: balance; }

.m-answer { display: flex; flex-direction: column; gap: .5rem; }
.m-input {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--sunk); color: var(--text);
  font-size: 1rem; outline: none; font-family: var(--sans);
}
.m-input:focus { border-color: var(--accent); background: var(--surface); }
.m-input.ok   { border-color: var(--good); background: var(--good-tint); }
.m-input.bad  { border-color: var(--over); background: var(--over-tint); }

.m-btn {
  width: 100%; padding: .68rem; border-radius: var(--r); border: 0;
  background: var(--accent); color: var(--on-accent);
  font-size: .88rem; font-weight: 600; cursor: pointer;
}
.m-btn:hover { filter: brightness(1.07); }
.m-btn[disabled] { opacity: .55; cursor: default; filter: none; }
.m-ghost {
  font-size: .78rem; text-align: center;
  padding: .5rem .1rem; background: none; border: 0;
  color: var(--muted); cursor: pointer;
}
.m-ghost:hover { color: var(--accent); }
.m-ghost[disabled] { opacity: .55; cursor: default; }

.m-verdict { border-radius: var(--r); padding: .8rem .9rem; display: flex; flex-direction: column; gap: .45rem; }
.m-verdict.ok  { background: var(--good-tint); }
.m-verdict.bad { background: var(--over-tint); }
.m-verdict .m-v-h { font-size: .82rem; font-weight: 650; }
.m-verdict.ok  .m-v-h { color: var(--good); }
.m-verdict.bad .m-v-h { color: var(--over); }
.m-verdict .m-v-word { font-family: var(--serif); font-size: 1.3rem; color: var(--text); }
.m-verdict .m-v-alt { font-size: .74rem; color: var(--muted); line-height: 1.45; }

.m-prog { display: flex; gap: .3rem; }
.m-prog span { flex: 1; height: 4px; border-radius: 2px; background: var(--sunk); }
.m-prog span.done  { background: var(--good); opacity: .55; }
.m-prog span.miss  { background: var(--over); opacity: .55; }
.m-prog span.now   { background: var(--accent); }

/* ── Tiles (session end / stats) ───────────────────────────────────── */
.m-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.m-tile {
  background: var(--sunk); border: 1px solid var(--border-soft);
  border-radius: var(--r); padding: .7rem .8rem;
  display: flex; flex-direction: column; gap: .12rem;
}
.m-tile .m-lab { font-size: .66rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.m-tile .m-val { font-size: 1.62rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.m-tile .m-foot { font-size: .7rem; color: var(--muted); }
.m-tile.hero { grid-column: 1 / -1; background: var(--tint); border-color: transparent; }
.m-tile.hero .m-val { font-size: 2.1rem; color: var(--accent); }

/* ── Pills & rows ──────────────────────────────────────────────────── */
.m-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .66rem; font-weight: 650; letter-spacing: .04em;
  padding: .16rem .5rem; border-radius: 999px; white-space: nowrap;
}
.m-pill.good { background: var(--good-tint); color: var(--good); }
.m-pill.warn { background: var(--over-tint); color: var(--over); }
.m-pill.soft { background: var(--sunk); color: var(--muted); border: 1px solid var(--border); }

.m-list { display: flex; flex-direction: column; }
.m-row {
  display: flex; justify-content: space-between; align-items: center; gap: .7rem;
  padding: .5rem 0; border-bottom: 1px solid var(--border-soft);
}
.m-row:last-child { border-bottom: 0; }
.m-row .m-nm { font-size: .92rem; font-family: var(--serif); line-height: 1.3; }
.m-row .m-nm em { font-style: normal; color: var(--muted); font-size: .74rem; display: block; font-family: var(--sans); }
.m-row .m-right { display: flex; flex-direction: column; align-items: flex-end; gap: .15rem; }
.m-row .m-acc { font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.m-chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.m-chip {
  font-size: .75rem; padding: .3rem .6rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  cursor: pointer;
}
.m-chip:hover { border-color: var(--accent); color: var(--accent); }
.m-chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.m-chip[disabled] { opacity: .45; cursor: default; }

.m-sechead { font-size: .66rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 650; margin: .3rem 0 -.4rem; }

/* accuracy / progress bars on stats */
.m-accrow { display: grid; grid-template-columns: 1fr 5.2rem auto; align-items: center; gap: .6rem; padding: .42rem 0; border-bottom: 1px solid var(--border-soft); }
.m-accrow:last-child { border-bottom: 0; }
.m-accrow .m-nm { font-size: .88rem; font-family: var(--serif); }
.m-accrow .m-nm em { font-style: normal; display: block; font-size: .7rem; color: var(--muted); font-family: var(--sans); }
.m-track { height: 6px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.m-fill { display: block; height: 100%; border-radius: 3px; background: var(--over); opacity: .75; }
.m-accrow .m-amt { font-size: .74rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

details.m-fold summary { font-size: .74rem; color: var(--muted); cursor: pointer; }
.m-note-p { font-size: .72rem; color: var(--muted); line-height: 1.5; margin: 0; }

/* ── Tabs ──────────────────────────────────────────────────────────── */
nav.m-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--border); background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}
nav.m-tabs button {
  padding: .62rem .2rem .85rem; border: 0; background: none; cursor: pointer;
  font-size: .7rem; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: .22rem;
  border-top: 2px solid transparent; margin-top: -1px;
}
nav.m-tabs button svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.6; }
nav.m-tabs button[aria-selected="true"] { color: var(--accent); border-top-color: var(--accent); }
nav.m-tabs button:focus-visible, .m-btn:focus-visible, .m-chip:focus-visible, .m-ghost:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}

/* ── Toast ─────────────────────────────────────────────────────────── */
.m-toast {
  position: absolute; left: 50%; bottom: 5rem; transform: translateX(-50%);
  z-index: 40; max-width: min(22rem, calc(100% - 2rem));
  font-size: .8rem; line-height: 1.4; text-align: left;
  padding: .6rem .8rem; border-radius: var(--r); cursor: pointer; border: 1px solid var(--good);
  background: var(--good-tint); color: var(--good); box-shadow: var(--shadow);
}
.m-toast.err { border-color: var(--over); background: var(--over-tint); color: var(--over); }
.m-wrap { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
