/* ── REC. — SHAPE OS design language ─────────────────────────────
   #fcfcfc canvas + dot grid, 340px frosted left panel, frosted
   floating pill toolbars, soft sage accent, black primary actions,
   DM Sans. */

:root {
  --bg: #fcfcfc;
  --dot-color: #d1d4d8;
  --card-bg: #ffffff;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 8px 32px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  --accent: #000000;
  --accent-hover: #333333;
  --accent-light: #f0f0f0;
  --brand: #dff0cb;
  --brand-ink: #1a1d12;
  --brand-soft: #ecf6dd;
  --brand-glow: rgba(223,240,203,0.35);
  --text: #1a1a1a;
  --text-secondary: #888888;
  --text-light: #bbbbbb;
  --border: #e8e6e3;
  --line: #eceae7;
  --danger: #e5484d;
  --live: #fa5252;
  --radius: 14px;
  --radius-sm: 10px;
  --toolbar-bg: rgba(255,255,255,0.92);
  --toolbar-shadow: 0 2px 20px rgba(0,0,0,0.08);
  --sidebar-width: 340px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
}

/* The fix: a class that sets display must never beat the hidden attribute. */
[hidden] { display: none !important; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Pages with no left panel (login, watch) center floating chrome over full width. */
body.no-panel { --sidebar-width: 0px; }

a { color: inherit; }

/* ── Dot-grid canvas ── */
.canvas {
  position: fixed;
  inset: 0;
  left: var(--sidebar-width);
  background: var(--bg);
  background-image: radial-gradient(circle, var(--dot-color) 1.2px, transparent 1.2px);
  background-size: 47.6px 47.6px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: left 320ms var(--ease);
}
.canvas-inner {
  min-height: 100%;
  padding: 96px 32px 140px;
  display: flex;
  flex-direction: column;
}
.canvas-center {
  min-height: 100%;
  padding: 96px 24px 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ── Left panel ── */
.panel {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--toolbar-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  z-index: 1001;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
  gap: 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--text);
}
.logo-dot {
  width: 11px; height: 11px;
  border-radius: 3px;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
  flex-shrink: 0;
}
.panel-body { flex: 1; overflow-y: auto; padding: 6px 12px; }
.panel-footer { flex-shrink: 0; padding: 12px 16px; border-top: 1px solid var(--border); }

.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 12px 6px;
  margin: 0;
}

.add-btn {
  width: 100%;
  padding: 11px;
  border: 2px dashed var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}
.add-btn:hover { border-color: var(--text-secondary); color: var(--text); }

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 2px;
  text-decoration: none;
  color: var(--text);
}
.list-item:hover { background: var(--accent-light); }
.list-item.active { background: var(--brand); color: var(--brand-ink); }
.list-item .li-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); flex-shrink: 0;
}
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-name {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-item .li-meta { font-size: 11px; color: var(--text-secondary); }

.panel-user { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.panel-user-name {
  flex: 1; font-size: 13px; font-weight: 500;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  width: 32px; height: 32px;
  border: none; background: transparent;
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}
.icon-btn:hover { background: var(--accent-light); color: var(--text); }

/* ── Floating frosted chrome ── */
.float-top {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: var(--toolbar-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius);
  padding: 7px 9px 7px 14px;
  box-shadow: var(--toolbar-shadow);
  border: 1px solid rgba(0,0,0,0.05);
  z-index: 1000;
  max-width: calc(100vw - var(--sidebar-width) - 32px);
  transition: left 320ms var(--ease);
}
.float-top .ctx-title {
  font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.float-topright {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: 16px;
  display: flex; align-items: center; gap: 8px;
  background: var(--toolbar-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: 11px;
  padding: 6px 8px 6px 14px;
  box-shadow: var(--toolbar-shadow);
  border: 1px solid rgba(0,0,0,0.05);
  z-index: 1000;
}
.dock {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
  transform: translateX(-50%);
  background: var(--toolbar-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--toolbar-shadow);
  border: 1px solid rgba(0,0,0,0.05);
  z-index: 1000;
  width: min(900px, calc(100vw - var(--sidebar-width) - 48px));
  transition: left 320ms var(--ease);
}
.dock.pill { padding: 7px 9px; width: auto; }

/* ── Buttons ── */
.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  border-radius: 10px;
  padding: 9px 15px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  transition: background 0.14s, border-color 0.14s, transform 0.06s, opacity 0.14s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-brand { background: var(--brand); color: var(--brand-ink); }
.btn-brand:hover:not(:disabled) { background: #d4ebb8; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--accent-light); }
.btn-soft { background: #fff; border-color: var(--border); }
.btn-soft:hover:not(:disabled) { border-color: var(--text-secondary); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }

/* ── Cards (dashboard) ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(0,0,0,0.03);
  padding: 18px;
  transition: box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}
.rec-card { display: flex; flex-direction: column; gap: 8px; }
.rec-card:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-2px); }
.rec-card h3 { margin: 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.rec-card .meta { color: var(--text-secondary); font-size: 12px; }
.rec-card .row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.empty {
  text-align: center; color: var(--text-secondary);
  max-width: 360px; margin: 0 auto;
}
.empty h2 { font-size: 19px; font-weight: 600; color: var(--text); margin: 0 0 6px; }

/* ── Setup card / toggles (recorder) ── */
.setup-card { width: 100%; max-width: 480px; padding: 24px; }
.setup-card .card-label {
  font-size: 11px; font-weight: 700; color: var(--text-light);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 4px;
}
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.toggle-row .label { font-weight: 600; font-size: 14px; }
.toggle-row .hint { color: var(--text-secondary); font-size: 12px; }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch .track {
  position: absolute; inset: 0; background: var(--border);
  border-radius: 999px; transition: background 0.15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; background: #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.record-cta { display: flex; justify-content: center; margin-top: 22px; }
.record-btn {
  width: 84px; height: 84px; border-radius: 50%; border: none;
  background: var(--brand); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 6px var(--brand-glow);
  transition: transform 0.1s var(--ease);
}
.record-btn:hover { transform: scale(1.05); }
.record-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.record-btn .dot { width: 26px; height: 26px; background: var(--accent); border-radius: 50%; }

.status-line { text-align: center; color: var(--text-secondary); margin-top: 16px; min-height: 20px; font-size: 13px; }

/* ── Stage / preview ── */
.stage {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
}
.preview-frame {
  width: 100%; max-width: 860px; position: relative;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow-hover);
  overflow: hidden; background: #111;
}
.preview-frame video, .preview-frame canvas { width: 100%; display: block; background: #111; }

.recording-pill {
  display: inline-flex; align-items: center; gap: 9px;
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px;
  padding: 0 6px;
}
.live-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--live); }
.live-dot.on { animation: pulse 1.4s ease-out infinite; }
.live-dot.paused { background: var(--text-light); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(250,82,82,0.55); }
  100% { box-shadow: 0 0 0 12px rgba(250,82,82,0); }
}

/* Countdown overlay */
.countdown {
  position: fixed; inset: 0;
  background: rgba(20,20,20,0.78);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.countdown span { font-size: 150px; font-weight: 700; color: var(--brand); }

/* Play overlay on a video */
.play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none; background: rgba(0,0,0,0.05);
}
.play-overlay .ring {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--toolbar-bg);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--toolbar-shadow);
  transition: transform 0.1s var(--ease);
}
.play-overlay:hover .ring { transform: scale(1.06); }
.play-overlay svg { margin-left: 4px; }

/* ── Editor dock ── */
.dock-transport {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.dock-transport .time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.dock-transport .time .total { color: var(--text-secondary); font-weight: 500; }
.dock-transport select {
  font-family: inherit; font-weight: 600; font-size: 13px;
  border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 9px; background: #fff; cursor: pointer; color: var(--text);
}
.dock-transport .sep { width: 1px; height: 22px; background: var(--border); }
.dock-transport .save-state { font-size: 12px; color: var(--text-secondary); margin-left: auto; }

.play-btn {
  width: 38px; height: 38px; border-radius: 10px; border: none;
  background: var(--accent); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.14s, transform 0.06s;
}
.play-btn:hover:not(:disabled) { background: var(--accent-hover); }
.play-btn:active { transform: scale(0.96); }
.play-btn:disabled { opacity: 0.4; cursor: default; }

/* Timeline */
.timeline-wrap { margin-top: 12px; }
.timeline {
  position: relative; display: flex; gap: 3px; height: 54px;
  cursor: pointer; user-select: none; touch-action: none;
}
.segment {
  background: var(--brand-soft);
  border: 1.5px solid transparent;
  border-radius: 9px; min-width: 12px;
  position: relative; display: flex; align-items: flex-end;
  padding: 5px 7px; overflow: hidden;
  transition: border-color 0.1s, background 0.1s;
}
.segment.alt { background: #e4eed3; }
.segment.selected { border-color: var(--accent); background: var(--brand); }
.segment .tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  color: rgba(26,29,18,0.55); white-space: nowrap;
}
.playhead {
  position: absolute; top: -5px; bottom: -5px; width: 2px;
  background: var(--accent); border-radius: 2px; pointer-events: none;
}
.playhead::before {
  content: ""; position: absolute; top: -4px; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--accent);
}
.edit-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }

.hint-line { text-align: center; color: var(--text-light); font-size: 12px; margin-top: 14px; }

/* ── Watch page scrub ── */
.scrub {
  position: relative; height: 8px; background: var(--border);
  border-radius: 999px; cursor: pointer; margin-top: 14px;
  width: 100%; max-width: 860px;
}
.scrub .fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: var(--accent); border-radius: 999px;
}

/* ── Login ── */
.login-card { width: 100%; max-width: 360px; padding: 26px; }
.login-card h1 { font-size: 19px; font-weight: 700; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-secondary); margin: 0 0 18px; font-size: 13px; }
.login-card input[type="password"] {
  width: 100%; font-family: inherit; font-size: 14px;
  padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 12px;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-error { color: var(--danger); font-size: 13px; margin: 0 0 12px; }
.title-input {
  font-family: inherit; font-weight: 600; font-size: 14px; color: var(--text);
  background: transparent; border: 1px solid transparent;
  border-radius: 9px; padding: 6px 9px; min-width: 100px; max-width: 30vw;
}
.title-input:hover { border-color: var(--border); }
.title-input:focus { outline: none; border-color: var(--accent); background: #fff; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-weight: 600; font-size: 13px;
  box-shadow: var(--toolbar-shadow); opacity: 0; pointer-events: none;
  transition: opacity 0.2s; z-index: 3000;
}
.toast.show { opacity: 1; }

.unsupported { max-width: 460px; padding: 24px; }
.unsupported p.card-label {
  font-size: 11px; font-weight: 700; color: var(--text-light);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 8px;
}

/* ── Responsive ── */
@media (max-width: 860px) {
  :root { --sidebar-width: 0px; }
  .panel {
    position: static; width: 100%; min-width: 0; height: auto;
    flex-direction: row; align-items: center; border-right: none;
    border-bottom: 1px solid var(--border); padding: 8px 12px;
  }
  .panel-header { padding: 0; flex: 1; }
  .panel-body { display: none; }
  .panel-footer { border-top: none; padding: 0; }
  .canvas { position: static; inset: auto; height: auto; min-height: calc(100vh - 56px); }
  .canvas-inner { padding: 84px 16px 130px; }
  .canvas-center { padding: 84px 16px 130px; }
  .float-top, .dock { max-width: calc(100vw - 24px); width: auto; }
  .dock { width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
