/* Dark theme (the admin page and each display's own menu). */
:root {
  color-scheme: dark;  /* dark date and time pickers, scrollbars and form controls */
  --bg: #161615;
  --card: #1F1F1D;
  --line: #33332F;
  --line-strong: #4A4A45;
  --text: #ECEAE3;
  --sub: #A8A69E;
  --muted: #75736C;
  --hover: #2A2A27;
  --input: #141413;
  --primary: #3A86D4;
  --primary-hover: #7DB5EC;
  --primary-soft: #172D44;
  --danger: #E26565;
  --danger-soft: #3A1C1C;
  --ok: #8CC152;
  --warn: #E0A33F;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 20px; margin: 0; font-weight: 600; }
h3 { font-size: 16px; margin: 0 0 6px; font-weight: 600; }
.sub { color: var(--sub); margin: 0 0 12px; }
.hint { color: var(--sub); font-size: 13px; margin: 4px 0 0; }
.opt { color: var(--muted); font-weight: 400; }
.strong { font-weight: 600; }
.center { text-align: center; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }

button, .btn { font: inherit; min-height: 40px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--card); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { background: var(--hover); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: #2F72B8; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--hover); }
button.danger { color: var(--danger); }
button.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
button.icon-btn { width: 40px; padding: 0; }
button:disabled { opacity: 0.4; cursor: default; }
button.wide { width: 100%; }
input, select { font: inherit; height: 40px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--input); color: var(--text); min-width: 0; }
input[type=checkbox], input[type=radio] { height: auto; width: 18px; height: 18px; accent-color: var(--primary); }
input[type=range] { padding: 0; border: none; accent-color: var(--primary); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; font-size: 13px; color: var(--sub); font-weight: 600; }
.field input, .field select { font-weight: 400; font-size: 15px; }
.field.narrow { max-width: 260px; }
.check { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--sub); }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin: 0 0 16px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }

/* sign-in */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 32px; }
.login-logo { font-size: 36px; color: var(--primary); margin-bottom: 8px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 20px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 17px; color: var(--primary); }
.brand span:last-child { color: var(--text); }
/* Admin header: the business and the always-there actions on top, the sections underneath (they wrap, never hide). */
.admin-topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 16px; padding: 10px 20px 0; }
.admin-topbar .brand { min-width: 0; }
.admin-topbar #hname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions .sync-btn, .top-actions .alert-btn { min-height: 36px; padding: 0 14px; border-radius: var(--radius); background: none; font-weight: 600; white-space: nowrap; }
.top-actions .sync-btn { border: 1px solid var(--primary); color: var(--primary); }
.top-actions .sync-btn:hover { background: var(--primary-soft); color: var(--primary-hover); }
.top-actions .sync-btn:disabled { opacity: 0.5; }
.top-actions .alert-btn { border: 1px solid var(--danger); color: var(--danger); }
.top-actions .alert-btn:hover { background: var(--danger-soft); }
.account-menu { position: relative; }
.account-menu summary { list-style: none; cursor: pointer; min-height: 36px; display: flex; align-items: center; gap: 6px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); font-weight: 600; white-space: nowrap; max-width: 220px; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary::after { content: "\25BE"; color: var(--sub); }
.account-menu #whoami { overflow: hidden; text-overflow: ellipsis; }
.account-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 240px; display: grid; padding: 6px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35); }
.account-pop a, .account-pop button { display: block; text-align: left; padding: 10px 12px; border: none; border-radius: 8px; background: none;
  color: var(--text); font: inherit; text-decoration: none; cursor: pointer; min-height: 0; }
.account-pop a:hover, .account-pop button:hover { background: var(--primary-soft); }
.account-pop #logout { color: var(--danger); }
#tabs { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px; margin-top: 6px; }
#tabs button { border: none; border-radius: 0; background: none; min-height: 48px; padding: 0 16px; color: var(--sub); border-bottom: 3px solid transparent; }
#tabs button:hover { color: var(--text); background: none; }
#tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
@media (max-width: 700px) {
  .admin-topbar { grid-template-columns: 1fr; padding: 10px 12px 0; }
  .top-actions { margin-top: 8px; flex-wrap: wrap; }
  .account-pop { left: 0; right: auto; }
  #tabs button { min-height: 44px; padding: 0 10px; }
}
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }

/* display */
.preview { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; margin: 0 0 16px; border: 8px solid #2C2C2A; }
.preview iframe { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; }
.preview.portrait { max-width: 520px; }
.zone-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.zone-settings fieldset { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.zone-settings legend { padding: 0 5px; color: var(--sub); font-size: 13px; font-weight: 600; }
.zone-settings .check { font-size: 14px; margin-bottom: 8px; }
.zone-settings .check:last-child, .zone-settings .field:last-child { margin-bottom: 0; }
.zone-settings .catalog-zone-choices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.catalog-dialog { max-height: 90vh; overflow-y: auto; width: min(800px, 94vw); }
#catalogFields { margin-top: 18px; }
.catalog-dialog textarea { background: var(--input); color: var(--text); resize: vertical; }
.catalog-section { margin-top: 16px; }
.catalog-section-head { margin-bottom: 12px; }
.catalog-item-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.catalog-item-row img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.catalog-item-row .catalog-item-detail { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.catalog-item-row .catalog-item-meta { color: var(--sub); font-size: 13px; }
.catalog-price-row, .catalog-daypart-row { padding: 14px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.catalog-daypart-row .days { margin-bottom: 10px; }
.catalog-photos { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.catalog-photo { width: 100px; }
.catalog-photo img { display: block; width: 100px; height: 80px; object-fit: cover; border-radius: 8px; margin-bottom: 6px; }
.catalog-photo button { width: 100%; }
.catalog-schedule { margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.catalog-daypart-checks { display: flex; gap: 8px 16px; flex-wrap: wrap; }
.catalog-daypart-checks .check { margin: 0; font-size: 14px; font-weight: 400; }
@media (max-width: 600px) { .catalog-item-row { flex-wrap: wrap; align-items: start; } .catalog-item-row > .row { width: 100%; }
  .catalog-dialog .grid2 { grid-template-columns: 1fr; } }
.tv-status { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.tv-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tv-line .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.tv-line.warn { color: var(--warn); }
.tv-line.warn .dot { background: #E24B4A; }
.tv-line .sub { margin: 0; }
.status { margin-top: 16px; color: var(--sub); display: flex; gap: 24px; flex-wrap: wrap; font-size: 14px; }
.display-list { margin-top: 14px; }
.display-row { display: flex; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.display-row:first-child { border-top: 0; }
.display-row .display-detail { flex: 1; min-width: 0; }
.display-row .display-name { font-weight: 600; overflow-wrap: anywhere; }
.display-row .display-meta { color: var(--sub); font-size: 13px; overflow-wrap: anywhere; }
.targeting { margin: 0 0 14px; padding: 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); min-width: 0; }
.targeting legend { padding: 0 5px; font-size: 13px; color: var(--sub); font-weight: 600; }
.target-display-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; max-height: 220px; overflow-y: auto; }
.target-display-list .check { margin: 0; color: var(--text); font-weight: 400; align-items: start; }
.target-display-list input { flex-shrink: 0; margin-top: 2px; }
@media (max-width: 600px) { .targeting .grid2, #displayForm .grid2, .zone-settings { grid-template-columns: 1fr; } .display-row { align-items: start; flex-wrap: wrap; } }

/* calendar */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 24px; align-items: start; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-head { margin: 16px 0 6px; font-size: 12px; color: var(--muted); text-align: center; }
.day { min-height: 84px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font: inherit; text-align: left; }
.day:hover { border-color: var(--line-strong); background: var(--card); }
.day.out { visibility: hidden; }
.day.past { background: #1A1A18; color: var(--muted); }
.day.today .num { background: var(--primary); color: #fff; border-radius: 999px; padding: 0 7px; }
.day.sel { outline: 2px solid var(--primary); outline-offset: -1px; }
.day .count { font-size: 12px; background: var(--primary-soft); color: var(--primary-hover); border-radius: 6px; padding: 1px 6px; }
.day .grp { font-size: 11px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ev-row, .ev-cols { display: grid; grid-template-columns: 190px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 130px; gap: 16px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.ev-cols { border-top: none; padding-top: 4px; padding-bottom: 6px; font-size: 12px; font-weight: 600; color: var(--sub); }
.ev-row .t { color: var(--sub); font-size: 14px; white-space: nowrap; }
.ev-row .acts { display: flex; justify-content: flex-end; }
.ev-row .n { font-weight: 600; }
.ev-row .l { color: var(--sub); font-size: 13px; }
.ev-row.overlap { background: #3A2C12; border-top-color: #6B4E1A; }
.same { font-size: 12px; color: var(--warn); font-weight: 600; margin-top: 2px; }
.same.clash { color: var(--danger); }
.ev-row.editing { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.empty { color: var(--sub); padding: 12px 0; border-top: 1px solid var(--line); }
.day-panel { margin-top: 24px; }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.copy-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copy-box .sub { margin: 0; }
#evFormDay { margin: 2px 0 14px; }

/* media */
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; border: 2px dashed var(--line-strong); border-radius: 14px; padding: 28px; background: var(--card); cursor: pointer; }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop-icon { font-size: 30px; color: var(--sub); }
.drop .sub { margin: 0; font-size: 13px; }
.m-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-top: 10px; }
.m-row.off { opacity: 0.6; }
.thumb { width: 90px; height: 90px; display: flex; align-items: center; justify-content: center; background: #2C2C2A; border-radius: 8px; overflow: hidden; }
.thumb { position: relative; }
.thumb img, .thumb video { max-width: 100%; max-height: 100%; }
.thumb .play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.badge.vid { background: #3A2018; color: #F0997B; }
.progress { margin-top: 10px; padding: 10px 14px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary-hover); font-weight: 600; }
.m-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-meta { color: var(--sub); font-size: 13px; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-hover); margin-left: 8px; font-weight: 400; vertical-align: 1px; }
.badge.full { background: #26234A; color: #AFA9EC; }
.badge.off { background: var(--hover); color: var(--sub); }
.badge.live { background: #1F3310; color: var(--ok); }
.warn { color: var(--warn); }
.m-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.sched { grid-column: 1 / -1; background: var(--bg); border-radius: 10px; padding: 16px; }
.sched .row { margin-bottom: 10px; }
.days { display: flex; gap: 4px; }
.days button { width: 44px; padding: 0; }
.days button[aria-pressed=true] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-hover); font-weight: 600; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.chips .badge { margin: 0; }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px 16px; }
.field .plain { font-weight: 400; color: var(--text); font-size: 14px; padding-top: 8px; }
.sched .seg { align-self: flex-start; }
.sched .field { margin-bottom: 10px; }

/* messages and rooms */
.strip-preview { margin: 16px 0 8px; background: #0F0F0E; border: 1px solid var(--line); color: #B4B2A9; border-radius: 10px; padding: 12px 16px; display: flex; gap: 32px; overflow-x: auto; white-space: nowrap; font-size: 14px; }
.strip-preview span { display: inline-flex; align-items: center; gap: 6px; }
.strip-preview .icon { color: #9FE1CB; }
.strip-preview .empty-strip { color: #6f6e69; }
#msgList .msg-row, #msgList .msg-editor { border-top: 1px solid var(--line); }
.msg-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; }
.msg-row.off { opacity: 0.6; }
.msg-icon { font-size: 22px; color: var(--primary); display: flex; justify-content: center; }
.msg-text { min-width: 0; }
.msg-editor { background: var(--bg); border-radius: 10px; padding: 16px; margin: 8px 0; }
.icon-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.icon-pick button { width: 44px; min-height: 40px; padding: 0; font-size: 20px; }
.icon-pick button[aria-pressed=true] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-hover); }
.icon-pick .none { font-size: 11px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 12px; margin: 8px 0; max-height: 420px; overflow-y: auto; padding: 2px; }
.room-grid .room-row { display: flex; gap: 4px; padding: 0; border: none; }
.room-grid .r-name { flex: 1; height: 36px; border-color: transparent; background: var(--bg); }
.room-grid .r-name:hover { border-color: var(--line-strong); }
.room-grid .icon-btn { width: 36px; min-height: 36px; }
details.paste { margin-top: 12px; }
details.paste summary { cursor: pointer; color: var(--primary); font-weight: 600; }
details.paste textarea { width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); margin-bottom: 8px; }
#roomFilter { width: 220px; }
.room-row { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.room-row input[type=text] { flex: 1; min-width: 160px; }
.room-add { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.room-add input:first-child { width: 200px; }

/* settings */
.logo-prev { width: 64px; height: 64px; border-radius: 12px; background: #2C2C2A; display: flex; align-items: center; justify-content: center; color: #9FE1CB; font-size: 30px; overflow: hidden; }
.logo-prev img { width: 100%; height: 100%; object-fit: contain; }
.swatches { display: flex; gap: 10px; margin-top: 4px; }
.swatches button { width: 36px; height: 36px; min-height: 0; border-radius: 50%; padding: 0; border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line-strong); }
.swatches button[aria-pressed=true] { box-shadow: 0 0 0 3px var(--text); }
.swatches button.usual { width: auto; border-radius: 18px; padding: 0 12px; background: var(--card); color: var(--text); font-size: 13px; }
/* Holiday themes (Settings) */
.theme-row { display: flex; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.theme-row:first-child { border-top: 0; }
.theme-pic { width: 192px; height: 108px; flex: none; border-radius: 8px; object-fit: cover; background: #1E1E1C; }
.theme-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.theme-body input[type=number] { width: 64px; }
.theme-row.now .theme-when { color: var(--accent, #1D9E75); font-weight: 600; }
.theme-add { margin-top: 12px; }
@media (max-width: 640px) { .theme-row { flex-direction: column; } .theme-pic { width: 100%; height: auto; aspect-ratio: 16 / 9; } }
.geo-hit { display: block; width: 100%; text-align: left; border: none; border-top: 1px solid var(--line); border-radius: 0; }
#geoResults { margin: 8px 0 12px; }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; margin: -4px 0 16px; z-index: 2; }

/* Segmented choices */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: none; border-radius: 0; min-height: 36px; padding: 0 14px; border-left: 1px solid var(--line-strong); }
.seg button:first-child { border-left: none; }
.seg button[aria-pressed=true] { background: var(--primary); color: #fff; font-weight: 600; }
.seg-row { margin: 0 0 12px; }
.seg-row .seg button { min-height: 40px; padding: 0 22px; }
.where { font-size: 12px; color: var(--sub); margin-right: 6px; }

/* activity */
.act-card { padding: 0; margin-top: 12px; overflow-x: auto; }
.act { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.act th { text-align: left; font-size: 12px; color: var(--sub); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.act td { padding: 9px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.act td:nth-child(1), .act td:nth-child(2) { white-space: nowrap; color: var(--sub); }
.act td:nth-child(3) { white-space: nowrap; }
.act tr.bad td { background: var(--danger-soft); }
.act tr.bad td:last-child { color: var(--danger); }
@media (max-width: 599px) {
  #tab-logs .act-card { border: 0; background: none; overflow: visible; }
  #tab-logs .act, #tab-logs .act tbody { display: block; }
  #tab-logs .act thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  #tab-logs .act tr {
    display: block;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
  }
  #tab-logs .act td {
    display: block;
    padding: 4px 0;
    border: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #tab-logs .act td::before {
    content: attr(data-label);
    display: block;
    color: var(--sub);
    font-size: 12px;
    font-weight: 600;
  }
  #tab-logs .act tr.bad { background: var(--danger-soft); }
  #tab-logs .act tr.bad td { background: none; }
  #tab-logs .act td[colspan]::before { content: none; }
  #tab-logs .inline { flex-wrap: wrap; max-width: 100%; }
  #tab-logs .inline select { max-width: 100%; }
}

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #3A3A36; color: #fff; padding: 12px 20px; box-shadow: 0 8px 24px rgba(0,0,0,.4); border-radius: 10px; opacity: 0; transition: all 0.2s; pointer-events: none; z-index: 10; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--danger); }

@media (max-width: 860px) {
  .cal-layout { grid-template-columns: 1fr; }
  .day { min-height: 60px; }
  .day .grp { display: none; }
  .m-row { grid-template-columns: 64px minmax(0, 1fr); }
  .thumb { width: 64px; height: 64px; }
  .m-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .ev-cols { display: none; }
  .ev-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .ev-row .t, .ev-row .loc, .ev-row .grp { grid-column: 1; }
  .ev-row .acts { grid-column: 2; grid-row: 1 / span 4; }
}

/* display device menu */
.narrow-main { max-width: 820px; }
.kv { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 8px 16px; font-size: 14px; }
.kv .k { color: var(--sub); }
.ok { color: var(--ok); font-weight: 600; }
.warn { color: var(--warn); }
.topbar a.btn { text-decoration: none; }
.preset-dialog { max-height: 90vh; overflow-y: auto; }
.preset-dialog textarea { background: var(--input); color: var(--text); }
.preset-row { display: flex; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.preset-row:first-child { border-top: 0; }
.preset-detail { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.preset-meta, .preset-description { color: var(--sub); font-size: 13px; margin-top: 4px; }
.preset-style { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; margin-left: 6px; background: var(--danger-soft); color: var(--danger); }
.preset-style.notice { background: #332814; color: var(--warn); }
@media (max-width: 600px) { .preset-row { flex-wrap: wrap; align-items: start; } .preset-row > .row { width: 100%; } }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv .k { margin-top: 6px; } }

/* Location: a dropdown of every room that filters as you type */
.combo { position: relative; display: flex; }
.combo input { flex: 1; padding-right: 40px; font-weight: 400; font-size: 15px; }
.combo-btn { position: absolute; right: 1px; top: 1px; bottom: 1px; min-height: 0; width: 38px; padding: 0; border: none; background: transparent; color: var(--sub); }
.combo-list { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.5); max-height: 280px; overflow-y: auto; font-weight: 400; color: var(--text); font-size: 15px; }
.combo-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.combo-list li[aria-selected=true], .combo-list li:hover { background: var(--primary-soft); }
.combo-list li.none { color: var(--sub); cursor: default; background: none; }

/* emergency alert */
button.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button.danger-fill:hover { background: #791F1F; }
.alert-banner { background: var(--danger); color: #fff; padding: 10px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-weight: 600; }
.alert-banner.notice { background: #854F0B; }
.alert-banner button { background: #fff; color: var(--danger); border-color: #fff; min-height: 32px; }
.dlg { background: var(--card); color: var(--text); border: 1px solid var(--line-strong); border-radius: 16px; padding: 24px; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.dlg::backdrop { background: rgba(0, 0, 0, 0.65); }
.dlg textarea, .qr-ed textarea { width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); }

/* live pictures of the displays */
.shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.shot { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.shot .img { aspect-ratio: 16 / 9; background: #1E1E1C; display: flex; align-items: center; justify-content: center; color: #9C9A92; font-size: 14px; text-align: center; padding: 0; }
.shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.shot .cap { padding: 10px 14px; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }

/* QR codes */
.thumb.qr { background: #fff; padding: 6px; }
.thumb.qr svg { width: 100%; height: 100%; }
.qr-ed { background: var(--bg); border-radius: 10px; padding: 16px; margin: 12px 0; }
.badge.qrb { background: #0F2E26; color: #5DCAA5; }

/* Media tab: how pictures and videos work */
details.help { margin: 14px 0 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
details.help summary { cursor: pointer; padding: 12px 16px; font-weight: 600; color: var(--primary-hover); }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 28px; padding: 0 16px 14px; font-size: 14px; }
.help-grid h4 { margin: 10px 0 6px; font-size: 14px; }
.help-grid ul { margin: 0 0 8px; padding-left: 18px; color: var(--sub); }
.help-grid li { margin: 3px 0; }
.help-grid b { color: var(--text); }
.help-table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; font-size: 13px; }
.help-table th { text-align: left; color: var(--sub); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.help-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); }

/* An unknown device claiming to be one of the displays */
.tv-line.stranger { align-items: center; gap: 10px; }
.tv-line.stranger button { flex: none; }

/* A Delete button after the first click: "Click again to delete" */
button.armed, button.armed:hover { background: var(--danger); border-color: var(--danger); color: #fff; width: auto; padding: 0 12px; }

/* ---- Modules: each part of the display display, with its settings behind a gear ---- */
.page-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.page-tools .sub { margin: 0; }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin: 10px 0 18px; }
.mod-card { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 10px 14px; }
.mod-icon { color: var(--primary-hover); display: flex; font-size: 22px; }
.mod-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mod-text .sub { margin: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The settings panel slides in from the right */
.dlg.drawer { margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(620px, 100vw); border-radius: 0; border-width: 0 0 0 1px; overflow-y: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.drawer .mod-body { margin-bottom: 16px; }
.mod-h { margin-top: 18px; }
/* Footer: version and the logs */
.app-foot { max-width: 1180px; margin: 0 auto; padding: 16px 20px 28px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.foot-link { min-height: 0; padding: 0; border: none; background: none; color: var(--primary-hover); font-size: 13px; }
.foot-link:hover { background: none; text-decoration: underline; }

/* ---- Media chains: linked items play one right after another ---- */
.chain { border: 1px solid var(--primary); border-radius: 14px; padding: 2px 10px 10px; margin-top: 10px; background: rgba(58, 134, 212, 0.06); }
.chain-head { display: flex; align-items: center; gap: 8px; padding: 6px 2px 0; color: var(--primary-hover); }
.chain-head .sub { margin: 0; }
.link-row { display: flex; justify-content: center; margin: 6px 0 -4px; }
.link-btn { min-height: 26px; padding: 0 12px; font-size: 12px; border-radius: 999px; color: var(--sub); background: transparent; border: 1px dashed var(--line-strong); }
.link-btn[aria-pressed=true] { color: var(--primary-hover); border: 1px solid var(--primary); background: var(--primary-soft); }

/* ---- Event descriptions ---- */
#evDesc { width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--input); color: var(--text); resize: vertical; }
.ev-row .desc { color: var(--sub); font-size: 13px; white-space: pre-line; }

/* Holidays, seasons and clock changes on the calendar, each kind in its own color */
.day .hol { font-size: 11px; font-weight: 600; line-height: 1.25; color: #C7A6E8; max-width: 100%; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }  /* up to two lines */
.day .hol.fed { color: var(--warn); }
.day .hol.season { color: #7FC8A9; }
.day .hol.clock { color: var(--primary-hover); }

/* Renaming a picture or video right in the Media list */
.m-name-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.m-name-row .m-name { min-width: 0; }
.m-name-row .rename { width: 30px; min-height: 30px; flex: none; color: var(--sub); }
.m-name-row .rename:hover { color: var(--text); }
.m-rename { width: 100%; font: inherit; font-weight: 600; padding: 4px 8px; border: 1px solid var(--primary); border-radius: var(--radius); background: var(--input); color: var(--text); }
.m-actions a.btn { text-decoration: none; }

/* The holiday checklist (Events settings) */
.hol-group { margin: 12px 0 4px; }
.hol-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.hol-head strong { margin-right: auto; }
.hol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 12px; }
.hol-item { margin: 2px 0; }
.hol-item .sub { margin: 0; font-size: 12px; }
.day .hol.observed { color: var(--warn); opacity: 0.75; font-weight: 400; }

/* Logs > Errors */
#logPick { overflow-x: auto; }
.err-table td { vertical-align: top; }
.err-table code { font-size: 12px; color: var(--sub); }
.err-table details { margin-top: 6px; }
.err-table summary { cursor: pointer; color: var(--primary-hover); font-size: 13px; }
.err-table pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--input); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; margin: 6px 0 0; max-height: 320px; overflow: auto; }

/* Room metadata stays together when the room editor is narrow. */
.room-grid .room-row { display: grid; grid-template-columns: 1fr 1fr 36px; align-items: end; }
.room-grid .r-name { grid-column: 1 / 4; width: 100%; }
.room-grid .field { margin: 0; min-width: 0; font-size: 12px; }
.room-grid input { width: 100%; min-width: 0; }
@media (max-width: 600px) {
  .cal-grid .day { min-width: 0; padding: 4px; overflow: hidden; }
  .day .count { max-width: 100%; padding: 1px 4px; font-size: 11px; }
  .day .count-label { display: none; }
  .day .hol { display: block; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

.door-look-dialog { width: min(960px, calc(100vw - 24px)); max-width: 960px; }
.door-look-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.door-look-preview { width: min(100%, 290px); position: relative; overflow: hidden; margin: auto; }
.door-look-preview iframe { border: 0; transform-origin: top left; position: absolute; top: 0; left: 0; }
#doorLookOpen { margin-bottom: 12px; }
#doorLookColors input { width: 100%; min-height: 42px; }
#doorLookCustom { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
@media (max-width: 600px) {
  .door-look-grid { grid-template-columns: minmax(0, 1fr); }
  .door-look-preview { width: min(100%, 230px); }
}

/* accounts and roles */
.whoami { margin-right: 8px; }
.view-only-banner { background: var(--card); border-bottom: 1px solid var(--line-strong); padding: 8px 20px; font-weight: 600; }
.accounts-list { display: grid; gap: 8px; margin: 12px 0 16px; }
.account-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 640px) { .account-row { grid-template-columns: 1fr; } }

/* catalog CSV import */
.import-result { margin: 12px 0; }
.import-errors { max-height: 240px; overflow: auto; margin: 6px 0; padding-left: 20px; font-size: 14px; }
/* ---- Designs: the list and the free-form designer ---- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.design-list { display: grid; gap: 0; margin-top: 8px; }
.design-row { display: flex; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.design-row:first-child { border-top: 0; }
.design-thumb { position: relative; width: 96px; max-height: 96px; flex: none; background: #0F0F0E; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.design-thumb span { position: absolute; background: var(--primary-soft); border: 1px solid var(--primary); border-radius: 2px; }
.design-detail { flex: 1; min-width: 0; }
.design-name { font-weight: 600; overflow-wrap: anywhere; }
.design-meta { color: var(--sub); font-size: 13px; overflow-wrap: anywhere; }
.design-actions { justify-content: flex-end; }
@media (max-width: 700px) { .design-row { flex-wrap: wrap; } .design-actions { width: 100%; justify-content: flex-start; } }
/* The editor uses the room beside the page column on wide windows. */
.design-editor { margin-inline: calc((100% - min(1500px, 100vw - 40px)) / 2); }
.designer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.designer-name { flex: 1 1 220px; min-width: 0; }
.designer-name input { width: 100%; font-size: 18px; font-weight: 600; }
.designer-name input[readonly] { border-color: transparent; background: transparent; padding-left: 0; }
.designer-dirty { margin: 0; font-size: 13px; }
.designer-actions { margin-left: auto; }
.designer { display: grid; grid-template-columns: 210px minmax(0, 1fr) 270px; gap: 16px; align-items: start; }
.designer-palette h3, .designer-panel h3 { margin-bottom: 4px; }
.designer-palette .hint { margin: 0 0 10px; }
.designer-modules { display: grid; gap: 6px; }
.designer-module { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 0; padding: 8px 10px;
  text-align: left; white-space: normal; touch-action: pan-y; cursor: grab; }  /* a vertical swipe still scrolls */
.designer-module span { color: var(--sub); font-size: 12px; line-height: 1.35; }
.designer-module:disabled { cursor: default; }
.designer-main { min-width: 0; }
.designer-canvas-wrap { position: relative; display: flex; justify-content: center; }
.designer-canvas { position: relative; flex: none; background-color: #0F0F0E; border: 1px solid var(--line-strong); touch-action: none;
  background-image: linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: calc(100% / 12) calc(100% / 12); user-select: none; -webkit-user-select: none; }
.designer-canvas:focus { outline: none; }
.designer-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; padding: 16px;
  text-align: center; color: var(--sub); }
.dz-zone { position: absolute; display: flex; align-items: flex-start; justify-content: flex-start; padding: 4px 6px; overflow: visible;
  background: rgba(58, 134, 212, 0.18); border: 1px solid var(--primary); border-radius: 3px; color: var(--text); cursor: move; }
.read-only .dz-zone { cursor: default; }
.dz-zone:focus-visible { outline: 2px solid var(--text); outline-offset: -3px; }
.dz-zone.selected { background: rgba(58, 134, 212, 0.32); border: 2px solid var(--primary-hover); z-index: 2; }
.dz-zone.warn { border-color: var(--warn); }
.dz-zone.invalid { background: rgba(226, 101, 101, 0.3); border: 2px dashed var(--danger); }
.dz-label { display: flex; flex-direction: column; min-width: 0; max-height: 100%; overflow: hidden; font-size: 13px; line-height: 1.3; pointer-events: none; }
.dz-label > * { flex: none; }
.dz-label strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dz-size { color: var(--sub); font-size: 12px; }
.dz-badge { position: absolute; top: 4px; right: 4px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--warn); color: #000; font-size: 12px; font-weight: 600; text-align: center; line-height: 20px; pointer-events: none; }
.dz-handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--primary); border-radius: 3px; z-index: 3; }
.dz-handle::before { content: ""; position: absolute; inset: -10px; }  /* a finger-sized target */
.dz-n, .dz-s { left: calc(50% - 7px); cursor: ns-resize; }
.dz-e, .dz-w { top: calc(50% - 7px); cursor: ew-resize; }
.dz-n, .dz-ne, .dz-nw { top: -8px; }
.dz-s, .dz-se, .dz-sw { bottom: -8px; }
.dz-e, .dz-ne, .dz-se { right: -8px; }
.dz-w, .dz-nw, .dz-sw { left: -8px; }
.dz-ne, .dz-sw { cursor: nesw-resize; }
.dz-nw, .dz-se { cursor: nwse-resize; }
.dz-min { position: absolute; border: 2px dashed var(--warn); pointer-events: none; }
.dz-drop { position: absolute; border: 2px dashed var(--primary-hover); background: rgba(58, 134, 212, 0.12); pointer-events: none;
  display: flex; align-items: center; justify-content: center; color: var(--danger); font-weight: 600; }
.dz-drop.none { border-color: var(--danger); background: rgba(226, 101, 101, 0.15); }
.designer-tip { position: absolute; transform: translateY(-100%); margin-top: -4px; padding: 2px 8px; border-radius: 6px; background: #000;
  color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none; z-index: 4; }
.designer-ghost { position: fixed; left: 0; top: 0; z-index: 30; padding: 6px 10px; border-radius: 8px; background: var(--primary);
  color: #fff; font-size: 13px; font-weight: 600; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }
.designer-side { display: grid; gap: 12px; min-width: 0; }
.designer-panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-width: 0; }
.designer-panel .sub { margin-bottom: 6px; }
.designer-fields { gap: 0 10px; margin-top: 10px; }
.designer-fields .field { margin-bottom: 8px; }
.designer-fields input { width: 100%; }
.design-warnings { margin: 0 0 6px; padding-left: 18px; }
.design-warnings li { margin: 4px 0; }
.link-btn-plain { min-height: 0; padding: 0; border: none; background: none; color: var(--primary-hover); font-weight: 600; text-decoration: underline; }
.link-btn-plain:hover { background: none; }
.designer-lower { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; margin-top: 18px; align-items: start; }
.designer-preview { margin-top: 10px; }
.designer-preview.portrait { max-width: 420px; margin-inline: auto; }
.designer-preview.empty iframe { visibility: hidden; }
.designer-preview.empty::after { content: "Add a module to see the preview."; position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; color: var(--sub); }
.designer-history #designHistory { max-height: 420px; overflow-y: auto; }
.design-version { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.design-version:first-child { border-top: 0; }
.design-version .hint { margin: 0; }
.design-zone-fields { grid-template-columns: minmax(0, 1fr); }
#designNewForm input, #designNewForm select { width: 100%; }
@media (max-width: 600px) { #designNewForm .grid2 { grid-template-columns: 1fr; } }
@media (min-width: 1101px) { .designer-modules { max-height: min(70vh, 760px); overflow-y: auto; padding-right: 4px; } }
@media (max-width: 1100px) {
  .designer { grid-template-columns: minmax(0, 1fr) 260px; }
  .designer-palette { grid-column: 1 / -1; }
  .designer-modules { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
@media (max-width: 760px) {
  .designer, .designer-lower { grid-template-columns: minmax(0, 1fr); }
  .designer-main { order: -1; }
  .designer-actions { margin-left: 0; }
}

/* A way back from a page reached through another one (Settings > Designs) */
.back-link { padding: 0; min-height: 32px; margin-bottom: 8px; color: var(--sub); }
.back-link:hover { color: var(--text); background: none; }
