:root {
  --bg: #0b0d12;
  --bg-elev: #12151c;
  --bg-elev-2: #181c25;
  --border: #232838;
  --text: #e7e9ee;
  --text-dim: #98a0b3;
  --accent: #7c3aed;
  --accent-2: #06b6d4;
  --danger: #ef4444;
  --good: #22c55e;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, 0.25), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(6, 182, 212, 0.2), transparent 60%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); }
a:hover { filter: brightness(1.15); }

.muted { color: var(--text-dim); }
.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--grad); box-shadow: 0 0 24px rgba(124,58,237,0.55); }
.brand-name { font-size: 16px; }
.nav { display: inline-flex; align-items: center; gap: 12px; }
.nav-link { color: var(--text-dim); text-decoration: none; font-size: 14px; }
.nav-link:hover { color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer;
  transition: transform 0.06s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn:hover { background: var(--bg-elev-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.compact { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-primary { background: var(--grad); border-color: transparent; color: white; box-shadow: 0 8px 30px rgba(124,58,237,0.35); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; }
.btn-link { background: transparent; border: none; color: var(--accent-2); padding: 0; height: auto; font-weight: 600; cursor: pointer; }
.btn.delete { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.35); color: #fca5a5; }
.btn.delete:hover { background: rgba(239,68,68,0.18); }

.hero { max-width: 880px; margin: 0 auto; padding: 64px 24px 40px; text-align: center; }
.hero-title { font-size: clamp(36px, 6vw, 56px); line-height: 1.05; margin: 0 0 14px; letter-spacing: -0.02em; }
.accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { color: var(--text-dim); font-size: 17px; max-width: 560px; margin: 0 auto 32px; }

.dropzone { border: 1.5px dashed var(--border); background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)); border-radius: var(--radius); padding: 56px 20px; cursor: pointer; transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent-2); background: rgba(6,182,212,0.05); transform: translateY(-1px); }
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dz-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: white; font-size: 22px; box-shadow: 0 16px 40px rgba(124,58,237,0.4); }
.dz-title { font-weight: 700; font-size: 18px; margin-top: 6px; }
.dz-sub { color: var(--text-dim); font-size: 14px; }

.card { margin-top: 24px; padding: 20px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); text-align: left; }
.card-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-weight: 700; }
.card-value { color: var(--text-dim); font-variant-numeric: tabular-nums; }

.progress { width: 100%; height: 8px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden; }
.progress-bar { width: 0%; height: 100%; background: var(--grad); transition: width 0.25s ease; }

.share { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.share-input { flex: 1 1 280px; min-width: 220px; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Watch page */
.watch .player-shell { max-width: 1080px; margin: 24px auto; padding: 0 20px 60px; }
.player-frame { border-radius: var(--radius); overflow: hidden; background: black; box-shadow: var(--shadow); aspect-ratio: 16 / 9; }
.player-frame video { width: 100%; height: 100%; display: block; background: black; }
.meta { margin-top: 22px; }
.title { font-size: 22px; margin: 0 0 10px; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { font-size: 12px; color: var(--text-dim); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; }

/* Auth pages */
.auth-shell { max-width: 440px; margin: 60px auto; padding: 0 20px; }
.auth-card { padding: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.field.compact { margin: 0; flex: 1; }
.field-label { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.input { height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text); font-size: 14px; outline: none; transition: border-color 0.2s ease; width: 100%; font-family: inherit; }
.input:focus { border-color: var(--accent-2); }
textarea.input, input[type="file"].input { padding: 8px 12px; height: auto; }
input[type="range"] { width: 100%; accent-color: var(--accent-2); }
.error { margin: 6px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.4); color: #fecaca; font-size: 13px; }
.success { margin: 6px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.35); color: #bbf7d0; font-size: 13px; }

.page-title { font-size: 22px; margin: 0; letter-spacing: -0.01em; }

/* Clips page */
.clips-shell { max-width: 1100px; margin: 24px auto; padding: 0 20px 60px; }
.clips-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.clips-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.clip-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s ease, border-color 0.2s ease; }
.clip-card:hover { transform: translateY(-2px); border-color: rgba(6,182,212,0.45); }
.clip-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: black; overflow: hidden; }
.clip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-placeholder { width: 100%; height: 100%; display: grid; place-items: center; font-size: 36px; background: var(--bg-elev-2); }
.clip-duration { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.75); color: white; font-size: 11px; padding: 2px 6px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.clip-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.clip-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-meta { font-size: 12px; }
.clip-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }

/* Editor */
.editor-shell { max-width: 1280px; margin: 24px auto; padding: 0 20px 60px; }
.editor-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 18px; gap: 12px; }
.editor-header > .page-title { text-align: center; }
@media (max-width: 880px) {
  .editor-header { grid-template-columns: 1fr; text-align: left; }
  .editor-header > .page-title { text-align: left; }
}

.editor-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 920px) { .editor-grid { grid-template-columns: 1fr; } }

.editor-main { display: flex; flex-direction: column; gap: 18px; }
.editor-controls { display: flex; flex-direction: column; gap: 14px; }
.control-group { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.control-title { margin: 0 0 10px; font-size: 14px; }
.checkbox-row { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0 12px; font-size: 14px; }

/* Trim panel */
.trim-panel { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px 20px; }
.trim-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.trim-times { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.trim-times b { color: var(--text); margin-left: 4px; font-weight: 600; }

.trim-slider { padding: 8px 12px 4px; }
.trim-track { position: relative; height: 36px; }
.trim-track::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 8px;
  margin-top: -4px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.trim-fill {
  position: absolute;
  top: 50%;
  height: 8px;
  margin-top: -4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  pointer-events: none;
  z-index: 1;
}
.trim-range {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 36px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  pointer-events: none;
  margin: 0;
  z-index: 2;
}
.trim-range::-webkit-slider-runnable-track { background: transparent; height: 36px; border: none; }
.trim-range::-moz-range-track { background: transparent; height: 36px; border: none; }
.trim-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--accent-2);
  cursor: grab;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  margin-top: 0;
}
.trim-range::-webkit-slider-thumb:active { cursor: grabbing; }
.trim-range::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--accent-2);
  cursor: grab;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
}
.trim-range:focus { outline: none; }

.trim-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* Footer */
.footer { text-align: center; color: var(--text-dim); font-size: 13px; padding: 30px 20px 40px; }

@media (max-width: 540px) {
  .topbar { padding: 14px 16px; }
  .hero { padding-top: 36px; }
  .dropzone { padding: 40px 16px; }
}
