/* ==========================================================================
   MyLoom — application styles
   Single stylesheet, no build step. Organised as: tokens, base, primitives,
   layout, library, recorder, player, watch page, settings, responsive.
   ========================================================================== */

/* --- Design tokens -------------------------------------------------------- */
:root {
  --accent: #625df5;
  --accent-soft: #eeedfe;
  --accent-dark: #4f4ae0;

  --bg: #f6f6fa;
  --surface: #ffffff;
  --surface-2: #fafafd;
  --line: #e7e7f0;
  --line-strong: #d6d6e4;

  --text: #16161d;
  --text-2: #55555f;
  --muted: #86868f;

  --ok: #12a150;
  --warn: #c2860a;
  --danger: #e5484d;
  --danger-soft: #fdeceb;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 45, .05);
  --shadow: 0 4px 16px rgba(20, 20, 45, .08);
  --shadow-lg: 0 18px 50px rgba(20, 20, 45, .18);

  --sidebar-w: 248px;
  --header-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f14;
    --surface: #17171f;
    --surface-2: #1d1d27;
    --line: #282833;
    --line-strong: #363644;
    --text: #f2f2f7;
    --text-2: #b6b6c2;
    --muted: #86868f;
    --accent-soft: #221f45;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 4px 18px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f14; --surface: #17171f; --surface-2: #1d1d27; --line: #282833;
  --line-strong: #363644; --text: #f2f2f7; --text-2: #b6b6c2; --muted: #86868f;
  --accent-soft: #221f45;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 4px 18px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.6);
}

/* --- Base ----------------------------------------------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.pad { padding: 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 650; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.gap-lg { gap: 18px; }
.mt { margin-top: 14px; } .mt-lg { margin-top: 24px; } .mb { margin-bottom: 14px; }

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
  transition: background .13s, border-color .13s, transform .06s, filter .13s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(1.06); background: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon { padding: 8px; width: 34px; height: 34px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); z-index: 1; }

/* --- Forms ---------------------------------------------------------------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text-2); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(98,93,245,.16); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
input[type=range] { accent-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.check { display: flex; align-items: flex-start; gap: 9px; margin: 11px 0; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; flex: none; accent-color: var(--accent); width: 15px; height: 15px; }
.check .check-sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
fieldset { border: 0; margin: 0; padding: 0; }

/* --- Cards, badges, chips ------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card.pad { padding: 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-body { padding: 20px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.ok { background: rgba(18,161,80,.12); color: var(--ok); border-color: transparent; }
.badge.warn { background: rgba(194,134,10,.14); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13px; cursor: pointer; color: var(--text-2);
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; object-fit: cover;
  background: var(--accent); color: #fff; display: inline-flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 650; text-transform: uppercase;
}
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* --- Toasts & modals ------------------------------------------------------ */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 9000; display: flex; flex-direction: column; gap: 9px; align-items: center; pointer-events: none; }
.toast {
  background: #16161d; color: #fff; padding: 11px 17px; border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: 14px; max-width: min(92vw, 460px);
  animation: toast-in .22s ease-out; pointer-events: auto;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,15,25,.55); backdrop-filter: blur(3px);
  z-index: 8000; display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade-in .15s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; animation: modal-in .18s ease-out;
}
.modal.wide { max-width: 760px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--surface); }
.close-x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.close-x:hover { background: var(--surface-2); color: var(--text); }

/* --- App layout ----------------------------------------------------------- */
.app-root { min-height: 100vh; }
.boot-splash { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); }
.boot-logo, .brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, #625df5, #9b5cf6);
  animation: pulse 1.4s ease-in-out infinite;
}
.brand-mark { animation: none; width: 26px; height: 26px; border-radius: 8px; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-head { padding: 16px; border-bottom: 1px solid var(--line); }
.ws-switch {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  cursor: pointer; font: inherit; color: var(--text); text-align: left;
}
.ws-switch:hover { background: var(--surface-2); border-color: var(--line); }
.ws-logo { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; flex: none; background: linear-gradient(135deg,#625df5,#9b5cf6); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px; }
.ws-name { font-weight: 620; font-size: 14px; }
.record-btn { margin: 14px 16px 8px; }
.nav { padding: 8px 10px; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 14px 8px 6px; display: flex; align-items: center; justify-content: space-between; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 14px; cursor: pointer; border: 0; background: none;
  width: 100%; text-align: left; font-family: inherit;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; flex: none; font-size: 15px; }
.nav-item .count { margin-left: auto; font-size: 11.5px; color: var(--muted); flex: none; }
.space-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.storage-bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 7px 0 5px; }
.storage-bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--header-h); border-bottom: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 40;
}
.searchbox { position: relative; flex: 1; max-width: 460px; }
.searchbox input { padding-left: 34px; background: var(--surface-2); }
.searchbox::before { content: "🔍"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .6; }
.content { padding: 24px; flex: 1; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 3px; }
.mobile-only { display: none; }

/* --- Notifications dropdown ---------------------------------------------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 60;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; animation: modal-in .13s ease-out;
}
.dropdown-menu.wide { min-width: 340px; max-width: 380px; max-height: 440px; overflow: auto; }
.dropdown-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 11px; border: 0;
  background: none; border-radius: var(--radius-sm); font: inherit; font-size: 14px;
  color: var(--text); cursor: pointer; text-align: left;
}
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-sep { height: 1px; background: var(--line); margin: 5px 0; }
.dot-badge { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.notif { display: flex; gap: 10px; padding: 10px 11px; border-radius: var(--radius-sm); cursor: pointer; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: var(--accent-soft); }

/* --- Library grid --------------------------------------------------------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 18px; }
.video-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow .16s, transform .16s, border-color .16s;
  position: relative;
}
.video-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--line-strong); }
.thumb {
  position: relative; aspect-ratio: 16/9; background: #101018; display: block; overflow: hidden; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #2a2a3d, #16161f); color: #6a6a85; font-size: 30px;
}
.thumb .len {
  position: absolute; right: 7px; bottom: 7px; background: rgba(0,0,0,.78); color: #fff;
  font-size: 11.5px; padding: 2px 6px; border-radius: 5px; font-variant-numeric: tabular-nums;
}
.thumb .play-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(10,10,20,.28); opacity: 0; transition: opacity .16s;
}
.thumb:hover .play-overlay { opacity: 1; }
.play-overlay i { width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.94); display: flex; align-items: center; justify-content: center; }
.play-overlay i::after { content: ""; border-left: 13px solid #16161d; border-top: 8px solid transparent; border-bottom: 8px solid transparent; margin-left: 4px; }
.card-meta { padding: 12px 14px 13px; }
.card-title { font-weight: 600; font-size: 14.5px; margin-bottom: 5px; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title:hover { color: var(--accent); }
.card-sub { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.card-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; opacity: 0; transition: opacity .15s; }
.video-card:hover .card-actions, .card-actions:focus-within { opacity: 1; }
.card-actions .btn { background: rgba(255,255,255,.94); border-color: transparent; box-shadow: var(--shadow-sm); color: #16161d; }
.card-select { position: absolute; top: 8px; left: 8px; z-index: 2; width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state.tall { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h1, .empty-state h2 { color: var(--text); margin-bottom: 8px; }
.empty-state .btn { margin-top: 16px; }

.skeleton { background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-card { height: 232px; border-radius: var(--radius); }
.watch-skeleton { max-width: 1000px; margin: 30px auto; padding: 0 20px; }
.sk-player { aspect-ratio: 16/9; border-radius: var(--radius); background: var(--line); animation: shimmer 1.3s infinite; background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%); background-size: 200% 100%; }
.sk-line { height: 15px; margin-top: 16px; border-radius: 5px; background: var(--line); }
.sk-line.short { width: 40%; }

/* --- Stats ---------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 25px; font-weight: 680; margin-top: 5px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.bars { display: flex; align-items: flex-end; gap: 2px; height: 110px; }
.bars > i { flex: 1 1 0; max-width: 46px; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; transition: opacity .12s; }
.bars > i:hover { opacity: 1; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 72px; }
.spark > i { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; min-height: 3px; position: relative; }
.spark > i > b { display: block; height: 100%; background: var(--accent); border-radius: 3px 3px 0 0; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 700; }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* --- Tabs ----------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 10px 14px; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 550;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- Auth screens --------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: linear-gradient(150deg, #4f4ae0, #7c3aed 60%, #a855f7); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; }
.auth-side h2 { font-size: 30px; color: #fff; max-width: 15ch; line-height: 1.2; }
.auth-side ul { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 13px; }
.auth-side li { display: flex; gap: 11px; align-items: flex-start; opacity: .95; font-size: 14.5px; }
.auth-side li::before { content: "✓"; font-weight: 700; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; margin-bottom: 26px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }

/* --- Recorder ------------------------------------------------------------- */
.recorder { max-width: 900px; margin: 0 auto; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.mode {
  border: 2px solid var(--line); border-radius: var(--radius); padding: 18px 14px; text-align: center;
  cursor: pointer; background: var(--surface); transition: border-color .14s, background .14s;
}
.mode:hover { border-color: var(--line-strong); }
.mode.active { border-color: var(--accent); background: var(--accent-soft); }
.mode .ico { font-size: 26px; margin-bottom: 7px; }
.mode .t { font-weight: 620; font-size: 14px; }
.mode .d { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.preview-stage {
  position: relative; aspect-ratio: 16/9; background: #0b0b12; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line);
}
.preview-stage video, .preview-stage canvas { width: 100%; height: 100%; object-fit: contain; }
.preview-stage .placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #6a6a85; gap: 8px; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: blink 1.1s infinite; flex: none; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.rec-status { position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.7); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-variant-numeric: tabular-nums; }

.countdown-overlay {
  position: fixed; inset: 0; z-index: 9500; background: rgba(10,10,18,.9);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.countdown-num { font-size: 130px; font-weight: 750; animation: count-pop .85s ease-out; }
@keyframes count-pop { from { transform: scale(.55); opacity: .2; } to { transform: scale(1); opacity: 1; } }

.rec-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); margin-top: 14px;
}
.upload-progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.upload-progress > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .25s; }

.draw-palette { display: flex; gap: 6px; align-items: center; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.active { border-color: var(--text); transform: scale(1.12); }

/* --- Video player --------------------------------------------------------- */
.player {
  position: relative; background: #000; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16/9; width: 100%; user-select: none;
}
.player.fullscreen, .player:fullscreen { border-radius: 0; aspect-ratio: auto; height: 100%; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.player-center {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.big-play {
  width: 72px; height: 72px; border-radius: 50%; background: rgba(255,255,255,.94);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 26px rgba(0,0,0,.4);
  transition: transform .15s, opacity .15s;
}
.big-play::after { content: ""; border-left: 21px solid #101018; border-top: 13px solid transparent; border-bottom: 13px solid transparent; margin-left: 6px; }
.player-center:hover .big-play { transform: scale(1.07); }
.player.playing .big-play { opacity: 0; pointer-events: none; }

.player-controls {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 9px;
  background: linear-gradient(transparent, rgba(0,0,0,.82));
  opacity: 0; transition: opacity .18s; color: #fff;
}
.player:hover .player-controls, .player.paused .player-controls, .player.controls-locked .player-controls { opacity: 1; }
.scrub { position: relative; height: 16px; display: flex; align-items: center; cursor: pointer; }
.scrub-track { position: relative; height: 4px; width: 100%; background: rgba(255,255,255,.28); border-radius: 3px; transition: height .12s; }
.scrub:hover .scrub-track { height: 6px; }
.scrub-buffer { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.32); border-radius: 3px; }
.scrub-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; }
.scrub-knob { position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: #fff; transform: translate(-50%, -50%); opacity: 0; transition: opacity .12s; }
.scrub:hover .scrub-knob { opacity: 1; }
.scrub-marker { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 8px; height: 8px; border-radius: 50%; background: #ffd23f; border: 1px solid rgba(0,0,0,.35); }
.scrub-marker.chapter { width: 3px; height: 12px; border-radius: 1px; background: rgba(255,255,255,.85); }
.scrub-tooltip {
  position: absolute; bottom: 22px; transform: translateX(-50%); background: rgba(0,0,0,.9);
  color: #fff; padding: 3px 8px; border-radius: 5px; font-size: 12px; pointer-events: none;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.player-buttons { display: flex; align-items: center; gap: 4px; margin-top: 3px; }
.pbtn {
  background: none; border: 0; color: #fff; cursor: pointer; padding: 7px; border-radius: 6px;
  font-size: 15px; line-height: 1; display: flex; align-items: center; justify-content: center; min-width: 32px;
}
.pbtn:hover { background: rgba(255,255,255,.17); }
.pbtn.active { color: var(--accent); }
.time-label { font-size: 12.5px; font-variant-numeric: tabular-nums; padding: 0 7px; opacity: .92; }
.volume-wrap { display: flex; align-items: center; }
.volume-wrap input { width: 0; opacity: 0; transition: width .18s, opacity .18s; accent-color: #fff; }
.volume-wrap:hover input, .volume-wrap input:focus { width: 68px; opacity: 1; margin-left: 4px; }
.speed-menu { position: absolute; bottom: 46px; right: 10px; background: rgba(20,20,28,.97); border-radius: 9px; padding: 5px; min-width: 108px; }
.speed-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: #fff; padding: 7px 11px; border-radius: 6px; font: inherit; font-size: 13.5px; cursor: pointer; }
.speed-menu button:hover { background: rgba(255,255,255,.14); }
.speed-menu button.active { color: var(--accent); font-weight: 650; }
.player .cc-box {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 62px; max-width: 82%;
  background: rgba(0,0,0,.78); color: #fff; padding: 6px 13px; border-radius: 7px;
  font-size: clamp(13px, 2vw, 18px); text-align: center; pointer-events: none;
}
.player .chapter-flag { position: absolute; left: 12px; top: 12px; background: rgba(0,0,0,.7); color: #fff; padding: 5px 11px; border-radius: 999px; font-size: 12.5px; }
.reaction-float { position: absolute; bottom: 70px; font-size: 30px; animation: float-up 1.7s ease-out forwards; pointer-events: none; }
@keyframes float-up { 0% { opacity: 1; transform: translateY(0) scale(.7); } 100% { opacity: 0; transform: translateY(-130px) scale(1.35); } }

/* --- Watch page ----------------------------------------------------------- */
.watch-body { background: var(--bg); }
.watch-top {
  height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.watch-brand { display: flex; align-items: center; gap: 9px; font-weight: 650; color: var(--text); }
.watch-brand:hover { text-decoration: none; }
.watch-brand img { height: 26px; width: auto; max-width: 130px; object-fit: contain; }
.watch-top-actions { display: flex; align-items: center; gap: 8px; }
.watch-root { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
.watch-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.watch-title { font-size: 20px; margin: 16px 0 6px; }
.watch-byline { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; flex-wrap: wrap; }
.watch-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.watch-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }
.side-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.side-panel > header { padding: 12px 15px; border-bottom: 1px solid var(--line); font-weight: 650; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.side-body { padding: 14px 15px; max-height: 380px; overflow-y: auto; }
.gate-card { max-width: 400px; margin: 60px auto; text-align: center; }
.cta-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 18px; border-radius: var(--radius); background: var(--accent-soft);
  border: 1px solid var(--accent); margin-top: 16px; flex-wrap: wrap;
}

.comment { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment-body { min-width: 0; flex: 1; }
.comment-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.comment-head .name { font-weight: 620; color: var(--text); }
.comment-head time { color: var(--muted); font-size: 12px; }
.comment-text { font-size: 14px; margin-top: 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-tools { display: flex; gap: 10px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.comment-tools button { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: 12.5px; padding: 0; }
.comment-tools button:hover { color: var(--accent); }
.ts-chip { background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 1px 6px; font-size: 11.5px; font-weight: 650; cursor: pointer; font-variant-numeric: tabular-nums; }
.comment.reply { margin-left: 32px; border-left: 2px solid var(--line); padding-left: 12px; border-bottom: 0; }
.reaction-bar { display: flex; gap: 5px; flex-wrap: wrap; }
.reaction-bar button {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 9px; font-size: 13px; cursor: pointer; display: inline-flex; gap: 4px; align-items: center;
}
.reaction-bar button:hover { border-color: var(--accent); }
.emoji-picker { display: flex; gap: 4px; flex-wrap: wrap; }
.emoji-picker button { font-size: 18px; background: none; border: 0; cursor: pointer; padding: 4px 5px; border-radius: 7px; }
.emoji-picker button:hover { background: var(--surface-2); transform: scale(1.15); }

.transcript-line { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; display: flex; gap: 9px; }
.transcript-line:hover { background: var(--surface-2); }
.transcript-line.active { background: var(--accent-soft); color: var(--accent); }
.transcript-line time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.transcript-line.active time { color: var(--accent); }

.chapter-item { display: flex; gap: 10px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.chapter-item:hover { background: var(--surface-2); }
.chapter-item time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: 12.5px; }

/* --- Annotation editor ---------------------------------------------------- */
.modal.editor-modal { max-width: 1040px; }
.editor-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
/* Cap the stage by width so the 16:9 ratio holds and the panels below stay
   visible without scrolling the dialog. */
.editor .player { max-width: min(100%, calc(46vh * 16 / 9)); margin: 0 auto; }
.editor-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 14px; align-items: start; }
.ov-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13.5px; border: 1px solid transparent;
}
.ov-row:hover { background: var(--surface-2); }
.ov-row.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.overlay-layer .ov { pointer-events: none; }
.overlay-layer .ov-link { pointer-events: auto; }
.nav-more {
  margin-left: 4px; padding: 0 4px; border-radius: 4px; color: var(--muted);
  opacity: 0; font-size: 15px; line-height: 1;
}
.nav-item:hover .nav-more { opacity: 1; }
.nav-more:hover { background: var(--line); color: var(--text); }

@media (max-width: 780px) {
  .editor-grid { grid-template-columns: 1fr; }
}

/* --- Copy field ----------------------------------------------------------- */
.copy-field { display: flex; gap: 8px; }
.copy-field input { font-size: 13px; background: var(--surface-2); }
.embed-body { background: #000; }

/* --- Settings ------------------------------------------------------------- */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 26px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 78px; }
.settings-max { max-width: 640px; }
.section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.section:first-child { padding-top: 0; }
.section:last-child { border-bottom: 0; }
.section h3 { margin-bottom: 4px; }
.section > .hint { margin-bottom: 14px; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 1080px) {
  .watch-layout { grid-template-columns: 1fr; }
  .watch-side { position: static; }
}
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
}
@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 84vw; max-width: 300px; z-index: 200;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(10,10,20,.45); z-index: 150; }
  .mobile-only { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 0 14px; }
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
  .mode-grid { grid-template-columns: 1fr; }
  .watch-root { padding: 14px 14px 48px; }
  .modal { max-height: 92vh; }
}
@media (max-width: 480px) {
  .video-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .countdown-num { font-size: 92px; }
}

@media print { .sidebar, .topbar, .player-controls { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
