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

:root {
  --bg: #000;
  --bg1: #1c1c1e;
  --bg2: #2c2c2e;
  --bg3: #3a3a3c;
  --sep: rgba(255,255,255,0.10);
  --text: #fff;
  --text2: rgba(255,255,255,0.55);
  --text3: rgba(255,255,255,0.30);
  --accent: #FF453A;
  --accent-blue: #0A84FF;
  --accent-green: #30D158;
  --sheet-bg: rgba(28,28,30,0.96);
  --r: 7px;
  --r-lg: 10px;
  --r-xl: 13px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }

button, textarea, input { font-family: var(--font); }
button { cursor: pointer; border: none; background: none; }
textarea { resize: vertical; }

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(10,132,255,0.18), transparent 35%),
    radial-gradient(circle at bottom, rgba(255,69,58,0.16), transparent 30%),
    #000;
}

.lock-card {
  width: min(100%, 360px);
  padding: 24px;
  border-radius: var(--r-lg);
  background: rgba(28,28,30,0.96);
  border: 0.5px solid var(--sep);
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
}

.lock-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.lock-subtitle {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text2);
}

.lock-input {
  width: 100%;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 0.5px solid var(--sep);
  background: var(--bg1);
  color: var(--text);
  outline: none;
}

.lock-input::placeholder { color: var(--text3); }

.lock-input::-ms-reveal,
.lock-input::-ms-clear {
  filter: invert(1);
}

.lock-input::-webkit-credentials-auto-fill-button,
.lock-input::-webkit-textfield-decoration-container {
  color: #fff;
}

.lock-btn {
  width: 100%;
  margin-top: 12px;
  padding: 13px 16px;
  border-radius: var(--r);
  background: var(--accent-blue);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.lock-error {
  margin-top: 10px;
  font-size: 13px;
  color: #ff8a80;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  transition: opacity .25s;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 110;
  background: var(--sheet-bg);
  backdrop-filter: blur(40px) saturate(180%);
  border-radius: 12px 12px 0 0;
  border-top: 0.5px solid rgba(255,255,255,0.14);
  max-height: 88vh;
  overflow-y: auto;
  transform: translateY(0);
  transition: transform .35s cubic-bezier(0.32,0.72,0,1);
}

.sheet.hidden { transform: translateY(110%); pointer-events: none; }
.sub-sheet { z-index: 120; }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.22);
  border-radius: 2px;
  margin: 10px auto 0;
}

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

.sheet-title { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.sheet-body { padding: 20px; padding-bottom: 40px; }

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text2);
  margin-bottom: 8px;
}

.setting-group {
  background: var(--bg2);
  border-radius: var(--r);
  overflow: hidden;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--sep);
}

.setting-row:last-child { border-bottom: none; }
.setting-row.single { padding: 10px 16px; }
.setting-row.notes-row { align-items: flex-start; }
.setting-key { font-size: 15px; color: var(--text); white-space: nowrap; }

.setting-input {
  background: none;
  border: none;
  outline: none;
  color: var(--text2);
  font-size: 15px;
  text-align: right;
  width: 100%;
}

.setting-input::placeholder { color: var(--text3); }
.setting-input.full { text-align: left; color: var(--text); }

.weight-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.weight-display {
  text-align: left;
  font-weight: 600;
  flex: 1;
}

.weight-step-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.weight-step-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: var(--r);
  background: var(--bg3);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.weight-step-btn:active {
  opacity: 0.7;
}

.notes-input {
  min-height: 84px;
  line-height: 1.45;
  padding-top: 2px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg3);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s;
}

.icon-btn:active { opacity: 0.6; }
.close-btn { background: var(--bg3); }

.text-btn { font-size: 17px; font-weight: 500; color: var(--accent-blue); }
.text-btn.muted { color: var(--text2); }
.text-btn.accent { color: var(--accent-blue); font-weight: 600; }

.add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  background: var(--bg2);
  border-radius: var(--r);
  color: var(--accent-blue);
  font-size: 15px;
  font-weight: 500;
  width: 100%;
  margin-top: 10px;
  transition: opacity .15s;
}

.add-btn:active { opacity: 0.6; }

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.action-btn {
  width: 100%;
  padding: 7px 8px;
  background: var(--bg2);
  border-radius: var(--r);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}

.danger-btn {
  width: 100%;
  padding: 7px 8px;
  background: var(--bg2);
  border-radius: var(--r);
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
}

.custom-btn-list { display: grid; gap: 6px; margin-bottom: 0; }

.custom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  background: var(--bg2);
  border-radius: var(--r);
}

.custom-item-left { display: flex; align-items: center; gap: 10px; }
.custom-item-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.custom-item-label { font-size: 15px; }

.custom-item-del {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,69,58,0.15);
  color: var(--accent);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s;
}

.custom-item-del:active { opacity: 0.6; }

.color-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2.5px solid transparent;
  transition: border-color .15s, transform .15s;
}

.color-swatch:active { transform: scale(0.9); }
.color-swatch.active { border-color: #fff; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 120px;
  min-height: 100vh;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--sep);
}

.nav-title { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.nav-right { display: flex; align-items: center; gap: 10px; }
.nav .icon-btn { background: rgba(255,255,255,0.1); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; transition: background .3s, box-shadow .3s; }
.status-dot.idle { background: var(--bg3); }
.status-dot.running { background: var(--accent-green); box-shadow: 0 0 8px rgba(48,209,88,0.6); }
.status-dot.paused { background: #FF9F0A; box-shadow: 0 0 8px rgba(255,159,10,0.5); }
.status-dot.ended { background: var(--accent); }

.hero-section {
  padding: 30px 20px 20px;
  text-align: center;
  position: sticky;
  top: 53px;
  z-index: 35;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(18px);
}

.timecode {
  font-size: clamp(52px, 16vw, 80px);
  font-weight: 200;
  letter-spacing: -2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hero-meta { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; }

.half-pill {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 50px;
  background: var(--bg2);
  color: var(--text2);
}

.hero-count { font-size: 13px; color: var(--text2); }

.mass-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px auto 0;
  max-width: 280px;
}

.mass-label { font-size: 12px; font-weight: 600; color: var(--text2); letter-spacing: 0.04em; }

.mass-track {
  flex: 1;
  height: 4px;
  background: var(--bg2);
  border-radius: 2px;
  overflow: hidden;
}

.mass-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #FF453A, #FF9F0A, #FFD60A);
  border-radius: 2px;
  transition: width .5s cubic-bezier(0.25,1,0.5,1);
}

.mass-val { font-size: 12px; font-weight: 600; color: var(--text2); min-width: 20px; text-align: right; }

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 4px 20px 24px;
  position: sticky;
  top: 181px;
  z-index: 34;
  background: linear-gradient(180deg, rgba(0,0,0,0.9), rgba(0,0,0,0.72));
  backdrop-filter: blur(14px);
}

.t-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: var(--bg2);
  transition: all .15s;
}

.t-btn:active:not(:disabled) { transform: scale(0.92); opacity: 0.8; }
.t-btn:disabled { opacity: 0.3; cursor: default; }
.t-btn.play-t { width: 66px; height: 66px; background: var(--accent-green); color: #000; box-shadow: 0 0 24px rgba(48,209,88,0.35); }
.t-btn.stop-t { background: var(--accent); box-shadow: 0 0 24px rgba(255,69,58,0.35); }
.t-btn.ghost-t { background: rgba(255,255,255,0.08); }
.hidden { display: none !important; }

.home-swipe {
  overflow: hidden;
  touch-action: pan-y;
}

.home-swipe-track {
  display: flex;
  width: 300%;
  transition: transform .28s ease;
  will-change: transform;
}

.home-swipe-track.is-dragging {
  transition: none;
}

.swipe-page {
  width: 33.3333%;
  flex: 0 0 33.3333%;
  min-height: 320px;
}

.reactions-section { padding: 0 16px 4px; }

.reaction-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.r-btn {
  border-radius: var(--r);
  padding: 8px 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: transform .12s, opacity .12s;
  position: relative;
  overflow: hidden;
  min-height: 76px;
  text-align: center;
}

.r-btn:active { transform: scale(0.93); }
.r-btn:disabled { opacity: 0.28; cursor: default; }
.r-label { font-size: 12px; font-weight: 600; letter-spacing: 0.01em; text-align: center; line-height: 1.2; }

.r-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background .2s;
}

.r-btn.tapped::after { background: rgba(255,255,255,0.18); }

.chart-section, .notes-section { padding: 20px 20px 8px; }

.swipe-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 20px 0;
  position: sticky;
  top: 189px;
  z-index: 30;
  background: linear-gradient(180deg, rgba(0,0,0,0.92), rgba(0,0,0,0.72));
  backdrop-filter: blur(10px);
}

.swipe-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  transition: transform .2s ease, background .2s ease;
}

.swipe-dot.active {
  background: rgba(255,255,255,0.72);
  transform: scale(1.1);
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-heading { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.section-count { font-size: 13px; color: var(--text2); }

.event-list { list-style: none; display: grid; gap: 6px; }

.saved-session-list {
  display: grid;
  gap: 8px;
}

.saved-session-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--r);
  background: var(--bg1);
}

.saved-session-title {
  font-size: 14px;
  font-weight: 600;
}

.saved-session-meta {
  font-size: 12px;
  color: var(--text2);
}

.saved-session-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.event-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.event-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.event-action-btn,
.tiny-action-btn {
  padding: 5px 7px;
  border-radius: var(--r);
  background: rgba(255,255,255,0.08);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
}

.event-action-btn.danger {
  color: #ff8a80;
}

.history-card {
  background: var(--bg2);
  border-radius: var(--r);
  padding: 14px;
}

.history-row {
  margin-bottom: 12px;
}

.history-heading {
  font-size: 15px;
}

.event-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r);
  background: var(--bg1);
}

.ev-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
  min-width: 62px;
}

.ev-badge {
  min-width: 34px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: rgba(255,255,255,0.12);
  border-radius: 500px;
  padding: 4px 8px;
}

.note-badge { background: rgba(64,200,224,0.18); color: #8de8f7; }
.ev-name { font-size: 14px; font-weight: 500; }
.ev-note-text { line-height: 1.35; }

.ev-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
}

.chart-wrap {
  background: var(--bg1);
  border-radius: var(--r-lg);
  overflow: hidden;
  padding: 4px;
  border: 0.5px solid var(--sep);
}

#pulseChart { width: 100%; height: auto; display: block; border-radius: 8px; }

.chart-filter-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
}

.filter-chip.active {
  background: rgba(255,255,255,0.18);
  color: var(--text);
}

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

.pie-row {
  margin-top: 18px;
}

.pie-wrap {
  margin-top: 0;
}

#pieChart {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.note-compose {
  display: grid;
  gap: 10px;
}

.note-input {
  width: 100%;
  min-height: 88px;
  border: 0.5px solid var(--sep);
  border-radius: var(--r);
  background: var(--bg1);
  color: var(--text);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
}

.note-input::placeholder { color: var(--text3); }
.note-input:disabled { opacity: 0.45; cursor: not-allowed; }

.note-save-btn {
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--r);
  background: var(--accent-blue);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.note-save-btn:disabled { opacity: 0.35; cursor: default; }

.summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin: 20px 20px 0;
  background: var(--bg1);
  border-radius: var(--r-lg);
  padding: 16px 10px;
  border: 0.5px solid var(--sep);
  position: sticky;
  bottom: 16px;
  z-index: 45;
  backdrop-filter: blur(18px);
}

.s-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 1;
}

.s-item strong { font-size: 17px; font-weight: 600; text-align: center; word-break: break-word; }
.s-item span { font-size: 11px; color: var(--text2); font-weight: 500; letter-spacing: 0.04em; }
.s-item.accent-item strong { color: #FF9F0A; }
.s-divider { width: 0.5px; background: var(--sep); align-self: stretch; }

@media (min-width: 640px) {
  .reaction-grid { grid-template-columns: repeat(4, 1fr); }
}
