/* Quid Agis — phone-first. Palette: lamplit Roman night. */
:root {
  --bg: #151210; --bg2: #1f1a16; --card: #262019; --line: #3a3128;
  --ink: #e9e2d6; --ink-dim: #a89b88; --gold: #c9a227; --gold-dim: #8a7119;
  --red: #a0392f; --green: #5a7d4f; --ghost: #9db4c0;
  --radius: 14px; --tap: 48px;
  font-size: 17px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
  display: flex; flex-direction: column;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.hidden { display: none !important; }

/* Header */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  border-bottom: 1px solid var(--line); background: var(--bg2);
}
header .brand { flex: 1; text-align: center; font-variant: small-caps; letter-spacing: .06em; font-size: 1.25rem; color: var(--gold); }
.back-btn { width: 92px; text-align: left; font-size: 1.7rem; line-height: 1; color: var(--ink-dim); padding-left: 2px; visibility: hidden; min-height: 36px; }
body.landing nav.tabs { display: none; }
body.landing main { padding-bottom: 24px; }
.landing-wrap { display: flex; flex-direction: column; justify-content: center; min-height: 66vh; text-align: center; }
.landing-wrap .big-brand { font-variant: small-caps; color: var(--gold); font-size: 2.2rem; letter-spacing: .06em; }
.land-btn { display: block; width: 100%; margin: 9px 0; padding: 20px 14px; font-size: 1.05rem; letter-spacing: .1em; border: 1px solid var(--gold-dim); border-radius: var(--radius); color: var(--gold); background: var(--card); }
.land-btn:active { background: #2d2620; }
.lang-toggle {
  display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
}
.lang-toggle button { padding: 6px 14px; min-height: 36px; color: var(--ink-dim); }
.lang-toggle button.active { background: var(--gold); color: #17130d; font-weight: bold; }

/* Main area */
main { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: 90px; }
.screen h2 { font-variant: small-caps; letter-spacing: .05em; color: var(--gold); margin-bottom: 4px; }
.tagline { color: var(--ink-dim); font-style: italic; margin-bottom: 18px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card h3 { margin-bottom: 6px; }
.card .sub { color: var(--ink-dim); font-size: .92rem; }
.card.tappable { position: relative; }
.card.tappable:active { background: #2d2620; }
.progress-pill {
  float: right; font-size: .8rem; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px;
}
.card.done .progress-pill { color: #17130d; background: var(--gold); border-color: var(--gold); }

/* Bottom tab bar */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--bg2); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
nav.tabs button {
  flex: 1; min-height: 56px; color: var(--ink-dim); font-size: .85rem;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 8px;
}
nav.tabs button .ico { font-size: 1.3rem; line-height: 1; }
nav.tabs button.active { color: var(--gold); }

/* Exercise player */
.player { display: flex; flex-direction: column; min-height: 70vh; }
.player .prompt { font-size: 1.5rem; text-align: center; margin: 28px 0 6px; }
.player .phon { text-align: center; color: var(--ink-dim); font-style: italic; margin-bottom: 4px; }
.player .gloss { text-align: center; color: var(--ink-dim); margin-bottom: 20px; }
.player .speak-btn {
  display: block; margin: 0 auto 22px; min-width: var(--tap); min-height: var(--tap);
  border: 1px solid var(--gold-dim); border-radius: 999px; padding: 8px 22px; color: var(--gold);
}
.choices { display: flex; flex-direction: column; gap: 10px; }
.choices button {
  min-height: var(--tap); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: 12px; font-size: 1.05rem;
}
.choices button.correct { border-color: var(--green); background: #24301f; }
.choices button.wrong { border-color: var(--red); background: #33201c; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.tiles button { border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 10px 14px; min-height: var(--tap); }
.tiles button.used { opacity: .3; pointer-events: none; }
.answer-line { min-height: 52px; border-bottom: 1px dashed var(--line); margin: 8px 0 4px; text-align: center; font-size: 1.2rem; padding: 10px; }
.player .footerbar { margin-top: auto; display: flex; gap: 10px; padding-top: 18px; }
.btn {
  flex: 1; min-height: 52px; border-radius: var(--radius); font-size: 1.05rem;
  background: var(--gold); color: #17130d; font-weight: bold;
}
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .35; }
.feedback { text-align: center; min-height: 26px; margin-top: 10px; }
.feedback.good { color: #9dc08b; }
.feedback.bad { color: #d98a7f; }
.timerbar { height: 4px; background: var(--line); border-radius: 2px; margin-top: 14px; overflow: hidden; }
.timerbar > div { height: 100%; background: var(--gold); width: 100%; transition: width linear; }

/* Ghosts */
.ghost-card { display: flex; gap: 12px; align-items: center; }
.ghost-card .sigil {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--ghost);
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: var(--ghost);
  flex-shrink: 0;
}
.difficulty { color: var(--ghost); font-size: .8rem; letter-spacing: .2em; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat .msg { max-width: 86%; padding: 10px 14px; border-radius: var(--radius); line-height: 1.45; }
.chat .msg.user { align-self: flex-end; background: #2c3440; }
.chat .msg.ghost { align-self: flex-start; background: var(--card); border: 1px solid #33404a; color: #d7e2e9; }
.chat .msg.ghost .la { font-size: 1.08rem; }
.chat .msg .trans { color: var(--ink-dim); font-size: .92rem; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.chat .msg .trans-btn { color: var(--ghost); font-size: .85rem; margin-top: 6px; text-decoration: underline; }
.chat .msg .replay { margin-left: 8px; color: var(--ghost); }
.chatbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; gap: 8px;
  padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px); background: var(--bg2);
  border-top: 1px solid var(--line);
}
.chatbar input {
  flex: 1; min-height: var(--tap); border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); padding: 0 16px; font: inherit; font-size: 1rem;
}
.chatbar button { min-width: var(--tap); min-height: var(--tap); border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 1.2rem; }
.chatbar button.rec { color: #d98a7f; border-color: #d98a7f; }
.ghost-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ghost-header .back { font-size: 1.4rem; min-width: var(--tap); min-height: var(--tap); color: var(--ink-dim); }

/* Account */
.field { margin-bottom: 14px; }
.field label { display: block; color: var(--ink-dim); font-size: .9rem; margin-bottom: 6px; }
.field input {
  width: 100%; min-height: var(--tap); border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); color: var(--ink); padding: 0 14px; font: inherit;
}
.notice { color: var(--ink-dim); font-size: .9rem; line-height: 1.5; }
a { color: var(--gold); }

/* Desktop frame: the app stays phone-shaped and centered on wide screens. */
@media (min-width: 700px) {
  body { align-items: center; background: #0d0b09; }
  header, main, nav.tabs, .chatbar { width: 480px; margin-left: auto; margin-right: auto; }
  header { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  main { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--bg); }
  nav.tabs, .chatbar { left: 50%; transform: translateX(-50%); right: auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
