:root {
  --bg:          #0A0A0A;
  --bg-widget:   #141414;
  --bg-elevated: #1c1c1c;
  --accent:      #C8102E;
  --accent-dim:  rgba(200, 16, 46, 0.1);
  --gold:        #F0B429;
  --text:        #F5F0E8;
  --muted:       #8A8A8A;
  --border:      rgba(255, 255, 255, 0.08);
  --border-mid:  rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: url('betweenrounds1.png') center center / cover no-repeat;
  opacity: 0.06;
  pointer-events: none;
  z-index: 0;
}

.screen { position: relative; z-index: 1; }

/* MT4U brand top accent */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  z-index: 1000;
  pointer-events: none;
}

/* ── Screens ───────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  padding: 0 24px;
  padding-top: max(env(safe-area-inset-top), 48px);
  padding-bottom: max(env(safe-area-inset-bottom), 24px);
  animation: screenSlideIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
  overflow: hidden;
}
.screen.active { display: flex; }

@keyframes screenSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ── Typography ────────────────────────────────────────────── */
.app-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.14em;
  color: var(--accent);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 18px;
  background: var(--accent);
  color: var(--text);
  border: none;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s, transform 0.1s;
  min-height: 54px;
}
.btn-primary:active { opacity: 0.82; transform: scale(0.99); }

.btn-ghost {
  display: block;
  width: 100%;
  padding: 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
  min-height: 48px;
}
.btn-ghost:active { color: var(--text); border-color: var(--border-mid); }
.btn-ghost.wide { max-width: 280px; }

.btn-back {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 16px 4px 0;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.btn-back:active { color: var(--text); }

/* ── HOME ──────────────────────────────────────────────────── */
.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 40px;
  flex-shrink: 0;
}

.streak-badge {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.home-greeting {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.home-sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.home-footer {
  padding-top: 24px;
  flex-shrink: 0;
}

.home-question-preview {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: left;
  font-style: italic;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  line-height: 1.65;
}

/* ── RECORD ────────────────────────────────────────────────── */
.record-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 20px;
  flex-shrink: 0;
}

.round-indicator {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.record-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  text-align: center;
}

.record-question {
  font-size: clamp(1.05rem, 3.8vw, 1.3rem);
  font-weight: 500;
  font-style: italic;
  line-height: 1.6;
  max-width: 300px;
  color: var(--text);
}

.record-timer {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 4rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  min-width: 90px;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}
.record-timer.active { color: var(--accent); }

.btn-record {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  flex-shrink: 0;
}
.btn-record.recording {
  background: var(--accent);
  border-color: var(--accent);
  animation: recPulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.btn-record:active { transform: scale(0.94); }

@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.45); }
  50%       { box-shadow: 0 0 0 18px rgba(200, 16, 46, 0); }
}

.record-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  display: block;
  transition: border-radius 0.2s, background 0.2s, width 0.2s, height 0.2s;
}
.btn-record.recording .record-dot {
  background: var(--text);
  border-radius: 4px;
  width: 18px;
  height: 18px;
}

.record-label {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.btn-record.recording .record-label { color: rgba(245, 240, 232, 0.8); }

.record-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-skip-q {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 12px 20px;
  min-height: 44px;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.55;
  transition: opacity 0.15s;
  letter-spacing: 0.02em;
}
.btn-skip-q:active { opacity: 1; }

/* ── COMPLETE ──────────────────────────────────────────────── */
.complete-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding: 0 8px;
}

.complete-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--accent);
  animation: popIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.complete-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.6rem;
  letter-spacing: 0.06em;
  color: var(--text);
  line-height: 1;
}

.complete-sub {
  color: var(--muted);
  max-width: 260px;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ── ARCHIVE ───────────────────────────────────────────────── */
.archive-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 20px;
  flex-shrink: 0;
}

.archive-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

.archive-entry {
  padding: 16px;
  background: var(--bg-widget);
  border-left: 3px solid var(--accent);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.12s;
}
.archive-entry:active { background: var(--bg-elevated); }

.archive-date { font-weight: 600; font-size: 0.9rem; }

.archive-tags { display: flex; gap: 6px; }

.archive-tag {
  font-size: 0.65rem;
  padding: 3px 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.1em;
}
.archive-tag.done { border-color: var(--accent); color: var(--accent); }

.archive-empty {
  color: var(--muted);
  text-align: center;
  padding: 60px 0;
  font-size: 0.95rem;
  line-height: 1.9;
}

/* ── PLAYBACK ──────────────────────────────────────────────── */
.playback-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 24px;
  flex-shrink: 0;
}

.playback-date {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
}

.playback-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.playback-block {
  background: var(--bg-widget);
  padding: 20px;
  border-left: 3px solid var(--border);
}
.playback-block.morning { border-left-color: var(--gold); }
.playback-block.evening { border-left-color: var(--accent); }

.playback-round-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 14px;
}

.playback-item { margin-bottom: 14px; }
.playback-item:last-child { margin-bottom: 0; }

.playback-q {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.55;
  font-style: italic;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-play-small {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-mid);
  background: none;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.12s, background 0.12s;
}
.btn-play-small:active { border-color: var(--accent); background: var(--accent-dim); }

.playback-duration { font-size: 0.8rem; color: var(--muted); }

.playback-not-answered {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
  padding: 4px 0;
  opacity: 0.55;
}

.btn-rerecord {
  margin-top: 14px;
  font-size: 0.82rem;
  padding: 11px 14px;
  min-height: 44px;
}

/* ── INTRO ─────────────────────────────────────────────────── */
#screen-intro {
  padding: 0;
  position: relative;
  justify-content: flex-end;
  animation: none;
}

.btn-skip {
  position: absolute;
  top: max(env(safe-area-inset-top), 20px);
  right: 20px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  padding: 10px 4px;
  min-height: 44px;
  z-index: 10;
  transition: opacity 0.4s ease;
  white-space: nowrap;
}
.btn-skip.intro-skip-active {
  animation: fadeInSlow 0.6s ease 2.5s both;
  pointer-events: auto;
}

.intro-scroll {
  flex: 1;
  overflow-y: auto;
  padding: max(env(safe-area-inset-top), 72px) 32px 32px;
  -webkit-overflow-scrolling: touch;
}

.intro-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: center;
  text-align: center;
}

.intro-line {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.85s ease, transform 0.85s ease;
  padding: 4px 0;
  line-height: 1.7;
}
.intro-line.visible {
  opacity: 1;
  transform: none;
}

/* Line type variants */
.intro-line-normal { font-size: 1rem; color: var(--text); }

.intro-line-small {
  font-size: 0.88rem;
  color: var(--muted);
}

.intro-line-pause {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 16px;
  letter-spacing: 0.01em;
}

.intro-line-bold {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.intro-line-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.6rem, 11vw, 3.4rem);
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-top: 28px;
  margin-bottom: 6px;
  line-height: 1;
  border-top: 1px solid rgba(200, 16, 46, 0.35);
  padding-top: 18px;
  width: 100%;
}

.intro-line-question {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 18px;
}

.intro-begin {
  padding: 24px 24px max(env(safe-area-inset-bottom), 32px);
  display: flex;
  flex-direction: row;
  gap: 10px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.intro-begin[hidden] { display: none; }
.intro-begin .btn-primary,
.intro-begin .btn-ghost { flex: 1; }

.intro-footer {
  padding: 20px 24px max(env(safe-area-inset-bottom), 32px);
  display: flex;
  flex-direction: row;
  gap: 10px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.intro-footer .btn-primary,
.intro-footer .btn-no { flex: 1; }

.intro-footer .btn-primary { background: #1a7a38; }

.btn-no {
  background: var(--accent-dim);
  border: 1px solid rgba(200, 16, 46, 0.35);
  color: rgba(245, 240, 232, 0.6);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  padding: 14px;
  width: 100%;
  min-height: 48px;
  transition: background 0.2s, color 0.2s;
}
.btn-no:active { background: rgba(200, 16, 46, 0.2); color: var(--text); }

@keyframes fadeInSlow {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── CALENDAR ──────────────────────────────────────────────── */
#screen-calendar {
  gap: 0;
  overflow: hidden;
}

.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  flex-shrink: 0;
}

.cal-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.cal-month-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  color: var(--text);
}

.cal-nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1.3rem;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.cal-nav-btn:active { color: var(--text); border-color: var(--border-mid); }

.cal-day-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 6px;
  flex-shrink: 0;
}
.cal-day-headers span {
  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(138, 138, 138, 0.55);
  letter-spacing: 0.1em;
  padding: 2px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 3px;
  flex: 1;
  min-height: 0;
}

.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
  border-radius: 2px;
  overflow: hidden;
  min-height: 0;
  transition: background 0.12s;
}

.cal-cell.clickable { cursor: pointer; }
.cal-cell.clickable:active { opacity: 0.75; }

.cal-cell-num {
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.cal-cell.empty .cal-cell-num { opacity: 0; }
.cal-cell.future .cal-cell-num { color: rgba(245, 240, 232, 0.14); }
.cal-cell.past .cal-cell-num { color: var(--muted); }

.cal-cell.has-session {
  background: rgba(200, 16, 46, 0.09);
}
.cal-cell.has-session .cal-cell-num { color: var(--text); }

.cal-cell.today {
  background: var(--accent);
}
.cal-cell.today .cal-cell-num { color: var(--text); font-weight: 700; }

/* Session dots */
.cal-dots {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  height: 5px;
  align-items: center;
}
.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.cal-cell.has-session .cal-dot { background: rgba(200, 16, 46, 0.7); }
.cal-cell.today .cal-dot { background: rgba(255, 255, 255, 0.85); }
.cal-dot.eve { background: var(--gold); }
.cal-cell.has-session .cal-dot.eve { background: rgba(240, 180, 41, 0.7); }
.cal-cell.today .cal-dot.eve { background: rgba(255, 255, 255, 0.85); }

.cal-hint {
  text-align: center;
  color: rgba(138, 138, 138, 0.7);
  font-size: 0.73rem;
  margin-top: 10px;
  flex-shrink: 0;
  font-style: italic;
  letter-spacing: 0.02em;
}
