*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.hidden { display: none !important; }

:root {
  --purple: #9147ff;
  --purple-dark: #6b2fbf;
  --bg: #0e0e10;
  --surface: #18181b;
  --text: #efeff1;
  --text-muted: #adadb8;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.site-header {
  background-color: var(--surface);
  border-bottom: 2px solid var(--purple);
  padding: 1rem 0;
}

.site-header h1 {
  font-size: 1.75rem;
  color: var(--purple);
}

.site-header .tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Hero */
.hero {
  text-align: center;
  padding: 4rem 0;
}

.hero h2 {
  font-size: 2.25rem;
  margin-bottom: 1rem;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.btn {
  display: inline-block;
  background-color: var(--purple);
  color: #fff;
  padding: 0.75rem 2rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  transition: background-color 0.2s;
}

.btn:hover {
  background-color: var(--purple-dark);
}

/* Widget grid */
.widgets-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 0 4rem;
  max-width: calc(3 * 340px + 2 * 1.5rem);
  margin-inline: auto;
}

.widget-card {
  background-color: var(--surface);
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  padding: 1.5rem;
  transition: border-color 0.2s;
  flex: 0 1 340px;
}

.widget-card:hover {
  border-color: var(--purple);
}

.widget-card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--purple);
}

.widget-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Footer */
.site-footer {
  background-color: var(--surface);
  border-top: 1px solid #2a2a2e;
  padding: 1rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* =====================
   Dashboard
   ===================== */

.dashboard-body {
  height: 100vh;
  height: 100dvh; /* mobile browsers: without the hidden address bar */
  overflow: hidden;
  display: flex;
  flex-direction: column; /* the managing banner above the page */
}

.dashboard-layout {
  display: flex;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */
.dashboard-sidebar {
  width: 220px;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  background-color: var(--surface);
  border-right: 1px solid #2a2a2e;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
}

.sidebar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--purple);
  text-decoration: none;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid #2a2a2e;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  gap: 0.25rem;
  flex: 1; /* push the footer to the bottom */
}

.sidebar-link {
  display: block;
  padding: 0.65rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.sidebar-link-external { margin-left: 0.25rem; font-size: 0.7em; opacity: 0.6; }

.sidebar-link:hover {
  color: var(--text);
  background-color: rgba(145, 71, 255, 0.08);
}

.sidebar-link.active {
  color: var(--purple);
  border-left-color: var(--purple);
  background-color: rgba(145, 71, 255, 0.1);
}

/* Main content */
.dashboard-main {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 2rem 2.5rem;
  overflow-y: auto;
}

.dash-section.hidden {
  display: none;
}

.dash-heading {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.dash-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.dash-section-header .dash-heading {
  margin-bottom: 0;
}

/* ── Overview (partials/overview.ejs) ───────────────────────────────────── */
.overview-hero {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  overflow: hidden;
  padding: 1.75rem 2rem;
  border: 1px solid rgba(145, 71, 255, 0.35);
  border-radius: 16px;
  background:
    radial-gradient(circle at 85% -20%, rgba(145, 71, 255, 0.45), transparent 55%),
    radial-gradient(circle at 10% 120%, rgba(63, 182, 255, 0.18), transparent 50%),
    var(--surface);
}
.overview-hero-text { display: flex; flex-direction: column; gap: 0.35rem; }
.overview-date { color: #cdb8ff; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.overview-hero h2 { font-size: 1.8rem; line-height: 1.2; }
.overview-hero p { color: var(--text-muted); }
.overview-status { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.overview-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(14, 14, 16, 0.55);
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}
.overview-chip .fa-twitch { color: #9147ff; }
a.overview-chip:hover { border-color: rgba(145, 71, 255, 0.6); }
.overview-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: #6b6b75; }
.is-bot-connected .overview-dot { background: #3ecf8e; box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.2); }
.is-bot-waiting .overview-dot,
.is-bot-connecting .overview-dot { background: #5b9bd5; }
.is-bot-error .overview-dot { background: #e05454; }

.overview-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.overview-tile {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon value" "label label" "note note";
  align-items: center;
  gap: 0.15rem 0.9rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid #2a2a2e;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.overview-tile:hover {
  border-color: color-mix(in srgb, var(--tile-color) 60%, transparent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}
.overview-tile-icon {
  display: grid;
  grid-area: icon;
  width: 2.6rem;
  height: 2.6rem;
  place-items: center;
  border-radius: 11px;
  background: color-mix(in srgb, var(--tile-color) 20%, transparent);
  color: var(--tile-color);
  font-size: 1.1rem;
}
.overview-tile-value { grid-area: value; justify-self: end; font-size: 2rem; font-weight: 700; line-height: 1; }
.overview-tile-label { grid-area: label; margin-top: 0.75rem; font-weight: 600; }
.overview-tile-note { grid-area: note; color: var(--text-muted); font-size: 0.8rem; }

.overview-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; }
.overview-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s;
}
.overview-action i { color: var(--purple); }
.overview-action:hover { border-color: var(--purple); background: rgba(145, 71, 255, 0.1); }

.overview-heading { margin: 2rem 0 0.9rem; font-size: 1.1rem; }

/* Overview: latest subs / follows / bits / raids (partials/recent-events.ejs) */
.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.recent-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  background: var(--surface);
}
.recent-card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid #2a2a2e;
  background: linear-gradient(135deg, color-mix(in srgb, var(--type-color) 22%, transparent), transparent 75%);
}
.recent-card-head h3 { font-size: 0.95rem; font-weight: 600; }
.recent-card-icon {
  display: grid;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 8px;
  background: var(--type-color);
  color: #fff;
  font-size: 0.85rem;
}
.recent-list { margin: 0; padding: 0.35rem 0; list-style: none; }
.recent-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.1rem 0.5rem;
  min-width: 0;
  padding: 0.4rem 1rem;
  font-size: 0.88rem;
}
.recent-list li + li { border-top: 1px solid rgba(255, 255, 255, 0.04); }
.recent-name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.recent-info { display: flex; grid-row: 2; grid-column: 1 / -1; align-items: center; gap: 0.4rem; min-width: 0; }
.recent-info .event-test-badge { padding: 0 0.35rem; font-size: 0.65rem; }
.recent-detail { overflow: hidden; color: var(--type-color); font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.recent-list time { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }
.recent-empty { padding: 1.25rem 1rem; color: var(--text-muted); font-size: 0.85rem; text-align: center; }

/* Empty state */
.empty-state {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 2rem;
  text-align: center;
  border: 1px dashed #2a2a2e;
  border-radius: 8px;
}

/* Button size variant */
.btn-sm {
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
}

.form-hint { color: var(--text-muted); font-size: 0.78rem; }
.form-status { color: #5cb85c; font-size: 0.9rem; }
.form-status.is-error { color: #ff8a80; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-group input {
  background-color: var(--surface);
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: var(--purple);
}

.form-group input[type="color"] {
  background: none;
  padding: 2px;
  height: 2.4rem;
  cursor: pointer;
}
.form-group input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.form-group input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

/* ── Header nav ────────────────────────────────────────────────────────────── */
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-branding {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.site-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}
.header-link:hover { color: var(--text); }

/* ── Language switcher ──────────────────────────────────────────────────────── */
.lang-switcher {
  display: flex;
  gap: 0.25rem;
}

.lang-btn {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}

.lang-btn:hover {
  color: var(--text);
  background-color: rgba(255, 255, 255, 0.06);
}

.lang-btn.active {
  color: var(--purple);
  background-color: rgba(139, 92, 246, 0.12);
}

/* ── Buttons extra ──────────────────────────────────────────────────────────── */
button.btn, button.btn-sm {
  cursor: pointer;
  border: none;
  font-family: inherit;
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid #2a2a2e;
}

.btn-ghost:hover {
  background-color: rgba(145, 71, 255, 0.08);
  color: var(--text);
}

.btn-danger {
  background-color: #d9534f;
}

.btn-danger:hover {
  background-color: #c9302c;
}

/* ── Sidebar footer: language and account ───────────────────────────────────── */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0.85rem 0;
  border-top: 1px solid #2a2a2e;
}

.lang-segment {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 3px;
  padding: 3px;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  background: var(--bg);
}
.lang-option {
  padding: 0.3rem 0.5rem;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}
.lang-option:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.lang-option.active { background: rgba(145, 71, 255, 0.25); color: #e3d6ff; }

.account-card {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem;
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  background: var(--bg);
}
.account-link {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  padding: 0.15rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.account-link:hover .account-name { color: #cdb8ff; }
.account-avatar {
  display: grid;
  flex: 0 0 2.1rem;
  height: 2.1rem;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
}
.account-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.account-name,
.account-username { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-name { font-size: 0.9rem; font-weight: 600; transition: color 0.15s; }
.account-username { color: var(--text-muted); font-size: 0.75rem; }
.account-logout {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}
.account-logout:hover { background: rgba(233, 25, 22, 0.18); color: #ff8a80; }
.lang-option:focus-visible,
.account-link:focus-visible,
.account-logout:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; }

/* ── Nav icon ──────────────────────────────────────────────────────────────── */
.nav-icon {
  margin-right: 0.4rem;
}

/* ── Login page ─────────────────────────────────────────────────────────────── */
.login-section {
  max-width: 480px;
  margin: 4rem auto;
  background-color: var(--surface);
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  padding: 2.5rem;
  text-align: center;
}

.login-section h2 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.login-sub {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.error-banner {
  background-color: rgba(217, 83, 79, 0.15);
  border: 1px solid #d9534f;
  border-radius: 6px;
  color: #d9534f;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.warning-banner {
  background-color: rgba(240, 173, 78, 0.15);
  border: 1px solid #f0ad4e;
  border-radius: 6px;
  color: #c07800;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.platform-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.btn-platform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  border-radius: 8px;
  text-decoration: none;
}

.btn-login {
  background-color: var(--platform-color);
  color: #fff;
}

.btn-login:hover {
  background-color: color-mix(in srgb, var(--platform-color) 75%, #000);
}

.platform-icon {
  font-size: 1.2rem;
}

/* ── Toggle switch ──────────────────────────────────────────────────────────── */
/* .toggle (44×24) and the smaller .toggle-switch (36×20) share one design: the
   knob size and travel are derived from the track size, so it is always
   centred with an even gap on every side, on and off. */
.toggle,
.toggle-switch {
  --toggle-width: 44px;
  --toggle-height: 24px;
  --toggle-gap: 3px;
  --toggle-knob: calc(var(--toggle-height) - 2 * var(--toggle-gap));
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: var(--toggle-width);
  height: var(--toggle-height);
  vertical-align: middle;
  cursor: pointer;
}
.toggle-switch {
  --toggle-width: 36px;
  --toggle-height: 20px;
}

.toggle input,
.toggle-switch input {
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  opacity: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background-color: #4a4a55;
  transition: background-color 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  top: var(--toggle-gap);
  left: var(--toggle-gap);
  width: var(--toggle-knob);
  height: var(--toggle-knob);
  border-radius: 50%;
  background-color: var(--text-muted);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s, background-color 0.2s;
}

input:checked + .toggle-slider { background-color: var(--purple); }
input:checked + .toggle-slider::before {
  background-color: #fff;
  transform: translateX(calc(var(--toggle-width) - var(--toggle-knob) - 2 * var(--toggle-gap)));
}
input:focus-visible + .toggle-slider { outline: 2px solid var(--purple); outline-offset: 2px; }
input:disabled + .toggle-slider { cursor: not-allowed; opacity: 0.5; }

/* ── Widget type picker modal ────────────────────────────────────────────────── */
.widget-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.widget-type-card {
  background-color: var(--bg);
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: var(--text);
  font-family: inherit;
}

.widget-type-card strong {
  font-size: 0.95rem;
}

.widget-type-card span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.widget-type-card:hover,
.widget-type-card.selected {
  border-color: var(--purple);
  background-color: rgba(145, 71, 255, 0.08);
}

/* ── Modal overlay ──────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-box {
  background-color: var(--surface);
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  padding: 2rem;
  width: min(90vw, 520px);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-wide {
  width: min(90vw, 860px);
}

.modal-title {
  font-size: 1.2rem;
  margin-bottom: 1.25rem;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-form input {
  background-color: var(--bg);
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.6rem 0.85rem;
  outline: none;
}

.modal-form input:focus {
  border-color: var(--purple);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* ── Media section (partials/media*.ejs) ─────────────────────────────────── */
.media-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; margin-bottom: 1.5rem; }
/* Both cards as tall as the taller one; the upload list scrolls instead of growing it */
#media-storage,
#media-storage > [data-media-part],
.storage-card { display: flex; flex-direction: column; }
#media-storage > [data-media-part],
.storage-card { flex: 1; }

/* Storage */
.storage-amount { margin-bottom: 0.6rem; color: var(--text-muted); }
.storage-amount strong { color: var(--text); font-size: 1.7rem; font-weight: 700; }
.storage-bar { display: flex; height: 0.7rem; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.07); }
.storage-bar span { min-width: 4px; height: 100%; background: var(--segment); }
.storage-bar span + span { box-shadow: -2px 0 0 var(--surface); }
.storage-foot { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 0.6rem 1rem; margin-top: auto; padding-top: 0.85rem; }
.storage-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; margin: 0; padding: 0; list-style: none; font-size: 0.82rem; }
.storage-legend li { display: flex; align-items: center; gap: 0.4rem; }
.storage-dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--segment); }
.storage-legend-size { color: var(--text-muted); }
.storage-free { color: var(--text-muted); font-size: 0.85rem; font-weight: 600; }
.storage-card.is-high .storage-free { color: #f5a623; }
.storage-card.is-full .storage-free { color: #ff6b6b; }
.storage-card.is-high .storage-bar { box-shadow: 0 0 0 1px rgba(245, 166, 35, 0.6); }
.storage-card.is-full .storage-bar { box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.7); }

/* Upload */
.upload-card { display: flex; flex-direction: column; gap: 0.75rem; }
.upload-drop {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 10rem;
  padding: 1.25rem;
  border: 2px dashed #34343a;
  border-radius: 12px;
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-drop strong { color: var(--text); font-size: 1rem; }
.upload-drop small { max-width: 28rem; margin-top: 0.3rem; font-size: 0.75rem; }
.upload-drop-icon { display: grid; width: 3rem; height: 3rem; margin-bottom: 0.3rem; place-items: center; border-radius: 50%; background: rgba(145, 71, 255, 0.16); color: #b892ff; font-size: 1.3rem; }
.upload-drop-link { color: #cdb8ff; font-weight: 600; text-decoration: underline; }
.upload-drop:hover,
.upload-card.is-dropping .upload-drop { border-color: var(--purple); background: rgba(145, 71, 255, 0.07); }
.upload-card.is-dropping .upload-drop-icon { transform: translateY(-3px); }
.upload-paused {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 10rem;
  padding: 1.25rem;
  border: 1px solid rgba(245, 166, 35, 0.45);
  border-radius: 12px;
  background: rgba(245, 166, 35, 0.08);
  text-align: center;
}
.upload-paused strong { color: #f5a623; font-size: 1rem; }
.upload-paused p { max-width: 30rem; color: var(--text-muted); font-size: 0.85rem; }
.upload-paused .upload-drop-icon { background: rgba(245, 166, 35, 0.16); color: #f5a623; }
.media-drop-hint.is-paused { color: #f5a623; }
.upload-drop { width: 100%; background: none; font: inherit; }
.upload-drop:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.upload-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 9rem; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
/* While files are listed, the drop zone makes room for them */
.upload-card:has(.upload-list:not(:empty)) .upload-drop { flex: 0 0 auto; min-height: 0; padding: 0.75rem; flex-direction: row; flex-wrap: wrap; gap: 0.2rem 0.5rem; }
.upload-card:has(.upload-list:not(:empty)) .upload-drop small { display: none; }
.upload-card:has(.upload-list:not(:empty)) .upload-drop-icon { width: 2rem; height: 2rem; margin: 0; font-size: 0.9rem; }
.upload-list:empty { display: none; }
.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  font-size: 0.82rem;
}
.upload-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row-size { color: var(--text-muted); }
.upload-row .upload-bar { grid-column: 1 / -1; display: block; }
.upload-row .upload-bar-fill { display: block; }
.upload-row-status { grid-column: 1 / 3; color: var(--text-muted); }
.upload-row-status:empty { display: none; }
.upload-row.is-done .upload-bar-fill { background: #3ecf8e; }
.upload-row.is-error { border-color: rgba(229, 72, 77, 0.45); }
.upload-row.is-error .upload-bar { display: none; }
.upload-row.is-error .upload-row-status { color: #ff8a80; }
.upload-row-dismiss { grid-row: 1; grid-column: 3; width: 1.6rem; height: 1.6rem; background: transparent; color: var(--text-muted); }
.upload-row.is-error .upload-row-size { display: none; }

/* Library */
.library-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
.library-search { flex: 1 1 14rem; background: var(--surface); }
.chip-count { color: var(--text-muted); font-weight: 500; }
.filter-chip i { color: var(--chip-color, inherit); }
.library-sort {
  padding: 0.45rem 0.75rem;
  border: 1px solid #2a2a2e;
  border-radius: 999px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}
.library-sort:focus { border-color: var(--purple); }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 1rem; }
.library-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.15s, transform 0.15s, opacity 0.15s;
}
.library-card:hover { border-color: color-mix(in srgb, var(--type-color) 55%, #2a2a2e); transform: translateY(-2px); }
.library-card.is-busy { opacity: 0.4; pointer-events: none; }
.library-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: repeating-conic-gradient(#1d1d22 0 25%, #18181c 0 50%) 0 0 / 16px 16px;
  cursor: zoom-in;
}
.library-thumb img,
.library-thumb video { display: block; width: 100%; height: 100%; object-fit: cover; }
.library-audio {
  display: grid;
  height: 100%;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--type-color) 22%, transparent), transparent 70%), #17171b;
  color: var(--type-color);
  font-size: 2.2rem;
}
.library-type {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--type-color);
  font-size: 0.8rem;
}
.library-open {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.4rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.library-thumb:hover .library-open,
.library-thumb:focus-visible .library-open { opacity: 1; }
.library-card-body { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; padding: 0.7rem 0.8rem 0.2rem; }
.library-name { overflow: hidden; font-size: 0.88rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.library-meta { overflow: hidden; color: var(--text-muted); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.library-actions { display: flex; justify-content: flex-end; gap: 0.25rem; padding: 0.3rem 0.5rem 0.5rem; }
.library-actions .btn-icon { background: transparent; color: var(--text-muted); }
.library-actions .btn-icon:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.library-actions .btn-delete-media:hover { background: rgba(229, 72, 77, 0.15); color: #ff8a80; }
.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 3rem 1rem;
  border: 1px dashed #2a2a2e;
  border-radius: 12px;
  color: var(--text-muted);
  text-align: center;
}
.library-empty i { font-size: 1.8rem; opacity: 0.6; }

/* ── Media picker dialog of the overlay editor ─────────────────────────────── */
.media-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: min(85vh, 720px);
  padding: 1.5rem;
  overflow: hidden;
}

.media-dialog-header { display: flex; align-items: center; justify-content: space-between; }
.media-dialog-header .modal-title { margin: 0; }

.media-dialog-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.media-search {
  display: flex;
  flex: 1 1 12rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.75rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
}
.media-search:focus-within { border-color: var(--purple); }
.media-search input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  outline: none;
}

.media-filters { display: inline-flex; gap: 0.2rem; padding: 0.2rem; border-radius: 8px; background: var(--bg); }
.media-filters:empty { display: none; }
.media-filter {
  padding: 0.3rem 0.7rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.media-filter:hover { color: var(--text); }
.media-filter.active { background: rgba(145, 71, 255, 0.25); color: var(--text); }

.media-upload-btn { position: relative; overflow: hidden; cursor: pointer; white-space: nowrap; }
.media-upload-btn:focus-within { outline: 2px solid var(--text); outline-offset: 2px; }
.media-upload-btn input { position: absolute; inset: 0; opacity: 0; pointer-events: none; }

.media-picker-grid {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  align-content: start;
  gap: 0.75rem;
  min-height: 0;
  margin: 0 -0.25rem;
  padding: 0.25rem;
  overflow-y: auto;
}
.media-picker-grid:empty { display: none; }

.media-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  background: var(--bg);
  transition: border-color 0.15s, transform 0.15s;
}
.media-card:not(.is-uploading):hover { border-color: var(--purple); transform: translateY(-2px); }
.media-card.is-selected { border-color: var(--purple); box-shadow: 0 0 0 1px var(--purple); }
.media-card:has(.media-card-pick:focus-visible) { outline: 2px solid var(--text); }

.media-card-pick {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  padding: 0 0 0.5rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  outline: none;
}
.media-card-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  /* Checkerboard: many images are transparent */
  background: repeating-conic-gradient(#1d1d21 0 25%, #141417 0 50%) 0 0 / 16px 16px;
  color: var(--purple);
  font-size: 2rem;
}
.media-card-thumb img,
.media-card-thumb video { width: 100%; height: 100%; object-fit: contain; }
.media-card[data-type="audio"] .media-card-thumb,
.media-card.is-uploading .media-card-thumb { background: linear-gradient(135deg, rgba(145, 71, 255, 0.22), rgba(145, 71, 255, 0.05)); }
.media-card-name {
  padding: 0.45rem 0.6rem 0;
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-card-details { padding: 0 0.6rem; color: var(--text-muted); font-size: 0.72rem; }

.media-card-action {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
}
.media-card-action:hover { background: var(--purple); }

.media-card.is-uploading { padding-bottom: 0.6rem; border-style: dashed; }
.media-card .upload-bar { display: block; margin: 0.5rem 0.6rem 0; }
.media-card .upload-bar-fill { display: block; }
.media-card.is-failed { border-color: #ff8a80; }
.media-card.is-failed .media-card-thumb,
.media-card.is-failed .media-card-details { color: #ff8a80; }
.media-card.is-failed .media-card-thumb { background: rgba(255, 138, 128, 0.08); }

.media-dialog-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  border: 2px dashed #2a2a2e;
  border-radius: 10px;
  color: var(--text-muted);
  text-align: center;
}
.media-dialog-empty i { color: var(--purple); font-size: 2.2rem; }

.media-dialog-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.media-drop-target {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border: 2px dashed var(--purple);
  border-radius: 12px;
  background: rgba(24, 24, 27, 0.92);
  font-size: 1.1rem;
  pointer-events: none;
}
.is-dropping .media-drop-target { display: flex; }

/* ── Upload progress bar ──────────────────────────────────────────────────── */
.upload-bar {
  height: 6px;
  background-color: #2a2a2e;
  border-radius: 3px;
  overflow: hidden;
}

.upload-bar-fill {
  height: 100%;
  background-color: var(--purple);
  width: 0%;
  transition: width 0.1s;
}


/* ── Test form ──────────────────────────────────────────────────────────────── */
.test-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.test-form select {
  background-color: var(--surface);
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.6rem 0.85rem;
  outline: none;
}

.test-form select:focus {
  border-color: var(--purple);
}

.test-form-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.75rem; margin-top: 0.25rem; }
.test-form-footer .btn { display: inline-flex; align-items: center; gap: 0.5rem; }
.test-feedback {
  margin-right: auto;
  font-size: 0.9rem;
  color: #5cb85c;
}
.test-feedback.is-error { color: #ff6b6b; }

.test-feedback.hidden {
  display: none;
}

/* Event log */
.event-log { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 2rem; max-width: 600px; }
.event-log-row { display: flex; align-items: center; gap: 0.75rem; background: var(--surface); border: 1px solid #2a2a2e; border-radius: 6px; padding: 0.55rem 0.75rem; }
.event-log-info { flex: 1; min-width: 0; }
.event-log-widget-name { font-weight: 500; font-size: 0.875rem; }
.event-log-widget-slug { font-size: 0.75rem; color: var(--text-muted); margin-left: 0.4rem; }
.event-log-event { flex: 2; display: flex; align-items: center; gap: 0.5rem; }
.event-type-tag { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.45rem; border-radius: 4px; white-space: nowrap; }
.event-log-payload { font-size: 0.85rem; color: var(--text-muted); }
.event-log-empty { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }

/* Global event history (partials/event-history.ejs) */
.event-test-badge { flex-shrink: 0; padding: 0.1rem 0.45rem; border: 1px solid rgba(245, 166, 35, 0.4); border-radius: 4px; background: rgba(245, 166, 35, 0.12); color: #f5a623; font-size: 0.7rem; font-weight: 600; }
.history-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.9rem; }
.history-summary { color: var(--text-muted); font-size: 0.85rem; }
.history-summary-tests { color: #f5a623; }
.history-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.history-actions .btn { display: inline-flex; align-items: center; gap: 0.45rem; }
.history-actions .btn:disabled { cursor: not-allowed; opacity: 0.4; }
.history-list { display: flex; flex-direction: column; margin: 0; padding: 0; overflow: hidden; border: 1px solid #2a2a2e; border-radius: 10px; list-style: none; }
.history-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  transition: background 0.15s, opacity 0.15s;
}
.history-row + .history-row { border-top: 1px solid rgba(255, 255, 255, 0.05); }
.history-row:hover { background: rgba(255, 255, 255, 0.025); }
.history-row.is-removing { opacity: 0.4; pointer-events: none; }
.history-icon {
  position: relative;
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border-radius: 9px;
  background: color-mix(in srgb, var(--type-color) 16%, transparent);
  color: var(--type-color);
}
.history-platform {
  position: absolute;
  right: -0.4rem;
  bottom: -0.35rem;
  padding: 0.2rem;
  border-radius: 50%;
  background: var(--surface);
  color: var(--platform-color);
  font-size: 0.65rem;
}
.history-main { min-width: 0; }
.history-line { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.history-name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.history-kind { flex-shrink: 0; color: var(--type-color); font-size: 0.78rem; font-weight: 600; }
.history-detail { display: flex; gap: 0.5rem; min-width: 0; margin-top: 0.1rem; color: var(--text-muted); font-size: 0.8rem; }
.history-amount { flex-shrink: 0; color: var(--text); }
.history-message { overflow: hidden; font-style: italic; text-overflow: ellipsis; white-space: nowrap; }
.history-row time { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }
.btn-remove-history { background: transparent; color: var(--text-muted); opacity: 0.6; transition: opacity 0.15s, color 0.15s, background 0.15s; }
.history-row:hover .btn-remove-history,
.btn-remove-history:focus-visible { opacity: 1; }
.btn-remove-history:hover { background: rgba(229, 72, 77, 0.15); color: #ff8a80; }
.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  border: 1px dashed #2a2a2e;
  border-radius: 10px;
  color: var(--text-muted);
  text-align: center;
}
.history-empty i { font-size: 1.6rem; opacity: 0.6; }

/* The confirm window for deleting (partials/confirm-dialog.ejs) */
.confirm-modal { z-index: 1100; backdrop-filter: blur(3px); }
.confirm-box { width: min(92vw, 420px); padding: 1.75rem; text-align: center; animation: confirm-in 0.16s ease-out; }
.confirm-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  place-items: center;
  border-radius: 50%;
  background: rgba(229, 72, 77, 0.15);
  color: #ff6b6b;
  font-size: 1.2rem;
}
.confirm-title { margin-bottom: 0.5rem; font-size: 1.15rem; }
.confirm-message { color: var(--text-muted); font-size: 0.92rem; line-height: 1.5; }
.confirm-modal.is-safe .confirm-icon { background: rgba(145, 71, 255, 0.18); color: #cdb8ff; }
.confirm-actions { display: flex; gap: 0.6rem; margin-top: 1.5rem; }
.confirm-actions .btn { flex: 1; }
.confirm-actions .btn-ghost { border: 1px solid #34343a; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
@media (prefers-reduced-motion: reduce) { .confirm-box { animation: none; } }

/* Page numbers under a list */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.3rem; margin-top: 0.75rem; }
.pager-btn {
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.pager-btn:hover:not(:disabled) { border-color: var(--purple); color: var(--text); }
.pager-btn.is-active { border-color: var(--purple); background: rgba(145, 71, 255, 0.2); color: var(--text); }
.pager-btn:disabled { opacity: 0.4; cursor: default; }
.pager-gap { color: var(--text-muted); }

/* ── Overlay editor ─────────────────────────────────────────────────────────── */
/* Top bar, then three columns: layers | stage (canvas) | layer settings.
   Code mode (.is-code-mode) hides the layer list and widens the settings. */
.editor {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.editor-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #2a2a2e;
  background: var(--surface);
}
.editor-topbar .btn { flex-shrink: 0; white-space: nowrap; }
/* Icon-only buttons; the label stays for screen readers */
@media (max-width: 1600px) {
  .editor-topbar .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.editor-back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem 0.35rem 0.55rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, background-color 0.15s;
}
.editor-back i { transition: transform 0.15s; }
.editor-back:hover,
.editor-back:focus-visible { background-color: rgba(145, 71, 255, 0.14); color: var(--text); }
.editor-back:hover i { transform: translateX(-3px); }

.editor-name {
  min-width: 8rem;
  max-width: 18rem;
  flex: 0 1 18rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  outline: none;
}
.editor-name:hover { border-color: #2a2a2e; }
.editor-name:focus { border-color: var(--purple); background: var(--bg); }

.editor-canvas-size {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.editor-canvas-size input {
  width: 4.6rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: center;
  outline: none;
}
.editor-canvas-size input:focus { border-color: var(--purple); }
.editor-unit { font-size: 0.8rem; }

.editor-topbar-tools {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

/* Controls joined into one pill (undo / redo, event simulator) */
.tool-group {
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  background: var(--bg);
}
.tool-group select {
  max-width: 11rem;
  padding: 0.3rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  outline: none;
}
.tool-group select option { background: var(--surface); }
.tool-group-btn {
  min-height: 1.875rem;
  padding: 0 0.75rem;
  font-size: 14px;
  border: none;
  border-left: 1px solid #2a2a2e;
  background: transparent;
  color: var(--purple);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.tool-group-btn:first-child { border-left: none; }
.tool-group-btn:hover:not(:disabled) { background: var(--purple); color: #fff; }
.tool-group-btn:disabled { opacity: 0.35; cursor: default; }

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 22rem;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.save-status[data-kind="unsaved"] { color: #f5a623; }
.save-status[data-kind="unsaved"] i { font-size: 0.5rem; }
.save-status[data-kind="saved"]   { color: #4caf50; }
.save-status[data-kind="error"]   { color: #ff8a80; }

.editor-workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.editor-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Layers list */
.editor-layers {
  display: flex;
  flex-direction: column;
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid #2a2a2e;
  background: var(--surface);
}
.layer-list {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 0 0.5rem 0.75rem;
  list-style: none;
}
.layer-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.25rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.layer-item:hover { background: #222226; }
.layer-item.is-selected { border-color: rgba(145, 71, 255, 0.6); background: rgba(145, 71, 255, 0.14); }
.layer-item.is-hidden .layer-icon,
.layer-item.is-hidden .layer-text { opacity: 0.45; }
.layer-item.dragging { border-style: dashed; border-color: var(--purple); background: rgba(145, 71, 255, 0.1); }
.layer-drag-handle { margin: -0.45rem -0.2rem -0.45rem -0.5rem; padding: 0.7rem 0.4rem 0.7rem 0.6rem; color: var(--text-muted); font-size: 0.8rem; cursor: grab; opacity: 0.45; touch-action: none; }
.layer-drag-handle:hover { opacity: 1; }
.layer-icon {
  display: grid;
  flex: 0 0 1.9rem;
  height: 1.9rem;
  place-items: center;
  border-radius: 7px;
  background: rgba(145, 71, 255, 0.18);
  color: #cdb8ff;
  font-size: 0.8rem;
}
.layer-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.layer-name { overflow: hidden; font-size: 0.88rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.layer-type { overflow: hidden; color: var(--text-muted); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.layer-actions { display: flex; gap: 0.1rem; }
.layer-action {
  width: 1.6rem;
  height: 1.6rem;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s;
}
.layer-action:hover { color: var(--text); }
.layer-action[data-action="delete"]:hover { background: rgba(233, 25, 22, 0.25); color: #ff8a80; }
/* With a mouse the actions appear on hover (touch screens always show them) */
@media (hover: hover) {
  .layer-item:not(:hover):not(.is-hidden) .layer-actions { width: 0; overflow: hidden; } /* room for the name */
  .layer-item:focus-within .layer-actions { width: auto; }
  .layer-action { opacity: 0; }
  .layer-item:hover .layer-action,
  .layer-item.is-hidden .layer-action[data-action="toggle"],
  .layer-action:focus-visible { opacity: 1; }
}
.layer-list-empty { padding: 0 1rem; color: var(--text-muted); font-size: 0.85rem; }

/* Stage: the canvas, scaled to fit (transform and --stage-scale set by stage.js) */
.editor-center { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.editor-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.06) 1px, transparent 0) 0 0 / 22px 22px,
    #121214;
}
.stage-canvas {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  outline: calc(1px / var(--stage-scale, 1)) solid rgba(145, 71, 255, 0.55);
  background: repeating-conic-gradient(#1c1c20 0% 25%, #17171a 0% 50%) 0 0 / 40px 40px;
  transform-origin: top left;
}
.stage-layer {
  position: absolute;
  cursor: move;
  touch-action: none; /* a finger drags the layer instead of scrolling */
  outline: calc(1px / var(--stage-scale, 1)) dashed rgba(255, 255, 255, 0.18);
}
.stage-layer[hidden],
.stage-guide[hidden] { display: none; }
.stage-layer:hover { outline-color: rgba(145, 71, 255, 0.7); }
.stage-layer.is-selected { outline: calc(2px / var(--stage-scale, 1)) solid var(--purple); }
.stage-layer-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  pointer-events: none;
}
.stage-layer-label {
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  max-width: 100%;
  overflow: hidden;
  padding: calc(2px / var(--stage-scale, 1)) calc(6px / var(--stage-scale, 1));
  border-radius: 0 0 calc(4px / var(--stage-scale, 1)) 0;
  background: var(--purple);
  color: #fff;
  font-size: calc(11px / var(--stage-scale, 1));
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-layer.is-selected .stage-layer-label { display: block; }
.stage-handle {
  --size: calc(10px / var(--stage-scale, 1));
  position: absolute;
  display: none;
  width: var(--size);
  height: var(--size);
  border: calc(1.5px / var(--stage-scale, 1)) solid var(--purple);
  border-radius: 2px;
  background: #fff;
}
.stage-layer.is-selected .stage-handle { display: block; }
.stage-handle[data-handle*="n"] { top: calc(var(--size) / -2); }
.stage-handle[data-handle*="s"] { bottom: calc(var(--size) / -2); }
.stage-handle[data-handle*="w"] { left: calc(var(--size) / -2); }
.stage-handle[data-handle*="e"] { right: calc(var(--size) / -2); }
.stage-handle[data-handle="n"],
.stage-handle[data-handle="s"] { left: calc(50% - var(--size) / 2); cursor: ns-resize; }
.stage-handle[data-handle="w"],
.stage-handle[data-handle="e"] { top: calc(50% - var(--size) / 2); cursor: ew-resize; }
.stage-handle[data-handle="nw"],
.stage-handle[data-handle="se"] { cursor: nwse-resize; }
.stage-handle[data-handle="ne"],
.stage-handle[data-handle="sw"] { cursor: nesw-resize; }
.stage-guide { position: absolute; z-index: 100000; pointer-events: none; background: #ff4fa3; }
.stage-guide.is-x { top: 0; bottom: 0; width: calc(1px / var(--stage-scale, 1)); }
.stage-guide.is-y { left: 0; right: 0; height: calc(1px / var(--stage-scale, 1)); }
.editor-stage.is-dragging { cursor: grabbing; user-select: none; }

/* Layer settings panel */
.editor-panel {
  display: flex;
  flex-direction: column;
  width: 380px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  border-left: 1px solid #2a2a2e;
}
.editor-panel.is-loading { opacity: 0.6; pointer-events: none; }
.editor-panel-empty { margin: auto; color: var(--text-muted); font-size: 0.9rem; text-align: center; }
.editor-panel-empty i { display: block; margin-bottom: 0.6rem; font-size: 1.4rem; color: var(--purple); }
.layer-panel { display: flex; flex: 1 0 auto; flex-direction: column; } /* as tall as its content, or it would cover the space below it */
.panel-header { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 0.5rem; }
.panel-back { display: none; align-self: flex-start; }

.layout-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; margin-top: 0.5rem; }
.layout-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  padding-left: 0.5rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  background: var(--bg);
}
.layout-field:focus-within { border-color: var(--purple); }
.layout-field span { color: var(--text-muted); font-size: 0.75rem; }
.editor-panel .layout-field input {
  width: 100%;
  min-width: 0;
  padding: 0.4rem 0.3rem 0.4rem 0;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  outline: none;
  appearance: textfield;
}
.editor-panel .layout-field input::-webkit-inner-spin-button { appearance: none; }

/* "Code editor" action card at the top of a custom widget's panel */
.code-editor-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}
.code-editor-card:hover,
.code-editor-card:focus-visible { border-color: var(--purple); background: rgba(145, 71, 255, 0.1); }
.code-editor-card:hover > .fa-chevron-right { transform: translateX(3px); }
.code-editor-card-icon {
  display: grid;
  flex: 0 0 2.2rem;
  height: 2.2rem;
  place-items: center;
  border-radius: 9px;
  background: #1e1e1e;
  color: #4fc1ff;
  font-size: 0.95rem;
}
.code-editor-card-text { display: flex; flex: 1; flex-direction: column; }
.code-editor-card-text strong { font-size: 0.92rem; }
.code-editor-card-text small { color: var(--text-muted); font-size: 0.75rem; }
.code-editor-card > .fa-chevron-right { color: var(--text-muted); font-size: 0.8rem; transition: transform 0.15s; }

/* Code mode: the settings give way to the code editor; the stage stays visible */
.editor.is-code-mode .editor-layers { display: none; }
.editor.is-code-mode .editor-panel { width: 55%; overflow: hidden; }
.editor.is-code-mode .layer-panel { flex: 1; min-height: 0; }
.editor.is-code-mode .panel-back { display: inline-flex; align-items: center; gap: 0.45rem; }
.editor.is-code-mode .code-editor-card,
.editor.is-code-mode .panel-settings { display: none; }
.editor.is-code-mode .cw-code { display: flex; flex: 1; flex-direction: column; gap: 0.5rem; min-height: 0; margin-top: 0.75rem; }

/* Title card: widget type icon, instance name and type badge */
.config-title-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  overflow: hidden;
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(145, 71, 255, 0.18), rgba(145, 71, 255, 0.02) 65%), var(--surface);
}
.config-title-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--purple);
}
.config-title-icon {
  display: grid;
  flex: 0 0 2.6rem;
  height: 2.6rem;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  box-shadow: 0 6px 18px rgba(145, 71, 255, 0.35);
  color: #fff;
  font-size: 1.05rem;
}
.config-title-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0; /* lets long names truncate instead of widening the card */
}
.config-title {
  width: 100%;
  min-width: 0;
  margin-left: -0.4rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  text-overflow: ellipsis;
  outline: none;
}
.config-title:hover { border-color: #3a3a40; }
.config-title:focus { border-color: var(--purple); background: var(--bg); }
.config-type-badge {
  align-self: flex-start;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  background: rgba(145, 71, 255, 0.2);
  color: #cdb8ff;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.config-section-title {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.5rem 0 0.75rem;
}

.editor-panel .form-group input,
.editor-panel .form-group textarea,
.editor-panel .form-group select {
  background-color: var(--bg);
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  padding: 0.55rem 0.8rem;
  outline: none;
  width: 100%;
  font-family: inherit;
}

.editor-panel .form-group input:focus,
.editor-panel .form-group textarea:focus,
.editor-panel .form-group select:focus {
  border-color: var(--purple);
}

.editor-panel .form-group textarea {
  min-height: calc(2lh + 1.25rem);
  resize: vertical;
  field-sizing: content; /* grows with its lines */
}

.panel-settings > .form-group + .form-group { margin-top: 0.85rem; }
.panel-settings > .toggle-row { flex-direction: row; align-items: center; justify-content: space-between; }

.media-picker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.media-pick-name {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Placeholder chips ───────────────────────────────────────────────────── */
.placeholder-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}
.placeholder-chip {
  font-family: monospace;
  font-size: 0.78rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--purple);
  background: transparent;
  color: var(--purple);
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.15s, color 0.15s;
}
.placeholder-chip:hover {
  background: var(--purple);
  color: #fff;
}

/* ── Translation mapping rows ────────────────────────────────────────────── */
.translation-mappings {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.translation-mapping-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.translation-mapping-row .mapping-from,
.translation-mapping-row .mapping-to {
  flex: 1;
  min-width: 0;
  height: 2.125rem;
  padding: 0 0.625rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  outline: none;
}
.translation-mapping-row input:focus { border-color: var(--purple); }

.mapping-arrow { flex-shrink: 0; color: var(--text-muted); font-size: 13px; }
.btn-add-mapping {
  height: 2.125rem;
  border: 1px dashed #3a3a40;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
.btn-add-mapping:hover { border-color: var(--purple); color: var(--text); }
.btn-add-mapping i { margin-right: 0.25rem; color: var(--purple); font-size: 13px; }


/* ── Subheadings ────────────────────────────────────────────────────────────── */
.dash-subheading {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.75rem;
}

/* ── Bot section ──────────────────────────────────────────────────────────── */
.bot-header {
  margin-bottom: 1.5rem;
}

.bot-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.bot-status-badge {
  display: inline-block;
  padding: 0.2em 0.7em;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-idle       { background: #3a3a3e; color: var(--text-muted); }
.status-connecting { background: #4a3a00; color: #f0a000; }
.status-connected  { background: #0d3320; color: #3fa66e; }
.status-waiting    { background: #1a2a40; color: #5b9bd5; }
.status-error      { background: #3d0c0c; color: #e05454; }

.bot-test-mode-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.bot-test-mode-label { font-weight: 600; font-size: 0.875rem; }

.bot-account-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.875rem;
}

.bot-account-row .bot-account-name { flex: 1; }

.bot-error-msg {
  margin-top: 0.5rem;
  color: #e05454;
  font-size: 0.875rem;
}

.bot-connect-warning {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  background: #3a2800;
  border: 1px solid #6b4a00;
  color: #f0c040;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Triggers: cards (bot/triggers.js) and the editor dialog (bot/trigger-editor.js).
   --type-color is the trigger type's color (trigger-types.js). */
.bot-trigger-grid { margin-top: 1.5rem; }
.bot-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #2a2a2e;
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.bot-card:hover {
  border-color: color-mix(in srgb, var(--type-color) 60%, transparent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}
.bot-card.is-disabled .bot-card-banner,
.bot-card.is-disabled .bot-card-body { opacity: 0.5; }
.bot-card-banner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, color-mix(in srgb, var(--type-color) 28%, transparent), transparent 75%);
  border-bottom: 1px solid #2a2a2e;
}
.bot-card-icon,
.bot-type-icon {
  display: grid;
  flex: 0 0 auto;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border-radius: 10px;
  background: var(--type-color);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--type-color) 40%, transparent);
  color: #fff;
  font-size: 1rem;
}
.bot-card-type { flex: 1; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.bot-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem 1rem 1rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.bot-card-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem; font-size: 1.1rem; font-weight: 600; }
.bot-card-command { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', monospace; }
.bot-card-alias {
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  font-size: 0.78rem;
}
.bot-card-actions { display: flex; flex-direction: column; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.bot-card-actions li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.85rem;
}
.bot-card-actions li i { color: var(--text-muted); font-size: 0.78rem; }
.bot-card-actions li.is-command i { color: #4fc1ff; }
.bot-card-actions li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-card-actions li.bot-card-more { justify-content: center; background: transparent; color: var(--text-muted); font-size: 0.78rem; }
.bot-card-speaker { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-muted); font-size: 0.8rem; }
.bot-card-speaker i { color: var(--purple); }
.bot-card-edit { margin-top: auto; color: var(--text-muted); font-size: 0.8rem; opacity: 0; transition: opacity 0.15s; }
.bot-card:hover .bot-card-edit,
.bot-card-body:focus-visible .bot-card-edit { opacity: 1; }

/* Editor dialog */
.bot-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.75rem; }
.bot-type-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 1rem;
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}
.bot-type-card .bot-type-icon { margin-bottom: 0.35rem; }
.bot-type-card span:last-child { color: var(--text-muted); font-size: 0.8rem; }
.bot-type-card:hover,
.bot-type-card:focus-visible {
  border-color: var(--type-color);
  background: color-mix(in srgb, var(--type-color) 10%, var(--bg));
  transform: translateY(-2px);
}

.bot-editor { display: flex; flex-direction: column; gap: 1.25rem; }
.bot-editor .modal-title { margin-bottom: 0; }
.bot-editor-head { display: flex; align-items: center; gap: 0.85rem; }
.bot-editor-title h3 { font-size: 1.2rem; }
.bot-link { padding: 0; border: 0; background: none; color: var(--purple); font: inherit; font-size: 0.82rem; cursor: pointer; }
.bot-link:hover { text-decoration: underline; }
.bot-type-note { color: var(--text-muted); font-size: 0.88rem; }
.bot-type-note i { margin-right: 0.3rem; color: var(--purple); }

.bot-field { display: flex; flex-direction: column; gap: 0.5rem; }
.bot-field-label { color: var(--text-muted); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.bot-field small { color: var(--text-muted); font-size: 0.78rem; }
.bot-command-input,
.bot-action-input {
  min-width: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
}
.bot-command-input:focus,
.bot-action-input:focus { border-color: var(--purple); }
.bot-command-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', monospace; font-size: 1rem; }

.bot-interval { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
/* The custom interval is a chip too: a borderless number field + "min" */
.bot-interval-custom { display: inline-flex; align-items: center; gap: 0.3rem; cursor: text; }
.bot-interval-custom:focus-within { border-color: var(--purple); }
.bot-interval-input {
  width: 4ch; /* up to 1440 */
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.bot-interval-input::-webkit-outer-spin-button,
.bot-interval-input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.bot-interval-input:placeholder-shown { width: 4.5em; } /* room for "Egyéni" / "Custom" */
.bot-interval-input::placeholder { color: var(--text-muted); text-align: center; }
.bot-interval-input:placeholder-shown + span { display: none; }

.bot-actions { display: flex; flex-direction: column; gap: 0.45rem; }
.bot-action { display: flex; align-items: center; gap: 0.55rem; }
.bot-action-icon { width: 1.1rem; color: var(--text-muted); font-size: 0.85rem; text-align: center; }
.bot-action-icon.fa-terminal { color: #4fc1ff; }
.bot-action-input { flex: 1; }
.bot-action-remove { width: 1.9rem; height: 1.9rem; background: transparent; color: var(--text-muted); }
.bot-action-remove:hover { color: var(--text); }
.bot-action-add { display: inline-flex; align-self: flex-start; align-items: center; gap: 0.35rem; }

.bot-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.bot-chips-label { margin-right: 0.2rem; color: var(--text-muted); font-size: 0.8rem; }
.bot-chip {
  padding: 0.2rem 0.6rem;
  border: 1px solid #2a2a2e;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.bot-chip:hover { border-color: var(--purple); }
.bot-chip.is-command { color: #4fc1ff; }
.bot-chip .bot-chip-platform { margin-left: 0.2rem; font-size: 0.75em; }
.bot-commands { border: 1px solid #2a2a2e; border-radius: 10px; }
.bot-commands summary { padding: 0.55rem 0.8rem; color: var(--text-muted); font-size: 0.85rem; cursor: pointer; }
.bot-commands summary i { margin: 0 0.25rem; color: #4fc1ff; }
.bot-commands .bot-chips { padding: 0.5rem 0.8rem; border-top: 1px solid #2a2a2e; }
.bot-commands .bot-chips-label { flex: 0 0 100%; }
.bot-command-help { padding: 0.55rem 0.8rem; border-radius: 8px; background: rgba(79, 193, 255, 0.08); font-size: 0.85rem; }
.bot-command-help code { margin-right: 0.35rem; color: #4fc1ff; }
.bot-command-help small { display: block; margin-top: 0.25rem; color: #f5b31b; }
.bot-command-help .bot-chip-platform { margin-right: 0.25rem; }
.bot-chip.is-active { border-color: var(--purple); background: rgba(145, 71, 255, 0.2); }
.bot-interval .bot-chip { font-family: inherit; font-size: 0.85rem; padding: 0.3rem 0.75rem; }

.trigger-accounts { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.trigger-account {
  --platform-color: var(--purple); /* chips without a platform (e.g. "default") */
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid #2a2a2e;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.trigger-account i { font-size: 1rem; }
.trigger-account small { color: var(--text-muted); font-size: 0.72rem; }
.trigger-account.is-active {
  border-color: var(--platform-color);
  background: color-mix(in srgb, var(--platform-color) 18%, var(--bg));
  color: var(--text);
}
.trigger-account.is-active i { color: var(--platform-color); }
.bot-card-accounts { display: inline-flex; gap: 0.35rem; font-size: 0.95rem; }

.bot-editor-error { padding: 0.5rem 0.75rem; border: 1px solid rgba(233, 25, 22, 0.5); border-radius: 8px; background: rgba(233, 25, 22, 0.12); color: #ff8a80; font-size: 0.85rem; }
.bot-editor-actions { margin-top: 0; }
.bot-editor-actions [data-delete] { margin-right: auto; display: inline-flex; align-items: center; gap: 0.4rem; }

/* ── Accounts to log in with again (src/middleware/accountPermissions.js) ── */
.btn-attention {
  flex-shrink: 0;
  background: linear-gradient(135deg, #f5a623, #e8790c);
  color: #1a1206;
  box-shadow: 0 2px 10px rgba(245, 166, 35, 0.25);
  transition: filter 0.15s, box-shadow 0.15s;
}
.btn-attention:hover { background: linear-gradient(135deg, #f5a623, #e8790c); filter: brightness(1.08); box-shadow: 0 2px 14px rgba(245, 166, 35, 0.4); }
.btn-attention i { margin-right: 0.3rem; }

/* The dot on a menu item: something there needs the user */
.nav-attention {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-left: 0.45rem;
  border-radius: 50%;
  background: #f5a623;
  vertical-align: 0.1em;
  animation: nav-attention-pulse 2s ease-out infinite;
}
.mobile-menu-btn { position: relative; }
.mobile-menu-btn .nav-attention { position: absolute; top: 0.4rem; right: 0.4rem; margin: 0; }
@keyframes nav-attention-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.7); }
  70%  { box-shadow: 0 0 0 0.45rem rgba(245, 166, 35, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .nav-attention { animation: none; box-shadow: 0 0 6px rgba(245, 166, 35, 0.8); }
}

/* Problems of a whole platform, on the overview (partials/platform-warnings.ejs) */
.platform-warning {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid rgba(245, 179, 27, 0.4);
  border-left: 4px solid var(--platform-color);
  border-radius: 12px;
  background: rgba(245, 179, 27, 0.08);
}
.platform-warning > i { margin-top: 0.15rem; color: var(--platform-color); font-size: 1.3rem; }
.platform-warning strong { display: block; margin-bottom: 0.2rem; }
.platform-warning p { color: var(--text-muted); font-size: 0.9rem; }
.platform-warning-detail { margin-top: 0.35rem; font-size: 0.8rem; word-break: break-word; }

/* ── Managing another account (partials/managing-banner.ejs) ─────────────── */
.managing-banner {
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.8rem;
  padding: 0.45rem 1rem;
  background: linear-gradient(90deg, #7a4a00, #a86400);
  color: #fff3dc;
  font-size: 0.88rem;
}
.managing-banner .btn { padding: 0.25rem 0.75rem; background: rgba(0, 0, 0, 0.35); font-size: 0.8rem; }
.managing-banner .btn:hover { background: rgba(0, 0, 0, 0.55); }

/* ── Admin (partials/admin*.ejs) ─────────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(20rem, 1fr);
  align-items: start;
  gap: 1.25rem;
}
.admin-side { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }

/* Users */
.user-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; }
.user-search {
  display: flex;
  flex: 1 1 16rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.85rem;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-muted);
}
.user-search:focus-within { border-color: var(--purple); }
.user-search input { flex: 1; min-width: 0; padding: 0.6rem 0; border: 0; outline: 0; background: none; color: var(--text); font: inherit; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid #2a2a2e;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-chip:hover { color: var(--text); }
.filter-chip.is-active { border-color: rgba(145, 71, 255, 0.6); background: rgba(145, 71, 255, 0.18); color: #cdb8ff; }
.user-count { margin-bottom: 0.5rem; color: var(--text-muted); font-size: 0.82rem; }
.user-list { display: flex; flex-direction: column; margin: 0; padding: 0; border: 1px solid #2a2a2e; border-radius: 10px; list-style: none; }
.user-list > li + li { border-top: 1px solid rgba(255, 255, 255, 0.05); }
.user-row { display: flex; align-items: center; gap: 0.85rem; padding: 0.7rem 0.85rem; transition: background 0.15s; }
.user-row:hover { background: rgba(255, 255, 255, 0.025); }
.user-row-text { display: flex; flex: 1; flex-direction: column; gap: 0.15rem; min-width: 0; }
.user-row-name { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; min-width: 0; }
.user-row-display { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.user-row-details { display: flex; flex-wrap: wrap; gap: 0.1rem 0.75rem; color: var(--text-muted); font-size: 0.8rem; }
.user-account i { color: var(--platform-color); }
.user-row-note { color: var(--text-muted); font-size: 0.8rem; text-align: right; }
.user-row-actions { display: flex; flex-shrink: 0; align-items: center; gap: 0.35rem; }
.user-row-actions .btn { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(145, 71, 255, 0.2);
  color: #cdb8ff;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.user-badge.is-main { background: rgba(245, 179, 27, 0.16); color: #f5c451; }
.user-badge.is-you { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }
.user-badge.is-blocked { background: rgba(245, 166, 35, 0.14); color: #f5a623; }
.user-empty { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 2rem 1rem; color: var(--text-muted); }
.user-more { padding: 0.6rem; text-align: center; }

/* A row's ⋯ menu */
.row-menu { position: relative; }
.row-menu > summary { list-style: none; background: transparent; color: var(--text-muted); }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary,
.row-menu > summary:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.row-menu-list {
  position: absolute;
  top: calc(100% + 0.3rem);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 13rem;
  padding: 0.3rem;
  border: 1px solid #34343a;
  border-radius: 10px;
  background: #1c1c21;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.row-menu-list button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.row-menu-list button i { width: 1rem; color: var(--text-muted); text-align: center; }
.row-menu-list button:hover,
.row-menu-list button:focus-visible { background: rgba(255, 255, 255, 0.07); outline: none; }
.row-menu-list button.is-danger,
.row-menu-list button.is-danger i { color: #ff8a80; }

/* Login access */
.access-status { display: flex; gap: 0.8rem; padding: 0.85rem 1rem; border: 1px solid; border-radius: 10px; }
.access-status > i { margin-top: 0.15rem; font-size: 1.05rem; }
.access-status p { color: var(--text-muted); font-size: 0.85rem; }
.access-status.is-open { border-color: rgba(62, 207, 142, 0.35); background: rgba(62, 207, 142, 0.08); }
.access-status.is-open > i, .access-status.is-open strong { color: #3ecf8e; }
.access-status.is-restricted { border-color: rgba(245, 166, 35, 0.4); background: rgba(245, 166, 35, 0.08); }
.access-status.is-restricted > i, .access-status.is-restricted strong { color: #f5a623; }
.link-button { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.35rem; padding: 0; border: 0; background: none; color: #f5a623; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.access-warning {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(229, 72, 77, 0.45);
  border-radius: 10px;
  background: rgba(229, 72, 77, 0.1);
  color: #ffb4b0;
  font-size: 0.85rem;
}
.access-warning p { flex: 1 1 12rem; }
.whitelist-add { display: flex; flex-direction: column; gap: 0.35rem; margin: 1.1rem 0; }
.whitelist-add-fields { display: flex; gap: 0.5rem; }
.whitelist-add-fields select,
.whitelist-add-fields input {
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.whitelist-add-fields input { flex: 1; }
.whitelist-add-fields select:focus,
.whitelist-add-fields input:focus { border-color: var(--purple); }
.whitelist-add-fields .btn { display: inline-flex; flex-shrink: 0; align-items: center; gap: 0.4rem; }
.whitelist-list { display: flex; flex-direction: column; margin: 0; padding: 0; border: 1px solid #2a2a2e; border-radius: 10px; list-style: none; }
.whitelist-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem; transition: opacity 0.15s; }
.whitelist-row + .whitelist-row { border-top: 1px solid rgba(255, 255, 255, 0.05); }
.whitelist-row.is-off .whitelist-icon,
.whitelist-row.is-off .whitelist-text { opacity: 0.5; }
.whitelist-icon {
  display: grid;
  flex: 0 0 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--platform-color) 18%, transparent);
  color: var(--platform-color);
}
.whitelist-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.whitelist-name { overflow: hidden; font-weight: 600; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.whitelist-details { display: flex; flex-wrap: wrap; gap: 0 0.6rem; color: var(--text-muted); font-size: 0.75rem; }
.wl-delete-btn { flex-shrink: 0; background: transparent; color: var(--text-muted); }
.wl-delete-btn:hover { background: rgba(229, 72, 77, 0.15); color: #ff8a80; }
.whitelist-empty { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 1.5rem 1rem; border: 1px dashed #2a2a2e; border-radius: 10px; color: var(--text-muted); font-size: 0.88rem; text-align: center; }
.whitelist-empty i { font-size: 1.3rem; opacity: 0.6; }

/* Shared bot account */
.shared-bot { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 0.9rem; border: 1px solid #2a2a2e; border-radius: 10px; background: var(--bg); }
.shared-bot-icon { display: grid; flex: 0 0 2.4rem; height: 2.4rem; place-items: center; border-radius: 50%; background: rgba(145, 71, 255, 0.18); color: #9147ff; font-size: 1.1rem; }
.shared-bot.is-empty .shared-bot-icon { background: rgba(255, 255, 255, 0.06); color: var(--text-muted); }
.shared-bot-text { display: flex; flex-direction: column; min-width: 0; }
.shared-bot-text span, p.shared-bot-text { color: var(--text-muted); font-size: 0.85rem; }
.shared-bot-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.4rem; margin-top: 0.75rem; }
.shared-bot-actions .btn { display: inline-flex; align-items: center; gap: 0.4rem; }

/* ── Scrollbars ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2a2a2e; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple); }
* { scrollbar-width: thin; scrollbar-color: #2a2a2e var(--bg); }

/* ── FontAwesome nav icons ────────────────────────────────────────────────── */
.nav-icon { width: 1.1em; text-align: center; flex-shrink: 0; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.18); }
.btn-icon.btn-danger:hover { background: #e91916; }

/* ── Media preview modal ─────────────────────────────────────────────────── */
.modal-preview-box {
  max-width: 860px;
  width: 90vw;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.modal-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid #2a2a2e;
}
.modal-preview-header span {
  font-size: 0.9rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#preview-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 1rem;
  background: #111;
}
#preview-body img  { max-width: 100%; max-height: 70vh; border-radius: 4px; }
#preview-body video { max-width: 100%; max-height: 70vh; outline: none; }
#preview-body audio { width: 100%; }

/* ── Profile (partials/profile.ejs) ─────────────────────────────────────── */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1.75rem 2rem;
  border: 1px solid rgba(145, 71, 255, 0.35);
  border-radius: 16px;
  background:
    radial-gradient(circle at 85% -20%, rgba(145, 71, 255, 0.45), transparent 55%),
    radial-gradient(circle at 10% 120%, rgba(63, 182, 255, 0.18), transparent 50%),
    var(--surface);
}
.profile-avatar {
  display: grid;
  flex: 0 0 4.5rem;
  height: 4.5rem;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #b48bff, var(--purple) 45%, var(--purple-dark));
  box-shadow: 0 0 0 4px rgba(145, 71, 255, 0.25), 0 8px 28px rgba(145, 71, 255, 0.45);
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
}
.profile-hero-text { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.profile-hero h2 { overflow: hidden; font-size: 1.8rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.profile-hero p { color: var(--text-muted); }
.profile-handle { color: #cdb8ff; font-weight: 600; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(18rem, 1fr) minmax(0, 2fr);
  align-items: start;
  gap: 1.25rem;
}
.dash-card {
  padding: 1.4rem 1.5rem;
  border: 1px solid #2a2a2e;
  border-radius: 14px;
  background: var(--surface);
}
.dash-card-head { display: flex; align-items: flex-start; gap: 0.85rem; margin-bottom: 1.25rem; }
.dash-card-head h3 { font-size: 1.05rem; line-height: 1.3; }
.dash-card-head p { color: var(--text-muted); font-size: 0.85rem; }
.dash-card-icon {
  display: grid;
  flex: 0 0 2.5rem;
  height: 2.5rem;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--tile) 18%, transparent);
  color: var(--tile);
  font-size: 1.05rem;
}

.profile-form { display: flex; flex-direction: column; gap: 1.1rem; }
.input-prefix {
  display: flex;
  align-items: center;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  background: var(--bg);
  transition: border-color 0.15s;
}
.input-prefix:focus-within { border-color: var(--purple); }
.input-prefix span { padding-left: 0.85rem; color: var(--text-muted); }
.form-group .input-prefix input { flex: 1; min-width: 0; padding-left: 0.2rem; border: 0; background: transparent; }
.profile-form .form-group > input { background: var(--bg); }
.profile-form-footer { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; }
.profile-form-footer .btn i { margin-right: 0.3rem; }

/* ── Platform accounts: a tile each ──────────────────────────────────────── */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 0.85rem;
}
.platform-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid #2a2a2e;
  border-radius: 14px;
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--platform-color) 16%, transparent), transparent 60%),
    var(--bg);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.platform-card:hover {
  border-color: color-mix(in srgb, var(--platform-color) 50%, #2a2a2e);
  box-shadow: 0 6px 22px color-mix(in srgb, var(--platform-color) 12%, transparent);
  transform: translateY(-2px);
}
.platform-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.platform-card-icon {
  position: relative;
  display: grid;
  flex: 0 0 2.75rem;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--platform-color) 18%, transparent);
  color: var(--platform-color);
  font-size: 1.3rem;
}
.platform-card-badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  padding: 2px 3px;
  border-radius: 50%;
  background: var(--bg);
  font-size: 0.6rem;
  line-height: 1;
}
.platform-pill {
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--platform-color) 16%, transparent);
  color: color-mix(in srgb, var(--platform-color) 55%, #fff);
  font-size: 0.72rem;
  font-weight: 600;
}
.platform-card-info { flex: 1; min-width: 0; }
.platform-card-user { overflow: hidden; font-size: 1.05rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.platform-card-username { min-height: 1.3em; overflow: hidden; color: var(--text-muted); font-size: 0.85rem; text-overflow: ellipsis; white-space: nowrap; }
.platform-card .kofi-warning { margin-top: 0.35rem; line-height: 1.4; }
.platform-card .btn-attention { text-align: center; }
.platform-card-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; padding-top: 0.75rem; border-top: 1px solid #222226; }
.platform-card-actions:empty { display: none; }
.platform-card-actions .btn-ghost {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding-inline: 0.6rem;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
.btn-disconnect:hover { border-color: rgba(229, 72, 77, 0.5); background: rgba(229, 72, 77, 0.1); color: #ff8a80; }

/* An account to log in with again (src/middleware/accountPermissions.js) */
.platform-card.needs-attention,
.platform-card.needs-attention:hover {
  border-color: rgba(245, 166, 35, 0.55);
  background: linear-gradient(90deg, rgba(245, 166, 35, 0.1), var(--bg) 70%);
  box-shadow: 0 0 0 1px rgba(245, 166, 35, 0.12), 0 0 18px rgba(245, 166, 35, 0.08);
}
.platform-card-alert { margin-top: 0.3rem; color: #f5a623; font-size: 0.8rem; line-height: 1.4; }
.platform-card-alert i { margin-right: 0.2rem; }

/* The last tile: connect another account */
.platform-card-add {
  justify-content: center;
  gap: 0.5rem;
  border-style: dashed;
  background: transparent;
}
.platform-card-add:hover { border-color: #3a3a40; box-shadow: none; transform: none; }
.platform-card-add-title { margin-bottom: 0.15rem; color: var(--text-muted); font-size: 0.85rem; font-weight: 600; }
.platform-card-add-title i { margin-right: 0.3rem; font-size: 0.8em; }
.btn-connect {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--platform-color) 35%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--platform-color) 9%, transparent);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
.btn-connect > i:first-child { color: var(--platform-color); }
.btn-connect-plus { margin-left: auto; color: var(--text-muted); font-size: 0.75em; }
.btn-connect:hover { border-color: var(--platform-color); background: color-mix(in srgb, var(--platform-color) 20%, transparent); }

.danger-zone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  border-color: rgba(229, 72, 77, 0.35);
  background: linear-gradient(90deg, rgba(229, 72, 77, 0.08), var(--surface) 60%);
}
.danger-zone-text { flex: 1 1 18rem; }
.danger-zone h3 { color: #ff6b6b; font-size: 1.05rem; }
.danger-zone p { color: var(--text-muted); font-size: 0.88rem; }
.danger-zone .btn i { margin-right: 0.35rem; }

@media (max-width: 1100px) {
  .dash-grid,
  .admin-grid,
  .media-top { grid-template-columns: minmax(0, 1fr); }
}

/* Ko-fi: its settings, in a window (partials/kofi-panel.ejs) */
.kofi-panel { display: flex; flex-direction: column; gap: 1rem; width: min(92vw, 600px); padding: 1.5rem; }
.modal-head { display: flex; align-items: center; gap: 0.85rem; padding-bottom: 1rem; border-bottom: 1px solid #2a2a2e; }
.modal-head > div { flex: 1; min-width: 0; }
.modal-head .modal-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-eyebrow { color: var(--text-muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.kofi-panel .form-group input { font-size: 0.9rem; }
.kofi-url { display: flex; flex-wrap: wrap; gap: 0.5rem; }
/* line-height: with some fonts a shorter line cuts off the underscores */
.kofi-url input { flex: 1 1 16rem; min-width: 0; font-family: monospace; line-height: 1.5; text-overflow: ellipsis; }
.kofi-panel a { color: #b98bff; }
.kofi-events { display: flex; flex-wrap: wrap; gap: 0.5rem; border: 0; }
.kofi-events legend { margin-bottom: 0.4rem; color: var(--text-muted); font-size: 0.85rem; }
.kofi-events .form-hint { flex-basis: 100%; }
.kofi-event {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  cursor: pointer;
}
.kofi-event:hover { border-color: #3a3a40; }
.kofi-event:has(:checked) { border-color: #ff5e5b; background: rgba(255, 94, 91, 0.08); }
.kofi-event input { accent-color: #ff5e5b; }
.kofi-event span { font-size: 0.88rem; font-weight: 600; }
/* Typed text is shown as dots, but the placeholder is not */
.secret-input:not(:placeholder-shown) { -webkit-text-security: disc; }
.kofi-warning { color: #f5a623; font-size: 0.78rem; }
.kofi-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem; padding-top: 1rem; border-top: 1px solid #2a2a2e; }
.kofi-actions .form-status { margin-right: auto; }
.kofi-actions .btn i { margin-right: 0.3rem; }

/* ── Variables ──────────────────────────────────────────────────────────── */
.variables-intro { max-width: 48rem; margin-bottom: 1.25rem; color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
.variable-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.variable-card {
  --card-color: var(--purple);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid #2a2a2e;
  border-radius: 14px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--card-color) 14%, transparent), transparent 55%), var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.variable-card.is-built-in { --card-color: #3ecf8e; }
#variable-built-in .variable-grid { margin-bottom: 1.5rem; }
.variable-card:not(.variable-new):hover {
  border-color: color-mix(in srgb, var(--card-color) 60%, transparent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}
.variable-head { display: flex; align-items: center; gap: 0.7rem; }
.variable-icon {
  display: grid;
  flex: 0 0 auto;
  width: 2.2rem;
  height: 2.2rem;
  place-items: center;
  border-radius: 10px;
  background: var(--card-color);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--card-color) 40%, transparent);
  color: #fff;
}
.variable-title { flex: 1; min-width: 0; }
.variable-title h3,
.variable-title small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.variable-title h3 { font-size: 1rem; font-weight: 600; }
.variable-title small { color: var(--text-muted); font-size: 0.75rem; }
.variable-delete {
  padding: 0.4rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.variable-card:hover .variable-delete,
.variable-delete:focus-visible { opacity: 1; }
.variable-delete:hover { color: #ff8a80; }
.variable-field { position: relative; display: block; }
.variable-value {
  width: 100%;
  padding: 0.35rem 2rem 0.35rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 8px;
  outline: none;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  font-size: 1.6rem;
  font-weight: 700;
  text-overflow: ellipsis;
  transition: border-color 0.15s;
}
.variable-value[type="number"] { appearance: textfield; }
.variable-value::-webkit-inner-spin-button { appearance: none; }
.variable-field:hover .variable-value { border-color: #3a3a40; }
.variable-value:focus,
.variable-field:hover .variable-value:focus { border-color: var(--card-color); }
.variable-field i {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  transform: translateY(-50%);
  pointer-events: none;
}
.variable-field .fa-check,
.variable-copy .fa-check { color: #5cb85c; }
/* What is wrong, below the field it is about */
.variable-error { display: none; align-items: baseline; gap: 0.4rem; color: #ff8a80; font-size: 0.8rem; line-height: 1.35; }
.variable-error i { flex-shrink: 0; }
.is-invalid .variable-error { display: flex; animation: variable-error 0.18s ease-out; }
.variable-field + .variable-error { margin-top: -0.35rem; }
.variable-card.is-invalid { --card-color: #ff5c5c; border-color: color-mix(in srgb, #ff5c5c 55%, transparent); }
.variable-card.is-invalid:not(.variable-new) .variable-value,
.variable-new.is-invalid #variable-name { border-color: #ff5c5c; background: rgba(255, 92, 92, 0.08); }
.variable-card.is-invalid .variable-field i { color: #ff8a80; }
@keyframes variable-error { from { opacity: 0; transform: translateY(-4px); } }
.variable-uses { display: flex; flex-direction: column; gap: 0.35rem; margin-top: auto; }
.variable-copy {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.variable-copy:hover { border-color: var(--card-color); color: var(--text); }
.variable-copy i { width: 1rem; text-align: center; }
.variable-copy code { overflow: hidden; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.variable-new { justify-content: space-between; border-style: dashed; border-color: #3a3a40; background: transparent; }
.variable-new h3 { font-size: 1rem; font-weight: 600; }
.variable-new h3 i { margin-right: 0.25rem; color: var(--purple); }
.variable-new .form-group { gap: 0.25rem; }
.variable-new .form-group label { font-size: 0.8rem; }
.variable-new .form-group input { width: 100%; min-width: 0; padding: 0.4rem 0.6rem; font-size: 0.9rem; }

/* ── Sources editor ─────────────────────────────────────────────────────── */
.sources-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.source-card {
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  overflow: hidden;
}
.source-card-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 0.75rem;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.source-card-header:hover { background: #222226; }
.source-drag-handle  { cursor: grab; color: var(--text-muted); font-size: 0.875rem; flex-shrink: 0; opacity: 0.45; transition: opacity 0.15s; padding: 0.5rem 0.375rem 0.5rem 0.75rem; margin: -0.5rem 0 -0.5rem -0.75rem; }
.source-drag-handle:hover  { opacity: 1; }
.source-drag-handle:active { cursor: grabbing; }
.source-card-header > .fa-solid:nth-child(2) { color: var(--accent); font-size: 0.875rem; flex-shrink: 0; }
.source-card.dragging { opacity: 0.35; border-style: dashed; }
.source-card-label   { font-weight: 600; font-size: 0.875rem; flex-shrink: 0; }
.source-card-preview { flex: 1; color: var(--text-muted); font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-chevron      { color: var(--text-muted); font-size: 0.75rem; flex-shrink: 0; transition: transform 0.2s; }
.source-card.expanded .source-chevron { transform: rotate(180deg); }
.source-card-body    { display: none; padding: 0.75rem; border-top: 1px solid #2a2a2e; background: var(--bg); }
.source-card.expanded .source-card-body { display: block; }

.source-fields {
  --control: 2.125rem; /* height of every control, so rows line up */
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem 0.625rem;
}
.source-fields > *         { grid-column: span 3; min-width: 0; margin: 0; }
.source-fields > .third      { grid-column: span 2; }
.source-fields > .two-thirds { grid-column: span 4; }
.source-fields > .full-width { grid-column: 1 / -1; }
.source-fields:has(> .image-only.hidden) > .offset { grid-column: span 3; }
.source-fields .form-group { gap: 0.25rem; }
.source-fields .form-group > label { overflow: hidden; font-size: 0.75rem; line-height: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.editor-panel .source-fields .form-group :is(input:not([type="checkbox"], [type="range"]), select, textarea) {
  min-width: 0;
  padding: 0.375rem 0.625rem;
  border-radius: 8px;
  background-color: var(--surface);
  font-size: 0.8125rem;
  line-height: 1.25rem;
}
.editor-panel .source-fields .form-group :is(input:not([type="checkbox"], [type="range"]), select) { height: var(--control); }
.source-fields .toggle-row         { display: flex; align-items: center; gap: 0.5rem; flex-direction: row; }
.source-fields .toggle-row label:first-child { flex: 1; margin-bottom: 0; }
.source-fields .placeholder-chips { margin-top: 0.125rem; }
.source-fields .color-field { gap: 0.3125rem; min-width: 0; }
.source-fields .color-swatch { flex: 0 0 var(--control); height: var(--control); }
.source-fields .third .color-swatch { flex-basis: 1.5rem; }
.editor-panel .source-fields .third .color-field input { padding: 0.4375rem 0.1875rem; border-color: transparent; background: none; font-size: 0.75rem; }

.source-more { border-top: 1px solid #2a2a2e; padding-top: 0.625rem; }
.source-more summary { color: var(--text-muted); font-size: 0.75rem; cursor: pointer; }
.source-more summary:hover { color: var(--text); }
.source-more .source-fields { margin-top: 0.75rem; }

.source-slider { display: flex; align-items: center; gap: 0.625rem; height: var(--control); }
.editor-panel .source-fields .source-slider input {
  flex: 1;
  min-width: 0;
  height: 1rem;
  margin: 0;
  padding: 0;
  border: none;
  background: linear-gradient(to right, var(--purple) var(--fill), #35353b var(--fill)) center / 100% 4px no-repeat;
  appearance: none;
  cursor: pointer;
}
.source-slider input::-webkit-slider-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: #fff; appearance: none; }
.source-slider input::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: #fff; }
.source-slider input:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; border-radius: 4px; }
.source-slider output { min-width: 2.625rem; color: var(--text-muted); font-size: 0.75rem; text-align: right; }

/* Buttons of which one is on, and buttons that are on or off */
.segment,
.icon-toggles {
  display: flex;
  gap: 2px;
  height: var(--control);
  padding: 2px;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  background: var(--surface);
}
.segment button,
.icon-toggle {
  display: grid;
  flex: 1;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px; /* a size the icon font is centered at */
  line-height: 1;
  cursor: pointer;
}
.segment button:hover,
.icon-toggle:hover { color: var(--text); }
.segment button[aria-pressed="true"],
.icon-toggle:has(:checked) { background: rgba(145, 71, 255, 0.35); color: #fff; }
.icon-toggle { position: relative; }
.icon-toggle input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.icon-toggle:has(:focus-visible) { outline: 2px solid var(--text); }

/* The chosen file; opens the media picker */
.media-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.375rem;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}
.media-field:hover { border-color: var(--purple); }
.media-field-thumb {
  display: grid;
  flex: 0 0 3.5rem;
  place-items: center;
  height: 2.5rem;
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg);
  color: var(--purple);
}
.media-field-thumb :is(img, video) { width: 100%; height: 100%; object-fit: contain; }
.media-field .media-pick-name { flex: 1; min-width: 0; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.media-field.is-empty { border-style: dashed; }
.media-field.is-empty .media-pick-name { color: var(--text-muted); }
.media-field.is-empty .media-field-action { display: none; }
.media-field-action { padding-right: 0.5rem; color: var(--purple); font-size: 0.75rem; font-weight: 600; }

.sources-add { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.375rem; }
.source-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.5625rem 0.1875rem;
  border: 1px dashed #3a3a40;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.6875rem;
  cursor: pointer;
}
.source-add i { color: var(--purple); font-size: 14px; }
.source-add:hover { border-color: var(--purple); background: rgba(145, 71, 255, 0.08); color: var(--text); }

/* ── Alerts editor ──────────────────────────────────────────────────────── */
.alert-kinds { display: grid; grid-template-columns: repeat(12, 1fr); gap: 0.375rem; }
.alert-kind { grid-column: span 3; }
.alert-kind:nth-child(n + 5) { grid-column: span 4; }
.alert-kind {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  padding: 0.625rem 0.1875rem 0.5rem;
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.alert-kind > i:first-child { color: var(--alert-color); font-size: 16px; }
.alert-kind span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-kind:hover { border-color: var(--alert-color); color: var(--text); }
.alert-kind[aria-pressed="true"] {
  border-color: var(--alert-color);
  background: color-mix(in srgb, var(--alert-color) 16%, var(--surface));
  color: var(--text);
  font-weight: 600;
}
.alert-kind.is-off > :not(.alert-kind-badge) { opacity: 0.4; }
.alert-kind-badge { position: absolute; top: 0.375rem; right: 0.375rem; color: var(--text-muted); font-size: 0.625rem; }

.alert-card {
  margin-top: 0.75rem;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--alert-color) 35%, #2a2a2e);
  border-radius: 12px;
  background: linear-gradient(165deg, color-mix(in srgb, var(--alert-color) 18%, transparent), transparent 7rem), var(--surface);
}
.alert-head {
  display: flex;
  align-items: center;
  gap: 0.6875rem;
  padding: 0.75rem;
}
.alert-head-icon {
  display: grid;
  flex: 0 0 2.1875rem;
  place-items: center;
  height: 2.1875rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--alert-color) 22%, transparent);
  color: var(--alert-color);
  font-size: 16px;
}
.alert-head-text { flex: 1; min-width: 0; line-height: 1.3; }
.alert-head-text h4 { font-size: 0.9375rem; }
.alert-head-text small { display: block; color: var(--text-muted); font-size: 0.75rem; }
.alert-head-text small:empty { display: none; }
.alert-play {
  display: grid;
  flex: 0 0 2.25rem;
  place-items: center;
  padding: 0;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.15s;
}
.alert-play:hover { background: var(--purple-dark); transform: scale(1.06); }
.alert-play svg { width: 1rem; height: 1rem; fill: currentColor; }
.alert-head .toggle-switch { flex-shrink: 0; }

.alert-variations { display: flex; flex-wrap: wrap; gap: 0.375rem; padding: 0 0.75rem 0.75rem; }
.alert-variation {
  padding: 0.25rem 0.6875rem;
  border: 1px solid #2f2f35;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.alert-variation:hover { border-color: var(--purple); color: var(--text); }
.alert-variation[aria-pressed="true"] { border-color: var(--purple); background: rgba(145, 71, 255, 0.25); color: var(--text); }
.alert-variation.is-add { border-style: dashed; }

.alert-body { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.75rem; border-top: 1px solid #2a2a2e; background: var(--bg); }
.alert-card.is-off .alert-body { opacity: 0.6; }
.alert-own { display: flex; flex-direction: column; gap: 0.75rem; }
.alert-own .sources-list { margin: 0; }
.alert-own .sources-list:empty { display: none; }

/* A setting: name on the left, control on the right */
.alert-row { display: grid; grid-template-columns: 5fr 6fr; align-items: center; gap: 0.625rem; font-size: 0.8125rem; }
.alert-row > span { color: var(--text-muted); display: flex; align-items: center; gap: 0.5rem; }
.alert-row > span i { flex: 0 0 1rem; width: 1rem; color: var(--purple); font-size: 14px; }
.alert-row :is(input, select) {
  width: 100%;
  min-width: 0;
  height: 2.125rem;
  padding: 0 0.625rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  background-color: var(--surface);
  color: var(--text);
  font: inherit;
  outline: none;
}
.alert-row :is(input, select):focus { border-color: var(--purple); }

.alert-note { color: var(--text-muted); font-size: 0.75rem; line-height: 1.45; }
.alert-note i { color: var(--purple); }
.alert-empty { padding: 1rem; border-radius: 10px; background: var(--surface); color: var(--text-muted); font-size: 0.8125rem; text-align: center; }
.alert-empty i { display: block; width: auto; margin-bottom: 0.375rem; color: var(--purple); font-size: 1.1875rem; }

.alert-conditions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem 0.75rem;
  border: 1px solid rgba(145, 71, 255, 0.3);
  border-radius: 10px;
  background: rgba(145, 71, 255, 0.07);
}
.alert-conditions-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.8125rem; font-weight: 600; }

.alert-reuse { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; padding: 0.75rem; border-radius: 10px; background: var(--surface); }
.alert-reuse details { width: 100%; }
.alert-reuse summary { color: var(--text-muted); font-size: 0.75rem; cursor: pointer; }
.editor-panel .alert-reuse textarea { padding: 0.375rem 0.625rem; border-radius: 8px; font-size: 0.8125rem; line-height: 1.25rem; }
.alert-reuse .placeholder-chips { margin-top: 0; }
.alert-reuse .form-group { margin-top: 0.75rem; }
.alert-link {
  padding: 0.375rem 0.75rem;
  border: 1px solid rgba(145, 71, 255, 0.5);
  border-radius: 8px;
  background: rgba(145, 71, 255, 0.12);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
.alert-link:hover { background: rgba(145, 71, 255, 0.3); }
.alert-link i { color: var(--purple); font-size: 13px; }

.alert-option { display: flex; align-items: center; gap: 0.625rem; font-size: 0.8125rem; cursor: pointer; }
.alert-option .toggle-switch { flex-shrink: 0; }

/* ── Timeline of an alert, under the canvas ─────────────────────────────── */
.editor-dock {
  --labels: 150px;
  --edge: 1rem;
  flex-shrink: 0;
  padding: 0.5rem var(--edge) 0.75rem;
  border-top: 1px solid #2a2a2e;
  background: var(--surface);
  line-height: 1.25rem;
  user-select: none;
}
.editor-dock .fa-solid { line-height: 1; }
.timeline-bar-top { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.25rem; }
.timeline-bar-top .alert-play { flex: 0 0 1.75rem; height: 1.75rem; }
.timeline-bar-top .alert-play svg { width: 0.75rem; height: 0.75rem; }
.timeline-clock { color: var(--text-muted); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.timeline-all {
  margin-left: auto;
  padding: 0.125rem 0.75rem;
  border: 1px solid #2f2f35;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.timeline-all:hover { border-color: var(--purple); color: var(--text); }
.timeline-all[aria-pressed="true"] { border-color: var(--purple); background: rgba(145, 71, 255, 0.25); color: var(--text); }

.timeline-body { position: relative; cursor: pointer; touch-action: none; }
.timeline-ruler { position: relative; height: 1.5rem; margin-left: var(--labels); border-bottom: 1px solid #2a2a2e; outline: none; }
.timeline-ruler:focus-visible { border-color: var(--purple); }
.timeline-tick {
  position: absolute;
  bottom: 0;
  height: 1.25rem;
  padding-left: 0.25rem;
  border-left: 1px solid #35353b;
  color: var(--text-muted);
  font-size: 0.6875rem;
  pointer-events: none;
}
.timeline-rows { max-height: 8.75rem; margin-right: calc(var(--edge) * -1); padding-right: var(--edge); overflow: hidden auto; scrollbar-width: none; }
.timeline-row { display: flex; align-items: center; height: 1.75rem; }
.timeline-label {
  display: flex;
  flex: 0 0 var(--labels);
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0 0.75rem 0 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  text-align: left;
  cursor: pointer;
}
.timeline-label:hover { color: var(--text); }
.timeline-label i { flex: 0 0 1rem; width: 1rem; color: var(--purple); font-size: 13px; }
.timeline-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-lane { position: relative; flex: 1; height: 1.25rem; overflow: hidden; border-radius: 6px; background: var(--bg); }
.timeline-bar {
  position: absolute;
  inset: 0 auto 0 0;
  min-width: 4px;
  border-radius: 6px;
  background: #713ac2;
  cursor: grab;
}
.timeline-bar[hidden] { display: none; }
.timeline-bar.is-fixed { cursor: pointer; }
.timeline-bar:not(.is-fixed):hover,
.timeline-bar.is-now { box-shadow: inset 0 0 0 1px #b98aff; }
.timeline-bar-edge { position: absolute; inset: 0 0 0 auto; display: none; width: 10px; cursor: ew-resize; }
.timeline-bar.can-resize .timeline-bar-edge { display: block; }
.timeline-bar-edge::after { content: ''; position: absolute; inset: 5px 4px 5px auto; width: 2px; border-radius: 1px; background: rgba(255, 255, 255, 0.6); }
.is-dragging .timeline-bar { cursor: grabbing; }
.timeline-track { position: absolute; inset: 0 0 0 var(--labels); pointer-events: none; }
.timeline-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; }
.timeline-playhead::before {
  content: '';
  position: absolute;
  top: 0;
  left: -4px;
  width: 10px;
  height: 10px;
  border-radius: 3px 3px 5px 5px;
  background: #fff;
}
.timeline-playhead.is-idle { opacity: 0.25; }

/* Small buttons of the cards: quiet until pointed at */
.source-card .btn-icon,
.alert-conditions .btn-icon {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
}
.source-card .btn-icon:hover,
.alert-conditions .btn-icon:hover { background: rgba(255, 138, 128, 0.15); color: #ff8a80; }

/* Own arrow: the native one sticks to the edge */
.editor-panel :is(.alert-row, .form-group) select {
  padding-right: 2rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23adadb8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-position: right 0.625rem center;
  background-repeat: no-repeat;
  background-size: 0.75rem;
  text-overflow: ellipsis;
}

/* Whole pixels everywhere: text lines and icons stay sharp and centered */
.alert-kinds,
.alert-card { line-height: 1.25rem; }
.alert-card .fa-solid { line-height: 1; }

/* ── Custom widget editor ──────────────────────────────────────────────────── */
.cw-hint        { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.75rem; }
.cw-sandbox-note i { color: var(--purple); margin-right: 0.25rem; }
.cw-muted       { color: var(--text-muted); }

.cw-error {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(233, 25, 22, 0.5);
  border-radius: 6px;
  background: rgba(233, 25, 22, 0.12);
  color: #ff8a80;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

/* Generated field controls */
.cw-field-controls { display: flex; flex-direction: column; gap: 0.75rem; }
.cw-group          { border: 1px solid #2a2a2e; border-radius: 8px; }
.cw-group-title    { padding: 0.6rem 0.8rem; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.cw-group-body     { display: flex; flex-direction: column; gap: 0.75rem; padding: 0 0.8rem 0.8rem; }
.cw-toggle-row     { flex-direction: row; align-items: center; justify-content: space-between; }
.cw-field > .btn    { align-self: flex-start; } /* button fields: not full width */
.cw-inline         { display: flex; align-items: center; gap: 0.5rem; }
.editor-panel .cw-field .cw-inline input[type="range"] { flex: 1; padding: 0; border: none; background: none; accent-color: var(--purple); }
.cw-range-value    { min-width: 4ch; color: var(--text-muted); font-size: 0.85rem; text-align: right; }

.cw-media-list     { display: flex; flex-direction: column; gap: 0.3rem; }
.cw-media-item     { display: flex; align-items: center; gap: 0.5rem; }
.cw-media-name     { flex: 1; overflow: hidden; font-size: 0.85rem; text-overflow: ellipsis; white-space: nowrap; }

.cw-code { display: none; }
.cw-code-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.cw-tabs         { display: flex; gap: 0.25rem; }
.cw-tab {
  padding: 0.35rem 0.8rem;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.cw-tab:hover      { color: var(--text); }
.cw-tab.active     { border-color: var(--purple); background: var(--purple); color: #fff; }
.cw-tab-error      { margin-left: 0.35rem; color: #f5a623; }
.cw-tab.active .cw-tab-error { color: #fff; }
.cw-code-actions   { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.cw-code-actions .btn-ghost { border: 1px solid #2a2a2e; } /* buttons too, like the links beside them */
.cw-import         { cursor: pointer; }
.cw-copy-status    { margin-top: 0; color: #5cb85c; }
.cw-monaco         { flex: 1; min-height: 300px; overflow: hidden; border: 1px solid #2a2a2e; border-radius: 6px; }

/* ── Overlay list: connected accounts ──────────────────────────────────────── */
.instance-connections { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.connection-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  background: rgba(145, 71, 255, 0.12);
  font-size: 0.75rem;
}
.connection-chip .connection-account-icon { font-size: 0.8rem; }
.connection-chip-muted { color: var(--text-muted); }
.connection-chip.is-warning { background: rgba(245, 166, 35, 0.12); color: #f5a623; }

/* Accounts dialog */
.connections-subtitle { margin: -0.75rem 0 1.25rem; color: var(--text-muted); font-size: 0.9rem; }
.connections-subtitle strong { color: var(--text); }
.connection-accounts { display: flex; flex-direction: column; gap: 0.75rem; }
.connection-account {
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  background: var(--bg);
  transition: border-color 0.15s;
}
.connection-account.is-on { border-color: rgba(145, 71, 255, 0.6); }
.connection-account-header { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 1rem; }
.connection-account-header .connection-account-icon { width: 1.5rem; font-size: 1.35rem; text-align: center; }
.connection-account-text { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.connection-account-name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.connection-account-platform { color: var(--text-muted); font-size: 0.8rem; }
/* While everything is connected, the accounts are only listed */
.connection-account.is-everything .connection-account-icon { color: var(--purple); }
.has-everything .connection-account:not(.is-everything) { border-color: #2a2a2e; opacity: 0.6; }
.has-everything .connection-account:not(.is-everything) :is(.toggle, .connection-events) { display: none; }
.connection-note { padding: 0 1rem 0.9rem 3.3rem; color: var(--text-muted); font-size: 0.85rem; }
.connection-events { display: flex; flex-direction: column; gap: 0.55rem; padding: 0 1rem 1rem 3.3rem; }
.connection-mode { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.9rem; cursor: pointer; }
.connection-mode input { margin-top: 0.3rem; accent-color: var(--purple); }
.connection-mode small { display: block; color: var(--text-muted); font-size: 0.78rem; }
.connection-event-list { display: flex; flex-wrap: wrap; gap: 0.45rem 1.1rem; padding-left: 1.6rem; }
.connection-event { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; cursor: pointer; }
.connection-event input { accent-color: var(--purple); }
.connections-error { margin-top: 0.9rem; color: #ff8a80; font-size: 0.85rem; }

/* Widget type icon in the "new layer" dialog */
.widget-type-icon { margin-bottom: 0.2rem; color: var(--purple); font-size: 1.1rem; }

/* ── Overlay list ───────────────────────────────────────────────────────────── */
/* Card grid shared by the overlay list and the bot triggers */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
.overlay-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #2a2a2e;
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.overlay-card:hover {
  border-color: rgba(145, 71, 255, 0.55);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(145, 71, 255, 0.15);
  transform: translateY(-2px);
}
.overlay-card.is-disabled .overlay-thumb { filter: grayscale(0.8) brightness(0.7); }

/* Layout map: the canvas with every layer as a box. Every card has the same
   16:9 area; the canvas (--ratio: width / height) is fitted into it. */
.overlay-thumb {
  position: relative;
  display: grid;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid #2a2a2e;
  background: #0b0b0d;
}
.overlay-thumb-canvas {
  position: relative;
  isolation: isolate; /* the layers' z-index stays inside */
  width: min(100%, 100% * var(--ratio) / (16 / 9));
  aspect-ratio: var(--ratio);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(145, 71, 255, 0.16), transparent 60%),
    repeating-conic-gradient(#1c1c20 0% 25%, #16161a 0% 50%) 0 0 / 16px 16px;
}
.overlay-thumb-layer {
  position: absolute;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(145, 71, 255, 0.75);
  border-radius: 4px;
  background: rgba(145, 71, 255, 0.2);
  color: #e3d6ff;
  font-size: 0.85rem;
}
.overlay-thumb-layer.is-hidden { border-style: dashed; opacity: 0.35; }
.overlay-thumb-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.overlay-thumb-edit {
  position: absolute;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  background: rgba(14, 14, 16, 0.55);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
}
.overlay-thumb:hover .overlay-thumb-edit,
.overlay-thumb:focus-visible .overlay-thumb-edit { opacity: 1; }

.overlay-card-body { display: flex; flex: 1; flex-direction: column; gap: 0.35rem; padding: 0.9rem 1rem 1rem; }
.overlay-card-title { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.overlay-card-name { overflow: hidden; font-size: 1.02rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.overlay-card-meta { color: var(--text-muted); font-size: 0.8rem; }
.overlay-card-actions { display: flex; align-items: center; gap: 0.15rem; margin-top: auto; padding-top: 0.6rem; }
.overlay-card-actions .btn { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.overlay-card-actions .btn:first-child { margin-right: auto; }
.overlay-card-actions .btn-icon-only { justify-content: center; width: 2.1rem; padding-inline: 0; border-color: transparent; }
.btn-danger-ghost:hover { border-color: rgba(233, 25, 22, 0.6); color: #ff8a80; }

/* "New overlay" card */
.overlay-card-new {
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 220px;
  padding: 1.5rem;
  border: 1px dashed #3a3a40;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
}
.overlay-card-new span:last-child { max-width: 16rem; color: var(--text-muted); font-size: 0.82rem; }
.overlay-card-new-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.3rem;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  box-shadow: 0 6px 18px rgba(145, 71, 255, 0.35);
  color: #fff;
  font-size: 1.1rem;
}

/* ── Color picker (public/js/lib/color-picker.js) ─────────────────────────── */
.color-field { display: flex; align-items: center; gap: 0.5rem; }
.color-field input { flex: 1; min-width: 0; }
.color-swatch {
  --checkerboard: repeating-conic-gradient(#8a8a92 0% 25%, #d4d4d8 0% 50%) 0 0 / 10px 10px;
  flex: 0 0 2.4rem;
  height: 2.3rem;
  padding: 0;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  background: linear-gradient(var(--color, transparent), var(--color, transparent)), var(--checkerboard);
  cursor: pointer;
}
.color-swatch:focus-visible,
.color-swatch[aria-expanded="true"] { outline: 2px solid var(--purple); outline-offset: 1px; }

/* ── Font picker (public/js/lib/font-picker.js) ───────────────────────────── */
.font-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 2.25rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}
.font-field:hover { border-color: #3a3a40; }
.font-field[aria-expanded="true"] { border-color: var(--purple); }
.font-field-name { flex: 1; min-width: 0; overflow: hidden; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.font-field i { color: var(--text-muted); font-size: 0.7rem; }
.font-popover {
  position: fixed;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.font-popover[hidden] { display: none; }
.font-search {
  margin: 0.5rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid #2a2a2e;
  border-radius: 8px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}
.font-search:focus { border-color: var(--purple); }
.font-list { height: 18rem; overflow-y: auto; padding-bottom: 0.35rem; }
.font-group {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 0.35rem 0.9rem;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.font-option {
  height: 2.2rem;
  padding: 0 0.9rem;
  overflow: hidden;
  font-size: 1.05rem;
  line-height: 2.2rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-height: 2.2rem;
  scroll-margin-top: 1.8rem;
}
.font-option:hover,
.font-option.is-active { background: rgba(145, 71, 255, 0.18); }
.font-option[aria-selected="true"] { color: #b98bff; }

.color-popover {
  --checkerboard: repeating-conic-gradient(#8a8a92 0% 25%, #d4d4d8 0% 50%) 0 0 / 10px 10px;
  position: fixed;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: 240px;
  padding: 0.75rem;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.color-popover[hidden] { display: none; }
.color-sv {
  position: relative;
  height: 150px;
  border-radius: 6px;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, var(--hue));
  cursor: crosshair;
  touch-action: none;
  outline: none;
}
.color-sv:focus-visible { box-shadow: 0 0 0 2px var(--purple); }
.color-sv-thumb {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.color-slider {
  width: 100%;
  height: 0.85rem;
  margin: 0;
  border: 1px solid #2a2a2e;
  border-radius: 999px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.color-slider[hidden] { display: none; }
.color-hue { background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.color-alpha { background: linear-gradient(to right, transparent, var(--solid)), var(--checkerboard); }
.color-slider::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  -webkit-appearance: none;
}
.color-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}
.color-slider::-moz-range-track { background: transparent; }

/* ── Outage popup (partials/outage.ejs, js/outage.js) ────────────────────── */
.outage {
  width: min(92vw, 440px);
  margin: auto;
  padding: 2.25rem 2rem 1.75rem;
  border: 1px solid rgba(145, 71, 255, 0.35);
  border-radius: 20px;
  background: radial-gradient(circle at 50% -10%, rgba(145, 71, 255, 0.35), transparent 60%), var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  color: var(--text);
  text-align: center;
}
.outage[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  animation: outage-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.outage::backdrop {
  background: rgba(8, 8, 10, 0.6);
  backdrop-filter: blur(6px) grayscale(0.6);
  animation: outage-fade 0.3s;
}
.outage-icon {
  position: relative;
  display: grid;
  width: 4.5rem;
  height: 4.5rem;
  margin-bottom: 0.5rem;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  box-shadow: 0 10px 30px rgba(145, 71, 255, 0.45);
  color: #fff;
  font-size: 1.7rem;
}
.outage-ring {
  position: absolute;
  inset: 0;
  border: 2px solid var(--purple);
  border-radius: 50%;
  animation: outage-pulse 2s ease-out infinite;
}
.outage-title { font-size: 1.35rem; }
.outage-message { color: var(--text-muted); line-height: 1.55; }
.outage-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: rgba(145, 71, 255, 0.12);
  color: #cdb8ff;
  font-size: 0.85rem;
}
.outage-retry { display: inline-flex; align-items: center; gap: 0.45rem; }

@keyframes outage-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes outage-fade { from { opacity: 0; } }
@keyframes outage-pulse { from { opacity: 0.8; transform: scale(1); } to { opacity: 0; transform: scale(1.8); } }
@media (prefers-reduced-motion: reduce) {
  .outage[open], .outage::backdrop, .outage-ring { animation: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Mobile & touch
   ══════════════════════════════════════════════════════════════════════════ */

/* Shown only on narrow screens (below) */
.mobile-topbar,
.sidebar-backdrop { display: none; }

/* Touch screens have no hover: show what desktop reveals on hover */
@media (hover: none) {
  .library-open { opacity: 1; background: transparent; font-size: 1.1rem; align-items: end; justify-items: end; padding: 0.5rem; }
  .bot-card-edit,
  .variable-delete { opacity: 1; }
  .media-drop-hint:not(.is-paused) { display: none; }
}

/* Fingers: bigger targets; only corner handles, edge ones would cover small layers */
@media (pointer: coarse) {
  .layer-action { width: 2.2rem; height: 2.2rem; }
  .stage-handle { --size: calc(16px / var(--stage-scale, 1)); }
  .stage-layer.is-selected .stage-handle:is([data-handle="n"], [data-handle="s"], [data-handle="e"], [data-handle="w"]) { display: none; }
}

/* ── Tablets and phones ──────────────────────────────────────────────────── */
@media (max-width: 860px) {
  /* Dashboard: top bar + the sidebar as a drawer */
  .dashboard-layout { flex-direction: column; }
  .mobile-topbar {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #2a2a2e;
    background: var(--surface);
  }
  .mobile-menu-btn {
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: 1.15rem;
    cursor: pointer;
  }
  .mobile-menu-btn:hover,
  .mobile-menu-btn:focus-visible { background: rgba(145, 71, 255, 0.14); }
  .mobile-topbar-title { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }

  .dashboard-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 950; /* above the page, below modals (1000) */
    width: min(80vw, 280px);
    transform: translateX(-100%);
    transition: transform 0.25s ease, visibility 0.25s;
    visibility: hidden;
  }
  .is-nav-open .dashboard-sidebar { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, 0.6); }
  .sidebar-link { padding-block: 0.8rem; }
  .lang-option { padding-block: 0.55rem; }
  .account-logout { width: 2.75rem; height: 2.75rem; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 940;
    display: block;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .is-nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  .dashboard-main { flex: 1; height: auto; min-height: 0; padding: 1.25rem 1rem 2rem; }
  .dash-heading { font-size: 1.3rem; }

  /* Overview */
  .overview-hero { padding: 1.25rem; }
  .overview-hero h2 { font-size: 1.45rem; }
  .overview-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
  .overview-tile { padding: 0.9rem 1rem; }
  .overview-tile-value { font-size: 1.6rem; }

  /* Dialogs: wider, less padding */
  .modal-box,
  .modal-wide { width: calc(100vw - 1.5rem); max-height: calc(100dvh - 1.5rem); padding: 1.25rem; }
  .modal-preview-box { padding: 0; }
  .modal-actions { flex-wrap: wrap; }

  .bot-type-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .media-picker-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .library-grid { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.75rem; }
  .media-dialog { height: 88dvh; }
  .platform-card { flex-wrap: wrap; }
  .profile-hero { gap: 1rem; padding: 1.25rem; }
  .profile-avatar { flex-basis: 3.5rem; height: 3.5rem; font-size: 1.5rem; }
  .profile-hero h2 { font-size: 1.4rem; }
  .dash-card { padding: 1.1rem; }

  /* Overlay editor: stage on top (stays in view), layers and settings below it */
  .editor-topbar { gap: 0.5rem; padding: 0.5rem 0.75rem; }
  .editor-name { flex: 1 1 8rem; max-width: none; }
  .editor-topbar-tools { flex-wrap: wrap; width: 100%; margin-left: 0; }
  .editor-topbar-tools .btn:last-child { margin-left: auto; }
  .editor-topbar-tools .save-status { order: 1; width: 100%; max-width: none; justify-content: flex-end; }
  .editor-topbar-tools .save-status:empty { display: none; }
  .tool-group select { max-width: 9rem; }

  .editor-workspace { flex-direction: column; overflow-y: auto; }
  .editor-center {
    position: sticky;
    top: 0;
    z-index: 5;
    order: -1;
    flex: 0 0 auto;
    border-bottom: 1px solid #2a2a2e;
  }
  .editor-stage { flex: 0 0 auto; height: 38dvh; min-height: 200px; }
  .timeline-rows { display: none; } /* only the ruler: the canvas needs the space */
  .editor-dock { --labels: 0px; }
  .editor-layers { width: auto; border-right: 0; border-bottom: 1px solid #2a2a2e; }
  .layer-list { flex: none; overflow: visible; }
  .editor-panel { width: auto; overflow: visible; border-left: 0; }
  .editor.is-code-mode .editor-panel { width: auto; overflow: visible; }
  .editor.is-code-mode .cw-monaco { flex: none; height: 60dvh; }
}

/* ── Phones ──────────────────────────────────────────────────────────────── */
@media (max-width: 560px) {
  /* 16px stops iOS from zooming in on focus */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea { font-size: 16px; }

  .overview-tile-note { display: none; }

  /* Dialogs become bottom sheets */
  .modal { align-items: flex-end; }
  .modal-box,
  .modal-wide { width: 100%; max-height: 90dvh; border-radius: 16px 16px 0 0; }

  /* Landing and login pages */
  .site-header .tagline { display: none; }
  .site-logo { width: 40px; height: 40px; }
  .site-header h1 { font-size: 1.4rem; }
  .hero { padding: 2.5rem 0; }
  .hero h2 { font-size: 1.7rem; }
  .login-section { margin: 2rem 1rem; padding: 1.75rem 1.25rem; }

  /* Event history: the time goes under the name, the buttons share a row */
  .history-actions { width: 100%; }
  .history-actions .btn { flex: 1 1 auto; justify-content: center; border: 1px solid #34343a; }
  .history-row { grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.15rem 0.75rem; padding: 0.65rem 0.7rem; }
  .history-icon,
  .btn-remove-history { grid-row: 1 / span 2; }
  .history-line { flex-wrap: wrap; row-gap: 0.1rem; }
  .history-name { max-width: 100%; }
  .history-row time { grid-row: 2; grid-column: 2; }

  /* Admin: the user's buttons go under the name */
  .user-row { flex-wrap: wrap; }
  .user-row-text { flex-basis: calc(100% - 3rem); }
  .user-row-actions { width: 100%; justify-content: flex-end; }
  .whitelist-add-fields { flex-wrap: wrap; }
  .whitelist-add-fields input { flex-basis: 100%; }
}
