/* ───────────────────────────────────────────────────────────
   ViewKill — design tokens & base styles
   Dark base with three preset directions: calm / graphite / editorial
   ─────────────────────────────────────────────────────────── */

:root {
  /* base palette — warm graphite */
  --bg-0: #0d0e10;            /* page background */
  --bg-1: #14161a;            /* card surface */
  --bg-2: #1a1d22;            /* raised surface (hover, focus) */
  --bg-3: #23262c;            /* input bg, deep hover */
  --bg-modal: rgba(8, 9, 11, 0.72);

  --line-1: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.10);
  --line-3: rgba(255, 255, 255, 0.18);

  --fg-1: #f4f5f7;            /* primary text */
  --fg-2: rgba(244, 245, 247, 0.66);
  --fg-3: rgba(244, 245, 247, 0.42);
  --fg-4: rgba(244, 245, 247, 0.26);

  /* status palette (muted but legible on dark) */
  --st-up:    oklch(0.76 0.14 152);  /* растёт */
  --st-flat:  oklch(0.70 0.01 250);  /* стабильно */
  --st-down:  oklch(0.78 0.13 78);   /* затухает */
  --st-dead:  oklch(0.62 0.16 24);   /* мёртво */
  --st-hot:   oklch(0.74 0.18 38);   /* hot */
  --st-fire:  oklch(0.74 0.20 30);   /* onFire */
  --st-fresh: oklch(0.80 0.14 195);  /* fresh */

  --accent: #5B8DEF;
  --accent-soft: color-mix(in oklch, var(--accent) 18%, transparent);
  --accent-fg: #0d0e10;

  /* typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Geist", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Geist Mono", Menlo, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* density */
  --row-pad-y: 14px;
  --row-gap: 16px;
  --thumb-w: 152px;

  --shadow-pop: 0 1px 0 rgba(255,255,255,0.04) inset, 0 18px 60px rgba(0,0,0,0.6);
}

/* preset: graphite — почти бесцветный, плотный */
.preset-graphite {
  --accent: #d8dadc;
  --accent-fg: #0d0e10;
  --accent-soft: rgba(216, 218, 220, 0.10);
}

/* preset: editorial — крупная типографика */
.preset-editorial {
  --row-pad-y: 22px;
  --row-gap: 24px;
}

/* density */
.density-compact {
  --row-pad-y: 9px;
  --row-gap: 12px;
  --thumb-w: 124px;
}
.density-comfy {
  --row-pad-y: 18px;
  --row-gap: 20px;
  --thumb-w: 168px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--fg-1);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "ss02", "cv01";
}

/* tabular numbers everywhere they appear */
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

button {
  font-family: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
}
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

input, textarea, select {
  font-family: inherit;
  color: inherit;
}

::selection { background: var(--accent-soft); color: var(--fg-1); }

/* scrollbars — slim */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  border: 2px solid var(--bg-0);
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); border: 2px solid var(--bg-0); background-clip: content-box; }

/* ─── App shell ─────────────────────────────────────────── */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 32px;
  background: color-mix(in oklch, var(--bg-0) 86%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--line-1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
}
.brand-clickable {
  padding: 4px 8px 4px 4px;
  margin: -4px -8px -4px -4px;
  border-radius: 9px;
  transition: background 0.15s ease;
}
.brand-clickable:hover { background: var(--bg-1); }
.brand-clickable:active { transform: scale(0.98); }

.crumb-home {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px 5px 7px;
  margin: -5px 0 -5px -8px;
  border-radius: 7px;
  color: var(--fg-2);
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}
.crumb-home:hover {
  background: var(--bg-2);
  color: var(--fg-1);
}
.brand-mark {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: -0.02em;
}
.brand-mark-glyph { display: block; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-3);
  font-size: 13px;
}
.crumbs button {
  color: var(--fg-2);
}
.crumbs button:hover { color: var(--fg-1); }
.crumbs .sep { color: var(--fg-4); }

.topbar-spacer { flex: 1; }

.topbar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--fg-2);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
}
.topbar-status .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--st-up);
  box-shadow: 0 0 0 0 var(--st-up);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--st-up) 50%, transparent); }
  70% { box-shadow: 0 0 0 6px color-mix(in oklch, var(--st-up) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .topbar-status .pulse { animation: none; }
}

/* ─── Main layout ───────────────────────────────────────── */

.main {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 36px 32px 80px;
  animation: pageIn 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .main { animation: none; }
}

.preset-editorial .main {
  max-width: 1180px;
  padding-top: 56px;
}

.section-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.preset-editorial .section-title { font-size: 28px; }

.section-sub {
  color: var(--fg-3);
  font-size: 13px;
  margin: 0 0 24px;
}

/* ─── Search ────────────────────────────────────────────── */

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 480px;
}
.search-input {
  width: 100%;
  height: 36px;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: 9px;
  padding: 0 12px 0 34px;
  color: var(--fg-1);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.search-input::placeholder { color: var(--fg-3); }
.search-input:focus {
  background: var(--bg-2);
  border-color: var(--line-3);
}
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-3);
  pointer-events: none;
}
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--fg-3);
}
.search-clear:hover { background: var(--bg-3); color: var(--fg-1); }
.kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--fg-3);
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: 4px;
  pointer-events: none;
}

/* ─── Folder card (home) ────────────────────────────────── */

.folders-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 8px;
}
.preset-editorial .folders-grid {
  grid-template-columns: 1fr;
  gap: 18px;
}

.folder-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color 0.22s ease, transform 0.22s cubic-bezier(0.2,0.8,0.2,1), background 0.22s ease, box-shadow 0.22s ease;
  text-align: left;
  width: 100%;
}
.folder-card:hover {
  border-color: var(--line-3);
  background: var(--bg-2);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}
.folder-card:active { transform: translateY(0); }

.folder-card.archived {
  opacity: 0.55;
}

/* Pinned folder: subtle accent border tint */
.folder-card.pinned {
  border-color: color-mix(in oklab, var(--line-2) 70%, var(--accent) 30%);
}
.folder-card.pinned:hover {
  border-color: color-mix(in oklab, var(--line-3) 50%, var(--accent) 50%);
}

/* Pin toggle in card corner */
.folder-pin-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--fg-3);
  background: transparent;
  border: 1px solid transparent;
  opacity: 0;
  transform: translateY(-1px);
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  z-index: 1;
}
.folder-card:hover .folder-pin-btn,
.folder-pin-btn:focus-visible,
.folder-pin-btn.active {
  opacity: 1;
}
.folder-pin-btn:hover {
  background: var(--bg-3);
  border-color: var(--line-2);
  color: var(--fg-1);
}
.folder-pin-btn.active {
  color: var(--accent);
  background: color-mix(in oklab, var(--bg-1) 70%, var(--accent) 12%);
  border-color: color-mix(in oklab, var(--line-2) 60%, var(--accent) 40%);
}
.folder-pin-btn.active:hover {
  background: color-mix(in oklab, var(--bg-2) 60%, var(--accent) 18%);
}

.folder-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-right: 30px; /* reserve space for the pin toggle in the card corner */
}

/* Folder sections (Pinned / All) on the home screen */
.folders-section + .folders-section { margin-top: 32px; }
.folders-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.folders-section-head svg { color: var(--fg-3); }
.folders-section-pinned .folders-section-head { color: var(--accent); }
.folders-section-pinned .folders-section-head svg { color: var(--accent); }
.folders-section-count {
  color: var(--fg-4);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  margin-left: 2px;
}
.folder-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.folder-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.folder-meta {
  display: flex;
  gap: 16px;
  color: var(--fg-3);
  font-size: 12px;
}
.folder-meta strong {
  display: block;
  color: var(--fg-1);
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.folder-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.thumbs-row {
  display: flex;
  gap: 4px;
}
.thumbs-row .thumb-mini {
  width: 44px;
  height: 28px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-3);
  flex-shrink: 0;
}
.thumbs-row .thumb-mini img { width: 100%; height: 100%; object-fit: cover; }
.thumbs-row .thumb-overflow {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--bg-3);
  display: grid;
  place-items: center;
  color: var(--fg-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.spark-cell {
  flex: 1;
  min-width: 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* ─── Verdict badges ────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge-arrow { display: inline-flex; width: 12px; height: 12px; }

.badge-up    { color: var(--st-up);    background: color-mix(in oklch, var(--st-up) 13%, transparent); }
.badge-flat  { color: var(--st-flat);  background: color-mix(in oklch, var(--st-flat) 13%, transparent); }
.badge-down  { color: var(--st-down);  background: color-mix(in oklch, var(--st-down) 13%, transparent); }
.badge-dead  { color: var(--st-dead);  background: color-mix(in oklch, var(--st-dead) 14%, transparent); }
.badge-na    { color: var(--fg-3);     background: var(--bg-3); }

.badge-fresh    { color: var(--st-fresh); background: color-mix(in oklch, var(--st-fresh) 12%, transparent); }
.badge-veryfresh{ color: var(--st-fresh); background: color-mix(in oklch, var(--st-fresh) 18%, transparent); }
.badge-hot      { color: var(--st-hot);   background: color-mix(in oklch, var(--st-hot) 14%, transparent); }
.badge-fire     { color: #fff;            background: linear-gradient(180deg, oklch(0.74 0.20 30), oklch(0.62 0.20 30)); }

/* ─── Folder screen ─────────────────────────────────────── */

.folder-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.folder-title {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 4px;
}
.preset-editorial .folder-title { font-size: 38px; }
.folder-title-dot {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
}
.folder-title-input {
  font: inherit;
  background: transparent;
  border: 0;
  outline: 0;
  border-bottom: 2px solid var(--accent);
  color: inherit;
  padding: 0;
  width: 100%;
}

.folder-sub {
  color: var(--fg-3);
  font-size: 13px;
}

.folder-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ─── Velocity summary block ────────────────────────────── */

.velocity-block {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  padding: 24px 26px;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  margin-bottom: 18px;
}
.preset-editorial .velocity-block {
  padding: 32px 36px;
}
.velocity-series {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg-2);
  font-size: 12px;
  margin-bottom: 14px;
}
.velocity-series .series-name { color: var(--fg-1); font-weight: 500; }
.velocity-headline {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.velocity-value {
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.preset-editorial .velocity-value { font-size: 52px; }
.velocity-unit {
  color: var(--fg-3);
  font-size: 14px;
}
.velocity-delta {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 14px;
}
.velocity-delta.up { color: var(--st-up); }
.velocity-delta.down { color: var(--st-down); }
.velocity-delta.dead { color: var(--st-dead); }

.velocity-sparkbox {
  width: 220px;
  align-self: center;
}

.velocity-growth {
  margin-top: 10px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.velocity-growth-label {
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}
.velocity-growth-label::after {
  content: "·";
  margin-left: 8px;
  color: var(--fg-3);
  opacity: 0.5;
}
.velocity-growth-value {
  color: var(--st-up);
  font-weight: 600;
  font-size: 14px;
}
.velocity-growth-unit {
  color: var(--fg-2);
}
.preset-editorial .velocity-growth { margin-top: 14px; }
.preset-editorial .velocity-growth-value { font-size: 15px; }

/* animated folder-settings panel */
.folder-settings-anim {
  overflow: hidden;
  animation: settingsIn 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes settingsIn {
  from { opacity: 0; transform: translateY(-6px); max-height: 0; }
  to   { opacity: 1; transform: translateY(0); max-height: 400px; }
}
@media (prefers-reduced-motion: reduce) {
  .folder-settings-anim { animation: none; }
}

/* ─── Tabs ──────────────────────────────────────────────── */

.tabs-wrap {
  position: relative;
  margin-bottom: 14px;
}
.tabs-wrap::before,
.tabs-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 6px; /* leave room for slim scrollbar at the bottom */
  width: 32px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.tabs-wrap::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg-0), transparent);
}
.tabs-wrap::after {
  right: 0;
  background: linear-gradient(-90deg, var(--bg-0), transparent);
}
.tabs-wrap.has-overflow-left::before { opacity: 1; }
.tabs-wrap.has-overflow-right::after { opacity: 1; }
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scroll-behavior: smooth;
  border-bottom: 1px solid var(--line-1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.20) transparent;
  padding-bottom: 2px;
}
.tabs::-webkit-scrollbar {
  height: 5px;
  background: transparent;
}
.tabs::-webkit-scrollbar-track { background: transparent; }
.tabs::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.18);
  border-radius: 3px;
  border: 0;
  transition: background 0.15s ease;
}
.tabs::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); }
.tab {
  position: relative;
  padding: 10px 14px;
  white-space: nowrap;
  color: var(--fg-3);
  font-size: 13px;
  border-radius: 0;
  transition: color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab:hover { color: var(--fg-2); }
.tab.active {
  color: var(--fg-1);
}
.tab.active::after {
  content: "";
  position: absolute;
  left: 14px; right: 14px;
  bottom: -1px; height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.tab .tab-dot {
  width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0;
}

/* ─── Window switcher (1d / 3d / ...) ───────────────────── */

.window-switch {
  display: inline-flex;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: 9px;
  padding: 2px;
}
.window-switch button {
  padding: 6px 12px;
  font-size: 12px;
  color: var(--fg-3);
  border-radius: 7px;
  transition: color 0.15s ease, background 0.15s ease;
}
.window-switch button:hover { color: var(--fg-1); }
.window-switch button.active {
  background: var(--bg-3);
  color: var(--fg-1);
}

/* ─── Charts row ────────────────────────────────────────── */

.charts-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}
.chart-card {
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chart-card-solo {
  padding: 20px 22px;
}
.chart-card.tall { grid-row: span 2; }
.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.chart-title {
  font-size: 12px;
  color: var(--fg-3);
  font-weight: 500;
  letter-spacing: 0;
}
.chart-area {
  flex: 1;
  min-height: 220px;
}
.chart-area.short { min-height: 160px; }
.chart-swap {
  animation: chartFade 280ms ease;
}
@keyframes chartFade {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .chart-swap { animation: none; }
}

/* segmented toggle in chart card head */
.seg-toggle {
  display: inline-flex;
  background: var(--bg-3);
  border-radius: 7px;
  padding: 2px;
  gap: 0;
}
.seg-toggle button {
  position: relative;
  padding: 5px 11px;
  font-size: 12px;
  color: var(--fg-3);
  border-radius: 5px;
  transition: color 0.15s ease, background 0.18s ease;
  white-space: nowrap;
}
.seg-toggle button:hover { color: var(--fg-1); }
.seg-toggle button.active {
  background: var(--bg-1);
  color: var(--fg-1);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 2px 6px rgba(0,0,0,0.3);
}

/* empty folder state — inline, low-key */
.folder-empty {
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  padding: 22px 24px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 12px;
  color: var(--fg-2);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.legend-item:hover { background: var(--bg-2); }
.legend-item.off { opacity: 0.35; }
.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ─── Toolbar over video list ───────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-count {
  font-size: 13px;
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}
.toolbar-count strong { color: var(--fg-1); font-weight: 600; }
.toolbar-spacer { flex: 1; }

.chips {
  display: inline-flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  color: var(--fg-2);
  font-size: 12px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { background: var(--bg-2); color: var(--fg-1); }
.chip.active {
  background: var(--accent-soft);
  border-color: color-mix(in oklch, var(--accent) 35%, transparent);
  color: var(--accent);
}

/* ─── Video list ────────────────────────────────────────── */

.video-list {
  display: flex;
  flex-direction: column;
}
.video-row {
  display: grid;
  grid-template-columns: auto var(--thumb-w) 1fr auto;
  gap: 18px;
  padding: var(--row-pad-y) 16px;
  margin: 0 -16px;
  border-top: 1px solid var(--line-1);
  border-radius: 10px;
  cursor: pointer;
  align-items: center;
  transition: background 0.12s ease;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}
.video-row .video-title,
.video-row .channel {
  user-select: text;
  -webkit-user-select: text;
}
.video-row + .video-row { border-top: 1px solid var(--line-1); }
.video-row:hover {
  background: rgba(255,255,255,0.025);
  border-top-color: transparent;
}
.video-row:hover + .video-row { border-top-color: transparent; }
.video-row.selected {
  background:
    linear-gradient(90deg, var(--accent-soft) 0%, transparent 75%),
    rgba(255,255,255,0.015);
  border-top-color: transparent;
}
.video-row.selected + .video-row { border-top-color: transparent; }
.video-row.selected::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 14%;
  bottom: 14%;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.video-thumb-wrap {
  position: relative;
  width: var(--thumb-w);
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-3);
  flex-shrink: 0;
}
.video-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.video-duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 5px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: #fff;
  background: rgba(0,0,0,0.78);
  border-radius: 3px;
  letter-spacing: -0.01em;
}

.video-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.video-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--fg-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.005em;
}
.density-compact .video-title { font-size: 13.5px; -webkit-line-clamp: 1; }
.preset-editorial .video-title { font-size: 16px; -webkit-line-clamp: 2; }

.video-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--fg-3);
  flex-wrap: wrap;
}
.video-meta-row .channel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--fg-2);
}
.video-meta-row .channel.music::before {
  content: "♪";
  color: var(--st-fresh);
  font-size: 11px;
}
.video-meta-row .channel.topic::before {
  content: "♪";
  color: var(--fg-3);
  font-size: 11px;
}
.video-meta-row .sep {
  color: var(--fg-4);
}

.video-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.video-stats .views {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.video-stats .vph {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.video-row-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.video-row:hover .video-row-actions { opacity: 1; }
/* Keep the actions (and the popover anchored inside them) visible while a menu
   is open, even after the cursor leaves the row — otherwise the fading opacity
   takes the popover with it and lower menu items become unclickable. */
.video-row-actions.menu-open { opacity: 1; }

/* ─── Add video form ────────────────────────────────────── */

.add-block {
  margin-top: 28px;
  padding: 18px;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
}
.add-tabs {
  display: inline-flex;
  margin-bottom: 14px;
  background: var(--bg-3);
  padding: 2px;
  border-radius: 8px;
}
.add-tabs button {
  padding: 5px 14px;
  font-size: 12px;
  border-radius: 6px;
  color: var(--fg-3);
  white-space: nowrap;
}
.add-tabs button.active { background: var(--bg-1); color: var(--fg-1); }

.add-row {
  display: flex;
  gap: 10px;
}
.input-text {
  flex: 1;
  height: 36px;
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--fg-1);
  font-size: 13px;
  outline: none;
}
.input-text:focus { border-color: var(--line-3); }

.textarea {
  width: 100%;
  min-height: 120px;
  background: var(--bg-3);
  border: 1px solid var(--line-1);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--fg-1);
  font-size: 13px;
  font-family: var(--font-mono);
  resize: vertical;
  outline: none;
}
.textarea:focus { border-color: var(--line-3); }

/* ─── Buttons ───────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { background: color-mix(in oklch, var(--accent) 88%, white); }
.btn-secondary {
  background: var(--bg-2);
  border-color: var(--line-1);
  color: var(--fg-1);
}
.btn-secondary:hover { background: var(--bg-3); border-color: var(--line-3); }
.btn-ghost {
  color: var(--fg-2);
  height: 32px;
  padding: 0 10px;
}
.btn-ghost:hover { background: var(--bg-2); color: var(--fg-1); }
.btn-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--fg-3);
}
.btn-icon:hover { background: var(--bg-3); color: var(--fg-1); }
.btn-danger {
  background: var(--st-dead);
  color: white;
}
.btn-danger:hover { background: color-mix(in oklch, var(--st-dead) 85%, black); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

.spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Boot loader: equalizer bars (rising-chart motif) ─── */
.vk-loader { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.vk-loader-label { color: var(--fg-3); font-size: 13px; }
.vk-bars { display: flex; align-items: flex-end; gap: 6px; height: 44px; }
.vk-bars span {
  width: 7px; height: 100%; border-radius: 4px; background: var(--accent);
  transform-origin: bottom; animation: vkbar 1.05s ease-in-out infinite;
}
.vk-bars span:nth-child(2) { animation-delay: .14s; }
.vk-bars span:nth-child(3) { animation-delay: .28s; }
.vk-bars span:nth-child(4) { animation-delay: .42s; }
@keyframes vkbar { 0%, 100% { transform: scaleY(.28); opacity: .55; } 50% { transform: scaleY(1); opacity: 1; } }

/* ─── Archive section ───────────────────────────────────── */

.disclosure {
  margin-top: 36px;
}
.disclosure-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line-1);
  cursor: pointer;
  color: var(--fg-2);
  font-size: 13px;
  width: 100%;
  text-align: left;
}
.disclosure-head:hover { color: var(--fg-1); }
.disclosure-head .chev {
  transition: transform 0.2s ease;
  color: var(--fg-3);
}
.disclosure.open .disclosure-head .chev {
  transform: rotate(90deg);
}
.disclosure-head .summary {
  margin-left: auto;
  color: var(--fg-3);
  font-size: 12px;
}
.disclosure-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.22s ease;
  opacity: 0;
}
.disclosure-body > * {
  min-height: 0;
  overflow: hidden;
}
.disclosure.open .disclosure-body {
  grid-template-rows: 1fr;
  opacity: 1;
}
.disclosure.open .disclosure-body > * {
  padding: 8px 0 20px;
}
@media (prefers-reduced-motion: reduce) {
  .disclosure-body { transition: none; }
}

/* ─── Poll log ──────────────────────────────────────────── */

.log-list {
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: 12px;
}
.log-row {
  display: grid;
  grid-template-columns: 88px 16px 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 7px 14px;
  border-radius: 6px;
}
.log-row:hover { background: var(--bg-1); }
.log-row .log-ts { color: var(--fg-3); }
.log-row .log-glyph { display: grid; place-items: center; }
.log-row.ok .log-glyph { color: var(--st-up); }
.log-row.fail .log-glyph { color: var(--st-dead); }
.log-row.retry .log-glyph { color: var(--st-down); }
.log-row .log-title { color: var(--fg-2); font-family: var(--font-sans); font-size: 12px; }
.log-row .log-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--fg-3);
  background: var(--bg-3);
}
.log-row .log-views { color: var(--fg-1); font-variant-numeric: tabular-nums; }

/* ─── Empty / onboarding ────────────────────────────────── */

.empty {
  text-align: center;
  padding: 80px 24px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.empty h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.empty p {
  margin: 0;
  color: var(--fg-3);
  max-width: 420px;
  line-height: 1.55;
}

/* ─── Poll progress banner ──────────────────────────────── */

.poll-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 18px;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--fg-2);
}
.poll-bar {
  flex: 1;
  height: 3px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
}
.poll-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ─── Modal ─────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-modal);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fadein 0.18s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 440px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-pop);
}
.modal h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.modal p {
  margin: 0 0 20px;
  color: var(--fg-2);
  font-size: 13.5px;
  line-height: 1.55;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* toast */
.toast {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 110;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(380px, calc(100vw - 32px));
  padding: 10px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-pop);
  animation: toastin 0.25s ease;
}
.toast-error   { border-color: var(--st-dead); }
.toast-success { border-color: var(--st-up); }
.toast-info    { border-color: var(--accent); }
@keyframes toastin {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast button { color: var(--fg-3); padding: 4px; }

/* misc */
.divider {
  height: 1px;
  background: var(--line-1);
  margin: 24px 0;
}

.dim { color: var(--fg-3); }
.dim-2 { color: var(--fg-4); }

/* preset overrides */
.preset-graphite .video-row.selected {
  background: var(--bg-2);
}
.preset-graphite .chip.active {
  background: var(--bg-3);
  border-color: var(--line-3);
  color: var(--fg-1);
}

/* ════════════════════════════════════════════════════════════════════════
   v2: topbar user menu, avatar, notifications bell, profile screen.
   Ported from the prototype; shares the existing design tokens.
   ════════════════════════════════════════════════════════════════════════ */

/* ─── Topbar cluster + user menu trigger ──────────────────── */
.topbar-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 2px 10px 2px 3px;
  border-radius: 999px;
  border: 1px solid var(--line-1);
  background: var(--bg-1);
  color: var(--fg-2);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.user-menu-trigger:hover,
.user-menu-trigger.open {
  background: var(--bg-2);
  border-color: var(--line-2);
  color: var(--fg-1);
}
.user-menu-name {
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-trigger svg:last-child {
  color: var(--fg-4);
  margin-left: -1px;
}
.flip { transform: rotate(180deg); transition: transform 0.18s ease; }

/* Avatar */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
  flex-shrink: 0;
  letter-spacing: 0.02em;
  position: relative;
}
.avatar.ring {
  box-shadow: 0 0 0 1.5px var(--bg-1), 0 0 0 2.5px color-mix(in oklab, currentColor 0%, var(--line-2));
}
.avatar.admin.show-admin-dot::after {
  content: "";
  position: absolute;
  right: 7%;
  bottom: 7%;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-0);
  box-sizing: border-box;
}
.avatar-initials {
  font-family: var(--font-sans);
  pointer-events: none;
  text-shadow: 0 1px 1px rgba(0,0,0,0.25);
  line-height: 1;
}
.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.avatar.has-image .avatar-initials { display: none; }

/* User menu popover content */
.user-menu-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 12px;
}
.user-menu-head-text { min-width: 0; }
.user-menu-head-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-1);
  letter-spacing: -0.01em;
}
.user-menu-head-role {
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.user-menu-head-role.muted { color: var(--fg-3); }
.user-menu-divider {
  height: 1px;
  background: var(--line-1);
  margin: 2px 4px;
}
.menu-item-trash {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--fg-1);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  background: transparent;
  border: 0;
  transition: background 0.12s ease;
}
.menu-item-trash:hover { background: var(--bg-3); }
.menu-item-trash > span:nth-child(2) { flex: 1; }
.menu-item-trash-count {
  font-size: 11px;
  padding: 1px 7px;
  background: color-mix(in oklab, var(--bg-3) 70%, var(--accent) 16%);
  color: var(--fg-1);
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

/* ─── Auth fields (reused by profile password form) ───────── */
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.auth-field-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
}
.auth-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--bg-1);
  color: var(--fg-1);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color 0.15s ease, background 0.15s ease;
  outline: none;
}
.auth-input:focus {
  border-color: var(--accent);
  background: var(--bg-2);
}
.auth-field-hint {
  font-size: 11.5px;
  color: var(--fg-3);
}

/* ─── Notifications bell ──────────────────────────────────── */
.bell-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-1);
  background: var(--bg-1);
  color: var(--fg-3);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.bell-trigger:hover,
.bell-trigger.open {
  background: var(--bg-2);
  color: var(--fg-1);
  border-color: var(--line-2);
}
.bell-trigger.has-unread {
  color: var(--fg-1);
  border-color: var(--line-2);
}
.bell-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-0);
  letter-spacing: -0.01em;
  line-height: 1;
}
.bell-popover {
  width: 380px;
  max-height: min(560px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
  background: rgba(20, 22, 26, 0.98);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
}
.bell-pop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line-1);
}
.bell-pop-head h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.005em;
}
.bell-pop-head .dim { margin: 2px 0 0; font-size: 12px; }
.bell-empty {
  padding: 48px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.bell-empty p {
  color: var(--fg-3);
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
  max-width: 28ch;
}
.bell-list { overflow-y: auto; flex: 1; padding: 4px 0; }
.bell-group-head {
  padding: 14px 16px 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-4);
}
.bell-group:first-child .bell-group-head { padding-top: 8px; }
.notif-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  padding: 10px 14px;
  cursor: default;
  text-align: left;
  position: relative;
  background: transparent;
  border: 0;
  transition: background 0.12s ease;
}
.notif-row.linked { cursor: pointer; }
.notif-row:hover { background: var(--bg-2); }
.notif-row.unread { background: color-mix(in oklab, var(--bg-1) 60%, var(--accent) 4%); }
.notif-row.unread:hover { background: color-mix(in oklab, var(--bg-2) 70%, var(--accent) 8%); }
.notif-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: transparent;
  transition: background 0.15s ease;
}
.notif-row.tone-danger::before { background: var(--st-dead); }
.notif-row.tone-danger.unread { background: color-mix(in oklab, var(--bg-1) 60%, var(--st-dead) 8%); }
.notif-row.tone-danger.unread:hover { background: color-mix(in oklab, var(--bg-2) 70%, var(--st-dead) 12%); }
.notif-row.tone-hot::before    { background: color-mix(in oklab, var(--st-fire) 70%, transparent); }
.notif-row.tone-fresh::before  { background: color-mix(in oklab, var(--st-fresh) 70%, transparent); }
.notif-row.tone-accent::before { background: color-mix(in oklab, var(--accent) 60%, transparent); }
.notif-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  color: var(--fg-2);
  flex-shrink: 0;
  margin-top: 1px;
}
.notif-row.tone-danger .notif-icon { color: var(--st-dead); background: color-mix(in oklab, var(--bg-3) 60%, var(--st-dead) 14%); }
.notif-row.tone-hot .notif-icon { color: var(--st-fire); background: color-mix(in oklab, var(--bg-3) 60%, var(--st-fire) 14%); }
.notif-row.tone-fresh .notif-icon { color: var(--st-fresh); background: color-mix(in oklab, var(--bg-3) 60%, var(--st-fresh) 14%); }
.notif-row.tone-accent .notif-icon { color: var(--accent); background: color-mix(in oklab, var(--bg-3) 60%, var(--accent) 14%); }
.notif-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-1);
  letter-spacing: -0.005em;
}
.notif-row.read .notif-title { color: var(--fg-2); font-weight: 400; }
.notif-text {
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.notif-ts {
  font-size: 11px;
  color: var(--fg-4);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.notif-dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }

/* ─── Profile screen ──────────────────────────────────────── */
.profile-screen { max-width: 780px; }
.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line-1);
}
.profile-avatar-btn {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  display: inline-block;
  flex-shrink: 0;
  background: transparent;
  border: 0;
}
.profile-avatar-btn .avatar { display: inline-flex; }
.profile-avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.profile-avatar-btn:hover .profile-avatar-overlay,
.profile-avatar-btn:focus-visible .profile-avatar-overlay { opacity: 1; }
.profile-header-main { flex: 1; min-width: 0; }
.profile-name-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.profile-name {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--fg-1);
}
.profile-role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  padding: 3px 8px;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: 6px;
}
.profile-role.admin {
  color: var(--accent);
  background: color-mix(in oklab, var(--bg-1) 70%, var(--accent) 10%);
  border-color: color-mix(in oklab, var(--line-1) 60%, var(--accent) 40%);
}
.profile-sub { margin: 6px 0 0; color: var(--fg-3); font-size: 13px; }
.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line-1);
  border: 1px solid var(--line-1);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 32px;
}
@media (max-width: 720px) { .profile-stats { grid-template-columns: repeat(2, 1fr); } }
.profile-stat {
  background: var(--bg-1);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg-1);
  line-height: 1.1;
}
.profile-stat-label { font-size: 12px; color: var(--fg-3); }
.profile-card {
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.profile-card-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line-1); }
.profile-card-head h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.005em;
}
.profile-card-head .dim { font-size: 12.5px; margin: 0; }
.profile-card-body { padding: 6px 22px 18px; }
.pref-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0;
}
.pref-row.locked { opacity: 0.75; }
.pref-row-text { flex: 1; min-width: 0; }
.pref-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg-1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pref-locked-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  padding: 1px 6px;
  background: var(--bg-3);
  border-radius: 4px;
  font-weight: 400;
}
.pref-hint {
  margin-top: 2px;
  font-size: 12px;
  color: var(--fg-3);
  line-height: 1.5;
  max-width: 50ch;
}
.pref-switch {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pref-switch:disabled { cursor: not-allowed; }
.pref-switch.on { background: var(--accent); border-color: var(--accent); }
.pref-switch-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.pref-switch.on .pref-switch-thumb { transform: translateX(16px); }
.pw-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 6px;
  border-top: 1px dashed var(--line-1);
  margin-top: 4px;
}
.pw-form .auth-field { margin-bottom: 0; }

/* Activity */
.activity-list { display: flex; flex-direction: column; }
.activity-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  padding: 10px 0;
  align-items: center;
  border-top: 1px solid var(--line-1);
}
.activity-row:first-child { border-top: 0; }
.activity-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--fg-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.activity-row.tone-danger .activity-icon { color: var(--st-dead); background: color-mix(in oklab, var(--bg-3) 60%, var(--st-dead) 14%); }
.activity-row.tone-hot .activity-icon { color: var(--st-fire); background: color-mix(in oklab, var(--bg-3) 60%, var(--st-fire) 14%); }
.activity-row.tone-accent .activity-icon { color: var(--accent); background: color-mix(in oklab, var(--bg-3) 60%, var(--accent) 14%); }
.activity-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.activity-title { font-size: 13px; color: var(--fg-1); }
.activity-text {
  font-size: 12px;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-ts { font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Avatar editor modal */
.avatar-editor-preview {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 4px;
  margin-bottom: 8px;
}
.avatar-editor-meta { min-width: 0; }
.avatar-editor-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-1);
  letter-spacing: -0.01em;
}
.avatar-editor-hint { font-size: 12px; margin-top: 2px; }
.avatar-editor-section { margin: 14px 0; }
.avatar-editor-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  margin-bottom: 8px;
}
.avatar-upload {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-3);
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg-1);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.avatar-upload:hover { background: var(--bg-2); border-color: var(--line-3); }
.avatar-editor-error {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--st-dead);
}
.avatar-color-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 8px; }
@media (max-width: 480px) { .avatar-color-grid { grid-template-columns: repeat(5, 1fr); } }
.avatar-color-swatch {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: 2px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}
.avatar-color-swatch:hover { transform: scale(1.08); }
.avatar-color-swatch.active { border-color: #fff; box-shadow: 0 0 0 1.5px var(--bg-0); }
.avatar-color-default {
  background: var(--bg-3);
  color: var(--fg-3);
  border: 1px dashed var(--line-2);
}
.avatar-color-default.active {
  border: 2px solid var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1.5px var(--bg-0);
}

/* ─── Hue picker (folder color) ─────────────────────────────── */
.hue-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hue-swatch {
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0d0e10;
  border: 1.5px solid transparent;
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}
.hue-swatch:hover { transform: scale(1.12); }
.hue-swatch.active {
  border-color: var(--fg-1);
  box-shadow: 0 0 0 1.5px var(--bg-0);
}
.folder-title-dot-btn {
  border: none;
  padding: 0;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.12s ease;
}
.folder-title-dot-btn:hover {
  transform: scale(1.18);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ─── Window picker + range calendar (folder window) ────────── */
.window-picker {
  position: relative;
}
.window-picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-1);
  background: var(--bg-1);
  color: var(--fg-2);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.window-picker-trigger:hover,
.window-picker-trigger.open {
  background: var(--bg-2);
  color: var(--fg-1);
  border-color: var(--line-2);
}
.window-picker-trigger.custom {
  border-color: color-mix(in oklab, var(--line-2) 60%, var(--accent) 40%);
  color: var(--fg-1);
}
.window-picker-trigger svg.flip { transform: rotate(180deg); }
.window-picker-label { line-height: 1; }
.window-picker-pop-anchor {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
}

.cal-popover {
  display: grid;
  grid-template-columns: 160px 1fr;
  background: rgba(20, 22, 26, 0.98);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;
  min-width: 600px;
}
.cal-presets {
  padding: 12px 8px;
  border-right: 1px solid var(--line-1);
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(0,0,0,0.12);
}
.cal-presets-head {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  padding: 4px 10px 10px;
}
.cal-preset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--fg-2);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.cal-preset:hover { background: var(--bg-2); color: var(--fg-1); }
.cal-preset.active {
  background: var(--bg-3);
  color: var(--fg-1);
}
.cal-preset.active svg { color: var(--accent); }
.cal-presets-divider {
  height: 1px;
  background: var(--line-1);
  margin: 6px 6px;
}
.cal-preset-custom { gap: 8px; }
.cal-preset-custom svg { color: var(--fg-3); }
.cal-preset-custom.active svg { color: var(--accent); }

.cal-body {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cal-nav {
  display: flex;
  align-items: center;
  padding: 0 2px;
}
.cal-nav-spacer { flex: 1; }
.cal-months {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.cal-month-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-1);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 10.5px;
  color: var(--fg-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 0;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-cell {
  height: 30px;
  border-radius: 6px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--fg-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s ease, color 0.1s ease;
  position: relative;
}
/* Exclude the selected endpoint: it already has accent bg + accent-fg text;
   the generic hover color (--fg-1, white) on its light accent box reads as a
   washed-out number. The endpoint keeps its own styling on hover. */
.cal-cell:hover:not(:disabled):not(.endpoint) { background: var(--bg-2); color: var(--fg-1); }
.cal-cell.blank { visibility: hidden; }
.cal-cell.future { color: var(--fg-4); cursor: not-allowed; }
.cal-cell.today { color: var(--accent); font-weight: 600; }
.cal-cell.in-range {
  background: var(--accent-soft);
  color: var(--fg-1);
  border-radius: 0;
}
.cal-cell.in-range:first-child,
.cal-cell.in-range.endpoint { border-radius: 6px; }
.cal-cell.endpoint {
  background: var(--accent) !important;
  color: var(--accent-fg);
  font-weight: 600;
}

.cal-foot {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cal-foot-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  min-width: 0;
  flex-wrap: wrap;
}
.cal-foot-label {
  font-size: 10.5px;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.cal-foot-range { color: var(--fg-1); font-weight: 500; }
.cal-foot-count { color: var(--fg-3); }
.cal-foot-hint { color: var(--fg-3); font-style: italic; }
.cal-foot-actions { display: flex; gap: 8px; }

@media (max-width: 680px) {
  .cal-popover { grid-template-columns: 1fr; min-width: 0; width: min(340px, calc(100vw - 20px)); }
  .cal-months { grid-template-columns: 1fr; gap: 12px; }
  /* держим поповер прижатым к правому краю кнопки (она справа в тулбаре):
     left:0 уводил 320px-поповер за правый край экрана (~195px overflow). */
  .window-picker-pop-anchor { right: 0; left: auto; }
}

/* ─── Auth screen (two-panel login/register) ────────────────── */
.ap-screen {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) 1fr;
  background: var(--bg-0);
}
@media (max-width: 860px) {
  .ap-screen { grid-template-columns: 1fr; }
  .ap-brand { display: none; }
}
.ap-brand {
  position: relative;
  padding: 44px 52px 34px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  overflow: hidden;
  border-right: 1px solid var(--line-1);
  background:
    radial-gradient(60% 70% at 18% 4%, color-mix(in oklab, var(--accent) 13%, transparent) 0%, transparent 68%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
}
.ap-brand-hero { display: flex; flex-direction: column; gap: 26px; max-width: 560px; }
.ap-brand-bottom { display: flex; flex-direction: column; gap: 22px; }
.ap-brand-mark {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.ap-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: 0 4px 18px -6px color-mix(in oklab, var(--accent) 70%, transparent);
}
.ap-brand-beta {
  margin-left: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 3px 7px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
}
.ap-tagline {
  font-size: clamp(34px, 3.4vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 600;
  margin: 0;
  max-width: 12em;
  text-wrap: balance;
}
.ap-lede {
  margin: 0;
  font-weight: 400;
  font-size: clamp(15px, 1.25vw, 17px);
  line-height: 1.55;
  letter-spacing: -0.01em;
  color: var(--fg-3);
  max-width: 38ch;
}
.ap-features {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ap-feature {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13.5px;
  color: var(--fg-2);
}
.ap-feature svg { flex: none; color: var(--accent); }
.ap-chart-wrap {
  position: relative;
  width: 100%;
  height: 140px;
  margin-top: 0;
}
.ap-chart { width: 100%; height: 100%; display: block; }
.ap-chart-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}
.ap-chart-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: apPulse 2.2s ease-out infinite;
}
@keyframes apPulse {
  0%   { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(3.4); opacity: 0; }
}
.ap-brand-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--fg-3);
}
.ap-brand-foot .mono { font-family: var(--font-mono); }
.ap-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  overflow-y: auto;
}
.ap-form { width: 100%; max-width: 372px; }
.ap-mini-brand {
  display: none;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 28px;
}
@media (max-width: 860px) { .ap-mini-brand { display: flex; } }
.ap-nav {
  display: flex;
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: 11px;
  padding: 3px;
  margin-bottom: 30px;
}
.ap-nav button {
  flex: 1;
  text-align: center;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-3);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.ap-nav button:hover { color: var(--fg-2); }
.ap-nav button.active { background: var(--bg-3); color: var(--fg-1); }
.ap-head { margin-bottom: 24px; }
.ap-title { font-size: 25px; font-weight: 600; letter-spacing: -0.025em; margin: 0; }
.ap-sub { margin: 7px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--fg-3); }
.ap-field { margin-bottom: 17px; }
.ap-field-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 7px;
}
.ap-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--fg-3);
}
.ap-label-aux {
  font-size: 11.5px;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
}
.ap-label-aux:hover { text-decoration: underline; }
.ap-input-wrap { position: relative; }
.ap-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--bg-1);
  color: var(--fg-1);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
.ap-input::placeholder { color: var(--fg-4); }
.ap-input.has-toggle { padding-right: 44px; }
.ap-input.mono { font-family: var(--font-mono); letter-spacing: 0.06em; }
.ap-input:focus {
  border-color: var(--accent);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ap-field.bad .ap-input { border-color: var(--st-dead); }
.ap-field.bad .ap-input:focus { box-shadow: 0 0 0 3px color-mix(in oklab, var(--st-dead) 22%, transparent); }
.ap-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--fg-3);
  transition: background 0.14s ease, color 0.14s ease;
}
.ap-toggle:hover { background: var(--bg-3); color: var(--fg-1); }
.ap-msg {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 11.5px;
  line-height: 1.4;
  min-height: 14px;
  color: var(--st-dead);
}
.ap-msg:empty { display: none; }
.ap-msg svg { flex: none; }
.ap-strength { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.ap-strength-track { flex: 1; display: flex; gap: 4px; }
.ap-strength-seg { flex: 1; height: 4px; border-radius: 999px; background: var(--bg-3); transition: background 0.2s ease; }
.ap-strength-label { font-size: 11px; font-weight: 500; min-width: 56px; text-align: right; }
.ap-row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 20px; }
.ap-check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--fg-2);
  cursor: pointer;
  user-select: none;
}
.ap-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.ap-check-box {
  width: 17px;
  height: 17px;
  flex: none;
  border-radius: 5px;
  border: 1px solid var(--line-3);
  background: var(--bg-1);
  display: grid;
  place-items: center;
  color: var(--accent-fg);
  transition: background 0.14s ease, border-color 0.14s ease;
}
.ap-check-box svg { opacity: 0; transform: scale(0.6); transition: opacity 0.14s ease, transform 0.14s ease; }
.ap-check input:checked + .ap-check-box { background: var(--accent); border-color: var(--accent); }
.ap-check input:checked + .ap-check-box svg { opacity: 1; transform: scale(1); }
.ap-check input:focus-visible + .ap-check-box { box-shadow: 0 0 0 3px var(--accent-soft); }
.ap-check.bad .ap-check-box { border-color: var(--st-dead); }
.ap-terms { font-size: 12px; line-height: 1.5; color: var(--fg-3); margin: 2px 0 20px; }
.ap-terms a { color: var(--fg-2); text-decoration: underline; text-decoration-color: var(--line-3); }
.ap-terms a:hover { text-decoration-color: var(--fg-2); }
.ap-submit {
  width: 100%;
  height: 46px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.ap-submit:disabled { opacity: 0.6; cursor: default; }
.ap-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--st-dead);
  padding: 10px 12px;
  margin-bottom: 18px;
  border-radius: 9px;
  background: color-mix(in oklab, var(--bg-1) 70%, var(--st-dead) 12%);
  border: 1px solid color-mix(in oklab, var(--line-1) 50%, var(--st-dead) 45%);
}
.ap-banner svg { flex: none; }
.ap-foot { margin-top: 26px; font-size: 13px; color: var(--fg-3); text-align: center; }
.ap-foot-link { color: var(--accent); font: inherit; font-weight: 500; cursor: pointer; }
.ap-foot-link:hover { text-decoration: underline; }
.ap-form > * { animation: apRise 0.5s cubic-bezier(0.22,1,0.36,1) both; }
.ap-form > *:nth-child(2) { animation-delay: 0.04s; }
.ap-form > *:nth-child(3) { animation-delay: 0.08s; }
.ap-form > *:nth-child(4) { animation-delay: 0.12s; }
.ap-form > *:nth-child(5) { animation-delay: 0.16s; }
.ap-form > *:nth-child(6) { animation-delay: 0.20s; }
.ap-form > *:nth-child(7) { animation-delay: 0.24s; }
@keyframes apRise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ap-form > *, .ap-chart-dot::after { animation: none !important; }
}

/* ─── Compare legend (live value table under the chart) ─────── */
.cmp-legend {
  margin-top: 14px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--bg-1);
  overflow: hidden;
}
.cmp-legend-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  border-bottom: 1px solid var(--line-1);
}
.cmp-legend-list {
  max-height: 260px;
  overflow-y: auto;
}
.cmp-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--fg-1);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}
.cmp-legend-row:hover { background: var(--bg-2); }
.cmp-legend-row.off { opacity: 0.4; }
.cmp-legend-row.off .cmp-legend-val { text-decoration: line-through; }
.cmp-legend-swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.cmp-legend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); }
.cmp-legend-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 500; flex-shrink: 0; }
.cmp-legend-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line-1);
  color: var(--fg-3);
}
.cmp-legend-search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg-1);
  font-size: 12.5px;
  font-family: var(--font-sans);
}
.cmp-legend-search input::placeholder { color: var(--fg-4); }
.cmp-legend.pinned {
  border-color: color-mix(in oklab, var(--line-2) 45%, var(--accent) 55%);
}
.cmp-legend-pin {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cmp-legend-pin-time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
.cmp-legend-pin .btn-icon { color: var(--fg-3); padding: 2px; }
.cmp-legend-pin .btn-icon:hover { color: var(--fg-1); }

/* ─── Bulk bar ─────────────────────────────────────────── */
.bulk-bar {
  position: sticky;
  top: 56px; /* below topbar */
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 46px; /* 32px container pad + 14px inner pad */
  margin-inline: -32px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-top-left-radius: var(--r-lg);
  border-top-right-radius: var(--r-lg);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
  box-shadow: 0 1px 0 var(--line-2), 0 6px 14px -8px rgba(0,0,0,.55);
  font-size: 13px;
  margin-bottom: 0;
}
.bulk-count { color: var(--fg-2); white-space: nowrap; }
.bulk-spacer { flex: 1; }

/* ─── Row checkbox ─────────────────────────────────────── */
.row-check {
  width: 18px; height: 18px;
  border: 1.5px solid var(--line-2);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  opacity: .35;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
  color: var(--bg-0);
  padding: 0;
}
.row-check.show, .video-row:hover .row-check, .row-check.checked {
  opacity: 1;
}
.row-check.checked {
  background: var(--accent);
  border-color: var(--accent);
}
@media (hover: none) {
  .row-check { opacity: 1; }
  .video-row-actions { opacity: 1; }
}

/* ─── Selected row highlight ──────────────────────────── */
.video-row.row-checked {
  background: rgba(var(--accent-rgb, 91, 141, 239), 0.08);
  border-color: var(--accent);
}

/* ─── Paused badge ─────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 4px; font-size: 10px; font-weight: 500; vertical-align: middle; margin-left: 8px; }
.badge-paused { background: var(--bg-3); color: var(--fg-3); border: 1px solid var(--line-2); }
.badge-unavail {
  color: var(--st-dead);
  background: color-mix(in oklab, var(--st-dead) 16%, transparent);
  border: 1px solid color-mix(in oklab, var(--st-dead) 35%, transparent);
}
.video-row.paused .badge-unavail { opacity: .7; }

/* ─── Tag filter row ───────────────────────────────────── */
.tag-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  /* tighten the row to the toolbar above it instead of floating below */
  margin-top: -6px;
  margin-bottom: 16px;
  padding: 0;
  flex-wrap: nowrap;        /* label + reset stay fixed; pills wrap internally */
}
.tag-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--fg-3);
  /* divider that separates this dimension from the pills */
  padding-right: 10px;
  border-right: 1px solid var(--line-1);
}
.tag-filter-label svg { color: var(--fg-3); }
.tag-filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;          /* many tags wrap gracefully here, not the whole row */
  flex: 1;
  min-width: 0;
}
.tag-filter-reset {
  flex-shrink: 0;
  align-self: flex-start;   /* stays pinned to first line when pills wrap */
  margin-top: 3px;
  padding: 0;
  background: none;
  border: none;
  color: var(--fg-3);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s;
}
.tag-filter-reset:hover { color: var(--fg-1); }
.tag-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--fg-2);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.tag-filter-pill:hover { border-color: var(--line-3); }
.tag-filter-pill.active { color: var(--fg-1); font-weight: 500; }
.tag-filter-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
/* "+" that opens the create-tag popover, sits at the end of the pills */
.tag-filter-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px dashed var(--line-3);
  background: transparent;
  color: var(--fg-3);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: border-color .15s, color .15s, background .15s;
}
.tag-filter-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in oklab, var(--accent) 10%, transparent);
}

/* ─── Create-tag popover ───────────────────────────────── */
.create-tag { display: flex; flex-direction: column; gap: 10px; padding: 10px; min-width: 200px; }
.create-tag-input {
  width: 100%; box-sizing: border-box;
  padding: 6px 9px; font-size: 13px;
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--fg-1); outline: none;
}
.create-tag-input:focus { border-color: var(--accent); }
.create-tag-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.create-tag-swatch {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  transition: transform .1s;
}
.create-tag-swatch:hover { transform: scale(1.12); }
.create-tag-swatch.on { border-color: var(--fg-1); box-shadow: 0 0 0 2px var(--bg-2); }
.create-tag-warn { font-size: 11px; color: var(--st-dead); }
.create-tag-submit { justify-content: center; }

/* ─── Tag management popover ────────────────────────────── */
.tag-manage { display: flex; flex-direction: column; padding: 6px; min-width: 240px; max-height: 320px; overflow-y: auto; }
.tag-manage-empty { padding: 12px; color: var(--fg-3); font-size: 12px; text-align: center; }
.tag-manage-row { padding: 3px 0; }
.tag-manage-main { display: flex; align-items: center; gap: 8px; }
.tag-manage-dot { width: 13px; height: 13px; border-radius: 50%; border: 1px solid var(--line-3); flex-shrink: 0; cursor: pointer; padding: 0; }
.tag-manage-dot:hover { transform: scale(1.12); }
.tag-manage-name {
  flex: 1; min-width: 0; background: transparent; border: 1px solid transparent;
  border-radius: 6px; padding: 4px 6px; color: var(--fg-1); font: inherit; font-size: 13px;
}
.tag-manage-name:hover { border-color: var(--line-2); }
.tag-manage-name:focus { border-color: var(--accent); background: var(--bg-2); outline: none; }
.tag-manage-count { color: var(--fg-4); font-size: 11px; flex-shrink: 0; }
.tag-manage .btn-icon { width: 24px; height: 24px; border-radius: 6px; }
.tag-manage .btn-icon.danger { color: var(--st-dead); }
.tag-manage .btn-icon.danger:hover { background: var(--st-dead); color: #fff; }
.tag-manage-del { opacity: 0.55; }
.tag-manage-row:hover .tag-manage-del { opacity: 1; }
.tag-manage-confirm { display: flex; gap: 2px; flex-shrink: 0; }
.tag-manage-palette { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 2px 4px 25px; }

/* ─── Video tags row ───────────────────────────────────── */
.video-tags-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* ─── Tag pill (chip on a video row) ───────────────────── */
/* Small colored label. --tag-color (per-tag hex) tints dot + bg + border via
   color-mix so each chip reads as "its color" without shouting. */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px 1px 5px;
  border-radius: 20px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--fg-2);
  background: color-mix(in oklch, var(--tag-color, var(--accent)) 12%, transparent);
  border: 1px solid color-mix(in oklch, var(--tag-color, var(--accent)) 26%, transparent);
  max-width: 160px;
  user-select: none;
}
.tag-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--tag-color, var(--accent));
}
.tag-pill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-pill-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  margin-left: 1px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-4);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.tag-pill-x:hover {
  color: var(--fg-1);
  background: rgba(255, 255, 255, 0.10);
}

/* ─── Tag picker (inside the glass Popover; don't redraw the panel) ───── */
.tag-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Search: borderless field that sits on --bg-3, no native focus ring. */
.tag-picker-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--bg-3);
  border: 1px solid transparent;
  color: var(--fg-3);
  transition: border-color 0.15s;
}
.tag-picker-search:focus-within {
  border-color: var(--accent-soft);
  color: var(--fg-2);
}
.tag-picker-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--fg-1);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 0;
}
.tag-picker-search input::placeholder { color: var(--fg-4); }

/* List */
.tag-picker-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 260px;
  overflow-y: auto;
}

/* Menu rows (toggle + create share the same hit-area shape). */
.tag-picker-row,
.tag-picker-create {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-2);
  font-family: var(--font-sans);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.tag-picker-row:hover,
.tag-picker-create:hover {
  background: var(--bg-2);
  color: var(--fg-1);
}

/* Checkbox-like state indicator. */
.tag-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border-radius: 4px;
  border: 1px solid var(--line-3);
  background: transparent;
  color: var(--accent-fg);
  transition: background 0.12s, border-color 0.12s;
}
.tag-check.on {
  background: var(--accent);
  border-color: var(--accent);
}
.tag-check.partial {
  border-color: var(--line-3);
}
.tag-check-dash {
  width: 7px;
  height: 2px;
  border-radius: 1px;
  background: var(--fg-2);
}

/* Color dot in a row — slightly bigger than the chip dot for scannability. */
.tag-picker-row .tag-pill-dot {
  width: 8px;
  height: 8px;
}
.tag-picker-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Create row — accent icon signals "new". */
.tag-picker-create { color: var(--fg-2); }
.tag-picker-create svg { color: var(--accent); flex-shrink: 0; }
.tag-picker-create span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty state */
.tag-picker-empty {
  padding: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fg-3);
}

/* ─── Paused row dimming ───────────────────────────────── */
/* Paused state is shown once, by «‖ пауза» in the rate slot (the rate is
   meaningless on a frozen history). The dimmed thumbnail + muted title tie the
   whole row to that single label so it reads "asleep" as a unit — no extra badge. */
.video-row.paused .video-thumb-wrap { opacity: 0.5; }
.video-row.paused .video-title { color: var(--fg-2); }
.paused-vph { color: var(--fg-3) !important; display: inline-flex; align-items: center; gap: 3px; }

/* ============================================================
   ===== MOBILE (≤720px) =====
   Единый телефонный брейкпоинт. Десктоп-правила выше не трогаем.
   ============================================================ */

/* базовые (вне media-query): таб-бар скрыт на десктопе */
.bottom-nav { display: none; }

@media (max-width: 720px) {
  /* — Каркас — */
  .topbar { gap: 10px; padding: 11px 14px; }
  .topbar-status {
    /* пилюля статуса → компактная точка-индикатор */
    gap: 0; padding: 0; border: 0; background: transparent;
  }
  .topbar-status > span:not(.pulse) { display: none; }
  .topbar .brand span { display: none; } /* остаётся только бренд-иконка */
  .crumbs { font-size: 12px; gap: 6px; min-width: 0; overflow: hidden; }
  .crumbs button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .main { padding: 16px 14px 96px; } /* нижний отступ под таб-бар */
  .preset-editorial .main { padding-top: 20px; }

  /* — Нижний таб-бар — */
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: color-mix(in oklch, var(--bg-0) 92%, transparent);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-top: 1px solid var(--line-1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .bn-tab {
    position: relative;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 9px 0 7px;
    font-size: 10px; color: var(--fg-3);
    background: none; border: 0; cursor: pointer;
  }
  .bn-tab.active { color: var(--fg-1); }
  .bn-glyph { font-size: 16px; line-height: 1; }
  .bn-badge {
    position: absolute; top: 4px; left: 56%;
    min-width: 14px; height: 14px; padding: 0 3px;
    font-size: 9px; line-height: 14px; text-align: center;
    color: #fff; background: var(--st-dead, #d2453f); border-radius: 7px;
  }

  /* — Плотный ряд видео (без превью, 2 колонки) — */
  .video-row {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 10px 10px;
    margin: 0 -10px;
  }
  .video-row .video-thumb-wrap { display: none; }   /* превью убираем */
  .video-row .row-check { display: none; }           /* чекбокс по наведению не нужен */
  .video-title { -webkit-line-clamp: 1; font-size: 13.5px; }
  .video-meta-row { gap: 7px; font-size: 11px; }
  .video-stats { align-items: flex-end; }
  /* действия ряда: всегда видимы (нет hover на тач), компактны */
  .video-row .video-row-actions { opacity: 1; }
  /* в ряду на телефоне видна только кнопка «ещё» (⋮) */
  .video-row .video-row-actions > .btn-icon { display: none; }
  .video-row .video-row-actions > .btn-icon[aria-label="Ещё действия"] { display: inline-flex; }

  /* — Строка пина под агрегатным графиком прироста — */
  .pin-bar {
    display: flex; align-items: center; gap: 8px;
    margin: 10px 0 4px; padding: 6px 8px;
    background: var(--bg-1); border: 1px solid var(--line-1); border-radius: 8px;
    font-size: 11px; color: var(--fg-2);
  }
  .pin-bar .pin-time {
    font-family: var(--font-mono, ui-monospace, monospace); color: var(--fg-1);
    display: inline-flex; align-items: center; gap: 4px;
  }
  .pin-bar .pin-step, .pin-bar .pin-clear {
    width: 26px; height: 26px; display: grid; place-items: center;
    border-radius: 6px; background: var(--bg-2); color: var(--fg-2); border: 0; cursor: pointer;
  }
  .pin-bar .pin-spacer { flex: 1; }

  /* — Bulk-операции: нижний лист над таб-баром — */
  .bulk-bar {
    position: fixed;
    top: auto;                /* сбросить desktop sticky top */
    left: 8px; right: 8px;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)); /* над таб-баром */
    z-index: 41;
    flex-wrap: wrap;
    margin-inline: 0;         /* убрать desktop bleed (-32px) */
    padding: 10px 12px;       /* desktop 46px паддинг ломал перенос */
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  }
  .bulk-bar .bulk-spacer { display: none; }
  .bulk-bar .btn span { display: none; }  /* на узком — только иконки действий */
  .bulk-bar .bulk-count { flex: 1; }

  /* — Home: карточки папок в один столбец — */
  .folders-grid { grid-template-columns: 1fr; gap: 14px; }

  /* — Profile: всё в столбец — */
  .profile-screen { max-width: 100%; }
  .profile-header { flex-direction: column; align-items: flex-start; gap: 14px; }
  .profile-name { font-size: 22px; }

  /* — Trash: ряды переносят действия на отдельную строку — */
  .trash-row { flex-wrap: wrap; }
  .trash-row .trash-actions { width: 100%; }
  .trash-row .trash-actions .btn { flex: 1; white-space: nowrap; }

  /* — Notifications (полноэкранный список из таба) — */
  .notifications-screen .notif-list { display: flex; flex-direction: column; gap: 2px; }

  /* — Auth: брендинг-панель прячем, форма во всю ширину
       (базовое .ap-brand ниже их 860px-правила переопределяет display — глушим тут). — */
  .ap-brand { display: none; }
  .ap-screen { grid-template-columns: 1fr; }

  /* — Tweaks-панель: если откроется на узком экране — нижний лист во всю ширину.
       Панель позиционируется инлайн-стилями, поэтому нужен !important. — */
  .twk-panel {
    left: 8px !important; right: 8px !important;
    top: auto !important;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    width: auto !important; max-width: none !important;
    max-height: 60vh; overflow-y: auto;
  }

  /* — Home топбар: тег-лайн и дублирующий колокол прячем
       (колокол доступен через таб «Уведомл.», тег-лайн — шум на узком) — */
  .brand-tagline { display: none; }
  .topbar-cluster .bell-trigger { display: none; }

  /* — Фильтр-чипы: переносим на 2-ю строку вместо скрытого горизонт-скролла,
       чтобы «на паузе» не обрезался и все статусы были видны — */
  .chips { flex-wrap: wrap; overflow-x: visible; }

  /* — Тулбар папки: спейсер не нужен; поиск растягиваем (flex-basis 0, чтобы
       не уходил на отдельную строку), сорт встаёт рядом на ту же строку. — */
  .toolbar { gap: 8px; }
  .toolbar .toolbar-spacer { display: none; }
  .toolbar .search-wrap { flex: 1 1 0; min-width: 0; max-width: none !important; }

  /* — Карточки папок: компактнее; спарклайн не вылазит за паддинг.
       (inline overflow:visible на svg бьём !important) — */
  .folder-card { padding: 16px; }
  .folder-card .spark-cell svg { overflow: hidden !important; max-width: 100%; }
  /* пустая папка (0 видео → пустой .thumbs-row): схлопываем подвал,
     убирая мёртвое вертикальное место */
  .folder-card-foot:has(.thumbs-row:empty) { display: none; }

  /* — Блок скорости в папке: 220px-спарклайн рядом со статами не влезает в 390px
       (давал ~7px горизонт-скролла). Складываем в одну колонку — спарклайн уходит
       под статы во всю строку и помещается. — */
  .velocity-block { grid-template-columns: 1fr; gap: 16px; padding: 18px 16px; }
  .velocity-sparkbox { width: 100%; max-width: 100%; overflow: hidden; }
  .velocity-sparkbox svg { max-width: 100%; }

  /* — Шапка папки: длинное имя максимум в 2 строки с эллипсисом — */
  .folder-title { font-size: 26px; }
  .folder-title > span:not(.folder-title-dot) {
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* Промежуток планшет/телефон: 2 колонки карточек папок. */
@media (min-width: 481px) and (max-width: 720px) {
  .folders-grid { grid-template-columns: 1fr 1fr; }
}

/* ═══ API / developer screen ═══════════════════════════════
   Scope is the through-line: read → fresh(cyan), write → amber,
   full → hot(orange). The same three colors tint key badges, the
   scope segmented control, and the endpoint verbs (GET=read,
   POST/PATCH/DELETE=write), so colour encodes capability everywhere. */
.api-screen { max-width: 860px; }
.api-head { margin-bottom: 28px; }
.api-head .section-sub { max-width: 60ch; }

.api-alert {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 18px; padding: 10px 13px;
  border-radius: var(--r-md);
  background: color-mix(in oklch, var(--st-dead) 12%, transparent);
  border: 1px solid color-mix(in oklch, var(--st-dead) 32%, transparent);
  color: color-mix(in oklch, var(--st-dead) 82%, white);
  font-size: 13px;
}

/* ─── keys panel ─── */
.api-panel {
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  margin-bottom: 40px;
  overflow: hidden;
}
.api-panel-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-1);
}
.api-panel-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.api-panel-count {
  font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--fg-3);
  padding: 1px 8px; border-radius: 999px; background: var(--bg-3);
}

/* fresh key reveal */
.api-fresh {
  margin: 14px 18px 4px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklch, var(--accent) 38%, transparent);
  animation: apiFreshIn 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes apiFreshIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .api-fresh { animation: none; } }
.api-fresh-top {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--fg-2); margin-bottom: 9px;
}
.api-fresh-top svg { color: var(--accent); flex: none; }
.api-fresh-key { display: flex; align-items: center; gap: 10px; }
.api-fresh-key code {
  flex: 1; min-width: 0;
  font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.02em;
  color: var(--fg-1);
  padding: 8px 11px; border-radius: var(--r-sm);
  background: var(--bg-0); border: 1px solid var(--line-1);
  overflow-x: auto; white-space: nowrap;
}
.api-fresh-key code::-webkit-scrollbar { display: none; }

/* key rows */
.api-keys { list-style: none; margin: 6px 0 0; padding: 0; }
.api-key {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center; gap: 14px;
  padding: 12px 18px;
  border-top: 1px solid var(--line-1);
}
.api-keys .api-key:first-child { border-top: none; }
.api-key-prefix {
  font-family: var(--font-mono); font-size: 13px; color: var(--fg-1);
  letter-spacing: 0.02em;
}
.api-key-label { font-size: 13px; color: var(--fg-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.api-key-nolabel { color: var(--fg-4); font-style: italic; }
.api-key-meta {
  font-size: 12px; color: var(--fg-3); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.api-key-del { color: var(--fg-4); opacity: 0; transition: opacity 0.15s, color 0.15s, background 0.15s; }
.api-key:hover .api-key-del,
.api-key-del:focus-visible { opacity: 1; }
.api-key-del:hover { color: var(--st-dead); background: color-mix(in oklch, var(--st-dead) 16%, transparent); }
@media (hover: none) { .api-key-del { opacity: 1; } }

/* scope badge */
.api-scope {
  display: inline-flex; align-items: center; height: 21px;
  padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.api-scope-read { color: var(--st-fresh); background: color-mix(in oklch, var(--st-fresh) 13%, transparent); }
.api-scope-write { color: var(--st-down); background: color-mix(in oklch, var(--st-down) 14%, transparent); }
.api-scope-full { color: var(--st-hot); background: color-mix(in oklch, var(--st-hot) 15%, transparent); }

/* ─── create row ─── */
.api-create {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px;
  border-top: 1px solid var(--line-1);
  background: var(--bg-2);
}
.api-create .api-create-label { flex: 1 1 180px; min-width: 140px; height: 34px; }

/* scope segmented control */
.api-scope-seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-0); border: 1px solid var(--line-1); border-radius: var(--r-md); }
.api-seg {
  height: 26px; padding: 0 12px; border-radius: 7px;
  font-size: 12px; font-weight: 500; color: var(--fg-3);
  transition: color 0.14s, background 0.14s;
}
.api-seg:hover { color: var(--fg-2); }
.api-seg.active { color: var(--fg-1); }
.api-seg-read.active { color: var(--st-fresh); background: color-mix(in oklch, var(--st-fresh) 15%, transparent); }
.api-seg-write.active { color: var(--st-down); background: color-mix(in oklch, var(--st-down) 16%, transparent); }
.api-seg-full.active { color: var(--st-hot); background: color-mix(in oklch, var(--st-hot) 17%, transparent); }
.api-create-btn { height: 34px; }

.api-empty {
  padding: 30px 18px; text-align: center;
  font-size: 13px; color: var(--fg-3);
}

/* ─── reference ─── */
.api-ref-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; margin: 32px 0 10px; }
.api-ref-lede { font-size: 13.5px; line-height: 1.6; color: var(--fg-2); margin: 0 0 14px; max-width: 64ch; }
.api-inline {
  font-family: var(--font-mono); font-size: 0.88em;
  padding: 1px 5px; border-radius: 5px;
  background: var(--bg-3); color: var(--fg-1);
  white-space: nowrap;
}
.api-code {
  margin: 0 0 6px; padding: 14px 16px;
  background: var(--bg-1); border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  overflow-x: auto;
}
.api-code code {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7;
  color: var(--fg-1); white-space: pre;
}

.api-endpoints { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line-1); border-radius: var(--r-lg); overflow: hidden; }
.api-endpoint {
  display: grid; grid-template-columns: 52px 232px 1fr;
  align-items: center; gap: 14px;
  padding: 11px 16px;
  border-top: 1px solid var(--line-1);
  background: var(--bg-1);
}
.api-endpoints .api-endpoint:first-child { border-top: none; }
.api-verb {
  justify-self: start;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 6px; border-radius: 5px; text-align: center;
}
.api-verb-get { color: var(--st-fresh); background: color-mix(in oklch, var(--st-fresh) 13%, transparent); }
.api-verb-post { color: var(--st-down); background: color-mix(in oklch, var(--st-down) 14%, transparent); }
.api-verb-delete { color: var(--st-dead); background: color-mix(in oklch, var(--st-dead) 15%, transparent); }
.api-path { font-family: var(--font-mono); font-size: 12.5px; color: var(--fg-1); white-space: nowrap; }
.api-endpoint-desc { font-size: 12.5px; color: var(--fg-3); line-height: 1.45; }
.api-ref-foot { font-size: 12.5px; line-height: 1.6; color: var(--fg-3); margin: 14px 0 0; max-width: 64ch; }

@media (max-width: 560px) {
  .api-key { grid-template-columns: 1fr auto auto; row-gap: 4px; }
  .api-key-label { grid-column: 1 / -1; order: 3; }
  .api-endpoint { grid-template-columns: 52px 1fr; }
  .api-endpoint-desc { grid-column: 1 / -1; }
  .api-create .api-create-label { flex-basis: 100%; }
}
