:root {
  --bg: #0e0f13;
  --panel: #171922;
  --panel-2: #1f2230;
  --line: #2a2e3e;
  --text: #e7e9f0;
  --muted: #8c92a8;
  --accent: #5b8cff;
  --accent-2: #3a6dff;
  --danger: #ff4d5e;
  --ok: #36c08a;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Keep the bottom sliders clear of the macOS window's rounded corners. */
  padding-bottom: 9px;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; }
.brand-logo { height: 30px; width: auto; display: block; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: 1; }
.spacer { flex: 1; }
.proj-info { color: var(--muted); font-size: 12.5px; }

.btn {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s, border-color .12s;
}
/* `display:inline-flex` above overrides the UA [hidden] rule, so re-assert it. */
.btn[hidden] { display: none; }
.btn:hover:not(:disabled) { background: #262a3a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); }
.btn.primary:hover:not(:disabled) { background: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.file-btn { position: relative; }
.select {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}

/* Export modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.modal-field .select { width: 100%; }
.modal-note { font-size: 12px; color: var(--muted); margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.modal.modal-wide { width: 520px; }

/* Cloud storage meter */
.storage-bar { height: 7px; border-radius: 4px; background: var(--panel-2); overflow: hidden; margin: 8px 0 0; }
.storage-bar > div { height: 100%; width: 0; background: var(--accent-2); transition: width .2s; }
.storage-bar > div.near { background: #e0a23a; }
.storage-bar > div.full { background: var(--danger); }

/* Projects list */
.projects-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow: auto; margin: 4px 0 16px; }
.projects-empty { color: var(--muted); font-size: 13px; padding: 18px 4px; text-align: center; }
.project-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.project-row.current { border-color: var(--accent-2); }
.project-row .pr-main { flex: 1; min-width: 0; }
.project-row .pr-name { font-size: 13.5px; font-weight: 600; background: transparent; border: 1px solid transparent; color: var(--text); border-radius: 6px; padding: 2px 6px; width: 100%; }
.project-row .pr-name:hover { border-color: var(--line); }
.project-row .pr-name:focus { border-color: var(--accent-2); outline: none; background: var(--panel); }
.project-row .pr-sub { font-size: 11.5px; color: var(--muted); margin: 2px 0 0 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.project-row .pr-badge { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); }
.project-row .pr-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Account widget */
.account-area { display: flex; align-items: center; gap: 8px; }
.account-chip { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 12.5px; }
.account-chip .credits { color: var(--ok); font-weight: 600; }
.account-chip .email { color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu { position: absolute; right: 16px; top: 52px; z-index: 60; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.5); min-width: 200px; }
.account-menu[hidden] { display: none; }
.account-menu button { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.account-menu button:hover { background: var(--accent-2); }
.account-menu .menu-info { padding: 8px 10px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* Auth + buy modals */
.google-btn { width: 100%; justify-content: center; background: #fff; color: #1f1f1f; border-color: #dadce0; font-weight: 600; }
.google-btn:hover:not(:disabled) { background: #f5f5f5; }
.google-btn .g { font-weight: 800; color: #4285f4; margin-right: 4px; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-error { color: var(--danger); font-size: 12.5px; margin: 4px 0 8px; }
.auth-error[hidden] { display: none; }
.auth-toggle { font-size: 12.5px; color: var(--muted); margin: 14px 0 0; }
.export-credit { font-size: 12.5px; color: var(--muted); margin: 4px 0 14px; }
.export-credit b { color: var(--text); }
.buy-options { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 16px; }
/* color must be set explicitly — <button> defaults to dark canvas text, which is
   nearly invisible on the dark panel. */
.buy-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; cursor: pointer; transition: border-color .12s, background .12s; }
.buy-option:hover { border-color: var(--accent); background: #262a3a; }
.buy-option .bo-label { display: inline-flex; align-items: center; font-size: 13.5px; color: var(--text); }
.buy-option .bo-price { font-weight: 700; font-size: 14px; color: var(--text); white-space: nowrap; }
.buy-option.sub { border-color: #2fa36f; position: relative; }
.buy-option.sub:hover { border-color: #4cd49a; }
.buy-option.sub .bo-price { color: #6ee0ab; }
.buy-option.locked { opacity: .45; pointer-events: none; }
.buy-option.selecting { border-color: var(--accent); }
/* "Connecting to secure payment portal…" indicator shown beneath the clicked option */
.bo-connecting { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 6px 4px 2px; }
.bo-stripe { height: 16px; width: auto; display: block; flex: none; }

/* Profile modal */
.prof-section { border-top: 1px solid var(--line); padding: 14px 0; }
.prof-section:last-of-type { border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.prof-row { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; }
.prof-row b { color: var(--text); }
.prof-sub-label { font-size: 12px; color: var(--muted); margin: 10px 0 8px; }
.prof-sub-status { font-size: 13.5px; color: var(--text); }
.prof-sub-status .badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
.prof-sub-status .badge.active { background: #163a2b; color: #6ee0ab; }
.prof-sub-status .badge.ending { background: #3a2a16; color: #f3b672; }
.prof-sub-dates { font-size: 12.5px; color: var(--muted); margin: 6px 0 10px; }
.prof-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.subtle { font-size: 12.5px; padding: 6px 12px; }
.btn.danger-outline { border-color: #6b2b33; color: #ff8b97; }
.btn.danger-outline:hover:not(:disabled) { background: #2a181b; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { background: #ff6b78; }

/* Subscription "what you get" tooltip */
.bo-info {
  display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 7px;
  border-radius: 50%; border: 1px solid currentColor; color: var(--muted);
  font: italic 700 10px/1 Georgia, serif; cursor: help;
}
.bo-info:hover, .bo-info:focus { color: var(--text); outline: none; }
.bo-tip {
  position: absolute; left: 12px; right: 12px; bottom: calc(100% + 8px);
  background: #0b0d12; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; box-shadow: 0 12px 30px rgba(0,0,0,.55); z-index: 80;
  opacity: 0; visibility: hidden; transform: translateY(4px); transition: opacity .12s, transform .12s;
  text-align: left; font-size: 12px; line-height: 1.5; color: var(--text); cursor: auto;
}
.bo-tip b { display: block; margin-bottom: 6px; color: #6ee0ab; }
.bo-tip ul { margin: 0; padding-left: 16px; }
.bo-tip li { margin: 3px 0; }
.bo-info:hover .bo-tip, .bo-info:focus .bo-tip { opacity: 1; visibility: visible; transform: translateY(0); }

/* Layout */
.layout { flex: 1; display: flex; min-height: 0; }
/* Order left→right: Patches shelf · Toolbox · Viewer */
.sidepanel { order: 0; }
.toolrail { order: 1; }
.viewer { order: 2; }
.toolrail {
  width: 56px; background: #bfc0c0; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 0;
}
.tool, .tbtn {
  width: 40px; height: 40px; border-radius: 9px;
  background: transparent; border: 1px solid transparent; color: var(--text);
  font-size: 18px; cursor: pointer; display: grid; place-items: center;
}
.tool:hover, .tbtn:hover { background: var(--panel-2); }
.tool.active { background: #b8e6cd; border-color: #8fd3b3; } /* selected tool/option — light green bar color */
.tool:disabled { opacity: .35; cursor: not-allowed; }
.tool.tool-text { font-size: 12px; font-weight: 700; letter-spacing: .5px; }
.rail-sep { width: 28px; height: 1px; background: var(--line); margin: 6px 0; }
.tool-options { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tool-options:not(:empty) { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.tool.subopt { width: 36px; height: 36px; }
/* Magic-wand tolerance slider (in the tool-options area). */
.tol-cap { font-size: 10px; color: #000; font-weight: 600; }
.tol-slider {
  writing-mode: vertical-lr; direction: rtl; width: 6px; height: 80px; margin: 2px 0; cursor: pointer;
  -webkit-appearance: none; appearance: none; background: #b8e6cd; border-radius: 999px;
}
.tol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: #2fa36f; border: 1px solid rgba(0,0,0,.45); box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.tol-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #2fa36f; border: 1px solid rgba(0,0,0,.45); box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.tol-slider::-moz-range-track { background: #b8e6cd; border-radius: 999px; }
/* Tool icon images: centered in the button, aspect-preserved, crisp pixel art. */
.tool-icon { width: 26px; height: 26px; object-fit: contain; display: block; image-rendering: pixelated; pointer-events: none; }
.subopt-icon { width: 24px; height: 24px; object-fit: contain; display: block; image-rendering: pixelated; pointer-events: none; }
.rail-color input { width: 36px; height: 36px; border: none; background: none; cursor: pointer; padding: 0; }
/* Eraser paints transparency: show a checkerboard swatch and disable color picking. */
.rail-color.transparent-mode {
  width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--line);
  cursor: not-allowed; background-color: #fff;
  background-image:
    linear-gradient(45deg, #c4c4c4 25%, transparent 25%),
    linear-gradient(-45deg, #c4c4c4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c4c4c4 75%),
    linear-gradient(-45deg, transparent 75%, #c4c4c4 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}
.rail-color.transparent-mode input { visibility: hidden; pointer-events: none; }
.rail-size { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 130px; }
.rail-size input[type=range] {
  writing-mode: vertical-lr; direction: rtl; width: 6px; height: 100px; margin: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none; background: transparent; --fill: 0%;
}
.rail-size input[type=range]::-webkit-slider-runnable-track {
  border-radius: 999px;
  background: linear-gradient(to top, #2fa36f var(--fill), #b8e6cd var(--fill)); /* filled (below handle) dark, rest light */
}
.rail-size input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #2fa36f; border: 1px solid rgba(0,0,0,.45); box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.rail-size input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #2fa36f; border: 1px solid rgba(0,0,0,.45); box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.rail-size input[type=range]::-moz-range-track { background: #b8e6cd; border-radius: 999px; }
.rail-size input[type=range]::-moz-range-progress { background: #2fa36f; border-radius: 999px; }
.rail-size span { font-size: 11px; color: #000; font-weight: 600; }

/* Viewer: left pane | vertical scrubber | right pane, with a horizontal
   scrubber beneath the right pane only. */
.viewer {
  flex: 1; display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: 1fr auto;
  gap: 2px; background: var(--line); position: relative; min-width: 0;
}
.pane-right { grid-column: 1; grid-row: 1; }  /* Edit (paint) window — left */
.vbar       { grid-column: 2; grid-row: 1; }  /* vertical slider → Edit */
.pane-left  { grid-column: 3; grid-row: 1; }  /* Application (patched) window — right */
.hbar       { grid-column: 3; grid-row: 2; }  /* horizontal slider → Application */
.pane { position: relative; background: #0a0b0e; overflow: hidden; min-width: 0; min-height: 0; }

/* Scrubbers (custom: buffered fill + animated loading stripe + frame thumb) */
.vbar, .hbar { position: relative; background: var(--panel); cursor: pointer; touch-action: none; }
.vbar { width: 12px; }
.hbar { height: 12px; }
.vbar > *, .hbar > * { pointer-events: none; }

/* Horizontal slider (Application) — orange */
.hbar { background: #f3b672; }
.hbar-done { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: #ff8c00; opacity: .5; transition: width .25s linear; }
.hbar-load {
  position: absolute; top: 0; bottom: 0; left: 0; right: 0; display: none; transition: left .25s linear;
  background-image: repeating-linear-gradient(-45deg, rgba(196,104,0,.6) 0 6px, rgba(243,182,114,.5) 6px 12px);
  background-size: 17px 17px; animation: hbufmove .7s linear infinite;
}
@keyframes hbufmove { to { background-position: 17px 0; } }
.hbar-thumb { position: absolute; top: -2px; bottom: -2px; width: 15px; left: 0; margin-left: -7px;
  background: #ff8c00; box-shadow: 0 0 0 1px rgba(0,0,0,.6); border-radius: 3px; }

/* Vertical slider (Canvas) — green */
.vbar { background: #b8e6cd; }
.vbar-done { position: absolute; left: 0; right: 0; top: 0; height: 0; background: #2fa36f; opacity: .5; transition: height .25s linear; }
.vbar-load {
  position: absolute; left: 0; right: 0; top: 0; bottom: 0; display: none; transition: top .25s linear;
  background-image: repeating-linear-gradient(-45deg, rgba(28,110,72,.6) 0 6px, rgba(184,230,205,.5) 6px 12px);
  background-size: 17px 17px; animation: vbufmove .7s linear infinite;
}
@keyframes vbufmove { to { background-position: 0 17px; } }
.vbar-thumb { position: absolute; left: -2px; right: -2px; height: 15px; top: 0; margin-top: -7px;
  background: #2fa36f; box-shadow: 0 0 0 1px rgba(0,0,0,.6); border-radius: 3px; }
.pane-label {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(0,0,0,.55); color: var(--text); padding: 3px 9px;
  border-radius: 6px; font-size: 12px;
  display: flex; align-items: center; gap: 6px;
}
.pane-label-stack { flex-direction: column; align-items: flex-start; gap: 5px; }
.pl-title { display: flex; align-items: center; gap: 6px; font-weight: 600; }
/* Title colors match each window's slider BAR. */
.pane-right .pl-title, .pane-right .pl-title .nav-sym { color: #b8e6cd; } /* Canvas — green bar */
.pane-left .pl-title, .pane-left .pl-title .nav-sym { color: #f3b672; }  /* Application — orange bar */
.pl-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.pl-edit { color: var(--text); }
.pl-edit .swatch { width: 16px; height: 16px; }
#editPatchInfo { display: inline-flex; align-items: center; gap: 5px; }
.bd-color { width: 24px; height: 18px; border: 1px solid var(--line); border-radius: 4px; background: none; padding: 0; cursor: pointer; }
.bd-color[hidden] { display: none; }
.nav-sym { color: var(--accent); font-size: 13px; cursor: default; }
.pane-select {
  background: rgba(20,22,30,.9); color: var(--text); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 6px; font-size: 12px; max-width: 240px; cursor: pointer;
}
.pane-select:focus { outline: 1px solid var(--accent); }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.empty-state {
  position: absolute; inset: 0; display: grid; place-items: center;
  text-align: center; color: var(--muted); padding: 40px;
  /* Let drags fall through to the panes beneath; only interactive bits opt back in. */
  pointer-events: none;
}
.empty-state .link-btn { pointer-events: auto; }
.empty-state h2 { color: var(--text); font-weight: 600; }
.empty-state p { max-width: 440px; }
.empty-hint { margin-top: 8px; font-size: 13px; }
.link-btn {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  cursor: pointer;
}
.link-btn:hover { filter: brightness(1.15); }

/* Drop target feedback while dragging a video file over a pane. */
.pane.drag-over::after {
  content: ''; position: absolute; inset: 6px; z-index: 6; pointer-events: none;
  border: 2px dashed var(--accent); border-radius: 10px; background: rgba(56,132,255,.10);
}

.overlay-msg {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(8,9,12,.78); z-index: 5; font-size: 15px; color: var(--text);
}
/* `display:grid` above overrides the UA [hidden] rule, so re-assert it. */
.overlay-msg[hidden] { display: none; }
.overlay-msg .spin { /* injected content wrapper */ }

/* Side panel */
.sidepanel {
  width: 280px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.panel-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }
.patch-list { padding: 8px; position: relative; }
.panel-hint { padding: 12px 14px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.muted { color: var(--muted); }

.patch-check { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex: none; }
.r-text {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; font-variant-numeric: tabular-nums;
}
.r-text:focus { outline: 1px solid var(--accent); }

/* Inactive Patches collapsible */
.inactive-section { border-top: 1px solid var(--line); margin-top: 4px; }
.inactive-head {
  padding: 9px 12px; font-size: 12.5px; color: var(--muted); cursor: pointer;
  user-select: none; display: flex; align-items: center; gap: 6px;
}
.inactive-head:hover { color: var(--text); }
.inactive-head .caret { transition: transform .15s; display: inline-block; }
.inactive-head.open .caret { transform: rotate(90deg); }
.inactive-list { padding: 0 8px 8px; }

/* Compare-window active-patch list (top-right of left pane) */
.compare-patches {
  position: absolute; top: 8px; right: 8px; z-index: 2; max-width: 220px;
  background: rgba(0,0,0,.62); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font-size: 12px; pointer-events: none;
}
.compare-patches[hidden] { display: none; }
.cp-title { color: var(--text); font-size: 11.5px; margin-bottom: 5px; }
.cp-item { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.cp-empty { color: var(--muted); font-size: 12px; padding: 1px 0; }
.cp-action { margin-top: 9px; }
.cp-head { color: var(--text); font-size: 11.5px; margin-bottom: 3px; }
.cp-hint { color: var(--text); font-size: 11px; margin-top: 5px; }
.cp-hint.cp-dim { color: var(--muted); margin-top: 7px; }
.orange-word { color: #f3b672; font-weight: 600; }
/* Clickable even though the overlay is pointer-events:none. Orange + bold, no underline. */
.cp-link { color: #f3b672; font-weight: 700; cursor: pointer; pointer-events: auto; }
.cp-link:hover { color: #fac487; }

.patch {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 8px; cursor: pointer; display: flex; align-items: stretch; overflow: hidden;
}
.patch-body { flex: 1; min-width: 0; padding: 10px; }
.patch.selected { outline: 2px solid #ff9500; outline-offset: 2px; } /* application enabled — sharp orange */
.patch.editing { background: #b8e6cd; border-color: #8fd3b3; } /* being edited — green slider-bar color */
.patch.editing .patch-name-label, .patch.editing .patch-name, .patch.editing .toggle { color: #10271d; }
.patch.editing .r-label, .patch.editing .name-edit { color: #2c5a45; }
.patch.dim { opacity: .35; } /* hidden patch (eye closed) — dimmed */
.patch.attention { opacity: 1; } /* override dim while calling attention */
/* Full-height drag grip down the left edge of the card. */
.drag-handle {
  display: flex; align-items: center; justify-content: center; width: 24px; flex: none;
  background: var(--bg); border-right: 1px solid var(--line); color: var(--muted);
  cursor: grab; user-select: none; font-size: 14px;
}
.drag-handle:hover { color: var(--text); background: #20232e; }
.drag-handle:active { cursor: grabbing; }
/* Enabled (selected) card → orange slider-bar handle with black dots, orange range field. */
.patch.selected .drag-handle { background: #f3b672; color: #000; }
.patch.selected .drag-handle:hover { background: #fac487; color: #000; }
.patch.selected .r-text { background: #f3b672; color: #1a1206; border-color: #e6b277; }
.appl-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 8px;
  padding: 6px 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 12px;
}
.appl-toggle:hover { border-color: #555a68; }
/* Enabled (selected) → orange slider-bar container + black words; switch uses the orange slider HANDLE. */
.appl-toggle.on { background: #f3b672; border-color: #f3b672; color: #1a1206; }
.appl-toggle.on:hover { background: #fac487; border-color: #fac487; }
.sw { width: 34px; height: 18px; border-radius: 999px; background: #5a5e6b; position: relative; flex: none; transition: background .15s; }
.appl-toggle.on .sw { background: #ff8c00; }
.knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.appl-toggle.on .knob { left: 18px; }

.r-label { font-size: 11px; color: var(--muted); margin-top: 8px; }
.patch-name-label { font-weight: 600; flex: 1; color: var(--text); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.name-edit { font-size: 12px; flex: none; }

/* Drop indicator (sits in the gap between cards) */
.drop-indicator { position: absolute; left: 8px; right: 8px; height: 2px; background: var(--accent); border-radius: 2px; pointer-events: none; z-index: 3; }
.drop-indicator[hidden] { display: none; }

/* Pulsing RED glow to call out the Show/Hide toggle (grows bigger + brighter) */
.toggle { display: inline-flex; align-items: center; }
.toggle.pulse { border-radius: 50%; animation: eyepulse .7s ease-in-out infinite; }
@keyframes eyepulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,45,70,0); color: var(--text); }
  50% { transform: scale(1.95); box-shadow: 0 0 30px 14px rgba(255,45,70,1); color: #ff3b4e; }
}

/* Red attention pulse for the Application toggles (fired from the hint link) */
.appl-toggle.pulse-red { animation: applpulse .7s ease-in-out infinite; position: relative; z-index: 1; }
@keyframes applpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,45,70,0); border-color: var(--line); transform: scale(1); }
  50% { box-shadow: 0 0 28px 10px rgba(255,45,70,.95); border-color: #ff3b4e; transform: scale(1.07); }
}

.del-area { display: flex; gap: 6px; align-items: center; }
.mini-btn.danger { background: var(--danger); color: #fff; border: none; }
.mini-btn.danger:hover { background: #ff6b78; }
.patch-row { display: flex; align-items: center; gap: 8px; }
.patch-name { font-weight: 600; flex: 1; background: transparent; border: none; color: var(--text); font-size: 13px; outline: none; min-width: 0; }
.patch-name:focus { border-bottom: 1px solid var(--accent); }
.swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(255,255,255,.2); flex: none; }
.swatch.thumb { background-color: transparent; background-size: contain; background-repeat: no-repeat; background-position: center; border-color: rgba(255,255,255,.12); }
.patch-range { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 12px; }
.icon-btn { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; }
.icon-btn:hover { color: var(--text); }
.icon-btn.del:hover { color: var(--danger); }
.toggle { cursor: pointer; }

/* Selection context menu */
.sel-menu {
  position: fixed; z-index: 50; min-width: 168px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 5px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.sel-menu[hidden] { display: none; }
.sel-menu button {
  display: block; width: 100%; text-align: left; background: transparent;
  border: none; color: var(--text); padding: 7px 10px; border-radius: 6px;
  cursor: pointer; font-size: 13px;
}
.sel-menu button:hover { background: var(--accent-2); }
.sel-menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.sel-menu-hint { color: var(--muted); font-size: 11px; padding: 4px 10px 4px; }

/* Floating-paste hint */
.float-hint {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 5; background: rgba(8,9,12,.9); border: 1px solid var(--line);
  color: var(--text); padding: 7px 10px 7px 14px; border-radius: 999px;
  font-size: 12.5px; display: flex; align-items: center; gap: 8px;
}
.float-hint[hidden] { display: none; }
.mini-btn {
  background: var(--accent-2); color: #fff; border: none; border-radius: 999px;
  padding: 5px 11px; cursor: pointer; font-size: 12px;
}
.mini-btn:hover { background: var(--accent); }
.mini-btn.ghost { background: var(--panel-2); border: 1px solid var(--line); }
.mini-btn.ghost:hover { background: #2a2f42; }

.toast {
  position: absolute; bottom: 48px; left: 50%; transform: translateX(-50%);
  z-index: 6; background: rgba(0,0,0,.82); color: #fff; padding: 8px 14px;
  border-radius: 999px; font-size: 12.5px; pointer-events: none;
}
.toast[hidden] { display: none; }
.toast svg, .pl-edit svg { width: 15px; height: 15px; vertical-align: middle; }
.edit-note { color: var(--muted); }
.edit-note svg { vertical-align: middle; }

/* Per-frame buffering badge */
.frame-busy {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 4; background: rgba(0,0,0,.7); color: var(--text);
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px;
  display: flex; align-items: center; gap: 8px;
}
.frame-busy[hidden] { display: none; }
.spinner.small { width: 14px; height: 14px; border-width: 2px; margin: 0; }

.spinner {
  width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress box */
.progress-box { width: min(420px, 70vw); text-align: center; }
.progress-label { font-size: 15px; margin-bottom: 12px; }
.bar {
  height: 12px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden;
}
.bar > span {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 999px; transition: width .18s ease;
}
.bar.indeterminate > span {
  width: 35%; border-radius: 999px;
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide {
  0% { margin-left: -35%; } 100% { margin-left: 100%; }
}
.progress-detail {
  display: flex; gap: 10px; justify-content: center; align-items: baseline;
  margin-top: 10px; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.progress-detail .pct { color: var(--text); font-size: 14px; font-weight: 600; }
