/* ================================================================
   SVHS Live — Apple-inspired Design System
   ================================================================ */

:root {
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', system-ui, sans-serif;
  --mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;

  --bg: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #e8e8ed;
  --surface: #ffffff;
  --surface-hover: #f9f9fb;
  --surface-active: #f0f0f2;

  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;

  --border: rgba(0,0,0,0.06);
  --border-strong: rgba(0,0,0,0.1);
  --divider: rgba(0,0,0,0.06);

  --accent: #1B4D72;
  --accent-light: #2A6A9E;
  --accent-hover: #164060;

  --green: #34c759;
  --green-soft: rgba(52,199,89,0.1);
  --orange: #ff9500;
  --orange-soft: rgba(255,149,0,0.1);
  --red: #ff3b30;
  --red-soft: rgba(255,59,48,0.1);
  --blue: #007aff;
  --blue-soft: rgba(0,122,255,0.1);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-full: 980px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.12);

  --tab-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --div-asb: #8B0000;
  --div-morgan: #1B4D72;
  --div-hackney: #2E7D32;
  --div-roadster: #E65100;
  --div-academy: #6A1B9A;
  --div-arabian: #00695C;
  --div-carriage: #4E342E;
  --div-friesian: #1A237E;
  --div-walktrot: #C2185B;
}

/* ---- Dark Mode ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --surface: #1c1c1e;
    --surface-hover: #2c2c2e;
    --surface-active: #3a3a3c;

    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;

    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);
    --divider: rgba(255,255,255,0.06);

    --accent: #5ba3d9;
    --accent-light: #7db8e3;
    --accent-hover: #4a8fc5;

    --green: #30d158;
    --green-soft: rgba(48,209,88,0.15);
    --orange: #ff9f0a;
    --orange-soft: rgba(255,159,10,0.15);
    --red: #ff453a;
    --red-soft: rgba(255,69,58,0.15);
    --blue: #0a84ff;
    --blue-soft: rgba(10,132,255,0.15);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.5);
  }
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  color: var(--text);
  background: var(--bg-secondary);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  padding-top: var(--safe-t);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-appearance: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: 17px;
  border: none;
  outline: none;
  -webkit-appearance: none;
  color: var(--text);
}

ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ---- App Layout ---- */
#app {
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 8px);
}

.view {
  display: none;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px 32px;
  animation: fadeUp 0.25s ease;
}

.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Install Banner ---- */
.install-banner {
  position: fixed;
  bottom: calc(var(--tab-h) + var(--safe-b) + 12px);
  left: 12px;
  right: 12px;
  z-index: 200;
  animation: fadeUp 0.3s ease-out;
}

.install-banner.hidden { display: none; }

.install-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}

.install-banner-icon {
  flex-shrink: 0;
}

.install-banner-icon img {
  border-radius: 10px;
  display: block;
}

.install-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 14px;
  line-height: 1.3;
}

.install-banner-text span {
  font-size: 13px;
  color: var(--text-secondary);
}

.install-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 980px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.install-dismiss {
  padding: 4px 8px;
  border: none;
  background: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
}

.install-instructions {
  margin-top: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.install-instructions.hidden { display: none; }

.install-instructions ol {
  margin: 0;
  padding-left: 20px;
}

.install-instructions li {
  margin-bottom: 4px;
}

.install-instructions strong {
  color: var(--text);
}

/* ---- Tab Bar ---- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg);
  border-top: 0.5px solid var(--border);
}

@supports (backdrop-filter: blur(24px)) {
  .tab-bar {
    background: color-mix(in srgb, var(--bg) 72%, transparent);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
  }
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 0 0;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.2s;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
}

.tab-item:active { opacity: 0.5; }
.tab-item.active { color: var(--accent); }

.tab-icon {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.tab-item.active .tab-icon { stroke-width: 2.2; }

.tab-badge {
  position: absolute;
  top: 2px;
  right: 50%;
  transform: translateX(14px);
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

/* ---- Page Title ---- */
.page-title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
  padding: 20px 0 6px;
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ---- Section ---- */
.section-label {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  padding: 28px 0 12px;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}

.card.interactive { cursor: pointer; }
.card.interactive:hover { box-shadow: var(--shadow-md); }
.card.interactive:active { transform: scale(0.98); }

/* ---- In-Ring Hero ---- */
.hero {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--green);
}

.hero.delayed::before { background: var(--orange); }
.hero.break::before { background: var(--text-tertiary); }

.hero .label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  margin-bottom: 14px;
}

.hero.delayed .label { color: var(--orange); }

.hero .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
}

.hero .number {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.hero .name {
  font-size: 21px;
  font-weight: 600;
  margin-top: 6px;
  color: var(--text);
  line-height: 1.3;
}

.hero .timer {
  font-family: var(--mono);
  font-size: 32px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-top: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ---- On Deck / Upcoming Row ---- */
.class-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  box-shadow: var(--shadow-sm);
}

.class-row:hover { background: var(--surface-hover); }
.class-row:active { transform: scale(0.985); background: var(--surface-active); }

.class-num {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  min-width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.class-info {
  flex: 1;
  min-width: 0;
}

.class-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.class-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.class-time {
  font-size: 13px;
  color: var(--text-tertiary);
}

.class-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Division Badge ---- */
.div-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- Status Badge ---- */
.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-in-ring { background: var(--green-soft); color: var(--green); }
.status-on-deck { background: var(--blue-soft); color: var(--blue); }
.status-scheduled { background: var(--bg-secondary); color: var(--text-tertiary); }
.status-completed { background: var(--bg-secondary); color: var(--text-secondary); }
.status-scratched { background: var(--red-soft); color: var(--red); text-decoration: line-through; }
.status-delayed { background: var(--orange-soft); color: var(--orange); }

/* ---- Progress ---- */
.progress-track {
  width: 100%;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s ease;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.timing-ahead { color: var(--green); }
.timing-behind { color: var(--orange); }

/* ---- Empty State ---- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 32px;
  text-align: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-tertiary);
  opacity: 0.4;
  margin-bottom: 16px;
}

.empty h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.empty p {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 260px;
}

/* ---- Day Tabs ---- */
.day-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 14px;
}

.day-tab {
  flex: 1;
  padding: 9px 0;
  border-radius: calc(var(--radius-md) - 3px);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  transition: all 0.2s;
}

.day-tab:active { opacity: 0.6; }

.day-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---- Division Chips ---- */
.chips {
  display: flex;
  gap: 8px;
  padding: 0 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 7px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid var(--border-strong);
  color: var(--text-secondary);
  background: var(--surface);
  transition: all 0.2s;
}

.chip:active { transform: scale(0.94); }

.chip.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ---- Search ---- */
.search-input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 42px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid transparent;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
}

.search-input::placeholder { color: var(--text-tertiary); }

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
  background-color: var(--surface);
}

/* ---- Alerts ---- */
.alert-item {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.alert-message {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
}

.alert-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.alert-sender { font-weight: 600; color: var(--text-secondary); }

/* ---- Info Section ---- */
.info-group {
  margin-bottom: 24px;
}

.info-group-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 0 4px 8px;
}

.info-list {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 0.5px solid var(--divider);
  font-size: 15px;
}

.info-row:last-child { border-bottom: none; }

.info-label { color: var(--text); font-weight: 500; }

.info-value {
  color: var(--text-secondary);
  text-align: right;
  max-width: 55%;
  line-height: 1.3;
}

.info-link { color: var(--accent); font-weight: 500; }

.info-row.interactive { cursor: pointer; }
.info-row.interactive:active { background: var(--surface-active); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 28px;
  border-radius: var(--radius-md);
  font-size: 17px;
  font-weight: 600;
  transition: all 0.12s;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-green { background: var(--green); color: #ffffff; }
.btn-orange { background: var(--orange); color: #ffffff; }
.btn-red { background: var(--red); color: #ffffff; }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--border-strong);
}

.btn-secondary:hover { background: var(--surface-hover); }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  height: 36px;
  padding: 0 12px;
  font-size: 15px;
}

.btn-block { width: 100%; }

.btn-sm {
  height: 36px;
  padding: 0 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

/* ---- Star Button ---- */
.star-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.star-btn:active { transform: scale(0.85); }
.star-btn.followed { color: var(--orange); }

/* ---- Form ---- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid transparent;
  font-size: 17px;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input::placeholder { color: var(--text-tertiary); }

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
  background: var(--surface);
}

.form-textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid transparent;
  font-size: 17px;
  color: var(--text);
  resize: vertical;
  line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-textarea::placeholder { color: var(--text-tertiary); }

.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
  background: var(--surface);
}

.form-error {
  font-size: 14px;
  color: var(--red);
  margin-top: 8px;
}

/* ---- Login ---- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - var(--tab-h) - var(--safe-b) - var(--safe-t) - 40px);
  padding: 24px 0;
}

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo svg {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.login-sub {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* ---- Admin ---- */
.admin-segment {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 20px;
}

.segment-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: calc(var(--radius-md) - 3px);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  transition: all 0.2s;
}

.segment-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.admin-current {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  text-align: center;
  margin-bottom: 16px;
  position: relative;
  box-shadow: var(--shadow-md);
}

.admin-current .ring-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.admin-current .class-num-xl {
  font-family: var(--font-display);
  font-size: 60px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.admin-current .class-name-lg {
  font-size: 19px;
  font-weight: 600;
  margin-top: 6px;
  color: var(--text);
  line-height: 1.3;
}

.admin-current .timer-lg {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-top: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.on-deck-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

.on-deck-label {
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.on-deck-name {
  flex: 1;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-actions .row {
  display: flex;
  gap: 8px;
}

.admin-actions .row > * { flex: 1; }

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 56px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  transition: transform 0.12s, opacity 0.12s;
  -webkit-user-select: none;
  user-select: none;
  letter-spacing: 0.01em;
}

.action-btn:active { transform: scale(0.97); opacity: 0.85; }
.action-btn:disabled { opacity: 0.35; pointer-events: none; }

.action-advance { background: var(--green); height: 64px; font-size: 17px; }
.action-start { background: var(--accent); height: 64px; font-size: 17px; }
.action-delay { background: var(--orange); }
.action-scratch { background: var(--red); }
.action-reset { background: var(--text-tertiary); }

/* ---- Broadcast Templates ---- */
.template-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 16px;
}

.template-chip {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.template-chip:hover { background: var(--surface-hover); }
.template-chip:active { transform: scale(0.95); }

/* ---- Analytics ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.activity-feed {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 0.5px solid var(--divider);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-icon svg { width: 14px; height: 14px; }

.push-icon {
  background: rgba(0, 122, 255, 0.12);
  color: var(--accent);
}

.audit-icon {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.activity-body { flex: 1; min-width: 0; }

.activity-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-transform: capitalize;
}

.activity-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

.fail-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--red);
  background: rgba(255, 59, 48, 0.1);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: 4px;
  vertical-align: middle;
}

@media (max-width: 380px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  top: calc(12px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: calc(100% - 32px);
  max-width: 420px;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  pointer-events: auto;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 0.35s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.toast.out { animation: toastOut 0.3s ease forwards; }

.toast .undo-btn {
  font-weight: 700;
  color: var(--accent-light);
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  margin-left: auto;
}

.toast .undo-btn:hover { text-decoration: underline; }

@keyframes toastIn {
  from { transform: translateY(-120%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-120%); opacity: 0; }
}

/* ---- Modal ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: overlayIn 0.2s ease;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.overlay.out { animation: overlayOut 0.2s ease forwards; }

@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayOut { from { opacity: 1; } to { opacity: 0; } }

.sheet {
  width: 100%;
  max-width: 500px;
  max-height: 85dvh;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--safe-b);
  animation: sheetUp 0.35s cubic-bezier(0.21, 1.02, 0.73, 1);
}

.overlay.out .sheet { animation: sheetDown 0.2s ease forwards; }

@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheetDown { from { transform: translateY(0); } to { transform: translateY(100%); } }

.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  margin: 10px auto 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
}

.sheet-title {
  font-size: 18px;
  font-weight: 700;
}

.sheet-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.sheet-close:active { background: var(--bg-tertiary); }

.sheet-body { padding: 0 20px 20px; }
.sheet-actions { padding: 0 20px 24px; display: flex; flex-direction: column; gap: 8px; }

/* Delay modal options */
.delay-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 16px;
}

.delay-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s;
}

.delay-option:hover { background: var(--surface-hover); }
.delay-option:active { background: var(--surface-active); }

.delay-option.selected {
  background: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  font-weight: 600;
}

.delay-option .option-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.delay-option.selected .option-icon {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.delay-option .check {
  margin-left: auto;
  opacity: 0;
  color: var(--accent);
  font-weight: 700;
}

.delay-option.selected .check { opacity: 1; }

.duration-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.duration-btn {
  padding: 12px 0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.duration-btn:active { transform: scale(0.94); }

.duration-btn.selected {
  background: var(--accent);
  color: #ffffff;
}

/* ---- Back Button ---- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 17px;
  font-weight: 500;
  color: var(--accent);
  padding: 8px 0;
  margin-bottom: 4px;
}

.back-btn:hover { text-decoration: underline; }

.back-btn svg {
  width: 20px;
  height: 20px;
}

/* ---- Class Detail ---- */
.detail-header {
  padding: 12px 0 20px;
}

.detail-num {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.detail-name {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-top: 6px;
}

.detail-rows {
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 0.5px solid var(--divider);
  font-size: 15px;
}

.detail-row:last-child { border-bottom: none; }

.detail-row .dl { color: var(--text-secondary); font-weight: 500; }
.detail-row .dv { font-weight: 600; }

.championship-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #FFD700 0%, #F0B400 100%);
  color: #5B4500;
  font-size: 12px;
  font-weight: 700;
}

/* Results */
.result-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--divider);
}

.result-row:last-child { border-bottom: none; }

.result-place {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.result-place:nth-child(1) { background: #FFD700; color: #5B4500; }

.result-info { flex: 1; min-width: 0; }
.result-horse { font-size: 15px; font-weight: 600; }
.result-entry { font-size: 13px; color: var(--text-secondary); margin-top: 1px; }
.result-trainer { font-size: 13px; color: var(--text-tertiary); }

/* ---- Version Label ---- */
/* ---- Toggle Switch ---- */
.notif-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-tertiary);
  border-radius: 31px;
  transition: background-color 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #34c759;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.version-label {
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 32px 0 16px;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}

/* ---- Loading ---- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 0;
  gap: 12px;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 14px;
  color: var(--text-tertiary);
}

/* ---- Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Utility ---- */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ---- Responsive ---- */
@media (max-width: 360px) {
  .page-title { font-size: 28px; }
  .hero .number { font-size: 40px; }
  .action-btn { height: 50px; font-size: 15px; }
}

@media (min-width: 600px) {
  .tab-bar {
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: 0.5px solid var(--border-strong);
    border-right: 0.5px solid var(--border-strong);
  }

  .sheet {
    border-radius: var(--radius-xl);
    margin-bottom: 20px;
    max-height: 80dvh;
  }

  #toast-container { max-width: 420px; }
}

@media (min-width: 1024px) {
  body {
    display: flex;
    justify-content: center;
  }

  #app {
    width: 100%;
    max-width: 680px;
    min-height: 100dvh;
    position: relative;
  }
}

@media (display-mode: standalone) {
  body { padding-top: var(--safe-t); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .tab-bar, #toast-container, .overlay { display: none !important; }
  #app { padding-bottom: 0; }
}

/* ================================================================
   New components: session header, announcements, filter toggle, sponsors
   ================================================================ */

.session-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  margin: -4px -16px 10px;
  background: var(--surface);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.session-header svg {
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.announcement-row {
  padding: 12px 16px;
  margin: 0 -16px;
  border-bottom: 0.5px solid var(--divider);
}

.announcement-row:last-child {
  border-bottom: none;
}

.announcement-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.announcement-icon {
  font-size: 14px;
}

.announcement-msg {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

.filter-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 3px;
}

.filter-mode-btn {
  flex: 1;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: calc(var(--radius-md) - 3px);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-mode-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

:root {
  --gold: #B8860B;
}
