:root {
  --bg: #0e0e10;
  --surface: #17171a;
  --surface2: #1f1f24;
  --text: #f4f4f5;
  --muted: #9a9aa1;
  --line: #2a2a30;
  --accent: #f4f4f5;
  --on-accent: #0e0e10;
  --radius: 16px;
  color-scheme: dark;
}

body.light {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface2: #f0f0f3;
  --text: #141416;
  --muted: #6b6b72;
  --line: #e4e4e8;
  --accent: #141416;
  --on-accent: #fafafa;
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 15px;
}

#main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
}

.screen { display: none; }
.screen.active { display: block; }

.screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.screen-head h2 { font-size: 22px; letter-spacing: -0.02em; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.card h3 { font-size: 16px; margin-bottom: 10px; }
.card h4 { font-size: 14px; margin-bottom: 6px; }

.center-card { text-align: center; padding: 24px 18px; }

.split-name { font-size: 20px; font-weight: 700; margin-top: 12px; }
.big-number { font-size: 56px; font-weight: 800; line-height: 1.1; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
}

.row + .row { border-top: 1px solid var(--line); }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.actions .btn, .actions a.btn { width: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease;
}

.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.big { min-height: 56px; font-size: 17px; }
.btn.small { min-height: 40px; font-size: 14px; padding: 6px 12px; }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.file-btn { margin-top: 10px; }

.icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
}

.small-icon { width: 14px; height: 14px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

.input:focus, .btn:focus-visible, .icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

label.muted { display: block; margin: 10px 0 6px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-top: 12px; }

.ring-wrap { position: relative; width: 150px; height: 150px; margin: 14px auto 0; }
.ring { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 8; }
.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dasharray 0.4s ease;
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-pct { font-size: 24px; font-weight: 800; }

.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin: 10px 0 4px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; }

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-weight: 600;
}

.ex-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ex-head h3 { margin-bottom: 2px; }

.set-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  font-size: 14px;
  font-weight: 600;
}

.chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.chip-x:active { color: var(--text); }

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.result-row:first-child { border-top: none; }
.result-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.result-info span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small-input { width: 74px; min-height: 44px; text-align: center; }
.log-row strong { margin-right: 4px; }
.log-right { display: inline-flex; align-items: center; }

.vol-row {
  display: grid;
  grid-template-columns: 86px 1fr 52px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.vol-label { font-size: 14px; }
.vol-bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.vol-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.vol-row span:last-of-type { text-align: right; }

.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 12px;
  min-height: 60px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.tab.active { color: var(--text); }
.tab .icon { width: 24px; height: 24px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

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

.demo-video {
  width: 100%;
  border-radius: 12px;
  background: #000;
  margin-bottom: 10px;
  display: block;
}

.demo-notes { margin: 12px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

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

@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}