/* Shadow Coach — compact dark gym UI. Mobile-first. */
:root {
  --bg: #0e1116;
  --panel: #161b22;
  --line: #262d36;
  --txt: #e8ecf1;
  --dim: #9aa3ad;
  --acc: #c8ff3d;
  --acc-dim: #8fb32a;
  --bad: #ff5d5d;
  --warn: #ffb84d;
  --radius: 10px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--txt);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.35;
  max-width: 640px; margin: 0 auto;
  padding-bottom: 76px; /* tab bar */
}

/* ShinyText (design-playbook §6, vanilla port) */
.shiny {
  background: linear-gradient(110deg, #f2f5f7 35%, var(--acc) 50%, #f2f5f7 65%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: sheen 7s ease-in-out infinite;
}
@keyframes sheen { 0%,100% { background-position: 110% 0; } 50% { background-position: -10% 0; } }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 6px;
}
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: 0.5px; }
.icon-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; font-size: 18px; padding: 6px 10px; cursor: pointer;
}
.icon-btn.off { opacity: 0.45; }

.tab { display: none; padding: 4px 12px 12px; }
.tab.active { display: block; }
.tab h2 { font-size: 15px; margin: 14px 0 8px; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }
.tab h2 .sub { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto; background: var(--panel); color: var(--txt);
  border: 1px solid var(--line); border-radius: 20px; padding: 8px 14px;
  font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.chips button.active { background: var(--acc); color: #10130a; border-color: var(--acc); font-weight: 700; }

.tip { margin: 0 2px 10px; color: var(--dim); font-size: 13px; min-height: 18px; }

.stage { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; border: 1px solid var(--line); }
#cam { display: block; width: 100%; aspect-ratio: 4 / 3; background: #000; }
.demo-wrap {
  position: absolute; top: 8px; right: 8px; width: 108px;
  background: rgba(10, 13, 17, 0.82); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px; text-align: center;
}
#demo { width: 100%; height: auto; display: block; }
#demo-label { font-size: 10px; color: var(--dim); }
.err {
  position: absolute; inset: auto 8px 8px 8px; background: rgba(60, 10, 10, 0.92);
  border: 1px solid var(--bad); border-radius: 8px; padding: 10px 12px; font-size: 13px;
}

.cue {
  margin: 10px 2px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  font-size: 14.5px; min-height: 42px; display: flex; align-items: center;
}
.cue.alert { border-color: var(--warn); color: var(--warn); }
.cue.good { border-color: var(--acc-dim); }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 0 2px 10px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 4px; text-align: center;
}
.stat .v { display: block; font-size: 17px; font-weight: 700; color: var(--acc); }
.stat .v small { font-size: 11px; font-weight: 400; color: var(--dim); }
.stat .k { display: block; font-size: 10px; color: var(--dim); margin-top: 2px; }
.stat .k em { font-style: normal; opacity: 0.7; }

.timerbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 14px; margin: 0 2px 10px;
}
.timerbar .phase { font-size: 12px; font-weight: 700; letter-spacing: 1.5px; color: var(--dim); }
.timerbar .phase.work { color: var(--acc); }
.timerbar .phase.rest { color: var(--warn); }
.timerbar .digits { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timerbar .round { font-size: 12px; color: var(--dim); }

.controls { display: flex; gap: 8px; margin: 0 2px 10px; }
.btn {
  flex: 1; padding: 13px 10px; border-radius: var(--radius); font-size: 15px; font-weight: 700;
  border: 1px solid var(--line); background: var(--panel); color: var(--txt); cursor: pointer;
  position: relative; overflow: hidden;
}
.btn.primary { background: var(--acc); border-color: var(--acc); color: #10130a; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.small { flex: 0 1 auto; padding: 9px 12px; font-size: 13px; font-weight: 600; }
.btn.danger { border-color: var(--bad); color: var(--bad); }

/* ClickSpark (design-playbook §6, vanilla port) */
.spark {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: #10130a; pointer-events: none;
  animation: sparkfly 0.55s ease-out forwards;
}
@keyframes sparkfly {
  to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

.setup { margin: 0 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.setup summary { padding: 10px 12px; cursor: pointer; font-size: 13.5px; color: var(--dim); }
.setup-row { display: flex; gap: 10px; padding: 4px 12px 12px; }
.setup-row label { flex: 1; font-size: 12px; color: var(--dim); display: flex; flex-direction: column; gap: 4px; }
.setup-row input, .form input, .form select {
  background: var(--bg); border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; padding: 9px 10px; font-size: 15px; width: 100%;
}

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { font-size: 13.5px; color: var(--dim); display: flex; flex-direction: column; gap: 6px; }
.form label.row { flex-direction: row; align-items: center; gap: 10px; color: var(--txt); }
.form label.row input { width: auto; }
.form .row.btns { flex-direction: row; gap: 8px; }
.note { font-size: 12.5px; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }

.bests { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.best-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.best-card .t { font-size: 12.5px; color: var(--dim); }
.best-card .s { font-size: 17px; font-weight: 700; color: var(--acc); }
.best-card .s small { font-size: 10px; color: var(--dim); font-weight: 400; }
.trend { display: flex; align-items: flex-end; gap: 2px; height: 22px; margin-top: 6px; }
.trend i { flex: 1; background: var(--acc-dim); border-radius: 2px 2px 0 0; min-height: 3px; opacity: 0.85; }

.sessions { display: flex; flex-direction: column; gap: 8px; }
.sess { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.sess > button {
  width: 100%; background: none; border: none; color: var(--txt); text-align: left;
  padding: 10px 12px; font-size: 13.5px; cursor: pointer; display: flex; justify-content: space-between;
}
.sess .detail { padding: 0 12px 10px; font-size: 12.5px; color: var(--dim); }
.sess .detail table { width: 100%; border-collapse: collapse; }
.sess .detail td, .sess .detail th { padding: 3px 4px; text-align: right; font-variant-numeric: tabular-nums; }
.sess .detail td:first-child, .sess .detail th:first-child { text-align: left; }
.empty { color: var(--dim); font-size: 13px; padding: 12px 2px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: rgba(14, 17, 22, 0.96); border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}
.tabs button {
  flex: 1; background: none; border: none; color: var(--dim);
  font-size: 13px; padding: 8px; cursor: pointer; border-radius: 8px;
}
.tabs button.active { color: var(--acc); font-weight: 700; }

.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.72);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal .card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; max-width: 440px; width: 100%; max-height: 85vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 10px; font-size: 18px; }
.modal ul { margin: 0 0 16px; padding-left: 20px; font-size: 14px; }
.modal li { margin-bottom: 8px; }
.modal .btn { width: 100%; }
#summary-body table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 14px; }
#summary-body td, #summary-body th { padding: 5px 4px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
#summary-body td:first-child, #summary-body th:first-child { text-align: left; }

#vid { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .shiny { animation: none; }
  .spark { display: none; }
}
