/* ===== CSS Variables (Theme) ===== */
:root {
  --primary: #1A73E8;
  --bg: #ffffff;
  --surface: #f5f5f5;
  --fg: #11181C;
  --muted: #687076;
  --border: #E5E7EB;
  --success: #22C55E;
  --warning: #F59E0B;
  --error: #EF4444;
  --font-scale: 1;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --primary: #1A73E8;
  --bg: #151718;
  --surface: #1e2022;
  --fg: #ECEDEE;
  --muted: #9BA1A6;
  --border: #334155;
  --success: #4ADE80;
  --warning: #FBBF24;
  --error: #F87171;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

@media (min-width: 601px) {
  #app {
    border-left: 0.5px solid var(--border);
    border-right: 0.5px solid var(--border);
  }
}

/* ===== Page Panels ===== */
.page-panel {
  position: absolute;
  inset: 0;
  padding: 8px 16px 16px;
  padding-top: calc(var(--safe-top) + 8px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overscroll-behavior: contain;
}
.page-panel.hidden {
  visibility: hidden;
  pointer-events: none;
}
.page-panel.offscreen-left {
  transform: translateX(-100%);
}
.page-panel.offscreen-right {
  transform: translateX(100%);
}

/* ===== Page Content ===== */
.page-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ===== Tab Bar ===== */
.tab-bar {
  display: flex;
  border-top: 1.5px solid var(--border);
  background: var(--bg);
  padding-bottom: max(var(--safe-bottom), 8px);
  padding-top: 8px;
  flex-shrink: 0;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--fg);
  cursor: pointer;
  padding: 4px 0;
  margin: 0 4px;
  position: relative;
  font-size: 10px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tab-item.active { color: #fff; background: var(--primary); }
.tab-item .material-icons { font-size: 24px; }
.tab-label { font-size: calc(11px * var(--font-scale)); font-weight: 600; }

.badge {
  position: absolute;
  top: -2px;
  right: calc(50% - 20px);
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  border-radius: 8px;
  text-align: center;
  padding: 0 4px;
}

/* ===== Page Title ===== */
.page-title {
  font-size: calc(28px * var(--font-scale));
  font-weight: 700;
  margin-bottom: 16px;
  margin-top: 8px;
  color: var(--fg);
  text-align: center;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 8px;
}

/* ===== Form Row (Score Input) ===== */
.form-row {
  display: flex;
  align-items: center;
  border-bottom: 1.5px solid var(--border);
  min-height: calc(48px * var(--font-scale));
}

.form-row-last {
  display: flex;
  align-items: center;
  min-height: calc(48px * var(--font-scale));
}

.half-row {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
  min-height: inherit;
  gap: 4px;
  transition: background 0.1s;
}

.half-row:active { background: var(--border); opacity: 0.7; }

.half-divider {
  width: 1.5px;
  align-self: stretch;
  background: var(--border);
  margin: 8px 0;
}

.form-label {
  font-size: calc(16px * var(--font-scale));
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  flex-shrink: 0;
}

.form-value {
  flex: 1;
  text-align: right;
  font-size: calc(16px * var(--font-scale));
  font-weight: 600;
  margin-right: 4px;
  min-width: 30px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-value.placeholder { color: var(--muted); font-weight: 400; }
.form-value.score-positive { color: var(--success); font-weight: 700; font-variant-numeric: tabular-nums; }
.form-value.score-negative { color: var(--error); font-weight: 700; font-variant-numeric: tabular-nums; }
.form-value.score-zero { color: var(--fg); font-weight: 700; font-variant-numeric: tabular-nums; }

.chevron {
  color: var(--muted);
  font-size: calc(20px * var(--font-scale));
  flex-shrink: 0;
  opacity: 0.5;
}

.chevron-img {
  width: calc(16px * var(--font-scale));
  height: calc(16px * var(--font-scale));
  flex-shrink: 0;
  opacity: 0.8;
  object-fit: contain;
  vertical-align: middle;
  filter: brightness(0.3);
}

/* Swap button inline */
.swap-btn-inline {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 158, 11, 0.09);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.swap-btn-inline .material-icons { font-size: 12px; color: var(--warning); }
.swap-placeholder { width: 20px; height: 20px; flex-shrink: 0; }

.form-label-farmer {
  font-size: calc(16px * var(--font-scale));
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  flex: 1.4;
}

.form-value-farmer {
  flex: 1;
  text-align: right;
  font-size: calc(16px * var(--font-scale));
  font-weight: 600;
  margin-right: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-value-farmer.placeholder { color: var(--muted); font-weight: 400; }

/* ===== Farmer Preview ===== */
.farmer-preview {
  color: var(--muted);
  font-size: calc(13px * var(--font-scale));
  margin-bottom: 12px;
  padding: 0 4px;
}

/* ===== Buttons ===== */
.button-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  margin-top: 4px;
  position: relative;
}
.button-row-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 10px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.button-row-overlay .stripe-bar { display: none; }
.button-row-overlay.active {
  opacity: 1;
  pointer-events: auto;
  background: linear-gradient(
    -45deg,
    #2563eb 25%, #93bbfd 25%,
    #93bbfd 50%, #2563eb 50%,
    #2563eb 75%, #93bbfd 75%
  );
  background-size: 40px 40px;
  animation: stripe-scroll 1.2s linear infinite;
}
@keyframes stripe-scroll {
  from { background-position: 0 0; }
  to { background-position: 40px 0; }
}
.button-row-overlay .overlay-text {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(15px * var(--font-scale));
  color: #fff;
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.45), 0 0 8px rgba(0,0,0,0.2);
}

.submit-btn {
  flex: 1;
  height: calc(48px * var(--font-scale));
  border-radius: 10px;
  background: var(--success);
  color: #fff;
  border: none;
  font-size: calc(16px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.08s, opacity 0.1s;
}

.submit-btn:active { transform: scale(0.95); opacity: 0.9; }
.submit-btn:disabled { opacity: 0.7; cursor: not-allowed; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.submit-btn .material-icons { font-size: calc(16px * var(--font-scale)); }

.clear-btn {
  flex: 1;
  height: calc(48px * var(--font-scale));
  border-radius: 10px;
  background: color-mix(in srgb, var(--border) 60%, transparent);
  color: var(--fg);
  border: none;
  font-size: calc(16px * var(--font-scale));
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.08s, opacity 0.1s;
}

.clear-btn:active { transform: scale(0.95); opacity: 0.7; }
.clear-btn .material-icons { font-size: calc(16px * var(--font-scale)); }

.undo-icon-btn {
  width: calc(48px * var(--font-scale));
  height: calc(48px * var(--font-scale));
  min-width: calc(48px * var(--font-scale));
  border-radius: 12px;
  background: var(--error);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  padding: 0;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}
.undo-icon-btn .material-icons { font-size: calc(24px * var(--font-scale)); font-weight: 700; }
.undo-icon-btn:active { transform: scale(0.93); opacity: 0.8; }


/* ===== Quick Reuse Button ===== */
.quick-reuse-btn.hidden { display: none; }
.quick-reuse-btn {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 19%, transparent);
  background: color-mix(in srgb, var(--primary) 7%, transparent);
  cursor: pointer;
  margin-bottom: 8px;
  gap: 6px;
  transition: opacity 0.1s;
}

.quick-reuse-btn:active { opacity: 0.7; }
.quick-reuse-btn .material-icons { font-size: calc(16px * var(--font-scale)); color: var(--primary); }
.quick-reuse-btn span:last-child { color: var(--primary); font-size: calc(13px * var(--font-scale)); font-weight: 500; }

/* ===== Round Summary ===== */
.round-section { margin-top: 8px; }
.round-title { font-size: calc(18px * var(--font-scale)); font-weight: 700; margin-bottom: 12px; color: var(--fg); text-align: center; }

.summary-table {
  border-radius: 10px;
  border: 1.5px solid var(--border);
  overflow: hidden;
}

.summary-header-row {
  display: flex;
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--border);
}

.summary-row {
  display: flex;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

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

.summary-cell { font-variant-numeric: tabular-nums; }
.summary-cell-name { flex: 1; font-weight: 500; display: flex; align-items: center; gap: 3px; }
.summary-cell-num {
  width: calc(60px * var(--font-scale));
  text-align: right;
  flex-shrink: 0;
}

/* ===== Pending Sync Panel (matches APK PendingSyncPanel) ===== */
.sync-panel {
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent);
  background: color-mix(in srgb, var(--warning) 7%, transparent);
  overflow: hidden;
}
.sync-panel-compact { margin-bottom: 12px; }
.sync-panel-full { margin-bottom: 0; }

.sync-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sync-panel-header-left {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.sync-panel-sync-btn {
  display: flex;
  align-items: center;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.sync-panel-sync-btn:disabled {
  background: var(--border);
  cursor: not-allowed;
  opacity: 0.7;
}

.sync-panel-offline {
  display: flex;
  align-items: center;
  padding: 6px 14px;
  margin: 0 10px 8px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--muted) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--muted) 20%, transparent);
  color: var(--muted);
  font-size: calc(11px * var(--font-scale));
}

.sync-panel-details {
  border-top: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
  padding: 8px 10px;
}

.sync-panel-item {
  display: flex;
  align-items: center;
  padding: 6px 4px;
  border-bottom: 0.5px solid color-mix(in srgb, var(--warning) 15%, transparent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sync-panel-item:last-of-type { border-bottom: none; }
.sync-panel-item:active { opacity: 0.7; }

.sync-item-time {
  color: var(--muted);
  font-size: calc(11px * var(--font-scale));
  font-variant-numeric: tabular-nums;
  width: 55px;
  flex-shrink: 0;
}
.sync-item-landlord {
  color: var(--foreground);
  font-size: calc(12px * var(--font-scale));
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sync-item-score {
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
  flex-shrink: 0;
}
.sync-item-farmers {
  color: var(--muted);
  font-size: calc(11px * var(--font-scale));
  margin-left: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sync-panel-force-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed color-mix(in srgb, var(--error) 40%, transparent);
  border-radius: 8px;
  background: transparent;
  color: var(--error);
  font-size: calc(12px * var(--font-scale));
  font-weight: 500;
  cursor: pointer;
}
.sync-panel-force-clear:active { opacity: 0.7; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  font-size: calc(14px * var(--font-scale));
  z-index: 1000;
  transition: opacity 0.3s;
  pointer-events: none;
  max-width: calc(100% - 40px);
  text-align: center;
  white-space: nowrap;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--primary); }
.toast.warning { background: var(--warning); color: #11181C; }

/* ===== Undo Banner ===== */
.undo-banner {
  position: fixed;
  bottom: calc(70px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 568px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: opacity 0.25s, transform 0.3s;
  overflow: hidden;
}

.undo-banner.offline { border-color: color-mix(in srgb, var(--warning) 40%, transparent); background: color-mix(in srgb, var(--warning) 10%, var(--surface)); }
.undo-banner.online { border-color: color-mix(in srgb, var(--error) 40%, transparent); background: color-mix(in srgb, var(--error) 10%, var(--surface)); }

.undo-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 12px;
  transition: width 1s linear;
}

.undo-banner.offline .undo-progress { background: color-mix(in srgb, var(--warning) 13%, transparent); }
.undo-banner.online .undo-progress { background: color-mix(in srgb, var(--error) 13%, transparent); }

.undo-content {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
  flex: 1;
}

.undo-banner.offline .undo-content .material-icons { color: var(--warning); }
.undo-banner.offline .undo-content .undo-text { color: var(--warning); }
.undo-banner.offline .undo-content .undo-countdown { color: color-mix(in srgb, var(--warning) 56%, transparent); }
.undo-banner.online .undo-content .material-icons { color: var(--error); }
.undo-banner.online .undo-content .undo-text { color: var(--error); }
.undo-banner.online .undo-content .undo-countdown { color: color-mix(in srgb, var(--error) 56%, transparent); }

.undo-text { font-size: calc(14px * var(--font-scale)); font-weight: 600; flex: 1; }
.undo-countdown { font-size: calc(13px * var(--font-scale)); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== Modal / Picker ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
  flex-direction: column;
}

.modal-sheet {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease-out;
}

/* Confirm Dialog */
.modal-overlay { opacity: 0; transition: opacity 0.2s ease; pointer-events: none; }
.modal-overlay.visible { opacity: 1; pointer-events: auto; }
.modal-overlay.visible.confirm-overlay { justify-content: center; align-items: center; }
.confirm-dialog {
  background: var(--surface);
  border-radius: 14px;
  padding: 24px;
  margin: 0 40px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.confirm-title { font-size: calc(17px * var(--font-scale)); font-weight: 600; color: var(--fg); margin-bottom: 8px; }
.confirm-msg { font-size: calc(14px * var(--font-scale)); color: var(--muted); margin-bottom: 20px; line-height: 1.4; }
.confirm-actions { display: flex; gap: 12px; }
.confirm-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  font-size: calc(15px * var(--font-scale));
  font-weight: 500;
  border: none;
  cursor: pointer;
}
.confirm-btn.cancel { background: var(--border); color: var(--fg); }
.confirm-btn.ok { background: var(--primary); color: #fff; }

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}

.modal-title { font-size: calc(17px * var(--font-scale)); font-weight: 600; color: var(--fg); }
.modal-close { background: none; border: none; color: var(--primary); font-size: calc(16px * var(--font-scale)); font-weight: 500; cursor: pointer; }

.picker-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(var(--safe-bottom), 20px);
}

.picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.picker-item:active { background: var(--border); }
.picker-item.selected { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.picker-item-text { font-size: calc(16px * var(--font-scale)); font-weight: 500; color: var(--fg); }
.picker-item-text.score { font-weight: 600; font-variant-numeric: tabular-nums; }
.picker-item-text.score-positive { color: var(--success); }
.picker-item-text.score-negative { color: var(--error); }
.picker-item-check { color: var(--primary); font-size: 18px; }

/* ===== History Page ===== */
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--muted);
  pointer-events: none;
  z-index: 1;
}

.history-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.search-input {
  flex: 1;
  height: calc(36px * var(--font-scale));
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  padding: 0 12px 0 38px;
  font-size: calc(14px * var(--font-scale));
  outline: none;
}

.search-input:focus { border-color: var(--primary); }
.search-input::placeholder { color: var(--muted); }

.filter-btn {
  width: calc(36px * var(--font-scale));
  height: calc(36px * var(--font-scale));
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-btn.active { border-color: var(--primary); color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }

/* Round header - expandable section */
.round-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  margin-top: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.round-header:active { opacity: 0.7; }
.round-header-left {
  display: flex;
  align-items: center;
  gap: 4px;
}
.round-chevron {
  font-size: 20px;
  color: var(--muted);
  line-height: 1;
  display: flex;
  align-items: center;
}
.round-header .round-title {
  font-size: calc(15px * var(--font-scale));
  font-weight: 600;
  color: var(--fg);
  line-height: 1.2;
  margin-bottom: 0;
}
.round-subtitle {
  font-size: calc(13px * var(--font-scale));
  color: var(--muted);
}

/* Game rows inside expanded round */
.round-games {
  padding: 0 4px;
}
.game-row {
  display: flex;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  gap: 4px;
}
.game-row.pending {
  background: color-mix(in srgb, var(--warning) 5%, transparent);
}
.game-row-time {
  min-width: 60px;
  font-size: calc(11px * var(--font-scale));
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
}
.game-row-time.pending-time {
  color: var(--warning);
}
.game-row-player {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}
.game-row-player-name {
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.game-row-player-score {
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.game-row-player-score.positive { color: var(--success); }
.game-row-player-score.negative { color: var(--error); }

.history-footer {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: calc(13px * var(--font-scale));
}

.history-footer.clickable { cursor: pointer; }

.pull-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 40px;
  margin-top: -40px;
  opacity: 0;
  transform: translateY(0);
  will-change: transform, opacity;
  pointer-events: none;
}
.pull-indicator-content {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.pull-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== Stats Page ===== */
.range-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
}

.range-scroll::-webkit-scrollbar { display: none; }

.range-chip {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
}

.range-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.stats-table { width: 100%; }

.stats-header {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 2px solid var(--border);
}

.stats-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.stats-row.incomplete { background: color-mix(in srgb, var(--muted) 13%, transparent); }
.stats-row.incomplete .stats-cell { opacity: 0.45; }
.stats-row.incomplete .stats-cell-name { opacity: 0.45; }

.stats-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: calc(13px * var(--font-scale));
  color: var(--muted);
  flex-shrink: 0;
}

.stats-cell-rank { width: calc(28px * var(--font-scale)); text-align: center; color: var(--muted); font-size: calc(13px * var(--font-scale)); }
.stats-cell-name { flex: 1; font-weight: 500; font-size: calc(14px * var(--font-scale)); color: var(--fg); display: flex; align-items: center; gap: 3px; padding: 0 4px; min-width: 0; }
.stats-cell-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-cell-score { width: calc(72px * var(--font-scale)); font-size: calc(14px * var(--font-scale)); font-weight: 700; }
.stats-cell-avg { width: calc(56px * var(--font-scale)); font-size: calc(12px * var(--font-scale)); }
.stats-cell-games { width: calc(44px * var(--font-scale)); font-size: calc(12px * var(--font-scale)); }
.stats-cell-winrate { width: calc(52px * var(--font-scale)); font-size: calc(12px * var(--font-scale)); }

.stats-header .stats-cell { font-weight: 600; font-size: calc(11px * var(--font-scale)); color: var(--muted); }

/* Charts section */
.charts-section { margin-top: 24px; }
.chart-title { font-size: calc(15px * var(--font-scale)); font-weight: 600; margin: 0; padding: 0; color: var(--fg); text-align: center; line-height: calc(18px * var(--font-scale)); }

.player-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.player-selector-label { color: var(--muted); font-size: calc(13px * var(--font-scale)); font-weight: 500; white-space: nowrap; }

.player-selector-btn {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  gap: 2px;
}

.player-selector-btn span:first-child { flex: 1; color: var(--fg); font-size: calc(13px * var(--font-scale)); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-selector-btn .material-icons { color: var(--muted); font-size: calc(20px * var(--font-scale)); }

.chart-container {
  width: 100%;
  overflow-x: hidden;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chart-container canvas { display: block; }
.chart-container svg { display: block; max-width: 100%; touch-action: pan-y; }

.radar-section { margin-top: 24px; display: flex; flex-direction: column; align-items: center; }

/* Player Picker Modal (Stats) */
.player-picker-content {
  background: var(--surface);
  border-radius: 14px;
  border: 0.5px solid var(--border);
  padding: 16px;
  width: 280px;
  margin: auto;
}

.player-picker-title { font-size: calc(17px * var(--font-scale)); font-weight: 700; text-align: center; margin-bottom: 12px; color: var(--fg); }

.player-picker-list { max-height: 300px; overflow-y: auto; }

.player-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 0.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.player-picker-item:active { opacity: 0.7; }
.player-picker-item.selected { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.player-picker-item.selected .player-picker-item-name { color: var(--primary); font-weight: 600; }

.player-picker-item-name { font-size: calc(15px * var(--font-scale)); color: var(--fg); }

.player-picker-done {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: calc(15px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
}

/* ===== Settings Page ===== */
.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.settings-card {
  background: var(--surface);
  border-radius: 12px;
  border: 1.5px solid var(--border);
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}

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

.settings-row-label {
  font-size: calc(15px * var(--font-scale));
  color: var(--fg);
  font-weight: 400;
}

.settings-row-value {
  font-size: calc(14px * var(--font-scale));
  color: var(--muted);
}

/* Segmented Control */
.segmented-control {
  display: flex;
  background: var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.segment-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.segment-btn.active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(20px); }

.settings-row-desc {
  font-size: calc(12px * var(--font-scale));
  color: var(--muted);
  margin-top: 2px;
}

.settings-action-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
}

.settings-action-btn.danger { background: var(--error); }
.settings-action-btn:disabled { background: var(--muted); opacity: 0.6; cursor: not-allowed; }

/* Server status indicator */
.server-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.normal { background: var(--success); }
.status-dot.slow { background: var(--warning); }
.status-dot.disconnected { background: var(--error); }
.status-dot.testing { background: var(--muted); animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
/* Swipe transition handled by JS transform + CSS transition */

/* ===== Auth Gate (Splash/Login/Checking/Denied) ===== */
.auth-gate {
  position: fixed;
  inset: 0;
  background: #2c4c7f;
  z-index: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: opacity 0.5s ease;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.auth-gate.fade-out {
  opacity: 0;
  pointer-events: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: #2c4c7f;
  z-index: 550;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: opacity 0.6s ease;
}

.auth-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.auth-logo-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  will-change: margin-top;
  /* No transition by default - prevent jump on initial render */
  transition: none;
  /* Initial state: center vertically to match Android system PWA splash screen */
  /* Logo group height: avatar(30vw) + margin(20) + text(30) ≈ 30vw + 50px */
  /* Center: 50vh - (30vw + 50px)/2 */
  margin-top: calc(50vh - 15vw - 25px);
}

/* Only enable transition after JS adds this class (after first paint) */
.auth-logo-group.animated {
  transition: margin-top 1s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.auth-logo-center {
  /* Centered state - matches Android system PWA splash screen position */
  /* With 192px-only icon, Chrome uses small layout: icon ~30vw */
  margin-top: calc(50vh - 15vw - 25px);
}

.auth-logo-shifted {
  /* Shifted state - moves logo up to make room for login UI */
  margin-top: clamp(80px, 28vh, 38vh);
}

.auth-avatar {
  /* Enlarged 2.25x total from original for splash screen presence */
  width: clamp(225px, 67vw, 400px);
  height: clamp(225px, 67vw, 400px);
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  margin-bottom: 20px;
  object-fit: cover;
  will-change: transform;
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* Show immediately - position matches system splash so no jump */
  opacity: 1;
}



@media (max-height: 667px) {
  .auth-avatar {
    border-radius: 20px;
  }
  .auth-logo-shifted {
    margin-top: clamp(60px, 20vh, 28vh);
  }
  .auth-quote {
    font-size: 19px;
  }
}

.auth-quote {
  color: rgba(255,255,255,0.85);
  font-size: 22px;
  font-style: italic;
  text-align: center;
  margin-bottom: 8px;
  font-weight: 400;
  letter-spacing: 0.5px;
  transition: opacity 0.4s ease;
}

/* App name text shown initially to match system splash */
.auth-app-name {
  color: rgba(255,255,255,0.85);
  font-size: 18px;
  font-style: normal;
  text-align: center;
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: 0.5px;
  transition: opacity 0.4s ease;
}

.auth-content {
  text-align: center;
  padding: 0 32px;
  width: 100%;
  max-width: 400px;
  margin-top: 24px;
  flex-shrink: 0;
  padding-bottom: 40px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.auth-content.visible {
  opacity: 1;
}

.auth-status-text {
  color: rgba(255,255,255,0.8);
  font-size: 16px;
  margin-bottom: 8px;
}

.auth-email-text {
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

.auth-email-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 16px;
  text-align: center;
  outline: none;
  display: block;
  margin-bottom: 16px;
}

.auth-email-input:focus {
  border-color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.15);
}

.auth-email-input::placeholder {
  color: rgba(255,255,255,0.4);
}

.auth-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 24px;
  border-radius: 28px;
  background: #fff;
  color: #3B5171;
  border: none;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.1s;
  margin-bottom: 12px;
}

.auth-btn-primary:active { transform: scale(0.97); opacity: 0.9; }
.auth-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  border-radius: 28px;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  border: 1.5px solid rgba(255,255,255,0.25);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.1s;
  margin-bottom: 12px;
}

.auth-btn-secondary:active { transform: scale(0.97); opacity: 0.9; }
.auth-btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  border-radius: 28px;
  background: #fff;
  color: #3B5171;
  border: none;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.1s, box-shadow 0.2s;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  font-family: 'Google Sans', 'Roboto', -apple-system, sans-serif;
}
.auth-google-btn:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.auth-google-btn:active { transform: scale(0.97); opacity: 0.9; }
.auth-google-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-google-btn svg { flex-shrink: 0; }

.auth-version {
  color: rgba(255,255,255,0.45);
  font-size: 13px;
  margin-top: 20px;
  letter-spacing: 0.5px;
}

.auth-error-text {
  color: #FF6B6B;
  font-size: 14px;
  margin-bottom: 16px;
}

.auth-lock-icon {
  font-size: 48px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 16px;
}

.auth-user-card {
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.auth-user-card-email {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.auth-user-card-role {
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  margin-top: 4px;
}

.main-app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ===== Offline Banner ===== */
.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: calc(13px * var(--font-scale));
  color: var(--warning);
  font-weight: 500;
}

/* ===== Date Filter Modal ===== */
.date-modal-content {
  background: var(--surface);
  border-radius: 14px;
  border: 0.5px solid var(--border);
  padding: 20px;
  width: 300px;
  margin: auto;
}

.date-filter-title {
  font-size: calc(17px * var(--font-scale));
  font-weight: 700;
  text-align: center;
  margin-bottom: 16px;
  color: var(--fg);
}

.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.date-preset-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-size: calc(13px * var(--font-scale));
  cursor: pointer;
  transition: all 0.15s;
}

.date-preset-btn:active { opacity: 0.7; }
.date-preset-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.date-inputs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.date-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-input-label { font-size: calc(14px * var(--font-scale)); color: var(--muted); width: 30px; }

.date-input {
  flex: 1;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 0 10px;
  font-size: calc(14px * var(--font-scale));
}

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

.date-action-btn {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: none;
  font-size: calc(15px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
}

.date-action-btn.clear { background: var(--border); color: var(--fg); }
.date-action-btn.confirm { background: var(--primary); color: #fff; }

/* ===== Loading Spinner ===== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== Sync Details Panel ===== */
.sync-details {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 8px;
  border: 0.5px solid var(--border);
}

.sync-detail-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 0.5px solid var(--border);
  font-size: calc(12px * var(--font-scale));
}

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

/* ===== Utilities ===== */
.hidden { display: none !important; }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* ===== Trend Chart Tooltip ===== */
.chart-tooltip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: calc(14px * var(--font-scale));
}

/* ===== Scrollbar (Desktop) ===== */
@media (min-width: 601px) {
  .page-content::-webkit-scrollbar { width: 6px; }
  .page-content::-webkit-scrollbar-track { background: transparent; }
  .page-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
}

/* ===== Full-Screen Data Loading Overlay ===== */
#data-loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 56px; /* above tab bar */
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(var(--overlay-rgb, 255,255,255), 0.75);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity 0.3s ease;
}
[data-theme="dark"] #data-loading-overlay {
  background: rgba(21,23,24, 0.8);
}
#data-loading-overlay.hidden {
  display: none;
}
.dl-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 40px;
  background: var(--surface);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  max-width: 280px;
  width: 80%;
}
.dl-overlay-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.dl-overlay-text {
  font-size: calc(14px * var(--font-scale));
  color: var(--fg);
  text-align: center;
  font-weight: 500;
}
.dl-overlay-subtext {
  font-size: calc(12px * var(--font-scale));
  color: var(--muted);
  text-align: center;
  margin-top: -8px;
}
.dl-overlay-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: -4px;
}
.dl-overlay-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  min-width: 2%;
}
.dl-overlay-error-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.dl-overlay-error-actions.hidden { display: none; }
.dl-overlay-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  font-size: calc(14px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.dl-overlay-btn:active { opacity: 0.7; }
.dl-overlay-btn.retry { background: var(--primary); color: #fff; }
.dl-overlay-btn.exit { background: var(--border); color: var(--fg);
}

/* ===== Voice Recording Overlay ===== */
#voice-recording-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 56px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(var(--overlay-rgb, 255,255,255), 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
}
[data-theme="dark"] #voice-recording-overlay {
  background: rgba(21,23,24, 0.85);
}
#voice-recording-overlay.hidden {
  display: none;
}
.vr-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 36px;
  background: var(--surface);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  max-width: 300px;
  width: 85%;
}
.vr-countdown {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -1px;
}
.vr-countdown.warning {
  color: var(--error);
}
.vr-status {
  font-size: calc(14px * var(--font-scale));
  color: var(--fg);
  font-weight: 500;
  text-align: center;
}
.vr-waveform-container {
  width: 100%;
  height: 48px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}
.vr-waveform-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.vr-silence-hint {
  font-size: calc(11px * var(--font-scale));
  color: var(--muted);
  text-align: center;
  transition: color 0.3s;
}
.vr-silence-hint.active {
  color: var(--warning);
}
.vr-stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border-radius: 24px;
  border: none;
  background: var(--error);
  color: #fff;
  font-size: calc(14px * var(--font-scale));
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.vr-stop-btn:active {
  opacity: 0.7;
  transform: scale(0.97);
}
/* Pulsing recording dot animation */
@keyframes vr-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.vr-status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--error);
  margin-right: 8px;
  vertical-align: middle;
  animation: vr-pulse 1.2s ease-in-out infinite;
}

/* ===== Stats Help Icon & Modal ===== */
.stats-section-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}
.stats-section-title {
  font-size: calc(15px * var(--font-scale));
  font-weight: 700;
  color: var(--fg);
  line-height: calc(18px * var(--font-scale));
  padding: 0;
  margin: 0;
}
.stats-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  width: calc(18px * var(--font-scale));
  height: calc(18px * var(--font-scale));
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  position: relative;
  z-index: 5;
  flex-shrink: 0;
}
.stats-help-icon .material-icons {
  font-size: calc(16px * var(--font-scale));
  line-height: calc(18px * var(--font-scale));
  color: var(--muted);
  opacity: 0.6;
  pointer-events: none;
}
.stats-help-icon:active .material-icons {
  opacity: 1;
}
.stats-help-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  max-height: 75vh;
  overflow-y: auto;
  padding: 0 20px 24px;
  animation: slideUp 0.25s ease-out;
}
.stats-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.stats-help-title {
  font-size: calc(17px * var(--font-scale));
  font-weight: 700;
  color: var(--fg);
}
.stats-help-body {
  font-size: calc(14px * var(--font-scale));
  color: var(--fg);
  line-height: 1.7;
}
.stats-help-body b {
  font-weight: 700;
  color: var(--fg);
}
/* ===== Trend Chart Zoom Indicator ===== */
.trend-zoom-indicator {
  position: absolute;
  top: 8px;
  right: 20px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.3s;
}


/* ===== Voice Input Button ===== */
.voice-mic-btn {
  width: calc(48px * var(--font-scale));
  height: calc(48px * var(--font-scale));
  min-width: calc(48px * var(--font-scale));
  border-radius: 12px;
  background: var(--primary);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s, background 0.2s;
  padding: 0;
  box-shadow: 0 2px 6px rgba(26, 115, 232, 0.35);
}
.voice-mic-btn .material-icons { font-size: calc(24px * var(--font-scale)); font-weight: 700; }
.voice-mic-btn:active { transform: scale(0.93); opacity: 0.8; }
.voice-mic-btn.listening {
  background: var(--error);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
  animation: voice-pulse 1.2s ease-in-out infinite;
}
@keyframes voice-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Voice listening banner */
.voice-banner {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--primary) 30%, transparent);
  margin-bottom: 8px;
  gap: 8px;
  animation: voice-banner-in 0.2s ease;
}
.voice-banner.error {
  background: color-mix(in srgb, var(--error) 10%, transparent);
  border-color: color-mix(in srgb, var(--error) 30%, transparent);
}
.voice-banner .voice-banner-icon {
  font-size: calc(20px * var(--font-scale));
  color: var(--primary);
  flex-shrink: 0;
}
.voice-banner.error .voice-banner-icon { color: var(--error); }
.voice-banner .voice-banner-text {
  flex: 1;
  font-size: calc(13px * var(--font-scale));
  font-weight: 500;
  color: var(--fg);
  line-height: 1.4;
}
.voice-banner .voice-banner-transcript {
  font-size: calc(12px * var(--font-scale));
  color: var(--muted);
  margin-top: 2px;
}
@keyframes voice-banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Voice confirm dialog */
.voice-confirm-body {
  white-space: pre-line;
  font-size: calc(15px * var(--font-scale));
  line-height: 1.6;
  color: var(--fg);
  padding: 12px 0;
}
.voice-confirm-body .voice-score-positive { color: var(--success); font-weight: 700; }
.voice-confirm-body .voice-score-negative { color: var(--error); font-weight: 700; }
