/* =========================================================================
   GuitarLoop — design tokens
   ========================================================================= */
:root {
  --bg: #F7F5F1;
  --surface: #FFFFFF;
  --surface-2: #FAF9F6;
  --surface-3: #F2EFEA;
  --border: #E9E5DE;
  --border-2: #DDD7CD;
  --text: #191714;
  --text-2: #5E5850;
  --text-3: #98918A;
  --ink: #191714;
  --accent: #E25822;
  --accent-2: #F07A3E;
  --accent-soft: #FCEEE6;
  --accent-line: rgba(226, 88, 34, 0.28);
  --danger: #D43F3A;
  --fret: #E4DFD6;
  --string: rgba(25, 23, 20, 0.045);

  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 20px;
  --shadow-xs: 0 1px 2px rgba(25, 23, 20, 0.05);
  --shadow-sm: 0 1px 2px rgba(25, 23, 20, 0.04), 0 2px 8px rgba(25, 23, 20, 0.04);
  --shadow: 0 1px 2px rgba(25, 23, 20, 0.04), 0 8px 24px -4px rgba(25, 23, 20, 0.08);
  --shadow-lg: 0 2px 4px rgba(25, 23, 20, 0.03), 0 24px 64px -12px rgba(25, 23, 20, 0.16);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

/* =========================================================================
   Base
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 400 14.5px/1.5 var(--sans);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent-soft); color: var(--text); }

.i {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  font: 600 11px/1 var(--mono);
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  vertical-align: 1px;
}
code { font: 500 0.9em var(--mono); background: var(--surface-3); padding: 2px 6px; border-radius: 5px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  font-weight: 600; font-size: 14px; letter-spacing: -0.005em; white-space: nowrap;
  border-radius: 10px; border: 1px solid transparent;
  transition: background .15s var(--ease), border-color .15s, box-shadow .15s, transform .08s, color .15s;
}
.btn:active { transform: translateY(0.5px) scale(0.99); }
.btn .i { width: 16px; height: 16px; }
.btn-dark { background: var(--ink); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.08); }
.btn-dark:hover { background: #2D2A26; }
.btn-secondary { background: var(--surface); border-color: var(--border-2); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { border-color: #CFC8BC; background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-lg { height: 48px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-xs .i { width: 14px; height: 14px; }
.btn-block { width: 100%; }

.text-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0; border: 0; background: none;
  font-weight: 600; font-size: 13px; color: var(--accent);
}
.text-btn:hover { color: #C1461A; }
.text-btn .i { width: 14px; height: 14px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .i { width: 19px; height: 19px; }
.icon-btn-sm { width: 32px; height: 32px; border-radius: 8px; border-color: var(--border); background: var(--surface); }
.icon-btn-sm .i { width: 15px; height: 15px; }
.icon-btn.toggle[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

/* =========================================================================
   Inputs
   ========================================================================= */
input[type="text"], .time-input, select {
  height: 36px; padding: 0 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 9px;
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, .time-input:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
select {
  -webkit-appearance: none; appearance: none; padding-right: 30px; cursor: pointer; font-size: 13px; font-weight: 500;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2398918A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

.switch {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0; cursor: pointer;
  position: relative; width: 38px; height: 22px; border-radius: 11px;
  background: var(--border-2); transition: background .2s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform .2s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 24px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--ink) var(--fill, 50%), var(--border) var(--fill, 50%));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%;
  background: #fff; border: 1px solid var(--border-2);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.12);
  transition: transform .15s var(--ease);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 1px solid var(--border-2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* =========================================================================
   Top bar
   ========================================================================= */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  height: 64px; padding: 0 28px;
  background: rgba(247, 245, 241, 0.82);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
body:not(.welcome-mode) .topbar { border-bottom-color: var(--border); }
.brand {
  display: flex; align-items: center; gap: 9px;
  color: var(--text); text-decoration: none;
  font-family: var(--serif); font-size: 26px; letter-spacing: -0.01em;
}
.brand-mark { width: 28px; height: 28px; border-radius: 7px; box-shadow: 0 1px 2px rgba(214, 70, 26, 0.25), 0 4px 10px -2px rgba(214, 70, 26, 0.3); }
.top-form {
  position: relative; flex: 1; max-width: 520px; margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 36px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow-xs);
}
.top-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.top-form input { flex: 1; min-width: 0; border: 0; height: 32px; padding: 0; background: transparent; box-shadow: none !important; }
.field-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.welcome-mode .top-form { visibility: hidden; }

.banner {
  max-width: 1080px; margin: 16px auto 0; padding: 12px 16px;
  border: 1px solid var(--accent-line); background: var(--accent-soft); color: #7A3412;
  border-radius: var(--r); line-height: 1.55;
}

/* =========================================================================
   Welcome
   ========================================================================= */
.welcome {
  position: relative; overflow: hidden;
  padding: 0 24px;
}
.welcome::before {
  content: ""; position: absolute; inset: -200px 0 auto; height: 900px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 340px at 72% 32%, rgba(240, 122, 62, 0.13), transparent 70%),
    radial-gradient(520px 320px at 24% 40%, rgba(236, 196, 140, 0.18), transparent 70%);
}
.hero { max-width: 840px; margin: 0 auto; padding: 72px 0 0; text-align: center; }
.eyebrow-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
  background: rgba(255,255,255,0.7); border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  animation: rise .7s var(--ease) both;
}
.eyebrow-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hero h1 {
  margin: 22px 0 18px;
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(48px, 8.2vw, 96px); line-height: 0.98; letter-spacing: -0.025em;
  animation: rise .8s .05s var(--ease) both;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.lead {
  margin: 0 auto 36px; max-width: 540px;
  font-size: 18px; line-height: 1.55; color: var(--text-2);
  animation: rise .8s .1s var(--ease) both;
}
.hero-form {
  position: relative; display: flex; gap: 8px; align-items: center;
  max-width: 620px; margin: 0 auto;
  padding: 6px 6px 6px 46px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg);
  transition: border-color .15s, box-shadow .15s;
  animation: rise .8s .15s var(--ease) both;
}
.hero-form:focus-within { border-color: var(--accent); box-shadow: var(--shadow-lg), 0 0 0 4px var(--accent-soft); }
.hero-form .field-icon { left: 16px; width: 20px; height: 20px; color: var(--accent); }
.hero-form input { flex: 1; min-width: 0; height: 48px; padding: 0; border: 0; font-size: 16px; background: transparent; box-shadow: none !important; }
.form-error { margin: 12px 0 0; color: var(--danger); font-size: 13.5px; }
.hero-sub {
  margin: 18px 0 0; font-size: 13.5px; color: var(--text-3);
  animation: rise .8s .2s var(--ease) both;
}
.hero-sub .sep { margin: 0 8px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---- Product preview ---- */
.preview {
  position: relative; max-width: 760px; margin: 64px auto 0;
  animation: rise 1s .3s var(--ease) both;
}
.pv-card {
  padding: 22px 24px 18px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.pv-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 30px; }
.pv-eyebrow, .eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.pv-title { font-family: var(--serif); font-size: 30px; line-height: 1.1; margin-top: 4px; }
.pv-speed { text-align: right; }
.pv-speed span { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.pv-speed b { font: 600 26px/1.1 var(--mono); letter-spacing: -0.03em; }
.pv-timeline { position: relative; height: 60px; }
.pv-region {
  position: absolute; left: 30%; width: 28%; top: 0; bottom: 0; border-radius: 6px;
  background: rgba(226, 88, 34, 0.12); box-shadow: inset 0 0 0 1.5px var(--accent);
}
.pv-handle { position: absolute; top: -10px; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); }
.pv-a { left: 30%; } .pv-b { left: 58%; }
.pv-handle span {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font: 700 10px/1 var(--sans); color: #fff; background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface), 0 2px 6px rgba(226, 88, 34, 0.35);
}
.pv-playhead {
  position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px;
  animation: pv-play 3.2s linear infinite;
}
@keyframes pv-play { from { left: 30%; } to { left: 58%; } }
.pv-scale { display: flex; justify-content: space-between; margin-top: 10px; font: 500 11px var(--mono); color: var(--text-3); }
.pv-transport { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.pv-time { font: 600 14px var(--mono); }
.pv-controls { display: flex; align-items: center; gap: 10px; }
.pv-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--text-2); }
.pv-btn .i { width: 17px; height: 17px; }
.pv-play { width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: #fff; }
.pv-on { color: var(--accent); background: var(--accent-soft); }
.pv-count { font-size: 13px; color: var(--text-3); }
.pv-count b { color: var(--text); font-family: var(--mono); }
.pv-float {
  position: absolute; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 12px; font-size: 13px; color: var(--text-2);
  background: rgba(255,255,255,0.92); border: 1px solid var(--border);
  box-shadow: var(--shadow); backdrop-filter: blur(8px);
  animation: float 6s ease-in-out infinite;
}
.pv-float b { color: var(--text); }
.pv-float .i { color: var(--accent); width: 16px; height: 16px; }
.pv-float-1 { top: -22px; right: -36px; }
.pv-float-2 { bottom: 58px; left: -56px; animation-delay: -3s; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ---- Sections ---- */
.section { max-width: 1080px; margin: 96px auto 0; }
.section-head { margin-bottom: 22px; }
.section-head h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 36px; letter-spacing: -0.015em; line-height: 1.1; }
.section-head p { margin: 6px 0 0; color: var(--text-2); }

.recent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.recent-card {
  display: block; padding: 0; text-align: left; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .2s;
}
.recent-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-2); }
.recent-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-3); }
.recent-card div { padding: 12px 14px 14px; }
.recent-card strong {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 14px; font-weight: 600; line-height: 1.35; letter-spacing: -0.005em;
}
.recent-card small { display: block; margin-top: 6px; font: 500 11.5px var(--mono); color: var(--text-3); }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-top: 1px solid var(--border); }
.features article { padding: 32px 32px 0 0; }
.features article + article { padding-left: 32px; border-left: 1px solid var(--border); }
.feat-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; margin-bottom: 18px;
  color: var(--accent); background: var(--accent-soft);
}
.features h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.features p { margin: 0; color: var(--text-2); line-height: 1.6; }

.storage-note {
  display: flex; align-items: center; gap: 18px;
  padding: 20px 22px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.storage-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 11px; background: var(--surface-3); color: var(--text-2); }
.storage-text { flex: 1; color: var(--text-2); line-height: 1.55; font-size: 13.5px; }
.storage-text strong { display: block; margin-bottom: 2px; color: var(--text); font-size: 14.5px; font-weight: 600; }
.storage-text b { color: var(--text); font-weight: 600; }
.storage-actions { display: flex; gap: 8px; flex: none; }
.blocked [data-storage-title] { color: var(--danger) !important; }
.storage-note.blocked { border-color: rgba(212, 63, 58, 0.35); }

.footer { max-width: 1080px; margin: 72px auto 0; padding: 28px 0 40px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); text-align: center; }

/* =========================================================================
   App
   ========================================================================= */
.app {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px 28px;
  max-width: 1480px; margin: 0 auto; padding: 24px 28px 48px; align-items: start;
  animation: rise .5s var(--ease) both;
}
.app-head { grid-column: 1 / -1; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.app-head-text { min-width: 0; }
.video-title {
  margin: 4px 0 0; font-family: var(--serif); font-weight: 400;
  font-size: clamp(26px, 3vw, 36px); line-height: 1.12; letter-spacing: -0.015em;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.video-title:empty::before { content: "Loading…"; color: var(--text-3); }
.stage { min-width: 0; }

.player-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
.video-wrap { position: relative; aspect-ratio: 16 / 9; background: #0E0D0C; }
.video-wrap iframe, .video-wrap #player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.gap-overlay {
  position: absolute; inset: 0; pointer-events: none;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  background: rgba(14, 13, 12, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: #fff; animation: fade .2s both;
}
.gap-count { font: 400 120px/1 var(--serif); animation: tick 1s var(--ease) infinite; }
.gap-label { font-size: 14px; color: rgba(255,255,255,0.8); }
.gap-label kbd { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); color: #fff; }
@keyframes tick { from { transform: scale(1.12); opacity: .5; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
.video-error {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  padding: 32px; max-width: 100%; color: #fff; line-height: 1.55; background: rgba(14, 13, 12, 0.92);
}

/* ---- Timeline ---- */
.timeline-wrap { padding: 30px 24px 0; }
.timeline { position: relative; height: 64px; cursor: crosshair; touch-action: none; user-select: none; -webkit-user-select: none; }
.track {
  position: absolute; inset: 0; border-radius: 10px;
  background:
    radial-gradient(circle at 25% 50%, var(--border-2) 0 2.5px, transparent 3px) 0 0 / 12.5% 100% repeat-x,
    repeating-linear-gradient(90deg, transparent 0 calc(6.25% - 1px), var(--fret) calc(6.25% - 1px) 6.25%),
    repeating-linear-gradient(180deg, transparent 0 9px, var(--string) 9px 10px),
    var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.region {
  position: absolute; top: 0; bottom: 0; border-radius: 7px;
  background: rgba(226, 88, 34, 0.11);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  cursor: grab; transition: background .15s;
}
.region:hover { background: rgba(226, 88, 34, 0.16); }
.region:active { cursor: grabbing; }
.timeline.loop-off .region { background: rgba(25, 23, 20, 0.04); box-shadow: inset 0 0 0 1.5px var(--border-2); }
.timeline.loop-off .handle::before, .timeline.loop-off .handle span { background: var(--text-3); box-shadow: 0 0 0 3px var(--surface); }
.handle { position: absolute; top: -14px; bottom: 0; width: 20px; margin-left: -10px; cursor: ew-resize; z-index: 2; outline: none; }
.handle::before { content: ""; position: absolute; left: 9px; width: 2px; top: 10px; bottom: 0; background: var(--accent); }
.handle span {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font: 700 10.5px/1 var(--sans); color: #fff; background: var(--accent);
  box-shadow: 0 0 0 3px var(--surface), 0 2px 8px rgba(226, 88, 34, 0.35);
  transition: transform .15s var(--ease);
}
.handle:hover span, .handle:focus-visible span { transform: translateX(-50%) scale(1.12); }
.handle:focus-visible span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent-line); }
.handle.top { z-index: 3; }
.playhead {
  position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; z-index: 1;
  background: var(--ink); border-radius: 1px; pointer-events: none;
}
.playhead::before {
  content: ""; position: absolute; top: -3px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink);
}
.hover-time {
  position: absolute; top: calc(100% + 8px); transform: translateX(-50%); z-index: 4;
  padding: 3px 7px; border-radius: 6px; pointer-events: none; white-space: nowrap;
  font: 600 11px var(--mono); color: #fff; background: var(--ink);
}
.scale { position: relative; height: 16px; margin-top: 10px; font: 500 11px var(--mono); color: var(--text-3); }
.scale span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.scale span:first-child { transform: none; }
.scale span:last-child { transform: translateX(-100%); }

/* ---- Transport ---- */
.transport {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  margin-top: 16px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.time-readout { font: 600 15px var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.time-sep { margin: 0 6px; color: var(--border-2); }
.time-dur { color: var(--text-3); }
.transport-center { display: flex; align-items: center; gap: 6px; }
.play-btn {
  display: grid; place-items: center; width: 52px; height: 52px; margin: 0 6px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15), 0 6px 16px -4px rgba(25, 23, 20, 0.35);
  transition: transform .12s var(--ease), background .15s;
}
.play-btn:hover { background: #2D2A26; transform: scale(1.04); }
.play-btn:active { transform: scale(0.97); }
.play-btn .i { width: 22px; height: 22px; }
.play-btn .ic-pause, .play-btn.is-playing .ic-play { display: none; }
.play-btn.is-playing .ic-pause { display: block; }
.play-btn .ic-play { margin-left: 2px; }
.transport-hint { justify-self: end; font-size: 12.5px; color: var(--text-3); }

/* =========================================================================
   Side panel
   ========================================================================= */
.panel {
  position: sticky; top: 88px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 112px); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--border-2) transparent;
}
.sec { padding: 20px 22px; }
.sec + .sec { border-top: 1px solid var(--border); }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 28px; }
.sec h3 { margin: 0; font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.meta { font-size: 12.5px; color: var(--text-3); }
.meta b { font-family: var(--mono); font-weight: 600; color: var(--text); }

.rate-big { font: 600 30px/1 var(--mono); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.speed-row { display: flex; align-items: center; gap: 12px; }
.speed-row input { flex: 1; min-width: 0; }
.seg {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-top: 14px; padding: 3px;
  background: var(--surface-3); border-radius: 10px;
}
.seg-btn {
  height: 28px; border: 0; border-radius: 7px; background: transparent;
  font: 600 11.5px var(--mono); color: var(--text-2); letter-spacing: -0.02em;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.03); }

.point + .point { margin-top: 16px; }
.point-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.badge {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font: 700 10px/1 var(--sans); color: #fff; background: var(--accent);
}
.point-name { font-weight: 600; font-size: 13.5px; }
.point-top .text-btn { margin-left: auto; font-size: 12.5px; }
.point-top kbd { margin-left: 2px; }
.stepper {
  display: flex; align-items: stretch; height: 40px;
  border: 1px solid var(--border-2); border-radius: 10px; overflow: hidden; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.nudge {
  display: grid; place-items: center; width: 36px; flex: none;
  border: 0; background: var(--surface-2); color: var(--text-2);
  transition: background .12s, color .12s;
}
.nudge:hover { background: var(--surface-3); color: var(--text); }
.nudge:active { background: var(--accent-soft); color: var(--accent); }
.nudge .i { width: 15px; height: 15px; }
.nudge + .nudge { border-left: 1px solid var(--border); }
.stepper .time-input {
  flex: 1; min-width: 0; height: auto; text-align: center;
  border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); border-radius: 0;
  font: 600 15px var(--mono); letter-spacing: -0.02em; box-shadow: none !important;
}

.field { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: default; }
label.field { cursor: pointer; }
.field + .field { margin-top: 16px; }
.field-label { font-weight: 600; font-size: 13.5px; }
.field-desc { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.trainer-opts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; padding: 14px;
  border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border);
  animation: rise .25s var(--ease) both;
}
.trainer-opts label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.trainer-opts select { width: 100%; height: 32px; }
.trainer-status { margin-top: 12px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.trainer-status b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.progress { position: relative; height: 6px; margin-top: 8px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress span { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .5s var(--ease); }
.progress-labels { display: flex; justify-content: space-between; margin-top: 5px; font: 500 10.5px var(--mono); color: var(--text-3); }
.trainer-done { color: #2F7D4F; font-weight: 600; }

.stat-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border);
}
.stat-right { display: flex; align-items: center; gap: 12px; }
.stat-num { font: 600 20px/1 var(--mono); letter-spacing: -0.03em; display: inline-block; }
.stat-num.bump { animation: bump .4s var(--ease); }
@keyframes bump { from { transform: scale(1.35); color: var(--accent); } to { transform: scale(1); } }

.saved-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.saved-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); transition: border-color .15s, background .15s;
}
.saved-item:hover { border-color: var(--border-2); background: var(--surface-2); }
.saved-item.on { border-color: var(--accent-line); background: var(--accent-soft); }
.saved-item.on::before { content: ""; position: absolute; left: -1px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.saved-item .info { flex: 1; min-width: 0; }
.saved-item input {
  width: 100%; height: 22px; padding: 0; border: 0; border-radius: 4px; background: transparent;
  font-weight: 600; font-size: 13.5px; text-overflow: ellipsis;
}
.saved-item input:focus { outline: none; box-shadow: 0 0 0 2px var(--accent-soft); background: var(--surface); }
.saved-item small { display: block; font: 500 11px var(--mono); color: var(--text-3); margin-top: 1px; }
.saved-item .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.saved-item .icon-btn .i { width: 15px; height: 15px; }
.saved-item .go { color: var(--ink); }
.saved-item .go .i { margin-left: 1px; }
.saved-item .del:hover { color: var(--danger); background: rgba(212, 63, 58, 0.08); }
.empty { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--r); border: 1px dashed var(--border-2); color: var(--text-3); }
.empty .i { margin-top: 1px; }
.empty p { margin: 0; font-size: 12.5px; line-height: 1.5; }

.sec-foot { background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.foot-note { margin: 0 0 10px; font-size: 12px; line-height: 1.5; color: var(--text-3); }
.foot-note strong { color: var(--text-2); font-weight: 600; }
.sec-foot .storage-actions { gap: 4px; margin-left: -10px; }

/* =========================================================================
   Toast & dialog
   ========================================================================= */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50;
  transform: translate(-50%, 12px) scale(0.98);
  max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 12px;
  font-size: 13.5px; font-weight: 500; text-align: center;
  color: #fff; background: var(--ink); box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

dialog {
  width: min(460px, calc(100vw - 32px)); padding: 26px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: rise .25s var(--ease); }
dialog::backdrop { background: rgba(25, 23, 20, 0.28); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 16px; font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: -0.01em; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0 0 16px; }
.shortcuts dt, .shortcuts dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.shortcuts dt { padding-right: 20px; white-space: nowrap; color: var(--text-2); }
.shortcuts dd { color: var(--text-2); }
.dialog-note { margin: 0 0 18px; font-size: 12.5px; color: var(--text-3); }

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
  .pv-float-1 { right: -8px; }
  .pv-float-2 { left: -8px; }
}
@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .top-form { order: 3; flex-basis: 100%; max-width: none; }
  .welcome-mode .top-form { display: none; }
  .hide-sm { display: none; }
  #helpBtn { margin-left: auto; }
  .welcome { padding: 0 16px; }
  .hero { padding-top: 40px; }
  .hero-form { flex-direction: column; align-items: stretch; padding: 8px; }
  .hero-form .field-icon { display: none; }
  .hero-form input { padding: 0 10px; }
  .preview { margin-top: 48px; }
  .pv-float { display: none; }
  .pv-card { padding: 18px 16px 14px; }
  .pv-title { font-size: 24px; }
  .section { margin-top: 64px; }
  .features { grid-template-columns: 1fr; border-top: 0; }
  .features article, .features article + article { padding: 24px 0; border-left: 0; border-top: 1px solid var(--border); }
  .storage-note { flex-direction: column; align-items: flex-start; }
  .app { padding: 16px 16px 40px; gap: 16px; }
  .app-head { flex-direction: column; align-items: stretch; }
  .timeline-wrap { padding: 28px 16px 0; }
  .transport { grid-template-columns: 1fr; justify-items: center; padding: 12px 16px; gap: 8px; }
  .transport-hint { display: none; }
  .time-readout { order: 2; }
  .sec { padding: 18px 16px; }
}
.welcome-mode .topbar { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; position: absolute; left: 0; right: 0; }
.welcome-mode .welcome { padding-top: 64px; }
