:root {
  color-scheme: dark;
  --bg: #0f1117;
  --panel: #171a23;
  --panel2: #202432;
  --text: #edf0f7;
  --muted: #9aa4ba;
  --line: #30364a;
  --accent: #9db7ff;
  --danger: #ff7e8a;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { border: 0; border-radius: 12px; background: var(--accent); color: #111827; padding: 10px 14px; font-weight: 700; cursor: pointer; }
button.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
button.ghost { background: transparent; color: var(--muted); }
button.danger { background: var(--danger); color: #1e0508; }
input, select { background: #10131c; border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 10px 12px; }
.hidden { display: none !important; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 28px; box-shadow: 0 20px 80px rgba(0,0,0,.35); display: grid; gap: 14px; }
.login-card h1 { margin: 0; }
.login-card p { color: var(--muted); margin: 0; }
.hint { font-size: 13px; }
.error { color: var(--danger) !important; min-height: 1.2em; }
.app { min-height: 100vh; display: grid; grid-template-columns: 290px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 18px; border-right: 1px solid var(--line); background: rgba(23,26,35,.96); display: flex; flex-direction: column; gap: 18px; }
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--panel2); color: var(--accent); font-size: 24px; }
.brand h1 { margin: 0; font-size: 22px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.folder-list { display: grid; gap: 8px; overflow: auto; padding-right: 4px; }
.folder-btn { width: 100%; background: transparent; color: var(--text); border: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.folder-btn.active { background: var(--panel2); border-color: var(--accent); }
.folder-btn small { color: var(--muted); }
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; }
.main { padding: 20px; min-width: 0; }
.toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.toolbar h2 { margin: 0 0 4px; font-size: 28px; }
.toolbar p { margin: 0; color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.controls input { width: min(340px, 40vw); }
.check { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); }
.settings-panel, .upload-panel { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); background: rgba(23,26,35,.65); border-radius: 18px; margin-bottom: 14px; }
.settings-panel input[type="number"] { width: 86px; margin-left: 6px; }
.upload-panel input[type="file"] { max-width: 360px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; min-width: 0; display: grid; }
.thumb { height: 160px; display: grid; place-items: center; background: #0b0d13; border-bottom: 1px solid var(--line); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .icon { font-size: 48px; color: var(--muted); }
.card.thumb-error .thumb { border-bottom-color: #56415a; }
.card-body { padding: 12px; display: grid; gap: 10px; }
.name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.meta { color: var(--muted); font-size: 12px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions button { padding: 8px 10px; border-radius: 10px; }
.preview-dialog { width: min(1100px, 94vw); border: 1px solid var(--line); border-radius: 22px; padding: 0; background: var(--panel); color: var(--text); box-shadow: 0 24px 90px rgba(0,0,0,.55); }
.preview-dialog::backdrop { background: rgba(0,0,0,.68); }
.preview-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.preview-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.preview-body { min-height: 280px; max-height: 68vh; overflow: auto; display: grid; place-items: center; background: #0b0d13; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 68vh; }
.preview-body audio { width: min(600px, 90%); }
.preview-error { color: var(--muted); padding: 24px; text-align: center; }
.preview-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.diag-dialog { width: min(980px, 94vw); }
.diagnostics-body { margin: 0; padding: 18px; max-height: 70vh; overflow: auto; white-space: pre-wrap; font-size: 12px; line-height: 1.45; background: #090b10; color: #d7def0; }
.toast { position: fixed; right: 18px; bottom: 18px; background: var(--panel2); border: 1px solid var(--line); padding: 12px 14px; border-radius: 14px; box-shadow: 0 10px 35px rgba(0,0,0,.35); max-width: 440px; z-index: 20; }
.launch-feed { position: fixed; right: 18px; bottom: 72px; width: min(360px, calc(100vw - 36px)); display: grid; gap: 8px; z-index: 19; pointer-events: none; }
.launch-card { pointer-events: auto; display: grid; grid-template-columns: 58px 1fr; gap: 10px; align-items: center; background: rgba(32,36,50,.96); border: 1px solid var(--line); border-radius: 16px; padding: 8px; box-shadow: 0 10px 35px rgba(0,0,0,.35); cursor: pointer; transition: opacity .45s ease, transform .45s ease; }
.launch-card.fading { opacity: .55; transform: translateY(4px); }
.mini-thumb { width: 58px; height: 46px; border-radius: 11px; background: #0b0d13; display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.launch-text { min-width: 0; display: grid; gap: 2px; }
.launch-text strong { font-size: 12px; color: var(--accent); }
.launch-text span { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .toolbar { flex-direction: column; }
  .controls { justify-content: stretch; width: 100%; }
  .controls input { width: 100%; }
}
.control-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 16px; }
.panel { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); background: rgba(23,26,35,.65); border-radius: 18px; min-width: 0; }
.panel h3 { width: 100%; margin: 0 0 2px; font-size: 15px; color: var(--accent); }
.panel input[type="number"] { width: 86px; margin-left: 6px; }
.panel select { max-width: 100%; min-width: 180px; flex: 1 1 180px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-status { width: 100%; margin: 0; color: var(--muted); font-size: 12px; }
.upload-panel input[type="file"] { max-width: 100%; }

.thumb video, .mini-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-video-fallback .thumb { border-bottom-color: var(--accent); }
.rename-box { flex: 1 1 100%; display: grid; grid-template-columns: minmax(180px, 1fr) auto auto auto; gap: 8px; align-items: center; padding-top: 8px; }
.rename-box input { width: 100%; }
@media (max-width: 700px) { .rename-box { grid-template-columns: 1fr; } }


/* Complete-plus3 polish: persistent display history + clearer visual states */
.folder-list { max-height: 34vh; }
.recent-panel {
  border: 1px solid var(--line);
  background: rgba(15, 17, 23, .58);
  border-radius: 18px;
  padding: 10px;
  display: grid;
  gap: 8px;
  min-height: 140px;
  max-height: 36vh;
}
.recent-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--accent); font-size: 13px; }
.mini-btn { padding: 4px 7px; border-radius: 8px; font-size: 12px; }
.recent-list { display: grid; gap: 8px; overflow: auto; padding-right: 2px; }
.empty-recent { color: var(--muted); font-size: 12px; margin: 8px 2px; }
.recent-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 9px;
  align-items: center;
  padding: 7px;
  border: 1px solid rgba(157, 183, 255, .22);
  border-radius: 14px;
  background: rgba(32,36,50,.62);
  cursor: pointer;
  min-width: 0;
}
.recent-card:hover { border-color: var(--accent); background: rgba(32,36,50,.92); }
.recent-text { min-width: 0; display: grid; gap: 1px; }
.recent-text strong { color: var(--accent); font-size: 11px; line-height: 1.1; }
.recent-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--text); }
.recent-text small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }

.launch-feed { width: min(430px, calc(100vw - 36px)); gap: 10px; }
.launch-card {
  grid-template-columns: 72px 1fr;
  padding: 10px;
  border-color: rgba(157, 183, 255, .58);
  box-shadow: 0 16px 52px rgba(0,0,0,.52), 0 0 0 1px rgba(157,183,255,.08) inset;
  animation: launch-pop .18s ease-out;
}
.launch-card.fading { opacity: .76; transform: translateY(3px); }
.mini-thumb { width: 72px; height: 54px; border: 1px solid rgba(255,255,255,.08); }
@keyframes launch-pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

@media (max-width: 820px) {
  .recent-panel { max-height: 240px; }
  .folder-list { max-height: 260px; }
}


/* Complete-plus4 fixes: red video outlines + more visible recent display history */
:root { --video-red: #ff3b3b; --video-red-soft: rgba(255, 59, 59, .38); --video-red-faint: rgba(255, 59, 59, .18); }
.card.kind-video {
  border-color: var(--video-red) !important;
  box-shadow: 0 0 0 1px var(--video-red-faint) inset;
}
.card.kind-video .thumb {
  position: relative;
  border-bottom-color: var(--video-red) !important;
  box-shadow: inset 0 0 0 1px var(--video-red-soft) !important;
}
.card.kind-video .actions button,
.card.kind-video button.secondary {
  outline: 1px solid var(--video-red-soft);
}
.mini-thumb.kind-video {
  position: relative;
  border-color: var(--video-red) !important;
  box-shadow: 0 0 0 1px var(--video-red-faint) inset;
}
.launch-card.kind-video,
.recent-card.kind-video {
  border-color: var(--video-red) !important;
  box-shadow: 0 0 0 1px var(--video-red-faint) inset, 0 12px 34px rgba(0,0,0,.35);
}
.recent-panel {
  min-height: 210px;
  border-color: rgba(157,183,255,.38);
}
.recent-card:first-child {
  background: rgba(45, 50, 70, .88);
  border-color: rgba(157,183,255,.7);
}
.recent-card.kind-video:first-child { border-color: var(--video-red) !important; }

/* Complete-plus5 final UI polish: larger interface, clearer recent history, no video badges */
:root {
  --ui-scale-note: 1.25;
}

/* Approximate 125% UI scale without using CSS zoom, so layout stays predictable. */
.app { grid-template-columns: 362px 1fr; }
.sidebar { padding: 22px; gap: 22px; }
.main { padding: 25px; }
button { border-radius: 15px; padding: 12px 17px; }
input, select { border-radius: 15px; padding: 12px 15px; }
.logo { width: 55px; height: 55px; border-radius: 18px; font-size: 30px; }
.brand { gap: 15px; }
.brand h1 { font-size: 28px; }
.brand p { font-size: 15px; }
.toolbar { gap: 22px; margin-bottom: 18px; }
.toolbar h2 { font-size: 35px; }
.toolbar p { font-size: 16px; }
.controls { gap: 12px; }
.controls input { width: min(425px, 40vw); }
.settings-panel, .upload-panel, .panel { padding: 15px; border-radius: 22px; gap: 12px; }
.panel h3 { font-size: 19px; }
.mini-status, .meta, .hint { font-size: 15px; }
.folder-list { gap: 10px; }
.folder-btn { padding: 12px 15px; border-radius: 15px; }
.grid { grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 18px; }
.card { border-radius: 22px; }
.thumb { height: 200px; }
.thumb .icon { font-size: 60px; }
.card-body { padding: 15px; gap: 12px; }
.name { font-size: 17px; }
.actions { gap: 10px; }
.actions button { padding: 10px 12px; border-radius: 13px; }
.control-grid { grid-template-columns: repeat(auto-fit, minmax(325px, 1fr)); gap: 15px; margin-bottom: 20px; }
.toast { right: 22px; bottom: 22px; padding: 15px 18px; border-radius: 18px; max-width: 550px; }
.launch-feed { right: 22px; bottom: 90px; width: min(520px, calc(100vw - 44px)); gap: 12px; }
.launch-card { grid-template-columns: 90px 1fr; padding: 12px; border-radius: 20px; }
.launch-card .mini-thumb { width: 90px; height: 68px; border-radius: 14px; }
.launch-text strong { font-size: 15px; }
.launch-text span { font-size: 16px; }

/* Recent display panel: larger thumbnails and text so the history is readable at a glance. */
.recent-panel {
  min-height: 285px;
  max-height: 46vh;
  padding: 13px;
  border-radius: 22px;
  gap: 10px;
}
.recent-head { font-size: 16px; }
.mini-btn { padding: 6px 9px; border-radius: 10px; font-size: 14px; }
.recent-list { gap: 10px; }
.empty-recent { font-size: 15px; }
.recent-card {
  grid-template-columns: 104px 1fr;
  gap: 12px;
  padding: 10px;
  border-radius: 18px;
}
.recent-card .mini-thumb {
  width: 104px;
  height: 78px;
  border-radius: 15px;
}
.recent-text { gap: 3px; }
.recent-text strong { font-size: 14px; }
.recent-text span { font-size: 15px; }
.recent-text small { font-size: 13px; }

/* Keep the thin red outline for videos, but remove the cluttery VIDEO pill. */
.card.kind-video .thumb::after,
.mini-thumb.kind-video::after {
  content: none !important;
  display: none !important;
}

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .recent-panel { max-height: 340px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}


/* Complete-plus6 final fixes: no video pills, stronger red outlines, safer card/action layout. */
.card { grid-template-rows: auto 1fr; }
.card-body { display: flex !important; flex-direction: column; min-height: 118px; }
.actions { margin-top: auto; display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.actions button { min-width: 0; white-space: nowrap; }

.card.kind-video,
.launch-card.kind-video,
.recent-card.kind-video {
  border: 2px solid var(--video-red) !important;
}
.card.kind-video .thumb,
.mini-thumb.kind-video {
  border: 2px solid var(--video-red) !important;
  box-shadow: inset 0 0 0 2px var(--video-red-faint) !important;
}
.card.kind-video .actions button,
.card.kind-video button.secondary {
  outline: 2px solid var(--video-red-soft) !important;
  outline-offset: -2px;
}
.card.kind-video .thumb::before,
.card.kind-video .thumb::after,
.mini-thumb.kind-video::before,
.mini-thumb.kind-video::after,
.launch-card.kind-video::before,
.launch-card.kind-video::after,
.recent-card.kind-video::before,
.recent-card.kind-video::after {
  content: "" !important;
  display: none !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.launch-card,
.recent-card {
  grid-template-columns: 112px minmax(0, 1fr) !important;
  overflow: hidden;
}
.launch-card .mini-thumb,
.recent-card .mini-thumb {
  width: 112px !important;
  height: 84px !important;
  flex: 0 0 auto;
}
.launch-text,
.recent-text {
  min-width: 0 !important;
  overflow: hidden;
  align-self: center;
}
.launch-text strong,
.launch-text span,
.recent-text strong,
.recent-text span,
.recent-text small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#randomCurrentBtn { white-space: nowrap; }


/* Complete-plus7 root fixes: constrain video thumbnails, remove badges/pills, keep controls visible. */
.card.kind-video,
.launch-card.kind-video,
.recent-card.kind-video {
  border: 3px solid var(--video-red) !important;
}
.card.kind-video .thumb,
.mini-thumb.kind-video {
  border: 3px solid var(--video-red) !important;
  box-shadow: inset 0 0 0 2px rgba(255,59,59,.22) !important;
}
.card.kind-video .thumb::before,
.card.kind-video .thumb::after,
.card.kind-video .card-body::before,
.card.kind-video .card-body::after,
.mini-thumb.kind-video::before,
.mini-thumb.kind-video::after,
.launch-card.kind-video::before,
.launch-card.kind-video::after,
.recent-card.kind-video::before,
.recent-card.kind-video::after,
.thumb::before,
.thumb::after,
.mini-thumb::before,
.mini-thumb::after {
  content: none !important;
  display: none !important;
}
.thumb,
.mini-thumb {
  overflow: hidden !important;
}
.thumb video,
.mini-thumb video {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  pointer-events: none !important;
}
.card {
  overflow: hidden !important;
}
.card-body {
  position: relative !important;
  z-index: 3 !important;
  background: var(--panel) !important;
}
.actions {
  position: relative !important;
  z-index: 4 !important;
  visibility: visible !important;
  opacity: 1 !important;
}
.actions button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  visibility: visible !important;
  opacity: 1 !important;
}
.card.kind-video .actions button,
.card.kind-video button.secondary {
  outline: 0 !important;
}
.launch-card,
.recent-card {
  align-items: stretch !important;
}
.launch-card .mini-thumb,
.recent-card .mini-thumb {
  align-self: center !important;
}
.launch-text,
.recent-text {
  align-self: center !important;
  min-width: 0 !important;
  max-width: 100% !important;
}
.launch-text strong,
.launch-text span,
.recent-text strong,
.recent-text span,
.recent-text small {
  display: block !important;
  min-width: 0 !important;
  max-width: 100% !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}


/* Complete-plus8 layout polish: side video preview, slimmer media preview controls, scrollable recent history. */
.preview-dialog {
  width: min(1240px, 94vw) !important;
  max-height: 92vh !important;
  overflow: hidden !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 230px !important;
  grid-template-areas:
    "head head"
    "body actions" !important;
}
.preview-head { grid-area: head; min-width: 0; }
.preview-body {
  grid-area: body;
  min-height: min(620px, calc(92vh - 88px)) !important;
  max-height: calc(92vh - 88px) !important;
  overflow: auto !important;
  border-right: 1px solid var(--line);
}
.preview-body img,
.preview-body video {
  max-width: 100% !important;
  max-height: calc(92vh - 110px) !important;
  object-fit: contain !important;
}
.preview-actions {
  grid-area: actions;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  flex-wrap: nowrap !important;
  gap: 10px !important;
  padding: 14px !important;
  border-top: 0 !important;
  border-left: 1px solid rgba(255,255,255,.03);
  overflow: auto;
  min-width: 0;
}
.preview-actions button { width: 100%; justify-content: center; }
.rename-box {
  display: grid;
  grid-template-columns: 1fr !important;
  gap: 8px !important;
  padding-top: 6px !important;
}
.rename-box.hidden { display: none !important; }

.sidebar {
  min-height: 0 !important;
  overflow: hidden !important;
}
.folder-list {
  flex: 0 1 auto !important;
  max-height: 26vh !important;
  min-height: 84px !important;
}
.recent-panel {
  flex: 1 1 0 !important;
  min-height: 260px !important;
  max-height: none !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}
.recent-list {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  padding-right: 6px !important;
}
.recent-card {
  flex: 0 0 auto !important;
  min-height: 108px !important;
}

.side-preview {
  position: fixed;
  top: 18px;
  right: 18px;
  width: min(520px, 36vw);
  max-width: calc(100vw - 36px);
  max-height: calc(100vh - 36px);
  z-index: 18;
  background: rgba(23, 26, 35, .98);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 22px 75px rgba(0,0,0,.55), 0 0 0 1px rgba(157,183,255,.08) inset;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto;
}
.side-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.side-preview-head strong,
.side-preview-head p {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.side-preview-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.side-preview-body {
  background: #0b0d13;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 280px;
}
.side-preview-body video {
  width: 100%;
  height: 100%;
  max-height: 58vh;
  object-fit: contain;
  display: block;
}
.side-preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.side-preview-actions #sideOpenModalPreview { grid-column: 1 / -1; }

@media (max-width: 1040px) {
  .side-preview {
    width: min(460px, calc(100vw - 28px));
    right: 14px;
    top: 14px;
  }
}
@media (max-width: 820px) {
  .preview-dialog {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "head"
      "body"
      "actions" !important;
  }
  .preview-body { border-right: 0; min-height: 320px !important; max-height: 62vh !important; }
  .preview-actions { border-left: 0; border-top: 1px solid var(--line) !important; }
  .side-preview {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
  .recent-panel { max-height: 420px !important; }
}


/* Complete-plus9: media-first cards, image side preview, compact non-blocking launch feed. */
.grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
  align-items: start !important;
}
.card {
  position: relative !important;
  display: block !important;
  border-radius: 24px !important;
  overflow: hidden !important;
  background: #0b0d13 !important;
  min-height: 0 !important;
}
.card .thumb {
  height: auto !important;
  aspect-ratio: 1 / 1 !important;
  border-bottom: 0 !important;
  cursor: pointer !important;
}
.card .thumb img,
.card .thumb video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.card .card-body {
  position: absolute !important;
  inset: auto 0 0 0 !important;
  z-index: 5 !important;
  min-height: 0 !important;
  padding: 54px 12px 12px !important;
  gap: 7px !important;
  background: linear-gradient(to top, rgba(5,7,11,.72) 0%, rgba(5,7,11,.42) 48%, rgba(5,7,11,0) 100%) !important;
  pointer-events: none !important;
}
.card .name,
.card .meta,
.card .actions {
  pointer-events: auto !important;
}
.card .name {
  color: #fff !important;
  text-shadow: 0 2px 10px rgba(0,0,0,.9) !important;
  line-height: 1.15 !important;
}
.card .meta {
  color: rgba(237,240,247,.78) !important;
  text-shadow: 0 1px 8px rgba(0,0,0,.9) !important;
  font-size: 12px !important;
}
.card .actions {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 8px !important;
  margin-top: 4px !important;
  position: relative !important;
  z-index: 8 !important;
}
.card .actions button {
  padding: 8px 10px !important;
  border-radius: 999px !important;
  background: rgba(157,183,255,.88) !important;
  color: #0f1117 !important;
  border: 1px solid rgba(255,255,255,.25) !important;
  box-shadow: 0 4px 18px rgba(0,0,0,.35) !important;
  backdrop-filter: blur(8px) !important;
}
.card .actions button.secondary {
  background: rgba(23,26,35,.74) !important;
  color: var(--text) !important;
}
.card.kind-video {
  border: 3px solid var(--video-red) !important;
}
.card.kind-video .thumb {
  border: 0 !important;
  box-shadow: inset 0 0 0 3px var(--video-red) !important;
}

/* Launch previews should be helpful but should never block the workspace. */
.launch-feed {
  width: min(360px, calc(100vw - 36px)) !important;
  max-height: 30vh !important;
  overflow: hidden !important;
  gap: 8px !important;
  pointer-events: none !important;
  z-index: 12 !important;
}
.launch-card {
  grid-template-columns: 72px minmax(0, 1fr) !important;
  padding: 8px !important;
  border-radius: 16px !important;
  opacity: .96 !important;
  pointer-events: auto !important;
}
.launch-card .mini-thumb {
  width: 72px !important;
  height: 54px !important;
  border-radius: 12px !important;
}
.launch-text strong { font-size: 12px !important; }
.launch-text span { font-size: 13px !important; }

/* The side preview now handles images and videos. */
.side-preview {
  width: min(540px, 36vw) !important;
  grid-template-rows: auto minmax(260px, 1fr) auto !important;
}
.side-preview-body img,
.side-preview-body video {
  width: 100% !important;
  height: 100% !important;
  max-height: 62vh !important;
  object-fit: contain !important;
  display: block !important;
}
.side-preview-body audio {
  width: min(440px, 92%) !important;
}
@media (max-width: 820px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)) !important; }
  .card .card-body { padding: 46px 10px 10px !important; }
  .launch-feed { width: min(320px, calc(100vw - 24px)) !important; right: 12px !important; bottom: 72px !important; }
}

/* Let visual launch notifications float above the UI without stealing clicks. Use Recent displays for reopening items. */
.launch-card { pointer-events: none !important; }


/* Complete-plus10: slightly taller media cards for clearer thumbnails/previews. */
.card .thumb {
  aspect-ratio: 5 / 6 !important;
}
@media (max-width: 820px) {
  .card .thumb { aspect-ratio: 5 / 6 !important; }
}

/* Plus13 polish: calmer monochrome theme, mobile layout, cleaner panels. */
:root {
  --bg: #08090b;
  --panel: #111216;
  --panel2: #181a1f;
  --text: #ececec;
  --muted: #a2a2a2;
  --line: rgba(238,238,238,.18);
  --accent: #e1e1e1;
  --danger: #d76666;
  --video-red: #ff4040;
  --video-red-soft: rgba(255,64,64,.45);
  --video-red-faint: rgba(255,64,64,.18);
}
body {
  background: radial-gradient(circle at top left, rgba(255,255,255,.035), transparent 32rem), var(--bg) !important;
}
.sidebar,
.login-card,
.panel,
.preview-dialog,
.side-preview,
.recent-panel,
.launch-card,
.toast {
  background: rgba(15,16,20,.96) !important;
  border-color: var(--line) !important;
  box-shadow: 0 18px 70px rgba(0,0,0,.54) !important;
}
button {
  background: #dcdcdc !important;
  color: #0d0e10 !important;
}
button.secondary,
button.ghost,
.folder-btn {
  background: rgba(255,255,255,.045) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
}
button.ghost { color: var(--muted) !important; }
button:hover, .folder-btn:hover {
  border-color: rgba(255,255,255,.42) !important;
  filter: brightness(1.08);
}
button:disabled { opacity: .45; cursor: not-allowed; }
.logo { background: rgba(255,255,255,.065) !important; color: var(--text) !important; border: 1px solid var(--line); }
.folder-list {
  border: 1px solid var(--line) !important;
  background: rgba(255,255,255,.026) !important;
  border-radius: 18px !important;
  padding: 10px !important;
}
.folder-btn.active {
  background: rgba(255,255,255,.14) !important;
  border-color: rgba(255,255,255,.62) !important;
}
.card { border-color: rgba(255,255,255,.18) !important; }
.card .actions button {
  background: rgba(235,235,235,.86) !important;
  color: #07080a !important;
}
.card .actions button.secondary {
  background: rgba(9,10,12,.78) !important;
  color: var(--text) !important;
  border-color: rgba(255,255,255,.24) !important;
}
input, select {
  background: rgba(5,6,8,.88) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}
.link-panel input { flex: 1 1 260px; min-width: min(100%, 220px); }

/* Prevent long names from pushing the side-preview close button away. */
.side-preview-head > div,
.preview-head > div { min-width: 0 !important; flex: 1 1 auto !important; }
#closeSidePreview,
#closePreview,
#closeDiagnostics { flex: 0 0 auto !important; align-self: start !important; }
.side-preview-head strong,
.side-preview-head p,
.preview-head strong,
.preview-head p { max-width: 100% !important; }

/* Ensure tucked-away preview/diagnostic elements are truly closed. */
.side-preview.hidden { display: none !important; visibility: hidden !important; pointer-events: none !important; }
dialog:not([open]) { display: none !important; }

/* Mobile: keep the site usable instead of turning it into a long vertical wall. */
@media (max-width: 720px) {
  body { font-size: 14px !important; }
  .app {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
  }
  .sidebar {
    position: static !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 10px !important;
    gap: 10px !important;
    border-right: 0 !important;
    border-bottom: 1px solid var(--line) !important;
  }
  .brand { gap: 10px !important; }
  .logo { width: 40px !important; height: 40px !important; border-radius: 13px !important; font-size: 22px !important; }
  .brand h1 { font-size: 18px !important; }
  .brand p { font-size: 11px !important; }
  .folder-list {
    display: flex !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: none !important;
    min-height: 0 !important;
    gap: 8px !important;
    padding: 8px !important;
    border-radius: 14px !important;
  }
  .folder-btn {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 92px !important;
    padding: 9px 11px !important;
    border-radius: 999px !important;
    gap: 10px !important;
  }
  .recent-panel {
    min-height: 120px !important;
    max-height: 180px !important;
    padding: 9px !important;
    border-radius: 14px !important;
  }
  .recent-card {
    min-height: 72px !important;
    grid-template-columns: 76px minmax(0,1fr) !important;
    padding: 6px !important;
  }
  .recent-card .mini-thumb { width: 76px !important; height: 56px !important; border-radius: 11px !important; }
  .recent-text strong { font-size: 11px !important; }
  .recent-text span { font-size: 12px !important; }
  .recent-text small { font-size: 10px !important; }
  .sidebar-footer { display: flex !important; gap: 8px !important; margin-top: 0 !important; }
  .sidebar-footer button { flex: 1 1 0 !important; padding: 9px 10px !important; }

  .main { padding: 10px !important; }
  .toolbar {
    display: grid !important;
    gap: 10px !important;
    margin-bottom: 10px !important;
  }
  .toolbar h2 { font-size: 23px !important; }
  .toolbar p { font-size: 12px !important; }
  .controls {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    justify-content: stretch !important;
  }
  .controls input { width: 100% !important; grid-column: 1 / -1; }
  .controls select,
  .controls button,
  .controls label { width: 100% !important; min-width: 0 !important; }

  .control-grid {
    display: grid !important;
    grid-auto-flow: column !important;
    grid-auto-columns: min(82vw, 330px) !important;
    grid-template-columns: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 10px !important;
    margin-bottom: 12px !important;
    padding-bottom: 5px !important;
    scroll-snap-type: x proximity;
  }
  .panel {
    scroll-snap-align: start;
    align-content: start !important;
    min-height: 132px !important;
    padding: 11px !important;
    border-radius: 16px !important;
  }
  .panel h3 { font-size: 15px !important; }
  .panel input[type="number"] { width: 72px !important; }
  .panel select { min-width: 0 !important; }
  .upload-panel input[type="file"] { font-size: 12px !important; }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }
  .card { border-radius: 16px !important; }
  .card .card-body {
    padding: 42px 8px 8px !important;
    gap: 5px !important;
  }
  .card .name { font-size: 12px !important; }
  .card .meta { font-size: 10px !important; }
  .card .actions { gap: 6px !important; }
  .card .actions button { padding: 7px 8px !important; font-size: 12px !important; }

  .side-preview {
    inset: auto 8px 8px 8px !important;
    width: auto !important;
    max-width: none !important;
    max-height: 58vh !important;
    border-radius: 18px !important;
    grid-template-rows: auto minmax(160px, 1fr) auto !important;
  }
  .side-preview-head { padding: 10px 12px !important; }
  .side-preview-body { min-height: 160px !important; }
  .side-preview-body img,
  .side-preview-body video { max-height: 36vh !important; }
  .side-preview-actions { padding: 9px !important; gap: 8px !important; }
  .preview-dialog { width: 96vw !important; max-height: 88vh !important; }
  .preview-body { min-height: 230px !important; }
  .launch-feed { width: min(280px, calc(100vw - 20px)) !important; right: 10px !important; bottom: 10px !important; max-height: 22vh !important; }
  .launch-card { grid-template-columns: 56px minmax(0,1fr) !important; }
  .launch-card .mini-thumb { width: 56px !important; height: 42px !important; }
}

/* Plus14 declutter pass: quieter monochrome UI, visual state instead of text. */
:root {
  --bg: #070708;
  --panel: #0d0e10;
  --panel2: #121317;
  --text: #eeeeea;
  --muted: #c9c7be;
  --line: rgba(245,243,235,.34);
  --line-soft: rgba(245,243,235,.18);
  --accent: #f1f0ea;
  --active: #85d59a;
  --active-soft: rgba(133,213,154,.18);
  --off: #d58a85;
  --off-soft: rgba(213,138,133,.16);
  --warn: #d6be7b;
  --warn-soft: rgba(214,190,123,.16);
}
body {
  background: linear-gradient(180deg, #09090a 0%, #060607 100%) !important;
}
.sidebar,
.login-card,
.panel,
.preview-dialog,
.side-preview,
.recent-panel,
.launch-card,
.toast,
.card,
.folder-list {
  background: rgba(10,11,13,.96) !important;
  border-color: var(--line-soft) !important;
}
.panel,
.recent-panel,
.folder-list,
.card,
.side-preview,
.preview-dialog {
  box-shadow: none !important;
}
.brand p,
#folderMeta,
.meta,
.hint,
.mini-status,
.recent-text small,
.launch-text span {
  color: var(--muted) !important;
}
#folderMeta { opacity: .78; }
.panel h3,
.recent-head,
.folder-btn.active,
.recent-text strong {
  color: var(--text) !important;
}
.panel h3 { letter-spacing: .02em; }
button,
button.secondary,
button.ghost,
.folder-btn,
input,
select {
  border-color: var(--line-soft) !important;
}
button.secondary,
button.ghost,
.folder-btn {
  background: rgba(255,255,255,.035) !important;
}
button:not(.ghost):not(.secondary) {
  background: #e9e6dc !important;
  color: #08090a !important;
}
button:hover,
.folder-btn:hover,
.card:hover {
  border-color: var(--line) !important;
  filter: none !important;
}
.folder-list,
.control-grid,
.panel {
  scrollbar-color: rgba(245,243,235,.32) transparent;
}
.quiet-status {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.state-btn.is-active {
  background: var(--active-soft) !important;
  border-color: rgba(133,213,154,.75) !important;
  color: #dff7e5 !important;
}
.state-btn.is-off {
  background: var(--off-soft) !important;
  border-color: rgba(213,138,133,.68) !important;
  color: #f6dddd !important;
}
.state-btn.is-warn {
  background: var(--warn-soft) !important;
  border-color: rgba(214,190,123,.68) !important;
  color: #f5edcf !important;
}
.panel-active {
  border-color: rgba(133,213,154,.45) !important;
}
.panel-off {
  border-color: rgba(213,138,133,.38) !important;
}
.card .meta {
  display: none !important;
}
.card .name {
  color: var(--text) !important;
  opacity: .94;
}
.recent-text small {
  display: none !important;
}
.launch-card {
  opacity: .96;
}
.launch-text strong {
  color: var(--text) !important;
}
/* Hide the diagnostics affordance until needed while keeping it available. */
#diagnosticsBtn {
  opacity: .72;
}
#diagnosticsBtn:hover {
  opacity: 1;
}
.sidebar-footer {
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}
/* The folder/tab strip gets its own quiet boundary so it never visually melts into the background. */
.folder-list {
  border: 1px solid var(--line-soft) !important;
  background: rgba(255,255,255,.018) !important;
}
.folder-btn.active {
  background: rgba(255,255,255,.105) !important;
  border-color: rgba(245,243,235,.52) !important;
}
@media (max-width: 720px) {
  .panel h3 { font-size: 14px !important; }
  .panel { min-height: 118px !important; }
  .controls { grid-template-columns: 1fr !important; }
  .recent-text small { display: none !important; }
}


/* Plus17: collapsible left sidebar, docked right preview sidebar, cleaner/vivid state buttons. */
.app {
  grid-template-columns: 362px minmax(0, 1fr) !important;
  transition: grid-template-columns .18s ease !important;
}
.app.preview-open {
  grid-template-columns: 362px minmax(0, 1fr) minmax(380px, 32vw) !important;
}
.app.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr) !important;
}
.app.sidebar-collapsed.preview-open {
  grid-template-columns: 0 minmax(0, 1fr) minmax(380px, 32vw) !important;
}
.sidebar {
  transition: transform .18s ease, opacity .18s ease, padding .18s ease !important;
  z-index: 6 !important;
}
.app.sidebar-collapsed .sidebar {
  transform: translateX(-100%) !important;
  opacity: 0 !important;
  pointer-events: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  border-right: 0 !important;
}
.sidebar-collapse-btn {
  margin-left: auto !important;
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  font-size: 24px !important;
}
.sidebar-open-btn {
  width: 46px !important;
  height: 46px !important;
  padding: 0 !important;
  border-radius: 14px !important;
  flex: 0 0 auto !important;
  color: var(--text) !important;
  background: rgba(255,255,255,.055) !important;
  border: 1px solid var(--line-soft) !important;
}
.toolbar {
  display: flex !important;
  align-items: center !important;
}
.toolbar > div:first-of-type { min-width: 0 !important; }

/* Dock the preview as the right column instead of an overlay. */
.side-preview {
  position: sticky !important;
  top: 0 !important;
  right: auto !important;
  width: auto !important;
  max-width: none !important;
  height: 100vh !important;
  max-height: 100vh !important;
  grid-column: 3 !important;
  z-index: 5 !important;
  border-radius: 0 !important;
  border-left: 1px solid var(--line-soft) !important;
  border-top: 0 !important;
  border-right: 0 !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
  background: rgba(8,9,11,.98) !important;
  grid-template-rows: auto minmax(0, 1fr) auto !important;
}
.side-preview.hidden { display: none !important; }
.side-preview-head {
  background: rgba(255,255,255,.018) !important;
}
.side-preview-body {
  min-height: 0 !important;
  background: #050607 !important;
  padding: 10px !important;
}
.side-preview-body img,
.side-preview-body video {
  max-height: calc(100vh - 190px) !important;
}
.side-preview-actions {
  background: rgba(255,255,255,.018) !important;
}

/* No PC toggle button in the cleaner UI; keep explicit On/Off/Timed only. */
#pcToggleBtn { display: none !important; }

/* More vivid but still sleek state/action feedback. */
:root {
  --vivid-green: rgba(43, 214, 110, .30);
  --vivid-green-line: rgba(102, 246, 158, .82);
  --vivid-red: rgba(244, 74, 74, .27);
  --vivid-red-line: rgba(255, 116, 116, .78);
  --vivid-yellow: rgba(245, 191, 70, .24);
  --vivid-yellow-line: rgba(255, 221, 116, .76);
}
.state-btn.is-active,
#loopStartBtn.is-active,
#pcOnBtn.is-active {
  background: var(--vivid-green) !important;
  border-color: var(--vivid-green-line) !important;
  color: #eaffef !important;
  box-shadow: 0 0 0 1px rgba(102,246,158,.18) inset !important;
}
.state-btn.is-off,
#loopStopBtn.is-off,
#pcOffBtn.is-off {
  background: var(--vivid-red) !important;
  border-color: var(--vivid-red-line) !important;
  color: #ffeaea !important;
  box-shadow: 0 0 0 1px rgba(255,116,116,.16) inset !important;
}
.state-btn.is-warn {
  background: var(--vivid-yellow) !important;
  border-color: var(--vivid-yellow-line) !important;
  color: #fff7d8 !important;
}
.panel-active {
  border-color: rgba(102,246,158,.55) !important;
}
.panel-off {
  border-color: rgba(255,116,116,.42) !important;
}

@media (max-width: 1050px) {
  .app.preview-open,
  .app.sidebar-collapsed.preview-open {
    grid-template-columns: 0 minmax(0,1fr) minmax(330px, 42vw) !important;
  }
  .app:not(.sidebar-collapsed).preview-open {
    grid-template-columns: 300px minmax(0,1fr) minmax(330px, 38vw) !important;
  }
}
@media (max-width: 820px) {
  .app,
  .app.preview-open,
  .app.sidebar-collapsed,
  .app.sidebar-collapsed.preview-open {
    grid-template-columns: 1fr !important;
  }
  .app.sidebar-collapsed .sidebar {
    display: none !important;
  }
  .side-preview {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    top: auto !important;
    bottom: 10px !important;
    width: auto !important;
    height: min(64vh, 560px) !important;
    max-height: 64vh !important;
    border: 1px solid var(--line-soft) !important;
    border-radius: 22px !important;
    z-index: 30 !important;
    box-shadow: 0 18px 70px rgba(0,0,0,.62) !important;
  }
  .side-preview-body img,
  .side-preview-body video {
    max-height: 44vh !important;
  }
}


/* Plus18: dedicated phone layout. Desktop remains unchanged; phones get a true app-style UI instead of a squeezed desktop. */
html, body {
  max-width: 100%;
  overflow-x: hidden !important;
}

@media (max-width: 720px) {
  html, body {
    width: 100%;
    min-height: 100dvh;
    overflow-x: hidden !important;
    overscroll-behavior-x: none;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
  }

  body {
    background: #060607 !important;
  }

  .app,
  .app.preview-open,
  .app.sidebar-collapsed,
  .app.sidebar-collapsed.preview-open {
    display: block !important;
    width: 100% !important;
    min-height: 100dvh !important;
    grid-template-columns: none !important;
    overflow-x: hidden !important;
  }

  /* The folder/profile area becomes a drawer, not a giant block above the gallery. */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: min(86vw, 360px) !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 60 !important;
    padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) !important;
    gap: 12px !important;
    border-right: 1px solid var(--line-soft) !important;
    border-bottom: 0 !important;
    background: rgba(7,8,10,.98) !important;
    box-shadow: 18px 0 58px rgba(0,0,0,.7) !important;
    transform: translateX(0) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .app.sidebar-collapsed .sidebar {
    display: block !important;
    transform: translateX(calc(-100% - 8px)) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .brand {
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr) 40px !important;
    align-items: center !important;
  }

  .brand h1,
  .brand p {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .folder-list {
    display: flex !important;
    gap: 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 8px !important;
  }

  .folder-btn {
    min-width: auto !important;
    flex: 0 0 auto !important;
    padding: 8px 10px !important;
    font-size: 13px !important;
  }

  .recent-panel {
    min-height: 180px !important;
    max-height: 42dvh !important;
  }

  .recent-card {
    min-height: 68px !important;
    grid-template-columns: 72px minmax(0, 1fr) !important;
  }

  .recent-card .mini-thumb {
    width: 72px !important;
    height: 54px !important;
  }

  .main {
    width: 100% !important;
    max-width: 100vw !important;
    padding: 8px 8px calc(12px + env(safe-area-inset-bottom)) !important;
    overflow-x: hidden !important;
  }

  .toolbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 35 !important;
    display: grid !important;
    grid-template-columns: 42px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 8px !important;
    margin: -8px -8px 8px !important;
    padding: calc(8px + env(safe-area-inset-top)) 8px 8px !important;
    background: rgba(6,7,9,.96) !important;
    border-bottom: 1px solid var(--line-soft) !important;
    backdrop-filter: blur(10px) !important;
  }

  .sidebar-open-btn {
    width: 42px !important;
    height: 42px !important;
    border-radius: 13px !important;
  }

  .toolbar h2 {
    margin: 0 !important;
    font-size: 18px !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  #folderMeta {
    display: none !important;
  }

  .controls {
    grid-column: 1 / -1 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 92px auto !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .controls input,
  .controls select,
  .controls label {
    min-width: 0 !important;
    width: 100% !important;
    height: 40px !important;
    padding: 8px 9px !important;
    font-size: 13px !important;
    border-radius: 12px !important;
  }

  .controls .check {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    background: rgba(255,255,255,.035) !important;
    border: 1px solid var(--line-soft) !important;
    color: var(--text) !important;
  }

  /* Controls stay available, but as small swipeable cards rather than a huge page. */
  .control-grid {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    margin: 0 -8px 10px !important;
    padding: 0 8px 8px !important;
    scroll-snap-type: x proximity !important;
    scrollbar-width: thin !important;
  }

  .panel {
    flex: 0 0 min(74vw, 290px) !important;
    min-height: 94px !important;
    padding: 9px !important;
    gap: 7px !important;
    border-radius: 15px !important;
    scroll-snap-align: start !important;
  }

  .panel h3 {
    font-size: 13px !important;
    line-height: 1.1 !important;
    margin-bottom: 0 !important;
  }

  .panel label,
  .panel span,
  .panel p {
    font-size: 12px !important;
  }

  .panel input,
  .panel select,
  .panel button {
    padding: 7px 8px !important;
    border-radius: 11px !important;
    font-size: 12px !important;
  }

  .panel input[type="number"] {
    width: 58px !important;
    margin-left: 4px !important;
  }

  .panel select {
    min-width: 0 !important;
    flex: 1 1 120px !important;
  }

  .button-row {
    gap: 6px !important;
  }

  .upload-panel input[type="file"] {
    max-width: 100% !important;
    font-size: 11px !important;
  }

  .grid {
    width: 100% !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .card {
    border-radius: 14px !important;
  }

  .card .thumb {
    aspect-ratio: 4 / 5 !important;
  }

  .card .card-body {
    padding: 38px 7px 7px !important;
    gap: 4px !important;
  }

  .card .name {
    font-size: 11px !important;
    line-height: 1.1 !important;
    max-height: 2.2em !important;
    overflow: hidden !important;
  }

  .card .actions {
    gap: 5px !important;
  }

  .card .actions button {
    padding: 6px 6px !important;
    min-height: 30px !important;
    font-size: 11px !important;
    border-radius: 999px !important;
  }

  /* Phone preview is a bottom sheet, not a full horizontal desktop sidebar. */
  .side-preview {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    height: auto !important;
    max-height: 54dvh !important;
    min-height: 0 !important;
    z-index: 70 !important;
    border: 1px solid var(--line-soft) !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    display: grid !important;
    grid-template-rows: auto minmax(120px, 1fr) auto !important;
    background: rgba(7,8,10,.985) !important;
    box-shadow: 0 18px 70px rgba(0,0,0,.75) !important;
  }

  .side-preview.hidden {
    display: none !important;
  }

  .side-preview-head {
    padding: 8px 10px !important;
    gap: 8px !important;
  }

  .side-preview-head strong {
    font-size: 13px !important;
  }

  .side-preview-head p {
    display: none !important;
  }

  #closeSidePreview {
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    border-radius: 999px !important;
  }

  .side-preview-body {
    min-height: 120px !important;
    max-height: 34dvh !important;
    padding: 6px !important;
    overflow: hidden !important;
  }

  .side-preview-body img,
  .side-preview-body video {
    width: 100% !important;
    height: 100% !important;
    max-height: 33dvh !important;
    object-fit: contain !important;
  }

  .side-preview-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 6px !important;
    padding: 8px !important;
  }

  .side-preview-actions #sideOpenModalPreview {
    grid-column: auto !important;
  }

  .side-preview-actions button {
    padding: 8px 6px !important;
    min-height: 34px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    white-space: nowrap !important;
  }

  .preview-dialog {
    width: calc(100vw - 16px) !important;
    max-height: 84dvh !important;
    border-radius: 18px !important;
  }

  .preview-head {
    padding: 10px 12px !important;
  }

  .preview-body {
    min-height: 180px !important;
    max-height: 48dvh !important;
  }

  .preview-actions {
    padding: 9px !important;
    gap: 7px !important;
  }

  .launch-feed,
  .toast {
    display: none !important;
  }
}

@media (max-width: 390px) {
  .controls {
    grid-template-columns: minmax(0, 1fr) 80px !important;
  }
  .controls .check {
    grid-column: 1 / -1 !important;
    justify-self: start !important;
    width: auto !important;
    padding: 7px 10px !important;
    height: auto !important;
  }
  .grid {
    gap: 7px !important;
  }
  .card .actions button {
    font-size: 10px !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
}

/* plus19: master account controls */
.admin-dialog { width: min(720px, 94vw) !important; }
.admin-body { padding: 16px 18px 18px; display: grid; gap: 14px; background: var(--panel); }
.admin-toggle { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(12,14,20,.72); color: var(--text); }
.admin-accounts { display: grid; gap: 9px; max-height: min(62vh, 520px); overflow: auto; padding-right: 4px; }
.admin-account-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 14px; background: rgba(8,10,15,.72); }
.admin-account-row.disabled { opacity: .58; }
.admin-account-row.master { border-color: rgba(157,183,255,.48); }
.admin-account-info { min-width: 0; display: grid; gap: 2px; }
.admin-account-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.admin-account-info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 12px; }
.admin-account-row button { min-width: 72px; }
@media (max-width: 720px) {
  .admin-dialog { width: calc(100vw - 16px) !important; max-height: 86dvh !important; }
  .admin-body { padding: 12px !important; }
  .admin-account-row { grid-template-columns: minmax(0, 1fr) 64px; padding: 9px; }
}


/* Plus21: login must fully own the screen, especially on mobile.
   Earlier mobile drawer rules used !important display/position rules for .app/.sidebar;
   because #app also has the hidden class before login, those later rules could still let
   the sidebar draw over the passkey screen. These ID-level guards win every time. */
#app.hidden,
#app.hidden .sidebar,
#app.hidden .side-preview,
#login:not(.hidden) ~ #app,
#login:not(.hidden) ~ #app .sidebar,
#login:not(.hidden) ~ #app .side-preview {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#login:not(.hidden) {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10000 !important;
  display: grid !important;
  place-items: center !important;
  min-height: 100dvh !important;
  width: 100vw !important;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)) !important;
  overflow: auto !important;
  background:
    radial-gradient(circle at 50% 18%, rgba(255,255,255,.055), transparent 34%),
    #060607 !important;
}

#login:not(.hidden) .login-card {
  position: relative !important;
  z-index: 10001 !important;
  width: min(420px, calc(100vw - 36px)) !important;
  max-width: calc(100vw - 36px) !important;
  margin: 0 auto !important;
}

@media (max-width: 720px) {
  #login:not(.hidden) {
    align-items: center !important;
    justify-items: center !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  #login:not(.hidden) .login-card {
    width: min(360px, calc(100vw - 28px)) !important;
    max-width: calc(100vw - 28px) !important;
    padding: 22px !important;
    border-radius: 20px !important;
    gap: 12px !important;
  }

  #login:not(.hidden) .login-card h1 {
    font-size: 24px !important;
  }

  #login:not(.hidden) .login-card input,
  #login:not(.hidden) .login-card button {
    width: 100% !important;
    min-height: 44px !important;
  }
}

/* plus22: paired sliders + compact numeric overrides */
.range-field {
  display: grid !important;
  grid-template-columns: auto minmax(120px, 1fr) 68px;
  align-items: center !important;
  gap: 8px !important;
  flex: 1 1 230px;
  min-width: 220px;
  color: var(--muted);
}
.range-field span {
  min-width: 72px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.range-field input[type="range"] {
  width: 100%;
  min-width: 96px;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  accent-color: var(--accent);
}
.range-field input[type="number"] {
  width: 68px !important;
  margin-left: 0 !important;
  padding: 7px 8px !important;
  text-align: center;
  font-size: 12px;
}
@media (max-width: 720px) {
  .range-field {
    grid-template-columns: 54px minmax(92px, 1fr) 56px;
    min-width: 100%;
    flex-basis: 100% !important;
    gap: 6px !important;
  }
  .range-field span { min-width: 0; font-size: 11px; }
  .range-field input[type="number"] { width: 56px !important; }
}


/* plus32: managed folders/users */
.folder-create-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.026);
}
.folder-create-panel.hidden { display: none !important; }
.folder-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.folder-create-panel input { min-width: 0; padding: 9px 10px !important; }
.folder-create-panel button { padding: 9px 12px !important; }
.folder-delete-details {
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 7px;
  color: var(--muted);
  font-size: 12px;
}
.folder-delete-details summary {
  cursor: pointer;
  color: rgba(255,255,255,.6);
  user-select: none;
}
.folder-delete-details[open] {
  background: rgba(255,60,80,.045);
  border-radius: 12px;
  padding: 8px;
}
.folder-delete-details p {
  margin: 6px 0;
}
.folder-delete-details .danger-check {
  justify-content: flex-start;
  margin: 6px 0;
}
.folder-delete-details button.danger {
  width: 100%;
}

.admin-create-user {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 11px;
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.026);
}
.admin-create-user strong { grid-column: 1 / -1; color: var(--text); }
.admin-create-user input { min-width: 0; }
.admin-create-user .mini-status { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .folder-create-row { grid-template-columns: 1fr; }
  .admin-create-user { grid-template-columns: 1fr; }
}

/* plus33: master account deletion controls */
.admin-account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.admin-delete-open {
  min-width: 72px;
}
.admin-delete-box {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding: 11px;
  border: 1px solid rgba(255, 98, 98, .35);
  border-radius: 14px;
  background: rgba(26, 8, 10, .62);
}
.admin-delete-box.hidden {
  display: none !important;
}
.admin-delete-box code {
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 7px;
  padding: 1px 5px;
}
.admin-delete-confirm {
  width: 100%;
}
@media (max-width: 760px) {
  .admin-account-actions {
    justify-content: stretch;
  }
  .admin-account-actions > button {
    flex: 1 1 74px;
  }
}


/* Search Block blacklist editor */
.blocklist-details {
  margin-top: 10px;
  border-top: 1px solid rgba(255,255,255,.10);
  padding-top: 8px;
}
.blocklist-details summary {
  cursor: pointer;
  color: rgba(245,245,245,.78);
  font-size: .88rem;
  user-select: none;
}
.blocklist-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  margin-top: 8px;
}
.block-list {
  display: grid;
  gap: 5px;
  max-height: 170px;
  overflow: auto;
  margin-top: 8px;
  padding-right: 2px;
}
.block-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 5px 6px;
  background: rgba(255,255,255,.025);
}
.block-entry span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(245,245,245,.82);
}
.block-entry.empty {
  display: block;
  color: rgba(245,245,245,.45);
}
.tiny.danger-mini {
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border-color: rgba(255,116,116,.32);
  color: #ffd6d6;
  background: rgba(244,74,74,.12);
}
.subtle-btn { opacity: .82; }
@media (max-width: 720px) {
  .blocklist-add { grid-template-columns: 1fr 1fr; }
  .blocklist-add input { grid-column: 1 / -1; }
}
.block-image-box {
  margin-top: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 8px;
  background: rgba(255,255,255,.025);
}
.block-image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: rgba(245,245,245,.82);
  font-size: .85rem;
}
.block-image-box .mini-status {
  margin: 7px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 760px) {
  .blocklist-add { grid-template-columns: 1fr; }
}


/* plus42: visible click acknowledgement for all command buttons. */
button,
.folder-btn {
  transition:
    background-color .16s ease,
    border-color .16s ease,
    color .16s ease,
    transform .10s ease,
    box-shadow .18s ease,
    filter .16s ease;
}
button.click-ack,
.folder-btn.click-ack {
  animation: webbot-click-ack .42s ease-out both !important;
}
@keyframes webbot-click-ack {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: none;
  }
  18% {
    background: rgba(160, 195, 255, .42) !important;
    border-color: rgba(220, 232, 255, .94) !important;
    color: #ffffff !important;
    transform: translateY(1px) scale(.975);
    box-shadow:
      0 0 0 2px rgba(160, 195, 255, .22) inset,
      0 0 18px rgba(160, 195, 255, .24) !important;
    filter: brightness(1.13);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}
button.danger.click-ack {
  animation-name: webbot-click-ack-danger !important;
}
@keyframes webbot-click-ack-danger {
  18% {
    background: rgba(255, 118, 118, .42) !important;
    border-color: rgba(255, 190, 190, .94) !important;
    color: #ffffff !important;
    transform: translateY(1px) scale(.975);
    box-shadow:
      0 0 0 2px rgba(255, 118, 118, .20) inset,
      0 0 18px rgba(255, 118, 118, .24) !important;
    filter: brightness(1.12);
  }
}
