/* ytbestof — dark, minimal, granulator-flavored UI */

:root {
  --bg:        #0e0e12;
  --bg-2:      #16161d;
  --card:      #1b1b24;
  --card-2:    #22222d;
  --line:      #2c2c38;
  --text:      #e9e9f0;
  --muted:     #8b8b9c;
  --accent:    #a970ff;   /* twitch-ish purple */
  --accent-2:  #c9a2ff;
  --accent-dim:#5a3fa0;
  --hot:       #ff5c8a;    /* selected zones */
  --ok:        #45d19a;
  --radius:    14px;
  --gap:       16px;
  --maxw:      880px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #201a33 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

.muted { color: var(--muted); }
.is-hidden { display: none !important; }

/* Header */
.site-header {
  padding: 20px 16px 4px;
  padding-top: max(20px, env(safe-area-inset-top));
  display: flex; justify-content: center;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.brand-mark .accent { color: var(--accent); }
.brand-tag { color: var(--muted); font-size: 13px; }

/* Layout */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 16px 60px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(60px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--gap);
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

/* Loader */
.load-form { display: flex; gap: 10px; }
.url-input {
  flex: 1; min-width: 0;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
}
.url-input:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }
.load-status { margin-top: 10px; font-size: 13px; min-height: 1.2em; }
.load-status.error { color: var(--hot); }
.load-status.ok { color: var(--ok); }
.linklike {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 13px; padding: 8px 0 0; text-align: left;
}
.linklike:hover { color: var(--accent-2); }

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: #2a2a37; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #14101f; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-2); }
.btn.icon { padding: 10px 14px; font-size: 15px; min-width: 46px; }
.btn.icon.play { background: var(--accent); border-color: var(--accent); color: #14101f; }

/* Player */
.player-card { padding: 0; overflow: hidden; }
.video-title { padding: 12px 14px 0; font-weight: 700; font-size: 15px; line-height: 1.3; }
.video-title:empty { display: none; }
.player-frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.player-frame > div, .player-frame iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.start-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: rgba(10,10,15,.72); color: var(--text);
  border: 0; cursor: pointer; font-size: 16px; font-weight: 600;
}
.start-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent); color: #14101f;
  display: grid; place-items: center; font-size: 26px;
}

.transport {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; flex-wrap: wrap;
}
.clip-indicator { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; }
.clip-indicator .clip-label { font-weight: 400; font-size: 13px; margin-left: 4px; }
.mode-toggle {
  margin-left: auto; display: inline-flex;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px;
}
.mode-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.mode-btn.is-active { background: var(--accent); color: #14101f; }
.mode-hint { padding: 0 12px 12px; font-size: 12px; margin: 0; }

/* Viz */
.viz-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.viz-title { font-size: 14px; margin: 0; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cut-count { font-size: 15px; font-weight: 700; }
.cut-count #cut-count { color: var(--hot); font-size: 18px; }
#cut-covered { font-weight: 400; margin-left: 8px; }
.canvas-holder { width: 100%; }
#curve-canvas { width: 100%; height: 150px; display: block; cursor: pointer; touch-action: none; }

/* Params */
.param-row { margin-bottom: 14px; }
.param-row.highlight {
  background: var(--bg-2); border: 1px solid var(--accent-dim);
  border-radius: 12px; padding: 14px; margin-bottom: 14px;
}
.param-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.param-help { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.param-control { display: flex; align-items: center; gap: 12px; }
.param-val {
  font-variant-numeric: tabular-nums; min-width: 46px; text-align: right;
  font-weight: 700; color: var(--accent-2);
}
.param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.autocut { width: 100%; margin: 4px 0 16px; }
.advanced { margin-top: 6px; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; }
.advanced summary:hover { color: var(--accent-2); }

/* Range slider */
.slider { flex: 1; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 5px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--fill,60%), var(--line) var(--fill,60%));
  outline: none; }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); cursor: pointer; }
.slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: pointer; }

/* Exports */
.export-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.clip-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.clip-item { display: flex; align-items: center; gap: 10px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.clip-item .clip-idx { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 22px; }
.clip-item .clip-time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--accent-2); white-space: nowrap; }
.clip-item .clip-name { flex: 1; min-width: 0; background: transparent; border: 0; border-bottom: 1px solid transparent;
  color: var(--text); padding: 4px 2px; font-size: 14px; }
.clip-item .clip-name:focus { outline: none; border-bottom-color: var(--accent); }
.clip-item .clip-jump { background: none; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); cursor: pointer; padding: 5px 9px; font-size: 12px; }
.clip-item .clip-jump:hover { color: var(--accent-2); border-color: var(--accent); }

/* Extension section */
.ext-card { border-color: var(--accent-dim); }
.ext-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.ext-emoji { font-size: 30px; line-height: 1; }
.ext-title { margin: 0 0 4px; font-size: 18px; }
.ext-sub { margin: 0; font-size: 13px; }
.ext-steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ext-steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.ext-num {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #14101f; font-weight: 800; font-size: 13px;
  display: grid; place-items: center;
}
.ext-link { color: var(--accent-2); text-decoration: none; }
.ext-link:hover { text-decoration: underline; }
.ext-install { display: inline-block; text-decoration: none; text-align: center; }
.ext-note { margin: 10px 0 0; font-size: 12px; }

/* Footer */
.site-footer { margin-top: 8px; text-align: center; font-size: 12px; }

@media (max-width: 560px) {
  .param-grid { grid-template-columns: 1fr; }
  .brand-tag { display: none; }
  .transport { gap: 8px; }
  .mode-toggle { margin-left: 0; width: 100%; justify-content: center; }
  .export-actions { width: 100%; }
  .export-actions .btn { flex: 1 1 auto; }
}

/* Bigger touch targets on touch devices */
@media (pointer: coarse) {
  .btn.icon { min-width: 54px; min-height: 48px; font-size: 17px; }
  .mode-btn { padding: 10px 16px; }
  .slider { height: 10px; }
  .slider::-webkit-slider-thumb { width: 24px; height: 24px; }
  .slider::-moz-range-thumb { width: 22px; height: 22px; }
  .clip-item .clip-jump { padding: 8px 12px; }
  #curve-canvas { height: 130px; }
}
