/* Sydney Trains-inspired brand skin. */
:root {
  --bg: #f3f1ed;
  --surface: #ffffff;
  --surface-2: #f6e8df;
  --text: #172b4d;
  --text-2: #5b6574;
  --line: #ded8d1;
  --accent: #e85d18;
  --accent-soft: #fff0e7;
  --on-accent: #ffffff;
  --ok: #16834b;
  --ok-soft: #e4f4ea;
  --bad: #c9362b;
  --bad-soft: #fbe9e7;
  --bell-top: #ffffff;
  --bell-bottom: #f4eee9;
  --shadow: 0 2px 3px rgba(23, 43, 77, .07), 0 10px 28px rgba(23, 43, 77, .09);
  --header-bg: rgba(255, 255, 255, .94);
  --tab-bg: rgba(255, 255, 255, .92);
  --navy: #172b4d;
  --orange: #f36c21;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101b2e;
    --surface: #192941;
    --surface-2: #263750;
    --text: #f7f5f2;
    --text-2: #b4bdc9;
    --line: #34465f;
    --accent: #ff7a30;
    --accent-soft: #4a2b20;
    --on-accent: #ffffff;
    --ok: #34c06e;
    --ok-soft: #14301f;
    --bad: #ee6060;
    --bad-soft: #3a1a1a;
    --bell-top: #232c3a;
    --bell-bottom: #161c26;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
    --header-bg: rgba(16, 27, 46, .95);
    --tab-bg: rgba(25, 41, 65, .94);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  border-top: 6px solid var(--orange);
  padding-top: env(safe-area-inset-top);
}

.app-header-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.train-roundel {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
}

.app-title {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
}

.brand-name {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.015em;
}

.product-name {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin-top: 4px;
}

.training-badge {
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: background .15s ease;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------- main / views ---------- */
#main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px calc(96px + env(safe-area-inset-bottom));
}

.view {
  max-width: 640px;
  margin: 0 auto;
  animation: view-in .22s ease;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- symbols (dot / dash) ---------- */
.sym {
  display: inline-block;
  vertical-align: middle;
  background: currentColor;
  border-radius: 99px;
}
.sym.s { width: 14px; height: 14px; }
.sym.l { width: 34px; height: 14px; }
.sym.small.s { width: 9px; height: 9px; margin-right: 6px; }
.sym.small.l { width: 22px; height: 9px; margin-right: 6px; }

/* ---------- learn ---------- */
.legend {
  color: var(--text-2);
  font-size: 14px;
  margin: 2px 2px 16px;
}

.learn-cat-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--navy);
  margin: 22px 4px 10px;
}

.learn-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-top: 4px solid var(--orange);
}

.learn-row { border-bottom: 1px solid var(--line); }
.learn-row:last-child { border-bottom: 0; }

.learn-row-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  text-align: left;
}
.learn-row-head:active { background: var(--surface-2); }

.learn-syms {
  flex: 0 0 96px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  color: var(--accent);
}

.learn-msg { font-size: 15.5px; font-weight: 600; line-height: 1.3; }

.learn-detail {
  padding: 0 16px 15px;
  color: var(--text-2);
  font-size: 14.5px;
  line-height: 1.5;
}

.learn-detail .pill-btn { margin-top: 10px; }

/* ---------- practice ---------- */
.practice-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px;
  margin: -2px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--line);
  white-space: nowrap;
  transition: all .15s ease;
}
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.scorebar { display: flex; gap: 7px; flex: 0 0 auto; }

.score-chip {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 7px 11px;
  color: var(--text-2);
}

.prompt-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  text-align: center;
  transition: box-shadow .2s ease;
  border-top: 5px solid var(--orange);
}
.prompt-card.flash-ok { animation: flash-ok .6s ease; }
.prompt-card.flash-bad { animation: shake .4s ease; }

@keyframes flash-ok {
  0% { box-shadow: 0 0 0 0 rgba(29, 154, 80, .45); }
  100% { box-shadow: 0 0 0 18px rgba(29, 154, 80, 0); }
}
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.prompt-cat {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--accent);
  margin-bottom: 8px;
}

.prompt-msg {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  text-wrap: balance;
}

.hint-btn {
  margin-top: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  padding: 6px 10px;
  border-radius: 9px;
}
.hint-btn:active { background: var(--accent-soft); }

.hint-text {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0 0;
}

/* sequence display */
.seq-display {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
  margin: 18px 0 4px;
  color: var(--text);
}

.seq-display .sym { animation: pop-in .18s ease; }
@keyframes pop-in {
  from { transform: scale(.4); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.seq-display .sym.pending {
  background: var(--accent);
  animation: none;
  transition: width .15s ease;
}

.seq-placeholder {
  color: var(--text-2);
  font-size: 14px;
}

/* the bell */
.bell-zone {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
}

.bell-btn {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: linear-gradient(180deg, var(--bell-top), var(--bell-bottom));
  border: 3px solid var(--orange);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .12s ease, box-shadow .12s ease;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.bell-btn.held {
  transform: scale(.93);
  box-shadow: 0 1px 4px rgba(16, 24, 40, .18), inset 0 2px 8px rgba(16, 24, 40, .12);
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.bell-btn:disabled { opacity: .45; }

.two-btn-zone {
  display: flex;
  gap: 14px;
}
.two-btn-zone[hidden] { display: none; }

.tb-btn {
  min-width: 120px;
  padding: 26px 20px;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(180deg, var(--bell-top), var(--bell-bottom));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  color: var(--accent);
  transition: transform .12s ease;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.tb-btn.held, .tb-btn:active { transform: scale(.95); background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* action row */
.action-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

.pill-btn {
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  transition: transform .1s ease, opacity .15s ease;
}
.pill-btn:active { transform: scale(.96); }
.pill-btn:disabled { opacity: .4; }

.pill-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.pill-btn.danger {
  color: var(--bad);
  border-color: var(--bad);
  background: none;
}

/* feedback */
.feedback {
  margin-top: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  text-align: center;
  animation: view-in .2s ease;
}
.feedback.good { border: 1.5px solid var(--ok); background: var(--ok-soft); }
.feedback.bad  { border: 1.5px solid var(--bad); background: var(--bad-soft); }

.feedback-title { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.feedback.good .feedback-title { color: var(--ok); }
.feedback.bad .feedback-title { color: var(--bad); }

.feedback-body { font-size: 14.5px; color: var(--text-2); line-height: 1.5; }
.feedback-body .answer-syms {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 10px 0 2px;
  color: var(--text);
}

.feedback-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.reveal-row { text-align: center; margin-top: 10px; }

/* ---------- listen ---------- */
.listen-blurb { color: var(--text-2); font-size: 14.5px; }

.listen-play-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 0 26px;
}

.bell-btn.listen-play { width: 108px; height: 108px; }
.bell-btn.listen-play.playing { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

.listen-status { font-size: 13.5px; color: var(--text-2); font-weight: 600; }

.listen-options { display: grid; gap: 10px; }
@media (min-width: 560px) { .listen-options { grid-template-columns: 1fr 1fr; } }

.option-btn {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px 16px;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  transition: transform .1s ease, border-color .15s ease;
}
.option-btn:active { transform: scale(.98); }
.option-btn .option-cat {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-2);
  margin-bottom: 4px;
}
.option-btn.correct { border-color: var(--ok); background: var(--ok-soft); }
.option-btn.wrong   { border-color: var(--bad); background: var(--bad-soft); }
.option-btn:disabled { opacity: .9; }

.listen-next-row { margin-top: 16px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 6px;
  background: var(--tab-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(23, 43, 77, .07);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}

.tab {
  flex: 1;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  padding: 6px 0 4px;
  border-radius: 14px;
  transition: color .15s ease, background .15s ease;
}
.tab.active { color: var(--accent); background: var(--accent-soft); }

@media (max-width: 390px) {
  .training-badge { display: none; }
}

@media (prefers-color-scheme: dark) {
  .learn-cat-title { color: var(--text); }
}

/* ---------- settings sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, .45);
  z-index: 30;
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 10px 22px calc(26px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .25);
  animation: sheet-up .25s ease;
}
@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.sheet-handle {
  width: 40px;
  height: 4.5px;
  border-radius: 99px;
  background: var(--line);
  margin: 4px auto 14px;
}

.sheet h2 { font-size: 19px; margin: 0 0 14px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15.5px;
  font-weight: 600;
}
.setting-row small { display: block; font-weight: 400; color: var(--text-2); }

.sheet .pill-btn.danger { margin-top: 18px; width: 100%; }

.settings-note {
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.5;
}

/* iOS-style switch */
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 50px;
  height: 30px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background .2s ease;
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s ease;
}
.switch:checked { background: var(--ok); border-color: var(--ok); }
.switch:checked::after { transform: translateX(20px); }

/* larger screens (iPad) */
@media (min-width: 700px) {
  .prompt-msg { font-size: 26px; }
  .bell-btn { width: 150px; height: 150px; }
}
