/*
 * SaaS Motion Pro — app.css
 * © 2026 Sabbir Hossen — SaaS Motion Pro. All rights reserved.
 */

/* ---------- Tokens ---------- */
:root {
  --bg: #111217;
  --panel: #16171d;
  --surface: #1c1e25;
  --raised: #23262f;
  --hover: #2a2e39;
  --border: #272a34;
  --border-strong: #363a47;
  --text: #eceef3;
  --text-2: #a4a8b6;
  --text-3: #6d7282;
  --accent: #7c6cff;
  --accent-hi: #9487ff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(124, 108, 255, 0.14);
  --accent-line: rgba(124, 108, 255, 0.45);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --r-lg: 12px;
  --r-md: 9px;
  --r-sm: 6px;
  --rail-w: 52px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 12px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, textarea { user-select: text; }
svg { display: block; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- App shell ---------- */
.app { display: flex; height: 100vh; width: 100vw; }

.rail {
  width: var(--rail-w);
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.18s var(--ease);
}
.rail-logo {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 5px; margin-bottom: 6px;
  color: var(--text); font-weight: 700; letter-spacing: 0.2px; white-space: nowrap;
}
.rail-logo .mark { width: 24px; height: 24px; flex: none; }
.rail-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.rail-spacer { flex: 1; }
.rail-btn {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px;
  border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text-2);
  white-space: nowrap; text-align: left;
  transition: background 0.12s, color 0.12s;
}
.rail-btn svg { width: 18px; height: 18px; flex: none; }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.active { background: var(--accent-soft); color: var(--text); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -6px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.rail-label { display: none; font-size: 12.5px; font-weight: 500; }
.app.w-lg .rail { --rail-w: 172px; }
.app.w-lg .rail-label { display: inline; }
.app.w-xs .rail { --rail-w: 44px; padding: 6px 4px; }
.app.w-xs .rail-btn { padding: 0 7px; }
.app.w-xs .rail-logo { padding: 0 3px; }
.rail-logo .rail-label { font-size: 13px; }

/* tooltip for icon-only rail */
.rail-btn[data-tip]:hover::after {
  content: attr(data-tip);
  position: fixed; left: calc(var(--rail-w) + 6px);
  margin-top: 0;
  padding: 4px 8px; border-radius: var(--r-sm);
  background: var(--raised); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 11.5px; pointer-events: none; z-index: 50;
  box-shadow: var(--shadow);
}
.app.w-lg .rail-btn[data-tip]:hover::after { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 6px;
  height: 44px; padding: 0 8px; flex: none;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.search-trigger {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text-3);
  transition: border-color 0.12s, background 0.12s;
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--raised); color: var(--text-2); }
.search-trigger svg { width: 15px; height: 15px; flex: none; }
.search-trigger span { flex: 1; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
kbd {
  font: 10.5px/1 var(--mono); color: var(--text-2);
  padding: 3px 5px; border-radius: 4px;
  background: var(--raised); border: 1px solid var(--border-strong);
  white-space: nowrap;
}
.app.w-xs .search-trigger kbd, .app.w-xs .search-trigger span { display: none; }
.app.w-xs .search-trigger { flex: none; width: 30px; padding: 0; justify-content: center; }

.icon-btn {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--text-2);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }

/* ---------- Workspace & panes ---------- */
.workspace { flex: 1; min-height: 0; display: flex; }
.workspace.split-v { flex-direction: column; }
.pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.workspace.is-split .pane { outline: 1px solid transparent; outline-offset: -1px; transition: outline-color 0.15s; }
.workspace.is-split .pane.focused { outline-color: var(--accent-line); }
.divider { flex: none; background: var(--border); position: relative; z-index: 2; }
.workspace:not(.split-v) .divider { width: 1px; cursor: col-resize; }
.workspace.split-v .divider { height: 1px; cursor: row-resize; }
.divider::after { content: ""; position: absolute; inset: -4px; }
.divider:hover, .divider.dragging { background: var(--accent); }

.pane-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 0;
}
.pane-title { font-size: 13px; font-weight: 650; white-space: nowrap; }
.chips {
  flex: none; display: flex; gap: 4px;
  padding: 8px 10px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .soon { font-size: 9.5px; color: var(--text-3); }
.chip.active .soon { color: rgba(255,255,255,0.7); }
.pane-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; }

/* ---------- Generic components ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.row > h3.grow { min-width: max-content; } /* card titles never get squeezed under their side note */
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 11px; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 17px; letter-spacing: -0.2px; }
h2 { font-size: 13.5px; }
h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-3); font-weight: 600; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px;
}
.card.flat { background: transparent; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 11px; color: var(--text-2); font-weight: 500; }
.hint { font-size: 10.5px; color: var(--text-3); }

.seg {
  display: flex; padding: 2px; gap: 2px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md);
}
.seg button {
  flex: 1; min-width: 0; height: 26px; padding: 0 6px;
  border: 0; border-radius: 7px; background: transparent; color: var(--text-2);
  font-size: 11.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 30%; }
/* exactly 4 options: one row when wide, 2 × 2 when narrow (never 3 + 1) */
.seg.wrap button:first-child:nth-last-child(4), .seg.wrap button:first-child:nth-last-child(4) ~ button { flex-basis: 22%; }
.app.w-xs .seg.wrap button:first-child:nth-last-child(4), .app.w-xs .seg.wrap button:first-child:nth-last-child(4) ~ button,
.app.w-sm .seg.wrap button:first-child:nth-last-child(4), .app.w-sm .seg.wrap button:first-child:nth-last-child(4) ~ button { flex-basis: 40%; }

.input, .select {
  height: 30px; padding: 0 10px; width: 100%;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md);
  outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); }

.stepper { display: flex; align-items: stretch; height: 30px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); overflow: hidden; }
.stepper button { width: 30px; border: 0; background: transparent; color: var(--text-2); font-size: 14px; }
.stepper button:hover { background: var(--hover); color: var(--text); }
.stepper input { width: 100%; min-width: 0; border: 0; background: transparent; text-align: center; outline: none; font-variant-numeric: tabular-nums; }
.stepper .unit { display: grid; place-items: center; padding-right: 8px; color: var(--text-3); font-size: 10.5px; }

.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { display: none; }
.toggle .track {
  width: 30px; height: 17px; border-radius: 99px; flex: none;
  background: var(--border-strong); position: relative; transition: background 0.15s;
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: #fff; transition: transform 0.15s var(--ease);
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(13px); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 32px; padding: 4px 14px; line-height: 1.2; /* grows instead of overflowing when a long label wraps on narrow panels */
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--raised); color: var(--text); font-weight: 600;
  transition: background 0.12s, transform 0.06s, border-color 0.12s;
}
.btn[style*="height"] { min-height: 0; } /* inline compact sizes win */
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.block { width: 100%; min-height: 36px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn.busy { pointer-events: none; opacity: 0.8; }
.btn.busy::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px;
  border-radius: 99px; font-size: 10px; font-weight: 600; letter-spacing: 0.2px;
  background: var(--raised); color: var(--text-2); border: 1px solid var(--border-strong);
}
.badge.accent { background: var(--accent-soft); color: var(--accent-hi); border-color: var(--accent-line); }
.badge.ok { background: rgba(52,211,153,0.12); color: var(--ok); border-color: rgba(52,211,153,0.35); }

.status-line {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-md);
  background: var(--bg); border: 1px dashed var(--border-strong);
  color: var(--text-2); font-size: 11.5px;
}
.status-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-line.good .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(52,211,153,0.15); }
.status-line.warn .dot { background: var(--warn); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 12px; min-height: 84px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.tile:hover { border-color: var(--accent-line); background: var(--raised); transform: translateY(-1px); }
.tile .ic { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent-hi); }
.tile .ic svg { width: 16px; height: 16px; }
.tile b { font-size: 12.5px; font-weight: 600; }
.tile small { color: var(--text-3); font-size: 10.5px; line-height: 1.35; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--r-sm); min-width: 0;
}
.list-item:hover { background: var(--hover); }
.list-item .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 28px 16px; color: var(--text-2);
}
.empty .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-hi); }
.empty .ic svg { width: 22px; height: 22px; }

.hero {
  position: relative; overflow: hidden;
  padding: 16px; border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(124,108,255,0.28), transparent 55%),
    radial-gradient(90% 120% at 0% 100%, rgba(34,211,238,0.14), transparent 60%),
    var(--surface);
}
.progress { height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; }

/* ---------- Command palette ---------- */
.palette-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 6, 10, 0.55);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 7vh 10px 10px;
  opacity: 0; pointer-events: none; transition: opacity 0.12s;
}
.palette-backdrop.open { opacity: 1; pointer-events: auto; }
.palette {
  width: 100%; max-width: 560px; max-height: 80vh;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: var(--shadow);
  transform: translateY(-6px) scale(0.99); transition: transform 0.14s var(--ease);
  overflow: hidden;
}
.palette-backdrop.open .palette { transform: none; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 12px; height: 48px; border-bottom: 1px solid var(--border); }
.palette-input svg { width: 17px; height: 17px; color: var(--text-3); flex: none; }
.palette-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: 14px; }
.palette-mode { font-size: 10.5px; }
.palette-results { flex: 1; overflow-y: auto; padding: 6px; }
.palette-section { padding: 8px 8px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-3); font-weight: 600; }
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer; min-width: 0;
}
.palette-item .pi-ic { width: 26px; height: 26px; flex: none; border-radius: 7px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.palette-item .pi-ic svg { width: 14px; height: 14px; }
.palette-item .pi-text { flex: 1; min-width: 0; }
.palette-item .pi-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.palette-item .pi-name mark { background: none; color: var(--accent-hi); font-weight: 700; }
.palette-item .pi-sub { font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pi-star { opacity: 0; border: 0; background: none; color: var(--text-3); padding: 4px; border-radius: 6px; }
.palette-item .pi-star svg { width: 14px; height: 14px; }
.palette-item .pi-star.on { opacity: 1; color: var(--warn); }
.palette-item:hover .pi-star, .palette-item.sel .pi-star { opacity: 1; }
.palette-item .pi-star:hover { background: var(--hover); }
.palette-item.sel { background: var(--accent-soft); }
.palette-item.sel .pi-ic { border-color: var(--accent-line); color: var(--accent-hi); }
.palette-foot { display: flex; gap: 12px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 10.5px; }
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }
.palette-empty { padding: 26px 12px; text-align: center; color: var(--text-3); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 200; width: max-content; max-width: calc(100vw - 24px); }
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px;
  background: var(--raised); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
  font-size: 12px; animation: toastIn 0.18s var(--ease);
}
.toast::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.ok::before { background: var(--ok); }
.toast.err::before { background: var(--err); }
.toast.leave { opacity: 0; transform: translateY(4px); transition: 0.2s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Stagger preview ---------- */
.stagger-viz { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); }
.stagger-viz .lane { height: 8px; position: relative; }
.stagger-viz .lane i {
  position: absolute; top: 0; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: left 0.25s var(--ease), width 0.25s var(--ease);
}

/* ---------- Shortcut recorder ---------- */
.shortcut-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.shortcut-row:last-child { border-bottom: 0; }
.shortcut-row .rec.listening { border-color: var(--accent); color: var(--accent-hi); }

.preview-banner {
  font-size: 11px; color: var(--warn); background: rgba(251,191,36,0.08);
  border: 1px solid rgba(251,191,36,0.3); border-radius: var(--r-md); padding: 6px 10px;
}

/* ---------- Quick Bar ---------- */
.quickbar {
  flex: none; display: flex; align-items: center; gap: 2px;
  padding: 4px 8px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border); background: var(--panel);
}
.quickbar::-webkit-scrollbar { display: none; }
.quickbar[hidden] { display: none; }
.qb-btn {
  flex: none; width: 30px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--text-2);
  transition: background 0.12s, color 0.12s, transform 0.06s;
}
.qb-btn svg { width: 16px; height: 16px; }
.qb-btn:hover { background: var(--hover); color: var(--text); }
.qb-btn:active { transform: scale(0.94); }
.qb-btn.busy { color: var(--accent-hi); animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
.qb-sep { flex: 1; min-width: 6px; }

/* ---------- Quick Actions page ---------- */
.qa-row { gap: 8px; }
.qa-ic { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 7px; background: var(--bg); border: 1px solid var(--border); color: var(--text-2); }
.qa-ic svg { width: 14px; height: 14px; }
.qa-sc { height: 26px; padding: 0 8px; font: 10.5px/1 var(--mono); font-weight: 500; }
.qa-sc.listening, .rec.listening { border-color: var(--accent) !important; color: var(--accent-hi) !important; background: var(--accent-soft) !important; }
.qa-pin { width: 26px; height: 26px; color: var(--text-3); }
.qa-pin.on { color: var(--accent-hi); }
.app.w-xs .qa-sc, .app.w-sm .qa-row [data-run] { display: none; }
.swatch { width: 34px; height: 30px; padding: 2px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); cursor: pointer; flex: none; }
.swatch::-webkit-color-swatch-wrapper { padding: 0; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 6px; }

/* ---------- Script Lab ---------- */
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.preset-chip {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); color: var(--text-2);
  font-size: 11.5px; text-align: left; white-space: nowrap; overflow: hidden;
}
.preset-chip img { width: 20px; height: 20px; flex: none; border-radius: 4px; }
.preset-chip:hover { border-color: var(--accent-line); color: var(--text); background: var(--raised); }
.tile .btn { align-self: stretch; }
a { color: var(--accent-hi); }

/* ---------- Range slider ---------- */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; }
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--border-strong); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* ---------- Preview tiles (js/preview.js) ---------- */
.pv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; }
.app.w-xs .pv-grid, .app.w-sm .pv-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); } /* 2+ columns on narrow panels */
.pv-tile { display: flex; flex-direction: column; gap: 6px; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text-2); cursor: pointer; text-align: left; font: inherit; transition: border-color .15s var(--ease), background .15s var(--ease); }
.pv-tile:hover { border-color: var(--border-strong); background: var(--raised); color: var(--text); }
.pv-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-line); color: var(--text); }
.pv-media { position: relative; height: 0; padding-top: 56.25%; border-radius: var(--r-sm); overflow: hidden; background: #0b0c10; }
.pv-media img, .pv-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-video { opacity: 0; transition: opacity .12s; }
.pv-tile.playing .pv-video { opacity: 1; }
.pv-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 6px; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-3); background: linear-gradient(135deg, var(--raised), var(--bg)); }
.pv-name { font-size: 11.5px; line-height: 1.25; padding: 0 2px 1px; display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.pv-tag { font-size: 9.5px; color: var(--text-3); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.palette { position: relative; }
.palette-pv { position: absolute; right: 10px; bottom: 44px; width: min(46%, 260px); border-radius: var(--r-md); overflow: hidden; background: #0b0c10; border: 1px solid var(--border-strong); box-shadow: var(--shadow); pointer-events: none; z-index: 2; }
.palette-pv video { display: block; width: 100%; height: auto; object-fit: cover; }
.palette-pv-name { display: block; font-size: 11px; color: var(--text-2); padding: 4px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pi-pv { color: var(--accent-2); display: inline-flex; width: 14px; height: 14px; margin-right: 4px; opacity: .8; }
.pi-pv svg { width: 12px; height: 12px; }
@media (max-width: 420px) { .palette-pv { display: none; } }

/* ---------- Pinned tools (js/workflow.js) ---------- */
.rail-pins { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; scrollbar-width: none; }
.rail-pins::-webkit-scrollbar { display: none; }
.rail-pin svg { color: var(--accent-2); }
.rail-pin.active svg { color: var(--text); }
.chips .chip-pin { margin-left: auto; flex: none; padding: 0 7px; display: inline-flex; align-items: center; color: var(--text-3); }
.chips .chip-pin svg { width: 13px; height: 13px; }
.chips .chip-pin.on { color: var(--accent-2); border-color: var(--accent-line); background: var(--accent-soft); }

/* ---------- Home ---------- */
.home-search { width: 100%; flex: none; }
.home-h { margin-bottom: 8px; }
.home-why { margin: 2px 0 8px; }
.home-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.home-pick { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 10px; border-radius: var(--r-md); border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--text); font: inherit; font-size: 12px; text-align: left; cursor: pointer; transition: background .12s var(--ease); }
.home-pick:hover { background: rgba(124, 108, 255, 0.26); }
.home-pick.is-action { border-color: var(--border-strong); background: var(--raised); }
.home-pick svg { width: 15px; height: 15px; flex: none; color: var(--accent-2); }
.home-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-tiles { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.home-tiles .tile { position: relative; min-height: 0; padding: 10px; }
.home-slot { position: absolute; top: 8px; right: 8px; font-size: 10px; color: var(--text-3); font-family: var(--mono); }
.home-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 14px; }
.home-group { display: flex; flex-direction: column; gap: 1px; }
.home-gname { display: flex; align-items: center; gap: 6px; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin: 2px 0 4px; }
.home-gname svg { width: 12px; height: 12px; }
.home-link { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; }
.home-link:hover { background: var(--hover); color: var(--text); }
.home-link svg { width: 14px; height: 14px; flex: none; opacity: .8; }
.home-link span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-pinned { display: inline-flex; color: var(--accent-2); }
.home-pinned svg { width: 11px; height: 11px; }
.pv-tile.applying { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(34, 211, 238, .35); }
.rail-head { display: flex; align-items: center; justify-content: center; gap: 6px; height: 18px; margin: 2px 0; color: var(--text-3); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.rail-head svg { width: 11px; height: 11px; }
.app.w-lg .rail-head { justify-content: flex-start; padding-left: 12px; }
.rail-head .rail-label { display: none; }
.app.w-lg .rail-head .rail-label { display: inline; }

/* Older CEF builds without aspect-ratio support */
@supports not (aspect-ratio: 1) {
  .compslib-thumb { height: 0; padding-top: 56.25%; }
  .ig-item, .moodboard-item { height: 0; padding-top: 100%; }
  .align-grid { height: 134px; }
  .colors-chip { min-height: 44px; }
}

/* ---------- Align & Anchor bar (js/alignbar.js) ---------- */
.alignbar { flex: none; display: flex; align-items: center; gap: 3px; padding: 4px 8px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); background: var(--panel); }
.alignbar::-webkit-scrollbar { display: none; }
.alignbar[hidden] { display: none; }
.ab-label { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); margin: 0 3px 0 2px; flex: none; }
.ab-anchor { display: grid; grid-template-columns: repeat(3, 9px); gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 5px; flex: none; }
.ab-dot { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 2px; background: var(--border-strong); cursor: pointer; }
.ab-dot.mid { background: var(--text-3); }
.ab-dot:hover { background: var(--accent-2); }
.ab-dot.busy, .ab-btn.busy { opacity: .5; pointer-events: none; }
.ab-sep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; flex: none; }
.ab-btn { flex: none; width: 26px; height: 26px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); cursor: pointer; }
.ab-btn:hover { background: var(--hover); color: var(--text); }
.ab-btn svg { width: 16px; height: 16px; }
.ab-to { display: inline-flex; margin-left: 6px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; flex: none; }
.ab-to button { border: 0; background: transparent; color: var(--text-3); font: inherit; font-size: 10.5px; padding: 3px 7px; cursor: pointer; }
.ab-to button.on { background: var(--accent-soft); color: var(--text); }
/* Home quick tools */
.home-quick { display: flex; flex-direction: column; gap: 8px; }
.home-qsec { display: flex; gap: 8px; align-items: flex-start; }
.home-qname { flex: none; width: 64px; padding-top: 7px; font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.home-qrow { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; }
.home-qbtn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 11.5px; cursor: pointer; white-space: nowrap; }
.home-qbtn:hover { border-color: var(--border-strong); background: var(--raised); color: var(--text); }
.home-qbtn svg { width: 14px; height: 14px; color: var(--accent-2); }
.home-qbtn.busy { opacity: .55; pointer-events: none; }
.app.w-xs .home-qsec, .app.w-sm .home-qsec { flex-direction: column; gap: 4px; }
.app.w-xs .home-qname, .app.w-sm .home-qname { width: auto; padding-top: 0; }

/* ---------- Group panels (panel-<group>.html) ---------- */
.app.panel-mode .rail { display: none; }
.app.panel-mode .chips .chip-pop { display: none; }
.chips .chip-pop { flex: none; padding: 0 7px; display: inline-flex; align-items: center; color: var(--text-3); }
.chips .chip-pop svg { width: 13px; height: 13px; }
.chips .chip-pin { margin-left: 0; }
.chips .chip-pop { margin-left: auto; }
/* Tool panels (slots): just the tool */
.app.panel-slot .chips, .app.panel-slot .quickbar, .app.panel-slot .alignbar { display: none; }
body.dragging-tab .chips .chip[draggable="true"]:not(.active) { opacity: .6; }
.chips .chip[draggable="true"] { cursor: grab; }

/* ---------- Responsive: names always visible, only vertical scrolling ---------- */
.pane-body { overflow-x: hidden; }
/* Narrow / medium panels: icon with its name underneath (never icon-only) */
.app:not(.w-lg) .rail { --rail-w: 64px; }
.app.w-xs .rail { --rail-w: 56px; }
.app:not(.w-lg) .rail-btn { flex-direction: column; justify-content: center; height: auto; min-height: 44px; padding: 5px 2px; gap: 3px; }
.app:not(.w-lg) .rail-btn .rail-label { display: block; max-width: 100%; font-size: 9.5px; font-weight: 500; line-height: 1.15; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app:not(.w-lg) .rail-logo .rail-label { display: none; }
.app:not(.w-lg) .rail-btn[data-tip]:hover::after { display: none; }
.app:not(.w-lg) .rail-btn.active::before { top: 10px; bottom: 10px; }
/* Tile grids: as many columns as fit — more when wider, fewer when narrower */
.pv-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.app.w-xs .pv-grid, .app.w-sm .pv-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.pv-name { white-space: normal; }
/* Chromium 99 (CEP 12) doesn't stretch flex children inside <button> → give the media an explicit width */
.pv-tile { align-items: stretch; width: 100%; min-width: 0; }
.pv-media { width: 100%; display: block; }
.pv-name { width: 100%; }

/* ---------- In-panel color picker (js/colorpop.js) ---------- */
.cp-pop { position: fixed; z-index: 1000; width: 232px; padding: 10px; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 7px; }
.cp-head { display: flex; gap: 6px; align-items: center; }
.cp-now { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border-strong); flex: none; }
.cp-hex { flex: 1; height: 28px; font-family: var(--mono); text-transform: uppercase; }
.cp-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.cp-sw { height: 22px; padding: 0; border: 1px solid rgba(255,255,255,.12); border-radius: 5px; cursor: pointer; }
.cp-sw.on, .cp-sw:hover { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.cp-label { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.cp-range { -webkit-appearance: none; appearance: none; width: 100%; height: 12px; border-radius: 6px; background: var(--raised); }
.cp-range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid #111; }
.cp-hue { background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
input[type="color"] { cursor: pointer; }

/* Motion Library: compact category chips + section headings */
.seg.ml-cats button { flex: 0 0 auto; padding: 0 10px; }
.ml-cat { text-transform: none; }
.qt-rename { flex: 1 1 100%; gap: 4px; margin-top: 2px; }
.qt-rename .input { height: 28px; min-width: 120px; }
.home-quick, .home-qsec, .home-qrow { min-width: 0; }
.home-qrow { max-width: 100%; }
.home-qbtn { max-width: 100%; overflow: hidden; }
.home-qbtn span { overflow: hidden; text-overflow: ellipsis; }
.qt-rename { flex-wrap: nowrap; min-width: 0; }
.qt-rename .input { min-width: 0; flex: 1 1 80px; }
.qt-rename .home-qbtn { flex: none; }
/* update banner (js/update.js) */
.update-banner { margin: 8px 10px 0; padding: 8px 10px; border: 1px solid var(--accent, #7c6cff); border-radius: 10px; background: color-mix(in srgb, var(--accent, #7c6cff) 12%, var(--surface)); font-size: 12px; }
.update-row { gap: 8px; align-items: center; flex-wrap: wrap; }
.update-row > svg { width: 15px; height: 15px; color: var(--accent-2); flex: none; }
.update-banner .btn.sm { height: 26px; padding: 0 10px; font-size: 11.5px; }
.update-notes, .update-how { display: none; }
.update-banner.open .update-notes, .update-banner.open .update-how { display: block; }
.update-notes { margin: 8px 0 4px 18px; padding: 0; line-height: 1.5; color: var(--text-2); }
