@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --bg: #10192e;
  --surface: #16223f;
  --surface-2: #1e2c4d;
  --ink: #f3efe3;
  --ink-soft: #aeb7d1;
  --navy-soft: #223257;
  --gold: #e0b23d;
  --gold-2: #efc968;
  --flag: #e2604b;
  --good: #4fb87a;
  --line: #2c3a5e;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.5;
}

h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 6px;
}

.topbar {
  padding: 28px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 16px; }
.account-bar { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }
.account-status { color: var(--ink-soft); white-space: nowrap; }
.brand-mark {
  width: 78px;
  height: 78px;
  flex: none;
  border-radius: 16px;
  background: #ffffff;
  border: 2px solid var(--gold);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-name {
  font-family: "Fraunces", Georgia, serif;
  font-size: 34px;
  font-weight: 700;
}
.brand-phase {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.main-tabs {
  display: flex;
  gap: 4px;
  max-width: 920px;
  margin: 0 auto;
  padding: 14px 20px 0;
}
.main-tab {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
.main-tab:hover { color: var(--ink); }
.main-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.layout {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
}
.hint { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 16px; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 16px;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--gold);
  background: var(--surface-2);
}
.dz-icon { font-size: 22px; color: var(--gold); }
.dz-text { font-size: 14.5px; color: var(--ink); font-weight: 500; }
.dz-sub { font-size: 12px; color: var(--ink-soft); }

.upload-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: #3b2420;
  color: var(--flag);
  border-radius: 8px;
  font-size: 13.5px;
}

.row { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 13.5px; }
.row select {
  font-family: inherit;
  font-size: 13.5px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.btn {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg);
  margin-top: 18px;
}
.btn.primary:hover:not(:disabled) { background: var(--gold-2); }

.progress { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.15s;
}
.progress-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.rep-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.rep-tab {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
  cursor: pointer;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rep-tab:hover { border-color: var(--gold); }
.rep-tab.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg);
  font-weight: 500;
}

.video-stage {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  background: #0a0f1c;
  border-radius: 8px;
  overflow: hidden;
}
.video-stage video {
  display: block;
  max-width: 100%;
  max-height: min(60vh, 640px);
  width: auto;
  height: auto;
}
.video-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.scrub-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 18px;
  font-size: 13px;
}
.scrub-label { color: var(--ink-soft); font-weight: 500; }
.scrub-readout {
  font-family: "IBM Plex Mono", monospace;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  margin: 10px 0 0;
  accent-color: var(--gold);
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 28px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
input[type="range"]:disabled::-webkit-slider-thumb { background: var(--line); }
input[type="range"]:disabled::-moz-range-thumb { background: var(--line); }

.phase-ticks {
  position: relative;
  height: 15px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.phase-ticks.two-rows { height: 30px; }
.phase-ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  cursor: pointer;
}
.phase-ticks span.row-2 { top: 15px; }
.phase-ticks span:first-child { transform: translateX(0); }
.phase-ticks span:last-child { transform: translateX(-100%); }
.phase-ticks span.active { color: var(--gold); font-weight: 500; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.metric-card {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px 16px;
}
.metric-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 22px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.metric-label { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.metric-caveat { font-size: 10.5px; color: var(--gold); margin-top: 2px; }

.coach-feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}
.coach-msg {
  background: var(--navy-soft);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14.5px;
  white-space: pre-wrap;
}
.coach-msg.question {
  background: var(--surface-2);
  align-self: flex-end;
  max-width: 80%;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}
.coach-msg.error { background: #3b2420; color: var(--flag); }

.ask-form { display: flex; gap: 8px; }
.ask-form input {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.ask-form input:focus, select:focus, .btn:focus-visible, .dropzone:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.history-empty {
  color: var(--ink-soft);
  font-size: 14px;
  padding: 28px 0;
  text-align: center;
}

.history-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.trend-chart {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 16px 16px 10px;
  position: relative;
}
.trend-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.trend-chart h3 {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 2px;
}
.trend-badge {
  flex: none;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.trend-badge.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.trend-badge.bad { background: color-mix(in srgb, var(--flag) 18%, transparent); color: var(--flag); }
.trend-badge.flat { background: var(--surface); color: var(--ink-soft); }
.trend-chart .trend-caveat {
  font-size: 11px;
  color: var(--ink-soft);
  margin: 0 0 10px;
}
.trend-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.trend-chart .grid-line { stroke: var(--line); stroke-width: 1; }
.trend-chart .axis-text { fill: var(--ink-soft); font-family: "IBM Plex Mono", monospace; font-size: 9px; }
.trend-chart .data-line { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-chart .data-point {
  fill: var(--gold);
  stroke: var(--surface-2);
  stroke-width: 2;
}
.trend-chart .hit-area { fill: transparent; }
.trend-chart .crosshair {
  stroke: var(--ink-soft);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  opacity: 0;
  pointer-events: none;
}
.trend-chart .end-label {
  fill: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 500;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11.5px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.1s;
  z-index: 5;
}
.chart-tooltip .tt-value {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.chart-tooltip .tt-date { color: var(--ink-soft); margin-top: 2px; }

.auth-layout { max-width: 420px; }
.auth-panel form .row { flex-direction: column; align-items: stretch; gap: 6px; }
.auth-panel form .row input {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.auth-panel form .row input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.auth-panel .btn.primary { width: 100%; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.auth-tab {
  flex: 1;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
  cursor: pointer;
}
.auth-tab:first-child { border-radius: 8px 0 0 8px; }
.auth-tab:last-child { border-radius: 0 8px 8px 0; }
.auth-tab.active { background: var(--gold); border-color: var(--gold); color: var(--bg); }

.paywall-panel { border-color: var(--gold); }
.paywall-panel h2 { color: var(--gold); }

.trial-hint { margin-top: 12px; margin-bottom: 0; }

#clear-history-btn { margin-top: 18px; }
.clear-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--flag) 55%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--flag) 10%, transparent);
  font-size: 13.5px;
}
.clear-confirm-text { flex: 1 1 220px; }
.btn.danger { border-color: var(--flag); color: var(--flag); }
.btn.danger:hover:not(:disabled) { border-color: var(--flag); background: color-mix(in srgb, var(--flag) 16%, transparent); }
