/* =====================================================================
   SwingLab — Concept A: Nordic Minimalist Sports Science
   Alabaster White · Hairline Borders · Emerald / Coral Telemetry
   ===================================================================== */

:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-subtle: #F1F3F6;
  --ink: #111827;
  --ink-secondary: #4B5563;
  --ink-muted: #8B93A1;
  --border: #E6E8EC;
  --border-strong: #D1D5DB;
  --emerald: #10B981;
  --emerald-soft: rgba(16, 185, 129, 0.12);
  --coral: #EF4444;
  --coral-soft: rgba(239, 68, 68, 0.12);
  --amber: #F59E0B;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-card: 0 2px 12px rgba(17, 24, 39, 0.04);
  --shadow-float: 0 12px 32px rgba(17, 24, 39, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang TC", "Noto Sans TC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.hidden {
  display: none !important;
}

/* App Shell */
.app {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 14px 24px;
  overflow-x: hidden;
}

/* Top Bar (Mobile-Safe: Zero Horizontal Overflow) */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
  width: 100%;
  max-width: 100%;
}

.module-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  max-width: 100%;
}

.module-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ink);
  padding: 4px 24px 4px 2px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.module-select:focus {
  outline: none;
}

.module-chevron {
  position: absolute;
  right: 2px;
  pointer-events: none;
  color: var(--ink-secondary);
  width: 16px;
  height: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.icon-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: var(--shadow-card);
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.icon-pill-btn:active {
  transform: scale(0.96);
}

.icon-pill-btn.icon-only {
  width: 36px;
  padding: 0;
  justify-content: center;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-muted);
}
.sync-dot.synced { background: var(--emerald); }
.sync-dot.syncing { background: var(--amber); animation: pulse 1s infinite; }
.sync-dot.error { background: var(--coral); }

/* Segmented Tabs (Concept A Signature) */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #ECEEF2;
  padding: 4px;
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
  max-width: 440px;
}

.seg-btn {
  height: 38px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 650;
  color: var(--ink-secondary);
  transition: all 0.2s ease;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.08);
}

/* Main Responsive Grid */
.live-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 860px) {
  .live-grid {
    grid-template-columns: 1.25fr 0.95fr;
    align-items: start;
    gap: 20px;
  }
}

/* Viewport Card */
.viewport-card {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 62dvh;
  background: #14171F;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

@media (max-width: 600px) {
  .viewport-card {
    aspect-ratio: 3 / 4;
    max-height: 46dvh;
  }
}

.viewport-card video,
.viewport-card canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#liveVideo {
  opacity: 1;
  background: #0F131A;
}

#liveVideo.mirror {
  transform: scaleX(-1);
}

#liveCanvas {
  background: transparent;
  pointer-events: none;
}

.viewport-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: linear-gradient(180deg, #F1F4F8 0%, #E7ECF2 100%);
  color: var(--ink-secondary);
  z-index: 2;
}

.placeholder-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  color: var(--ink);
}

.viewport-placeholder h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--ink);
}

.viewport-placeholder p {
  margin: 0;
  font-size: 13px;
  max-width: 300px;
  color: var(--ink-secondary);
}

/* Floating HUD badges inside Viewport */
.hud-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  z-index: 4;
  pointer-events: none;
}

.hud-top > * {
  pointer-events: auto;
}

.hud-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.hud-badge.live-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  animation: pulse 1.2s infinite;
}

.hud-btn-group {
  display: flex;
  gap: 6px;
}

.hud-mini-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.hud-mini-btn.active {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

.hud-bottom-feedback {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.angle-chip {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(17, 24, 39, 0.80);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rest-banner {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(17, 24, 39, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.rest-banner .rest-time {
  font-size: 56px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

/* Telemetry Panel (Right on iPad, Below Viewport on iPhone) */
.telemetry-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
}

/* Counter + Acoustic Waveform Row (Concept A Signature) */
.counter-wave-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
}

.counter-block {
  display: flex;
  flex-direction: column;
}

.counter-main {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.counter-num {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.counter-target {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink-muted);
}

.counter-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 500;
}

.wave-block {
  flex: 1;
  min-width: 140px;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.wave-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

.wave-label.good { color: var(--emerald); }
.wave-label.warn { color: var(--coral); }

#audioWaveCanvas {
  width: 100%;
  height: 46px;
  display: block;
}

/* 5-Indicator Biomechanical Status Pill Grid */
.indicator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ind-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 13px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(17, 24, 39, 0.025);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.ind-pill.pass {
  border-color: rgba(16, 185, 129, 0.35);
}

.ind-pill.fail {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.035);
}

.ind-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ind-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #D1D5DB;
  flex: none;
}

.ind-pill.pass .ind-dot { background: var(--emerald); }
.ind-pill.fail .ind-dot { background: var(--coral); }

.ind-name {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ind-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.ind-pill.pass .ind-val { color: var(--emerald); }
.ind-pill.fail .ind-val { color: var(--coral); }

.last-tip-bar {
  font-size: 13px;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.last-tip-bar strong {
  color: var(--ink);
  white-space: nowrap;
}

/* Compact 4-Phase Last Swing Strip */
.phase-strip-card {
  padding: 12px 14px;
}

.section-mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.phase-thumb {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.phase-thumb-box {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--ink-muted);
  font-size: 11px;
}

.phase-thumb-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.phase-thumb span {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-secondary);
}

/* Controls & Toggle Row (Concept A Bottom Bar) */
.control-dock {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 14px 16px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.control-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
}

.mini-select {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink);
}

/* Clean iOS Toggle Switch */
.switch {
  position: relative;
  width: 44px;
  height: 25px;
  display: inline-block;
  flex: none;
}

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

.slider {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background: #D7DBE2;
  transition: 0.2s ease;
  cursor: pointer;
}

.slider::before {
  content: "";
  position: absolute;
  width: 19px;
  height: 19px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: 0.2s ease;
}

.switch input:checked + .slider {
  background: var(--ink);
}

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

.cta-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-circle-tool {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--ink);
  flex: none;
  box-shadow: var(--shadow-card);
}

.btn-primary-pill {
  flex: 1;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.16);
  transition: transform 0.12s ease, background 0.15s ease;
}

.btn-primary-pill:active {
  transform: scale(0.985);
}

.btn-primary-pill.recording {
  background: var(--coral);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.24);
}

.btn-secondary-pill {
  height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary-pill.active {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

/* =====================================================================
   Review Tab (Slow-Motion Playback, Standard Ghost, Side-by-Side, 240fps)
   ===================================================================== */
.review-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 900px) {
  .review-layout {
    grid-template-columns: 1.25fr 0.9fr;
    align-items: start;
  }
}

.priority-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--coral);
  border-radius: var(--radius-lg);
  padding: 13px 15px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}

.priority-banner.good {
  border-left-color: var(--emerald);
}

.priority-banner h4 {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--ink);
}

.priority-banner p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-secondary);
}

/* Review Player Stage */
.review-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #11141B;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--border);
}

.review-stage.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: #232732;
}

.stage-pane {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.stage-pane canvas,
.stage-pane video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pane-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(17, 24, 39, 0.78);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 650;
}

.scrubber-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.scrubber-bar input[type="range"] {
  width: 100%;
  accent-color: var(--ink);
  cursor: pointer;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.speed-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.speed-btn.active {
  background: var(--ink);
  color: #FFFFFF;
}

/* History List */
.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.swing-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 2px;
}

.swing-item {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.swing-item.selected {
  border-color: var(--ink);
  background: #FAFAFC;
  box-shadow: 0 0 0 1px var(--ink);
}

.swing-score-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  flex: none;
  background: var(--emerald-soft);
  color: var(--emerald);
}

.swing-score-badge.abnormal {
  background: var(--coral-soft);
  color: var(--coral);
}

.swing-meta {
  flex: 1;
  min-width: 0;
}

.swing-meta-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

.swing-meta-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-chip {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  color: var(--ink-secondary);
}

.tag-chip.best {
  background: var(--amber-soft);
  color: #B45309;
}

.tag-chip.vid {
  background: var(--emerald-soft);
  color: #047857;
}

/* 240fps Import Card */
.import-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.import-card h4 {
  margin: 0 0 3px;
  font-size: 14px;
}

.import-card p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
}

/* Modal / Drawer */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(100%, 480px);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-float);
  border: 1px solid var(--border);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 750;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  font-size: 18px;
  display: grid;
  place-items: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 13px;
}

.field label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.field input[type="text"],
.field input[type="url"],
.field input[type="number"],
.field select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

.field-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.stat-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
}

.stat-box strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-box span {
  font-size: 11px;
  color: var(--ink-muted);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  background: var(--ink);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 92vw;
  text-align: center;
  box-shadow: var(--shadow-float);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

/* Counter quick reset & Today total pill */
.counter-top-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.mini-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  color: var(--ink-secondary);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
  flex-shrink: 0;
}

.mini-reset-btn:active {
  transform: scale(0.95);
}

.counter-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  flex-wrap: wrap;
}

.today-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--emerald-soft);
  color: #047857;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

/* Mobile Responsive Polish (<= 460px iPhone viewport) */
@media (max-width: 460px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .module-select { font-size: 16.5px; }
  .icon-pill-btn { height: 32px; padding: 0 8px; font-size: 11.5px; }
  .icon-pill-btn.icon-only { width: 32px; }
  .counter-wave-row { gap: 10px; padding: 12px 13px; }
  .counter-num { font-size: 38px; }
  .counter-target { font-size: 17px; }
  .wave-block { min-width: 0; max-width: 145px; }
  .indicator-grid { gap: 7px; }
  .ind-pill { padding: 9px 10px; gap: 6px; }
  .ind-name { font-size: 12.5px; }
  .ind-val { font-size: 11.5px; white-space: nowrap; flex-shrink: 0; }
  .hud-badge, .hud-mini-btn { font-size: 11px; padding: 4px 8px; }
  .import-card { flex-direction: column; align-items: flex-start; }
  .import-card > div:last-child { width: 100%; }
  .import-card .btn-secondary-pill { width: 100%; }
}

.live-grid > *, .review-layout > *, .telemetry-stack > * {
  min-width: 0;
  max-width: 100%;
}

/* =====================================================================
   V1.2 Upgrades: Wide Modal, 3D Multi-Angle Coach, Real-Human Video,
   Monthly Calendar History & 6-Month Progress Trend
   ===================================================================== */
.modal.modal-wide {
  width: min(100%, 600px);
}

.modal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #ECEEF2;
  padding: 3px;
  border-radius: var(--radius-pill);
  margin-bottom: 12px;
}

.modal-tab-btn {
  height: 34px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-secondary);
  transition: all 0.18s ease;
}

.modal-tab-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(17, 24, 39, 0.08);
}

/* 3D Coach Stage (V1.8.0 Studio Green Court + Floating Callouts) */
.stage-3d-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 270px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #A5D8C1 0%, #2A8F68 100%);
  border: 1px solid var(--border);
}

.stage-3d-mount {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.coach3d-callouts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 4;
}

.coach3d-tag {
  position: absolute;
  top: 0;
  left: 0;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #FFFFFF;
  opacity: 0;
  transition: opacity 0.12s linear;
  text-shadow:
    -1.6px -1.6px 0 #DC2626,
     1.6px -1.6px 0 #DC2626,
    -1.6px  1.6px 0 #DC2626,
     1.6px  1.6px 0 #DC2626,
     0      0     5px rgba(220, 38, 38, 0.72),
     0      2px   4px rgba(0, 0, 0, 0.35);
  will-change: transform, opacity;
}

.stage-3d-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #064E3B;
  font-size: 13px;
  font-weight: 700;
}

.angle-preset-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.angle-preset-btn {
  height: 34px;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
}

.angle-preset-btn.active {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

.phase-jump-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.phase-jump-btn {
  padding: 6px 4px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 650;
  color: var(--ink-secondary);
  text-align: center;
}

.phase-jump-btn:active {
  transform: scale(0.97);
}

.legend-3d {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.cue-3d-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--emerald-soft);
  color: #065F46;
  font-size: 12.5px;
  line-height: 1.55;
}

/* Real-Human YouTube Player Tab */
.yt-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: #0F172A;
  border: 1px solid var(--border);
}

.yt-frame-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.yt-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 10px;
  max-height: 210px;
  overflow-y: auto;
}

.yt-item {
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.yt-item.active {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--ink);
}

.yt-item-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.yt-item-sub {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Monthly Calendar History Modal */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 8px;
}

.cal-month-title {
  font-size: 15px;
  font-weight: 750;
  color: var(--ink);
}

.cal-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 5px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.cal-cell {
  aspect-ratio: 1 / 1.05;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  position: relative;
  font-variant-numeric: tabular-nums;
}

.cal-cell.empty {
  border-color: transparent;
  background: transparent;
  pointer-events: none;
}

.cal-cell.lvl-1 { background: rgba(16, 185, 129, 0.12); border-color: rgba(16, 185, 129, 0.30); }
.cal-cell.lvl-2 { background: rgba(16, 185, 129, 0.25); border-color: rgba(16, 185, 129, 0.48); }
.cal-cell.lvl-3 { background: #10B981; border-color: #059669; color: #FFFFFF; }

.cal-cell.selected {
  box-shadow: 0 0 0 2px var(--ink);
}

.cal-day-num {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
}

.cal-day-cnt {
  font-size: 10px;
  font-weight: 700;
  margin-top: 2px;
  opacity: 0.9;
}

.day-detail-card {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.rate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-top: 6px;
}

.rate-label {
  width: 68px;
  font-weight: 650;
  color: var(--ink-secondary);
  flex: none;
}

.rate-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: #E2E6EC;
  overflow: hidden;
}

.rate-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--emerald);
}

.rate-fill.warn {
  background: var(--coral);
}

.rate-pct {
  width: 36px;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.trend-6m {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.trend-bars {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  align-items: end;
  height: 82px;
  margin-top: 10px;
}

.trend-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}

.trend-bar-fill {
  width: 100%;
  max-width: 28px;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: var(--ink);
  opacity: 0.85;
}

.trend-val {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}

.trend-mon {
  font-size: 10.5px;
  color: var(--ink-muted);
}

/* V1.4: Real-Human Multi-Angle Video Category Bar & Cloud Photo Chip */
.video-angle-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.video-angle-btn {
  height: 34px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-secondary);
  white-space: nowrap;
  transition: all 0.15s ease;
}

.video-angle-btn.active {
  background: var(--ink);
  color: #FFFFFF;
  border-color: var(--ink);
}

.tag-chip.cloud {
  background: rgba(56, 189, 248, 0.16);
  color: #0369A1;
}

.yt-angle-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  margin-right: 5px;
}

@media (max-width: 460px) {
  .video-angle-btn { font-size: 11px; padding: 0 4px; }
}

/* =====================================================================
   V1.7: Mitsui #14 Theme — "Midnight Gym Scoreboard" (Proposal B)
   Ink-navy glass + vermilion + amber LED numerals, cut-corner panels,
   screentone / speed lines, scanning HUD. Pure CSS (no new image assets).
   ===================================================================== */
:root {
  --font-led: "Share Tech Mono", "Consolas", "SF Mono", "Menlo", "Courier New", monospace;
}

.mitsui-hero {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 14px;
  border-radius: 6px;
  border: 1px solid #1f2b40;
  background: #05070c;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%);
}

.mitsui-hero-img {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10.6;
  max-height: 245px;
  object-fit: cover;
  object-position: 50% 18%;
  filter: grayscale(0.45) contrast(1.14) saturate(1.28);
}

.mitsui-hero-scrim {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  aspect-ratio: 16 / 10.6;
  max-height: 245px;
  background:
    linear-gradient(180deg, transparent 58%, rgba(7, 9, 15, 0.94)),
    linear-gradient(90deg, rgba(255, 59, 48, 0.34), transparent 55%);
  pointer-events: none;
}

/* Manga screentone dots + scanning line over the artwork only */
.mitsui-hero::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  aspect-ratio: 16 / 10.6;
  max-height: 245px;
  z-index: 2;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.42) 1px, transparent 1.4px) 0 0 / 5px 5px;
  mix-blend-mode: multiply;
  opacity: 0.65;
  pointer-events: none;
}

.mitsui-hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  z-index: 3;
  background: linear-gradient(90deg, transparent, #36d6ff, transparent);
  box-shadow: 0 0 10px #36d6ff;
  opacity: 0.55;
  animation: mitsui-scan 4.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes mitsui-scan {
  0% { top: 0; opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { top: calc(100% - 68px); opacity: 0; }
}

@keyframes mitsui-scan-wide {
  0% { top: 0; opacity: 0; }
  12% { opacity: 0.55; }
  88% { opacity: 0.55; }
  100% { top: calc(100% - 2px); opacity: 0; }
}

.mitsui-hero-footer {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 10px 12px 13px;
  background: #05070c;
  border-top: 2px solid #ff3b30;
}

.mitsui-jersey-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  background: #ff3b30;
  color: #FFFFFF;
  font-family: var(--font-led);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transform: skewX(-12deg);
  box-shadow: 4px 0 0 #FFFFFF;
}

.mitsui-quote {
  font-size: 13px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1.35;
  color: #eaf0fb;
}

@media (min-width: 720px) {
  .mitsui-hero {
    flex-direction: row;
    align-items: stretch;
    height: 196px;
  }

  .mitsui-hero-img {
    width: 280px;
    height: 100%;
    max-height: none;
    flex: none;
    aspect-ratio: auto;
    object-fit: cover;
    object-position: 50% 42%;
  }

  .mitsui-hero-scrim {
    left: 0;
    right: auto;
    width: 280px;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    background:
      linear-gradient(90deg, transparent 58%, #05070c 100%),
      linear-gradient(180deg, transparent 68%, rgba(5, 7, 12, 0.72) 100%);
  }

  .mitsui-hero::before {
    left: 0;
    right: auto;
    width: 280px;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
  }

  .mitsui-hero::after {
    animation: mitsui-scan-wide 4.2s ease-in-out infinite;
  }

  .mitsui-hero-footer {
    flex: 1;
    justify-content: center;
    padding: 18px 28px;
    border-top: none;
    border-left: 2px solid #ff3b30;
    background:
      radial-gradient(80% 100% at 95% 50%, rgba(255, 59, 48, 0.16), transparent 70%),
      linear-gradient(90deg, #05070c 0%, #0b111c 100%);
    gap: 10px;
    overflow: hidden;
  }

  .mitsui-hero-footer::after {
    content: "14";
    position: absolute;
    right: 26px;
    top: 50%;
    transform: translateY(-50%) skewX(-10deg);
    font-family: var(--font-led);
    font-size: 132px;
    line-height: 1;
    color: transparent;
    -webkit-text-stroke: 1.5px rgba(255, 59, 48, 0.22);
    pointer-events: none;
  }

  .mitsui-quote {
    font-size: 19px;
    max-width: 82%;
  }
}
/* Batch Cleanup Panel inside Settings Modal */
.cleanup-panel {
  padding: 13px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  margin-bottom: 10px;
}

.cleanup-panel h4 {
  margin: 0 0 4px;
  font-size: 13.5px;
  font-weight: 750;
  color: var(--ink);
}

.cleanup-panel p {
  margin: 0 0 10px;
  font-size: 11.5px;
  color: var(--ink-muted);
  line-height: 1.5;
}

.btn-danger-pill {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--coral);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.btn-danger-pill:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* =====================================================================
   DATA-THEME="MITSUI" — V1.7 Midnight Gym Scoreboard (Proposal B)
   ===================================================================== */
html[data-theme="mitsui"] {
  --bg: #07090f;
  --surface: #0d121c;
  --surface-subtle: #121a28;
  --ink: #eaf0fb;
  --ink-secondary: #a6b3ca;
  --ink-muted: #8c9ab3;
  --border: #1f2b40;
  --border-strong: #31456a;
  --emerald: #2ef2a0;
  --emerald-soft: rgba(46, 242, 160, 0.16);
  --coral: #ff3b4e;
  --coral-soft: rgba(255, 59, 78, 0.2);
  --amber: #ffb02e;
  --amber-soft: rgba(255, 176, 46, 0.2);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-float: 0 14px 36px rgba(0, 0, 0, 0.75);
}

html[data-theme="mitsui"] body {
  background-color: #07090f;
  background-image:
    radial-gradient(90% 50% at 85% -5%, rgba(255, 59, 48, 0.22), transparent 60%),
    radial-gradient(70% 40% at 0% 30%, rgba(54, 214, 255, 0.1), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 100% 28px, 28px 100%;
  background-attachment: fixed;
}

/* Drifting vermilion speed lines (decorative, fixed behind content) */
html[data-theme="mitsui"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(100deg, transparent 0 46px, rgba(255, 59, 48, 0.05) 46px 48px);
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 55%);
  mask-image: linear-gradient(180deg, #000, transparent 55%);
  animation: mitsui-drift 9s linear infinite;
}

@keyframes mitsui-drift {
  to { background-position: 96px 0; }
}

html[data-theme="mitsui"] .app {
  position: relative;
  z-index: 1;
}

/* ---- Header ---- */
html[data-theme="mitsui"] .module-select {
  font-weight: 900;
  letter-spacing: 0.03em;
}

html[data-theme="mitsui"] .icon-pill-btn {
  border-radius: 8px;
  background: rgba(18, 26, 40, 0.75);
  border: 1px solid #1f2b40;
  color: #a6b3ca;
  box-shadow: none;
  backdrop-filter: blur(8px);
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}

html[data-theme="mitsui"] .icon-pill-btn svg {
  stroke-width: 1.9;
}

html[data-theme="mitsui"] .theme-pill-btn {
  background: linear-gradient(135deg, #ff3b30, #c4161c);
  border-color: transparent;
  color: #FFFFFF;
}

@media (max-width: 480px) {
  .theme-pill-btn #themeToggleLabel,
  #stdDemoBtn .std-label {
    display: none;
  }
  .theme-pill-btn,
  #stdDemoBtn {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
  html[data-theme="mitsui"] #syncLabel {
    max-width: 38px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-led);
  }
}
/* ---- Tabs ---- */
html[data-theme="mitsui"] .segmented {
  background: rgba(13, 18, 28, 0.85);
  border: 1px solid #1f2b40;
  border-radius: 8px;
}

html[data-theme="mitsui"] .seg-btn {
  border-radius: 6px;
  color: #8c9ab3;
}

html[data-theme="mitsui"] .seg-btn.active {
  background: linear-gradient(135deg, #ff3b30, #c4161c);
  color: #FFFFFF;
  box-shadow: 0 0 18px rgba(255, 59, 48, 0.45);
}

/* ---- Camera viewport: cut corner + cyan HUD brackets ---- */
html[data-theme="mitsui"] .viewport-card {
  border-radius: 8px;
  border: 1px solid #1f2b40;
  background: #05070c;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

html[data-theme="mitsui"] .viewport-card::before {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: 3;
  pointer-events: none;
  opacity: 0.7;
  background:
    linear-gradient(#36d6ff, #36d6ff) 0 0 / 18px 2px,
    linear-gradient(#36d6ff, #36d6ff) 0 0 / 2px 18px,
    linear-gradient(#36d6ff, #36d6ff) 100% 0 / 18px 2px,
    linear-gradient(#36d6ff, #36d6ff) 100% 0 / 2px 18px,
    linear-gradient(#36d6ff, #36d6ff) 0 100% / 18px 2px,
    linear-gradient(#36d6ff, #36d6ff) 0 100% / 2px 18px,
    linear-gradient(#36d6ff, #36d6ff) 100% 100% / 18px 2px,
    linear-gradient(#36d6ff, #36d6ff) 100% 100% / 2px 18px;
  background-repeat: no-repeat;
}

html[data-theme="mitsui"] .viewport-placeholder {
  background: radial-gradient(60% 60% at 50% 50%, rgba(54, 214, 255, 0.08), transparent 70%), #05070c;
  color: #a6b3ca;
}

html[data-theme="mitsui"] .placeholder-ring {
  border: 1.5px dashed #36d6ff;
  color: #36d6ff;
  background: transparent;
  animation: mitsui-spin 14s linear infinite;
}

html[data-theme="mitsui"] .placeholder-ring svg {
  animation: mitsui-spin 14s linear infinite reverse;
}

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

html[data-theme="mitsui"] .hud-badge,
html[data-theme="mitsui"] .hud-mini-btn {
  background: rgba(7, 9, 15, 0.82);
  border: 1px solid #1f2b40;
  color: #36d6ff;
  border-radius: 4px;
  font-family: var(--font-led);
}

html[data-theme="mitsui"] .hud-mini-btn.active {
  background: rgba(255, 59, 48, 0.25);
  border-color: #ff3b30;
  color: #FFFFFF;
}

/* ---- Cards (cut corner + vermilion edge) ---- */
html[data-theme="mitsui"] .card {
  position: relative;
  background: linear-gradient(180deg, rgba(18, 26, 40, 0.88), rgba(13, 18, 28, 0.88));
  border: 1px solid #1f2b40;
  border-radius: 8px;
  box-shadow: none;
  backdrop-filter: blur(8px);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
}

html[data-theme="mitsui"] .card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #ff3b30, transparent);
  pointer-events: none;
}

/* ---- LED scoreboard counter ---- */
html[data-theme="mitsui"] .counter-num {
  font-family: var(--font-led);
  font-weight: 400;
  font-size: 64px;
  letter-spacing: 0.02em;
  color: #ffb02e;
  text-shadow: 0 0 6px rgba(255, 176, 46, 0.9), 0 0 26px rgba(255, 120, 30, 0.55);
}

html[data-theme="mitsui"] .counter-target {
  font-family: var(--font-led);
  font-weight: 400;
  color: #8c9ab3;
}

html[data-theme="mitsui"] .counter-sub {
  color: #a6b3ca;
}

html[data-theme="mitsui"] .wave-label {
  font-family: var(--font-led);
  letter-spacing: 0.04em;
}

html[data-theme="mitsui"] .today-pill-btn {
  border-radius: 4px;
  background: rgba(54, 214, 255, 0.1);
  color: #36d6ff;
  border: 1px solid rgba(54, 214, 255, 0.4);
  font-family: var(--font-led);
}

html[data-theme="mitsui"] .mini-reset-btn {
  border-radius: 4px;
  font-family: var(--font-led);
}

/* ---- 5 indicators: stacked label/value + segmented LED underline ---- */
html[data-theme="mitsui"] .ind-pill {
  position: relative;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 9px 12px 11px;
  border-radius: 6px;
  background: rgba(13, 18, 28, 0.92);
  border: 1px solid #1f2b40;
  box-shadow: none;
  overflow: hidden;
  --led: #2a3550;
}

html[data-theme="mitsui"] .ind-pill::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--led) 0 8px, transparent 8px 11px);
}

html[data-theme="mitsui"] .ind-dot {
  border-radius: 2px;
  transform: rotate(45deg);
  width: 9px;
  height: 9px;
  background: #33405a;
}

html[data-theme="mitsui"] .ind-val {
  padding-left: 17px;
  font-family: var(--font-led);
  font-size: 16px;
  font-weight: 400;
  color: #a6b3ca;
  white-space: nowrap;
}

html[data-theme="mitsui"] .ind-pill.pass {
  --led: #2ef2a0;
  border-color: rgba(46, 242, 160, 0.4);
  background: rgba(13, 18, 28, 0.92);
}

html[data-theme="mitsui"] .ind-pill.pass .ind-dot {
  background: #2ef2a0;
  box-shadow: 0 0 12px #2ef2a0;
}

html[data-theme="mitsui"] .ind-pill.pass .ind-val {
  color: #2ef2a0;
}

html[data-theme="mitsui"] .ind-pill.fail {
  --led: #ff3b4e;
  border-color: rgba(255, 59, 78, 0.6);
  background: rgba(13, 18, 28, 0.92);
  animation: mitsui-warn 1.4s steps(2, end) infinite;
}

html[data-theme="mitsui"] .ind-pill.fail .ind-dot {
  background: #ff3b4e;
  box-shadow: 0 0 12px #ff3b4e;
}

html[data-theme="mitsui"] .ind-pill.fail .ind-val {
  color: #ff3b4e;
}

@keyframes mitsui-warn {
  50% { background: rgba(255, 59, 78, 0.14); }
}

/* Overall score pill (amber) */
html[data-theme="mitsui"] .ind-pill[data-ind="overall"] {
  --led: #ffb02e;
  border-color: rgba(255, 176, 46, 0.5);
  background: linear-gradient(90deg, rgba(255, 176, 46, 0.14), transparent 75%), rgba(13, 18, 28, 0.92);
  animation: none;
}

html[data-theme="mitsui"] .ind-pill[data-ind="overall"] .ind-dot {
  background: #ffb02e;
  box-shadow: 0 0 12px #ffb02e;
}

html[data-theme="mitsui"] .ind-pill[data-ind="overall"] .ind-val {
  color: #ffb02e;
  font-size: 22px;
  text-shadow: 0 0 12px rgba(255, 176, 46, 0.7);
}

/* ---- Coach tip ---- */
html[data-theme="mitsui"] .last-tip-bar {
  border-radius: 6px;
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.35);
  color: #eaf0fb;
}

html[data-theme="mitsui"] .last-tip-bar strong {
  color: #ff6a4d;
  letter-spacing: 0.06em;
}

/* ---- 4-phase strip ---- */
html[data-theme="mitsui"] .section-mini-head {
  color: #a6b3ca;
  letter-spacing: 0.06em;
}

html[data-theme="mitsui"] .phase-thumb-box {
  border-radius: 4px;
  background-color: #05070c;
  background-image: radial-gradient(circle, rgba(54, 214, 255, 0.12) 1px, transparent 1.4px);
  background-size: 7px 7px;
  border: 1px solid #1f2b40;
  color: #8c9ab3;
}

html[data-theme="mitsui"] .phase-thumb span {
  color: #a6b3ca;
}

/* ---- Controls ---- */
html[data-theme="mitsui"] .mini-select {
  border-radius: 6px;
  background: rgba(13, 18, 28, 0.92);
  border: 1px solid #1f2b40;
  color: #a6b3ca;
}

html[data-theme="mitsui"] .slider {
  background: #1a2438;
  border-radius: 4px;
}

html[data-theme="mitsui"] .slider::before {
  border-radius: 2px;
  background: #8c9ab3;
  box-shadow: none;
}

html[data-theme="mitsui"] .switch input:checked + .slider {
  background: rgba(255, 59, 48, 0.25);
  box-shadow: 0 0 0 1px #ff3b30;
}

html[data-theme="mitsui"] .switch input:checked + .slider::before {
  background: #ff6a4d;
  box-shadow: 0 0 10px #ff3b30;
}

html[data-theme="mitsui"] .btn-circle-tool {
  border-radius: 8px;
  background: rgba(18, 26, 40, 0.92);
  border: 1px solid #1f2b40;
  color: #36d6ff;
  box-shadow: none;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

html[data-theme="mitsui"] .btn-primary-pill {
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #ff6a4d, #ff3b30 50%, #b3121a);
  color: #FFFFFF;
  font-style: italic;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.4);
  box-shadow: none;
  clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
  animation: mitsui-pulse 2.2s ease-in-out infinite;
}

@keyframes mitsui-pulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 59, 48, 0.5)); }
  50% { filter: drop-shadow(0 0 16px rgba(255, 59, 48, 0.95)); }
}

html[data-theme="mitsui"] .btn-primary-pill.recording {
  background: linear-gradient(135deg, #1b2437, #0d121c);
  color: #36d6ff;
  box-shadow: inset 0 0 0 2px #36d6ff;
  animation: none;
}

html[data-theme="mitsui"] .btn-secondary-pill.active,
html[data-theme="mitsui"] .speed-btn.active,
html[data-theme="mitsui"] .video-angle-btn.active,
html[data-theme="mitsui"] .angle-preset-btn.active {
  background: #ff3b30;
  color: #FFFFFF;
  border-color: #ff6a4d;
}

/* ---- Review list, modal, misc ---- */
html[data-theme="mitsui"] .swing-item.selected {
  border-color: #ff3b30;
  background: #121a28;
  box-shadow: 0 0 0 1px #ff3b30;
}

html[data-theme="mitsui"] .modal {
  background: #0d121c;
  border-color: #31456a;
}

html[data-theme="mitsui"] .modal-tabs {
  background: #121a28;
}

html[data-theme="mitsui"] .modal-tab-btn.active {
  background: #ff3b30;
  color: #FFFFFF;
}

html[data-theme="mitsui"] .cal-cell.selected {
  box-shadow: 0 0 0 2px #ffb02e;
}

html[data-theme="mitsui"] .rate-track {
  background: #1a2438;
}

html[data-theme="mitsui"] .cue-3d-box {
  background: rgba(255, 59, 48, 0.14);
  color: #ffd29a;
  border: 1px solid rgba(255, 59, 48, 0.35);
}

html[data-theme="mitsui"] .toast {
  background: #c4161c;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  html[data-theme="mitsui"] body::before,
  .mitsui-hero::after,
  html[data-theme="mitsui"] .placeholder-ring,
  html[data-theme="mitsui"] .placeholder-ring svg,
  html[data-theme="mitsui"] .btn-primary-pill,
  html[data-theme="mitsui"] .ind-pill.fail {
    animation: none;
  }
}

/* Warning HUD badge when user walks too close to camera */
.hud-badge.warn-gate {
  background: rgba(239, 68, 68, 0.92) !important;
  color: #FFFFFF !important;
  border-color: #FCA5A5 !important;
}
