/* ═══════════════ Overlay Studio — admin styles ═══════════════ */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 14px;
  --radius-sm: 9px;
  --side-w: 252px;
}
:root, [data-theme="light"] {
  --bg: #f4f5f9; --panel: #ffffff; --panel-2: #f1f3f8; --panel-3: #e7eaf2;
  --line: #e3e6ee; --line-2: #d2d7e3;
  --text: #151827; --text-2: #434a60; --muted: #717890;
  --brand: #5b4cf5; --brand-2: #7c6ff7; --brand-soft: #eeecff; --on-brand: #fff;
  --ok: #15803d; --ok-soft: #e2f6e9;
  --warn: #b45309; --warn-soft: #fdf1dc;
  --danger: #c62828; --danger-soft: #fde8e8;
  --info: #1d4ed8; --info-soft: #e6edff;
  --idle: #6b7280; --idle-soft: #eef0f4;
  --shadow: 0 1px 2px rgba(16, 20, 40, .05), 0 4px 16px rgba(16, 20, 40, .06);
  --shadow-lg: 0 24px 60px rgba(16, 20, 40, .24);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d0f16; --panel: #161922; --panel-2: #1c202b; --panel-3: #252a37;
  --line: #262b38; --line-2: #343a4b;
  --text: #eceef5; --text-2: #b8bdd0; --muted: #8a90a6;
  --brand: #8b7fff; --brand-2: #a79fff; --brand-soft: #25224a; --on-brand: #fff;
  --ok: #4ade80; --ok-soft: #132d1d;
  --warn: #fbbf24; --warn-soft: #33270f;
  --danger: #f87171; --danger-soft: #381619;
  --info: #7ea4ff; --info-soft: #17223d;
  --idle: #9ca3af; --idle-soft: #22252e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── Shell ── */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 12px; background: var(--panel); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #d946ef); color: #fff;
  font-weight: 800; font-size: 13px; letter-spacing: .02em; box-shadow: 0 6px 16px rgba(91, 76, 245, .35);
}
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand-name span { color: var(--muted); font-weight: 600; }
.side-lbl { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 8px 6px; }
.side-select { margin: 0 0 12px; width: 100%; }
.nav-group { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 16px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 12px; border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--text-2); font-weight: 500; text-align: left; transition: background .15s, color .15s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--ok); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
[data-theme="dark"] .nav-badge { color: #06210f; }
.nav-badge.warn { background: var(--warn); color: #fff; }
.sidebar-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 4px; }
.theme-btn {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 0; background: none; color: var(--muted); font-size: 13px; text-decoration: none;
}
.theme-btn:hover { background: var(--panel-2); color: var(--text); }
.nav-backdrop, .nav-toggle-btn { display: none; }

/* ── Main ── */
.main { padding: 22px 30px 60px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.top-l { display: flex; align-items: center; gap: 12px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.top-client { color: var(--muted); font-size: 13px; }
.top-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.today-chip {
  font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--panel);
  border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px;
}

/* ── Buttons & inputs ── */
.btn, .btn-ghost, .btn-sm, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm); font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn { padding: 9px 16px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); }
.btn.primary, .btn-sm.primary {
  background: var(--brand); border-color: var(--brand); color: var(--on-brand);
  box-shadow: 0 4px 14px rgba(91, 76, 245, .28);
}
.btn.primary:hover, .btn-sm.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn:active, .btn-sm:active, .btn-ghost:active { transform: translateY(1px); }
.btn:disabled, .btn-sm:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm:disabled:hover { background: var(--panel); }
.btn-ghost { padding: 9px 16px; border: 1px solid var(--line-2); background: transparent; color: var(--text); }
.btn-ghost:hover, .btn:not(.primary):hover { background: var(--panel-2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); }
.btn-sm:hover { background: var(--panel-2); }
.btn-sm.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-sm.danger:hover { background: var(--danger-soft); }
.sel-sm {
  width: auto; padding: 6px 26px 6px 11px; font-size: 12.5px; border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); background: var(--panel); color: var(--text); cursor: pointer;
}
.sel-sm:hover { background: var(--panel-2); }
.sel-sm:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.icon-btn { width: 32px; height: 32px; padding: 0; border: 1px solid transparent; background: none; color: var(--muted); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

.select, .form select, input:not([type="checkbox"]):not([type="color"]):not([type="file"]), textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.select { width: auto; padding-right: 30px; }
.form select { width: 100%; }
input:focus, textarea:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input:disabled { background: var(--panel-2); color: var(--muted); }
textarea { resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; color: var(--muted); }
.search input { padding-left: 34px !important; min-width: 220px; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.seg-btn { border: 0; background: none; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--line-2); }
.seg-btn:hover { color: var(--text); background: var(--panel-2); }
.seg-btn.on { background: var(--brand-soft); color: var(--brand); }
.seg-btn.strong { color: var(--text); min-width: 64px; }

/* ── Tabs ── */
.tab { display: none; }
.tab.on { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* ── Cards, KPIs ── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-t { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.card-sub { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.card-actions.left { justify-content: flex-start; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi {
  text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
button.kpi:hover { border-color: var(--brand); transform: translateY(-1px); }
.kpi-lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-val { font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin: 4px 0 2px; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.step {
  width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff;
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; flex: none;
}

/* ── Lists ── */
.list { display: grid; gap: 4px; }
.li { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius-sm); }
.li:hover { background: var(--panel-2); }
.li-ic {
  width: 40px; height: 40px; border-radius: 10px; flex: none; display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 85%, #000), color-mix(in srgb, var(--c) 55%, #fff));
}
.li-main { min-width: 0; flex: 1; }
.li-t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-s { font-size: 12.5px; color: var(--muted); }
.li-a { display: flex; gap: 6px; }
.empty-note { color: var(--muted); padding: 22px; text-align: center; font-size: 13px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); grid-column: 1 / -1; }
.empty-state .big { font-size: 38px; margin-bottom: 8px; }
.empty-state b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ── Tables ── */
.tbl-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.tbl-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.tbl-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tbl-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  padding: 12px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.r { text-align: right; }
td.r .btn-sm + .btn-sm { margin-left: 6px; }
table.compact th { background: none; padding: 8px 10px; }
table.compact td { padding: 9px 10px; font-size: 13px; }
.cell-strong { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); }

/* ── Status pills & chips ── */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-live { background: var(--ok-soft); color: var(--ok); }
.s-live::before { animation: pulse 1.6s ease-in-out infinite; box-shadow: 0 0 0 0 currentColor; }
.s-scheduled { background: var(--info-soft); color: var(--info); }
.s-paused { background: var(--warn-soft); color: var(--warn); }
.s-ended { background: var(--idle-soft); color: var(--idle); }
@keyframes pulse { 50% { opacity: .35; } }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 6px;
  background: var(--panel-2); color: var(--text-2); font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
button.chip { border: 1px dashed var(--line-2); font-family: var(--mono); cursor: pointer; }
button.chip:hover { border-color: var(--brand); color: var(--brand); }

/* ── Banners ── */
.warn-banner, .err-banner, .info-banner {
  display: none; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
}
.warn-banner.on, .err-banner.on, .info-banner.on { display: block; }
.warn-banner { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }
.err-banner { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
.info-banner { background: var(--info-soft); color: var(--info); }
.warn-banner ul, .err-banner ul { margin: 6px 0 0; padding-left: 18px; }
.warn-banner .btn-sm { margin-left: 8px; }

/* ── Overlay cards ── */
.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.ov-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s;
}
.ov-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.ov-card.ended, .ov-card.paused { opacity: .86; }
.ov-thumb {
  position: relative; height: 112px; display: grid; place-items: center; overflow: hidden; border: 0; width: 100%; padding: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, .35) 0 2px, transparent 3px) 0 0 / 34px 34px,
    radial-gradient(circle at 70% 60%, rgba(255, 255, 255, .25) 0 1.5px, transparent 2.5px) 0 0 / 26px 26px,
    linear-gradient(135deg, color-mix(in srgb, var(--c) 90%, #000), color-mix(in srgb, var(--c) 55%, #fff));
}
.ov-card.paused .ov-thumb, .ov-card.ended .ov-thumb { filter: grayscale(.55); }
.ov-emoji { font-size: 46px; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .25)); transition: transform .25s; }
.ov-thumb:hover .ov-emoji { transform: scale(1.12) rotate(-6deg); }
.ov-thumb .pill { position: absolute; top: 10px; left: 10px; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.ov-thumb .play {
  position: absolute; right: 10px; bottom: 10px; font-size: 11.5px; font-weight: 700; color: #fff;
  background: rgba(0, 0, 0, .35); padding: 4px 9px; border-radius: 999px; opacity: 0; transition: opacity .15s;
}
.ov-thumb:hover .play { opacity: 1; }
.yearly-tag {
  position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(0, 0, 0, .28); padding: 3px 8px; border-radius: 999px;
}
.ov-body { padding: 14px 16px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ov-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ov-title-row h3 { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.3; }
.ov-dates { font-size: 12.5px; color: var(--text-2); }
.ov-meta { display: flex; flex-wrap: wrap; gap: 5px; }
.ov-actions { display: flex; align-items: center; gap: 4px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.ov-actions .spacer { flex: 1; }

/* Switch (button) */
.switch-btn {
  position: relative; width: 38px; height: 22px; border-radius: 999px; border: 0; padding: 0; flex: none;
  background: var(--line-2); transition: background .2s;
}
.switch-btn span {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch-btn[aria-checked="true"] { background: var(--ok); }
.switch-btn[aria-checked="true"] span { transform: translateX(16px); }

/* Switch (checkbox) */
.switch-label { display: inline-flex !important; align-items: center; gap: 10px; cursor: pointer; margin-top: 14px !important; font-weight: 500 !important; }
.switch-label input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--line-2); transition: background .2s; flex: none; }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch-label input:checked + .switch { background: var(--ok); }
.switch-label input:checked + .switch::after { transform: translateX(16px); }
.switch-label input:focus-visible + .switch { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── Templates ── */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tpl-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.tpl-card .ov-thumb { height: 130px; }
.tpl-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tpl-body h3 { margin: 0; font-size: 15px; }
.tpl-body p { margin: 0; color: var(--muted); font-size: 13px; flex: 1; }
.tpl-dates { font-size: 12px; color: var(--text-2); font-weight: 500; }
.tpl-actions { display: flex; gap: 8px; margin-top: 8px; }
.tpl-actions .btn-sm { flex: 1; }
.tpl-card.blank { background: transparent; border: 2px dashed var(--line); box-shadow: none; align-items: center; justify-content: center; text-align: center; }
.tpl-card.blank .tpl-blank-ic { font-size: 32px; margin-top: 22px; }
.tpl-card.blank .tpl-body { align-items: center; }
.tpl-card.blank .tpl-actions { width: 100%; margin-top: 12px; }
.tpl-card.blank .tpl-actions .btn { width: 100%; }

.tpl-share { display: grid; gap: 10px; padding: 14px 16px; margin-bottom: 16px; }
.tpl-share-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tpl-share-row b { flex: 1 1 200px; font-size: 14px; }
.tpl-share-row small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }

.tpl-filter { flex-wrap: wrap; margin-bottom: 16px; }
.tpl-filter .seg-btn .muted { font-weight: 500; opacity: .7; }

.tpl-active { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.tpl-card.inactive .ov-thumb, .tpl-card.inactive .tpl-body h3, .tpl-card.inactive .tpl-body p { opacity: .55; }

/* ── Calendar ── */
.cal-card { padding: 0; overflow: hidden; }
.cal-scroll { overflow-x: auto; }
.cal { --lbl: 230px; min-width: 820px; position: relative; }
.cal-head { display: flex; border-bottom: 1px solid var(--line); background: var(--panel-2); position: sticky; top: 0; }
.cal-label { width: var(--lbl); flex: none; padding: 10px 16px; font-size: 12.5px; }
.cal-months { flex: 1; display: flex; }
.cal-months span { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 0 10px 8px; border-left: 1px solid var(--line); }
.cal-months span.now { color: var(--brand); }
.cal-body { position: relative; }
.cal-lines { position: absolute; top: 0; bottom: 0; left: var(--lbl); right: 0; pointer-events: none; }
.cal-lines i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.cal-lines .today { width: 2px; background: var(--danger); z-index: 3; }
.cal-lines .today::before {
  content: "Today"; position: absolute; top: 4px; left: 4px; font-size: 10px; font-weight: 700; color: #fff;
  background: var(--danger); padding: 1px 6px; border-radius: 4px; font-style: normal; white-space: nowrap;
}
.cal-group { padding: 8px 16px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--panel-2); border-bottom: 1px solid var(--line); position: relative; z-index: 2; }
.cal-row { display: flex; align-items: center; border-bottom: 1px solid var(--line); min-height: 46px; }
.cal-row:last-child { border-bottom: 0; }
.cal-row .cal-label { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; font-size: 13px; }
.cal-row .cal-label span.n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-track { flex: 1; position: relative; height: 46px; }
.cal-bar {
  position: absolute; top: 10px; height: 26px; border-radius: 7px; border: 0; padding: 0 8px; min-width: 6px;
  background: var(--c); color: #fff; font-size: 11.5px; font-weight: 600; text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--c) 40%, transparent); z-index: 2; transition: transform .12s, box-shadow .12s;
}
.cal-bar:hover { transform: translateY(-1px); box-shadow: 0 6px 14px color-mix(in srgb, var(--c) 50%, transparent); }
.cal-bar.cut-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-bar.cut-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-bar.paused { background: repeating-linear-gradient(135deg, var(--c) 0 6px, color-mix(in srgb, var(--c) 55%, var(--panel)) 6px 12px); color: #fff; opacity: .75; }
.cal-bar.ended { opacity: .45; }

/* ── Settings & forms ── */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.span-2 { grid-column: 1 / -1; }
.form label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--text-2); }
.form > label:first-child, .form .card-sub + label { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row > div > label:first-child { margin-top: 14px; }
.req { color: var(--danger); }
.opt { color: var(--muted); font-weight: 400; font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.check-label { display: flex !important; align-items: center; gap: 9px; font-weight: 500 !important; cursor: pointer; margin: 14px 0 0 !important; color: var(--text) !important; }
.form-row .check-label { margin-top: 8px !important; min-height: 38px; }
.inline-checks { display: flex; gap: 22px; flex-wrap: wrap; }
.inline-checks .check-label { margin-top: 0 !important; }
.code { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; background: var(--panel-2) !important; tab-size: 2; }
.code-lg { min-height: 340px; white-space: pre; overflow: auto; }
.code-files { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.code-file-tab {
  display: flex; align-items: center; gap: 2px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 2px 2px 10px; cursor: pointer;
}
.code-file-tab.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--panel-2)); }
.code-file-name {
  border: 0; background: none; font-family: var(--mono); font-size: 12px; width: 84px; padding: 4px 2px;
  color: inherit; cursor: text;
}
.code-file-name:focus { outline: none; text-decoration: underline; }
.code-file-x {
  border: 0; background: none; width: 22px; height: 22px; border-radius: 50%; color: var(--muted);
  font-size: 14px; line-height: 1; cursor: pointer; flex: none;
}
.code-file-x:hover { background: var(--danger); color: #fff; }
.code-file-add { border: 1px dashed var(--line-2); background: none; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.code-file-add:hover { border-color: var(--brand); color: var(--brand); }
.ed-pane.drag-over { outline: 2px dashed var(--brand); outline-offset: -4px; background: color-mix(in srgb, var(--brand) 6%, transparent); border-radius: var(--radius-sm); }
.code-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.code-toolbar .hint { margin: 0; }
.code-toolbar > span:not(.hint) { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.emoji-field { position: relative; display: flex; gap: 8px; }
.emoji-field input { flex: 1; }
.emoji-picker {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 20; width: 260px; max-height: 220px;
  overflow-y: auto; padding: 8px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.emoji-picker button {
  border: 0; background: none; font-size: 20px; line-height: 1; padding: 6px 0; border-radius: 6px; cursor: pointer;
}
.emoji-picker button:hover { background: var(--panel-2); }

.color-field { display: flex; gap: 8px; }
.color-field input[type="color"] { width: 44px; height: 40px; padding: 3px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); flex: none; cursor: pointer; }
.json-details { margin-top: 14px; }
.json-details summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.danger-card { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.export-ok { color: var(--ok); font-weight: 600; font-size: 13px; }
.export-stale { color: var(--warn); font-weight: 600; font-size: 13px; }
.link-cell { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* ── Images tab ── */
.img-list { display: grid; gap: 8px; margin-bottom: 12px; }
.img-row { display: grid; grid-template-columns: 44px 140px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.img-thumb {
  width: 44px; height: 44px; border-radius: 8px; object-fit: contain; padding: 4px;
  background: repeating-conic-gradient(var(--panel-3) 0 25%, var(--panel) 0 50%) 0 0 / 12px 12px;
}
.img-size { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.img-add { display: grid; grid-template-columns: 140px minmax(0, 1fr) auto; gap: 8px; }

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px;
  background: rgba(10, 12, 22, .55); backdrop-filter: blur(4px);
}
.modal-overlay.on { display: flex; animation: fade .18s ease; }
.modal-overlay.top-layer { z-index: 120; }
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal.narrow { max-width: 420px; }
.modal.xwide { max-width: 1320px; height: calc(100vh - 40px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-x { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--panel-2); color: var(--muted); font-size: 22px; line-height: 1; flex: none; }
.modal-x:hover { color: var(--text); background: var(--panel-3); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-body p { margin: 0; color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--panel-2); flex-wrap: wrap; }
.modal-foot:empty { display: none; }
.ed-sub { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.check-list { display: grid; gap: 4px; max-height: 280px; overflow-y: auto; margin-bottom: 4px; }
.check-list .check-label { margin: 0 !important; padding: 9px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.check-list .check-label:hover { background: var(--panel-2); }

/* ── Editor ── */
.editor { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(380px, 5fr) 7fr; }
.ed-form { overflow-y: auto; padding: 0 20px 20px; border-right: 1px solid var(--line); }
.ed-tabs {
  display: flex; gap: 2px; position: sticky; top: 0; z-index: 2; background: var(--panel);
  border-bottom: 1px solid var(--line); margin: 0 -20px 16px; padding: 0 12px; overflow-x: auto;
}
.ed-tab { border: 0; background: none; padding: 13px 10px 11px; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.ed-tab:hover { color: var(--text); }
.ed-tab.on { color: var(--brand); border-bottom-color: var(--brand); }
[data-template-only] { display: none; }
#editorModal.tpl-mode [data-overlay-only] { display: none !important; }
#editorModal.tpl-mode [data-template-only] { display: block; }
.ed-tab .count { font-size: 11px; background: var(--panel-2); border-radius: 999px; padding: 1px 6px; margin-left: 2px; }
.ed-tab .count:empty { display: none; }
.ed-pane { display: none; }
.ed-pane.on { display: block; }
.ed-preview { display: flex; flex-direction: column; min-height: 0; background: var(--panel-2); padding: 14px 18px 18px; }
.ed-preview .err-banner { margin-bottom: 10px; }
.pv-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.pv-title { font-weight: 700; font-size: 13px; margin-right: auto; }

.stage {
  flex: 1; min-height: 0; display: flex; justify-content: center; align-items: stretch;
  border-radius: 12px; background:
    radial-gradient(circle, var(--line-2) 1px, transparent 1.5px) 0 0 / 16px 16px, var(--panel-3);
  padding: 12px; overflow: hidden;
}
.stage iframe {
  width: 100%; height: 100%; border: 0; border-radius: 10px; background: #fff;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .18); transition: width .3s ease;
}
.stage[data-device="mobile"] iframe { width: 390px; max-width: 100%; border-radius: 22px; box-shadow: 0 0 0 8px #11131b, 0 20px 50px rgba(0, 0, 0, .3); }
.stage[data-device="mobile"] { padding: 22px; }
.stage.big { margin: 14px 20px; border-radius: 12px; }

/* Desktop preview renders the iframe at a real 1920×1080 desktop viewport (so max-width media
   queries written for real monitors evaluate the same way they would on an actual monitor,
   instead of whatever the narrower side panel happens to measure) then scales it down with a
   CSS transform to fit. The wrapper's own box is resized to the post-scale footprint by JS
   (fitDesktopPreview) so it sits centered instead of leaving a stretched blank area around it. */
.stage[data-device="desktop"] { align-items: center; }
.stage[data-device="desktop"] .ed-frame-wrap {
  /* Safe fallback if JS hasn't sized this yet (or can't run for some reason): stay contained
     within the panel and clip the oversized iframe, rather than growing to fit it and
     overflowing the page. JS overwrites width/height inline with the precise scaled footprint. */
  width: 100%; height: 100%; max-width: 100%; flex: 1; min-width: 0; overflow: hidden;
  border-radius: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, .18); background: #fff;
}
.stage[data-device="desktop"] .ed-frame-wrap iframe {
  /* Fallback size for the brief window before fitDesktopPreview() gets a real measurement and
     overwrites width/height/transform inline: fill the wrapper at 100% rather than defaulting to
     an unscaled 1920px (which would overflow the wrapper's overflow:hidden and look "zoomed in"
     and cropped until JS catches up). */
  width: 100%; height: 100%; border: 0; box-shadow: none; border-radius: 0; transition: none;
  transform-origin: top left;
}

/* ── Toasts ── */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 16px;
  background: var(--text); color: var(--panel); border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 500; animation: toast-in .25s ease;
}
.toast::before { content: "✓"; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); color: #fff; font-size: 11px; font-weight: 800; flex: none; }
.toast.error::before { content: "!"; background: var(--danger); }
.toast.warn::before { content: "!"; background: var(--warn); }
.toast.out { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ── Responsive ── */
@media (max-width: 1280px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1080px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: auto 520px; overflow-y: auto; }
  .ed-form { overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .grid-2, .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: var(--side-w); z-index: 90;
    transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .4); }
  .nav-toggle-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); cursor: pointer; }
  .main { padding: 16px 16px 60px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .today-chip { display: none; }
}
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .search input { min-width: 0; }
  .search { flex: 1; }
  .top-r { width: 100%; }
  .img-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .img-row input[data-img="url"], .img-row .img-size { grid-column: 2 / -1; }
  .img-add { grid-template-columns: 1fr; }
  .modal-overlay { padding: 0; }
  .modal, .modal.xwide { max-height: 100vh; height: 100vh; border-radius: 0; }
  .cal { --lbl: 140px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* who is signed in (sidebar footer) */
.whoami { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 6px; border-radius: 10px; background: var(--panel-2); color: var(--muted, var(--text)); font-size: 12.5px; }
.whoami b { color: var(--text); font-weight: 650; overflow-wrap: anywhere; }
.whoami-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; flex: none; }

/* teammates on the same client / someone else saved */
.presence-chip { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; padding: 7px 10px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 12.5px; line-height: 1.35; }
.presence-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
#staleBanner { margin-bottom: 14px; }
#staleBanner .btn-sm { margin-left: 10px; }

/* author display rules (display:flex etc.) would otherwise beat the [hidden] attribute */
[hidden] { display: none !important; }

/* roles */
.role-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); color: var(--muted); text-transform: capitalize; }
.role-badge.admin { background: var(--warn-soft); color: var(--warn); }
.role-badge.editor { background: var(--ok-soft); color: var(--ok); }

/* client picker in Team access: search box + scrollable list */
.client-search { margin-bottom: 8px; }
.client-pick { max-height: 220px; overflow-y: auto; }
.client-count { margin-top: 6px; }
