/* URXSignage control panel. Plain CSS, no build step. */
:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1d242d;
  --line: #2a323d;
  --text: #e8ecf1;
  --muted: #93a0b0;
  --accent: #ffb020;
  --accent-ink: #1a1200;
  --danger: #ff5d5d;
  --ok: #39c686;
  --radius: 12px;
  --tabbar: 0px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- buttons and fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #3b4654; }
.btn:focus-visible, .icon-btn:focus-visible, .thumb:focus-visible, input:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn svg, .icon-btn svg, .tab svg { width: 18px; height: 18px; flex: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); }

label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; }
input[type=text], input[type=password], input[type=url] {
  width: 100%; min-height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit;
}
.field { margin-bottom: 14px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 0 0 10px; }

/* ---- shell */
.shell { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 22px;
  padding: 0 24px; height: 58px;
  background: rgba(14, 17, 22, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand img { width: 28px; height: 28px; }
.brand b { color: var(--accent); font-weight: 700; }
.tabs { display: flex; gap: 4px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 600;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: var(--text); background: var(--panel-2); }
.tab.active svg { color: var(--accent); }
.main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px; }
.footer {
  padding: 18px 24px calc(18px + var(--tabbar));
  text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .04em;
}
.footer b { color: var(--text); font-weight: 600; }
.footer a { color: inherit; }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .spacer { flex: 1; }
.page-head .count { color: var(--muted); font-size: 14px; }

/* ---- disk bar */
.disk { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; }
.disk-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.disk-row b { color: var(--text); font-weight: 600; }
.bar { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .4s; }
.bar.warn > i { background: var(--danger); }

/* ---- uploads in progress */
.uploads { display: grid; gap: 8px; margin-bottom: 18px; }
.upload {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px;
}
.upload .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.upload .state { font-size: 13px; color: var(--muted); }
.upload .bar { grid-column: 1 / -1; height: 6px; }
.upload.error { border-color: var(--danger); }
.upload.error .state { color: var(--danger); }
.upload.done .bar > i { background: var(--ok); }

/* ---- library grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.thumb {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 10; padding: 0; border: 0;
  background: #0a0d11 center / contain no-repeat; cursor: pointer; color: var(--muted);
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb .placeholder { position: absolute; inset: 0; display: grid; place-items: center; }
.thumb .placeholder svg { width: 34px; height: 34px; opacity: .5; }
.badge {
  position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .72); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .03em;
}
.badge.yt { background: #e62117; }
.badge.right { left: auto; right: 8px; }
.working {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px;
  padding: 12px; background: linear-gradient(transparent 20%, rgba(0, 0, 0, .82));
  color: #fff; font-size: 13px; font-weight: 600; text-align: left;
}
.working .bar { height: 6px; background: rgba(255, 255, 255, .22); }
.working.failed { color: #ffb3b3; }
.card-body { display: flex; align-items: flex-start; gap: 4px; padding: 10px 6px 10px 12px; }
.card-text { flex: 1; min-width: 0; }
.card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty {
  border: 2px dashed var(--line); border-radius: 16px; padding: 56px 20px; text-align: center; color: var(--muted);
}
.empty svg { width: 44px; height: 44px; color: var(--accent); margin-bottom: 10px; }
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

.dropzone {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(14, 17, 22, .86); border: 3px dashed var(--accent);
  font-size: 22px; font-weight: 700; color: var(--accent); pointer-events: none;
}

/* ---- dialogs */
dialog {
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text);
  padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(0, 0, 0, .66); }
dialog h2 { font-size: 18px; margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
dialog.preview { width: min(1100px, calc(100vw - 24px)); padding: 14px; }
.preview-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.preview-head .title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage { background: #000; border-radius: 10px; overflow: hidden; display: grid; place-items: center; }
.stage img, .stage video { display: block; max-width: 100%; max-height: calc(100vh - 150px); }
.stage iframe { display: block; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 150px); border: 0; }

/* ---- accounts */
.who { margin-left: auto; color: var(--muted); font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice { border: 1px solid var(--danger); background: rgba(255, 93, 93, .1); color: #ffd0d0; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; letter-spacing: .03em; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.active { background: rgba(57, 198, 134, .16); color: var(--ok); }
.pill.expired, .pill.suspended, .pill.no_plan { background: rgba(255, 93, 93, .16); color: var(--danger); }
.pill.admin { background: rgba(255, 176, 32, .16); color: var(--accent); }
.rows { display: grid; gap: 10px; margin-top: 14px; }
.row {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
}
.row.plan { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr) auto; }
.row-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-strong { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-cell { min-width: 0; }
.row-cell .bar { height: 5px; margin: 5px 0; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
select, textarea, input[type=date], input[type=number] {
  width: 100%; min-height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit;
}
textarea { padding: 10px 12px; resize: vertical; }
select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
dialog.wide { width: min(520px, calc(100vw - 32px)); }
.with-button { display: flex; gap: 8px; }
.with-button input { flex: 1; min-width: 0; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

/* ---- settings */
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; max-width: 460px; margin-bottom: 18px; }

/* ---- login */
.login { min-height: 100%; display: flex; flex-direction: column; }
.login-main { flex: 1; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.login-card .brand { font-size: 22px; margin-bottom: 4px; }
.login-card .brand img { width: 36px; height: 36px; }
.login-card .btn { width: 100%; }

/* ---- toasts */
#toasts { position: fixed; z-index: 90; left: 50%; bottom: calc(20px + var(--tabbar)); transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: #232b35; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.toast.error { border-color: var(--danger); }

/* ---- phones: bottom tab bar */
@media (max-width: 720px) {
  :root { --tabbar: calc(60px + env(safe-area-inset-bottom)); }
  /* no backdrop-filter here: it would make the top bar the anchor of the fixed tab bar inside it */
  .topbar { padding: 0 16px; height: 52px; backdrop-filter: none; background: var(--bg); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: var(--tabbar); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(22, 27, 34, .97); border-top: 1px solid var(--line);
    justify-content: space-around; gap: 0;
  }
  .tab { flex: 1; flex-direction: column; gap: 3px; height: 60px; padding: 0; border-radius: 0; font-size: 11px; justify-content: center; }
  .tab.active { background: transparent; color: var(--accent); }
  .tab svg { width: 22px; height: 22px; }
  .main { padding: 16px; }
  .who { display: none; }
  .row, .row.plan { grid-template-columns: 1fr; gap: 10px; }
  .row-actions { justify-content: flex-start; }
  .row-actions .btn { flex: 1; }
  .page-head h1 { width: 100%; }
  .page-head .spacer { display: none; }
  .page-head .btn { flex: 1; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-body { padding: 8px 2px 8px 10px; }
  .icon-btn { width: 32px; height: 36px; }
  dialog { padding: 18px; }
}

/* ================================================================ stage 2: playlists, layouts, designer */
.z-playlist { --zc: #3b82f6; }
.z-media { --zc: #10b981; }
.z-ticker { --zc: #f59e0b; }
.z-clock { --zc: #a855f7; }
.z-web { --zc: #ec4899; }

a.row.link, a.layout-card { color: inherit; text-decoration: none; }
a.row.link:hover, a.layout-card:hover { border-color: #3b4654; }
a.row.link:focus-visible, a.layout-card:focus-visible, .pick:focus-visible, .template:focus-visible, .zone-pick:focus-visible, .grip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row.pl { grid-template-columns: auto minmax(0, 1fr); }
.strip { display: flex; gap: 4px; width: 236px; height: 44px; }
.strip img { width: 56px; height: 44px; object-fit: cover; border-radius: 6px; background: #0a0d11; }
.strip-empty { display: grid; place-items: center; width: 56px; height: 44px; border-radius: 6px; background: var(--panel-2); color: var(--muted); }
.strip-empty svg { width: 20px; height: 20px; }

.editor-head { flex-wrap: nowrap; }
.btn.icon-only { padding: 0; width: 40px; flex: none; }
.title-input { flex: 1 1 220px; min-width: 0; max-width: 420px; font-size: 20px !important; font-weight: 700; background: transparent !important; border-color: transparent !important; padding: 0 8px !important; }
.title-input:hover, .title-input:focus { border-color: var(--line) !important; background: var(--bg) !important; }
.save-state { color: var(--muted); font-size: 13px; white-space: nowrap; }
.save-state.error { color: var(--danger); white-space: normal; }

/* playlist items */
.pl-items { display: grid; gap: 8px; margin-top: 12px; }
.pl-item {
  display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px 8px 4px;
}
.pl-item.dragging { border-color: var(--accent); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); position: relative; z-index: 2; }
.grip { display: grid; place-items: center; width: 32px; height: 48px; border: 0; background: transparent; color: var(--muted); cursor: grab; touch-action: none; border-radius: 8px; }
.grip:hover { color: var(--text); background: var(--panel-2); }
.grip svg { width: 20px; height: 20px; }
.dragging .grip { cursor: grabbing; }
.pl-index { color: var(--muted); font-size: 13px; width: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.pl-thumb { position: relative; width: 84px; height: 52px; border-radius: 8px; overflow: hidden; background: #0a0d11; flex: none; }
.pl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-thumb .badge { left: 4px; top: 4px; font-size: 9px; padding: 1px 5px; }
.pl-name { min-width: 0; }
.pl-controls { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.pl-buttons { display: flex; }
label.mini { margin: 0; }
label.mini > span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
label.mini select, label.mini input { min-height: 36px; padding: 0 8px; width: auto; }
label.mini input.num { width: 78px; }
label.check { display: inline-flex; align-items: center; gap: 7px; margin: 0; min-height: 36px; font-size: 14px; color: var(--text); cursor: pointer; }
label.check.block { display: flex; margin-bottom: 6px; position: static; border-top: 0; overflow: visible; }   /* not the schedule's .block */
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* media picker */
dialog.picker { width: min(860px, calc(100vw - 24px)); }
dialog.picker[open] { display: flex; flex-direction: column; max-height: min(86vh, 860px); overflow: hidden; }
dialog.picker h2 { flex: none; }
.pick-tools { flex: none; display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.pick-tools[hidden] { display: none; }
.pick-tools input[type=search] { flex: 1 1 200px; min-height: 38px; }
.pick-kinds { display: flex; gap: 6px; }
.pick-kinds .chip { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.pick-kinds .chip.on { background: var(--accent); border-color: var(--accent); color: #111; }
.pick-grid {
  flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; align-content: start;
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 3px 3px 8px;
}
.pick-grid > p { grid-column: 1 / -1; }
.pick { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; border-radius: 10px; background: transparent; padding: 0; cursor: pointer; color: var(--text); text-align: left; font: inherit; }
.pick[hidden] { display: none; }
.pick-pic { position: relative; display: block; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #0a0d11; outline: 2px solid var(--line); outline-offset: -2px; }
.pick-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pick-pic .badge { left: 6px; top: 6px; font-size: 10px; padding: 1px 6px; }
.pick-time { position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, .72); color: #fff; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pick-name { font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; word-break: break-word; padding: 0 2px; }
.pick.on .pick-pic { outline: 3px solid var(--accent); outline-offset: -3px; }
.pick.on .pick-pic img { opacity: .82; }
.pick::after {
  content: ""; position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border-radius: 50%; box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, .85); background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity .12s;
}
@media (hover: hover) { .pick:not([disabled]):hover::after { opacity: 1; } }
.pick.on::after {
  opacity: 1; border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.pick[disabled] { opacity: .45; cursor: default; }
.pick:focus-visible { outline: none; }
.pick:focus-visible .pick-pic { outline: 3px solid var(--ring); }

/* layouts list */
.layout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-top: 14px; }
.layout-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: block; }
.layout-pic { display: grid; place-items: center; height: 170px; background: #0a0d11; padding: 14px; }
.layout-info { padding: 10px 12px; }
.schematic { position: relative; background: #000; border: 1px solid #3b4654; border-radius: 3px; overflow: hidden; }
.schematic.landscape { width: 100%; max-width: 240px; aspect-ratio: 16 / 9; }
.schematic.portrait { height: 100%; max-height: 140px; aspect-ratio: 9 / 16; }
.schematic i { position: absolute; box-sizing: border-box; background: color-mix(in srgb, var(--zc) 45%, #000); border: 1px solid var(--zc); }
.pill.st-live { background: rgba(57, 198, 134, .16); color: var(--ok); }
.pill.st-changed { background: rgba(255, 176, 32, .16); color: var(--accent); }
.templates { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.templates.small { grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; }
.template { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border: 2px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.template .schematic.landscape { width: 100%; }
.template .schematic.portrait { height: 64px; }
.template.on { border-color: var(--accent); }
.template:hover { border-color: #3b4654; }
.template.on:hover { border-color: var(--accent); }

/* designer */
.designer { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.canvas-wrap { min-width: 0; }
.canvas { position: relative; background: #000; border: 1px solid #3b4654; border-radius: 4px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; margin: 0 auto 10px; }
.canvas.landscape { width: 100%; aspect-ratio: 16 / 9; }
.canvas.portrait { height: min(72vh, 760px); aspect-ratio: 9 / 16; max-width: 100%; }
.canvas .zone {
  position: absolute; box-sizing: border-box; border: 2px solid var(--zc); background: color-mix(in srgb, var(--zc) 30%, #05070a) center / cover no-repeat;
  color: #fff; cursor: move; overflow: visible; touch-action: none;
}
.canvas .zone:focus { outline: none; }
.canvas .zone.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--zc); z-index: 5; }
.canvas .zone.moving { opacity: .85; }
/* a ticker's text on the canvas, sized in % of its zone's height like on the screen */
.zone-text { position: absolute; inset: 0; overflow: hidden; container-type: size; display: flex; align-items: center; justify-content: flex-start; pointer-events: none; }
.zone-text span { display: block; padding-left: 2%; white-space: nowrap; line-height: 1.18; }
.zone-text.still { justify-content: center; }
.zone-band { position: absolute; left: 0; right: 0; pointer-events: none; }
.canvas .zone.has-text .zone-label { opacity: 0; transition: opacity .15s; }       /* the text itself says what the strip is */
.canvas .zone.has-text:hover .zone-label { opacity: 1; }
.zone-text.still span { padding: 0; max-width: 96%; white-space: normal; text-align: center; overflow-wrap: break-word; }
.zone-label { position: absolute; left: 0; top: 0; max-width: 100%; box-sizing: border-box; padding: 3px 8px; background: var(--zc); color: #fff; font-size: 12px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.zone-label b { margin-right: 6px; }
.zone-label span { opacity: .92; }
.handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--zc); border-radius: 50%; box-sizing: border-box; touch-action: none; z-index: 6; }
.handle::after { content: ""; position: absolute; inset: -10px; }      /* a bigger target for fingers */
.handle.n { left: 50%; top: 0; transform: translate(-50%, -50%); cursor: ns-resize; }
.handle.s { left: 50%; bottom: 0; transform: translate(-50%, 50%); cursor: ns-resize; }
.handle.e { right: 0; top: 50%; transform: translate(50%, -50%); cursor: ew-resize; }
.handle.w { left: 0; top: 50%; transform: translate(-50%, -50%); cursor: ew-resize; }
.handle.ne { right: 0; top: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.handle.sw { left: 0; bottom: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.handle.nw { left: 0; top: 0; transform: translate(-50%, -50%); cursor: nwse-resize; }
.handle.se { right: 0; bottom: 0; transform: translate(50%, 50%); cursor: nwse-resize; }
.guide { position: absolute; background: var(--accent); z-index: 8; pointer-events: none; }
.guide.v { top: 0; bottom: 0; width: 1px; }
.guide.h { left: 0; right: 0; height: 1px; }

.side { display: grid; gap: 14px; }
.side-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.side-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.side-title h2 { margin: 0; }
.side-label { margin-top: 12px; }
.geo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.geo label.mini input { width: 100%; padding: 0 6px; }
.color-row { display: flex; align-items: center; gap: 12px; }
input[type=color] { width: 56px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.zone-list { display: grid; gap: 4px; }
.zone-pick { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; min-width: 0; }
.zone-pick:hover { background: var(--panel-2); }
.zone-pick.on { border-color: var(--accent); background: var(--panel-2); }
.zone-pick span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.zone-pick b { white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--zc); flex: none; }
.btn.small svg { width: 14px; height: 14px; }

/* preview of a layout in the player */
dialog.player-preview.landscape { width: min(1200px, calc(100vw - 24px)); }
dialog.player-preview.portrait { width: auto; max-width: calc(100vw - 24px); }
.frame-box iframe { display: block; border: 0; background: #000; }
.landscape .frame-box iframe { width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 140px); }
.portrait .frame-box iframe { height: min(calc(100vh - 140px), 900px); aspect-ratio: 9 / 16; max-width: 100%; }

@media (max-width: 980px) {
  .designer { grid-template-columns: 1fr; }
  .pl-item { grid-template-columns: auto auto auto minmax(0, 1fr) auto; }
  .pl-controls { grid-column: 1 / -1; padding-left: 8px; }
  .pl-buttons { grid-row: 1; grid-column: 5; }
}
@media (max-width: 720px) {
  .tabs { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 1 0 62px; }
  .editor-head { flex-wrap: wrap; }
  .editor-head .title-input { flex: 1 1 calc(100% - 60px); max-width: none; }
  .editor-head .save-state { order: 5; width: 100%; }
  .strip { width: 116px; }
  .strip img:nth-child(n+3) { display: none; }
  .pl-index { display: none; }
  .pl-thumb { width: 64px; height: 44px; }
  .templates { grid-template-columns: repeat(2, 1fr); }
  .layout-grid { grid-template-columns: 1fr; }
  .canvas.portrait { height: min(64vh, 560px); }
}

/* ================================================================ stage 3: schedules */
.subtabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.subtab { padding: 6px 16px; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 600; }
.subtab:hover { color: var(--text); }
.subtab.active { background: var(--panel-2); color: var(--text); }
.subtab:focus-visible, .day:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row.sched { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }

.sched-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.sched-edit, .sched-view { display: grid; gap: 14px; min-width: 0; }
.slots { display: grid; gap: 10px; }
.slot { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 10px 4px; }
.slot.off { opacity: .55; }
.slot-rank { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.rank { color: var(--muted); font-size: 13px; font-weight: 700; }
.slot-body { display: grid; gap: 8px; min-width: 0; }
.slot-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.slot-line select { flex: 1 1 160px; min-width: 0; min-height: 38px; }
.slot-line input[type=time], .pv-row input[type=time] { width: auto; min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; flex: none; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.day { min-width: 42px; height: 34px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.day.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.presets { display: flex; gap: 10px; flex-wrap: wrap; }
.link-btn { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 6px 0; text-decoration: underline; }
.span-note { align-self: flex-end; padding-bottom: 8px; }
.slot-problem { color: var(--accent); font-size: 13px; margin: 0; }
.slot-problem:empty { display: none; }

.now-playing { margin: 0 0 12px; }
.week { display: grid; grid-template-columns: 44px repeat(7, minmax(0, 1fr)); gap: 4px; }
.week-hours { position: relative; margin-top: 24px; height: 420px; font-size: 11px; color: var(--muted); }
.week-hours span { position: absolute; right: 6px; transform: translateY(-50%); }
.week-label { height: 20px; margin-bottom: 4px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.week-day.today .week-label { color: var(--accent); }
.week-track { position: relative; height: 420px; background: #0a0d11; border-radius: 6px; overflow: hidden; }
.block { position: absolute; left: 0; right: 0; box-sizing: border-box; border-top: 1px solid rgba(0, 0, 0, .45); overflow: hidden; }
.block.default { opacity: .55; }
.block.nothing { background: repeating-linear-gradient(135deg, #12161c, #12161c 6px, #0a0d11 6px, #0a0d11 12px); }
.block span { display: block; padding: 3px 4px; font-size: 10px; line-height: 1.2; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .6); z-index: 2; }
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.pv-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pv-row select { width: auto; flex: 1 1 140px; }

@media (max-width: 980px) {
  .sched-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .week { grid-template-columns: 34px repeat(7, minmax(0, 1fr)); gap: 2px; }
  .week-hours span { right: 3px; font-size: 10px; }
  .week-track, .week-hours { height: 340px; }
  .block span { display: none; }
  .day { min-width: 38px; }
  .row.sched { grid-template-columns: 1fr; }
}

/* ================================================================ stage 4: screens */
.screen-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; margin-bottom: 18px; }
.screen-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.screen-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.screen-title { flex: 1; min-width: 0; }
.dot-status { width: 12px; height: 12px; border-radius: 50%; background: #5b6675; flex: none; }
.screen-card.online .dot-status { background: var(--ok); box-shadow: 0 0 0 4px rgba(57, 198, 134, .18); }
.screen-facts { grid-template-columns: 84px minmax(0, 1fr); gap: 5px 12px; font-size: 14px; }
.screen-facts dd { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.screen-buttons.second { padding-top: 10px; border-top: 1px solid var(--line); }
.group-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.group-row .row-main { flex: 1 1 160px; min-width: 0; }
#groups, #app-box { margin-bottom: 18px; }
.app-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.qr { border-radius: 8px; background: #fff; flex: none; }
.app-row a { overflow-wrap: anywhere; }
.code-input { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 26px !important; letter-spacing: .3em; text-transform: uppercase; text-align: center; min-height: 56px !important; }
@media (max-width: 720px) {
  .screen-list { grid-template-columns: 1fr; }
  .screen-buttons .btn { flex: 1 1 auto; }
}

/* ================================================================ designer: grid and right-click menu */
.grid-line { position: absolute; pointer-events: none; z-index: 1; opacity: .5; }
.grid-line.v { left: 50%; top: 0; bottom: 0; border-left: 1px dashed #fff; }
.grid-line.h { top: 50%; left: 0; right: 0; border-top: 1px dashed #fff; }
.ctx-menu { position: fixed; z-index: 80; min-width: 180px; padding: 6px; background: #232b35; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 50px rgba(0, 0, 0, .6); display: grid; gap: 2px; }
.ctx-item { display: block; width: 100%; min-height: 36px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.ctx-item:hover, .ctx-item:focus-visible { background: var(--panel-2); outline: none; }
.ctx-item.danger { color: var(--danger); }
.templates { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }

/* ================================================================ screens: quick choice and mute */
.screen-quick { display: flex; gap: 10px; align-items: flex-end; }
label.mini.grow { flex: 1; min-width: 0; }
label.mini.grow select { width: 100%; min-height: 38px; }
.btn.sound { min-height: 38px; }
.btn.sound.off { border-color: var(--danger); color: var(--danger); }

/* ================================================================ events and templates */
.section-head { margin-top: 28px; }
.section-head h2 { font-size: 18px; margin: 0; }
.tpl { position: relative; width: 100%; background: #000; border-radius: 8px; overflow: hidden; user-select: none; -webkit-user-select: none; }
.tpl img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tpl-box { position: absolute; box-sizing: border-box; }
.tpl-box.editing { outline: 2px dashed #fff; outline-offset: -2px; background: rgba(255, 255, 255, .12); cursor: move; touch-action: none; }
.tpl-handle { position: absolute; right: 2px; bottom: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-sizing: border-box; cursor: nwse-resize; touch-action: none; }
.tpl-handle::after { content: ""; position: absolute; inset: -12px; }
.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); padding: 10px; display: grid; gap: 10px; }
.tpl-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row.event { grid-template-columns: 200px minmax(0, 1fr) auto; }
.row.event.over { opacity: .6; }
.event-thumb { width: 200px; }
dialog.template-editor { width: min(1040px, calc(100vw - 24px)); }
.template-edit { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.template-stage { min-width: 0; margin-bottom: 10px; }
.tpl-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 190px; overflow: auto; padding: 3px; }
.tpl-pick { padding: 0; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; background: #000; cursor: pointer; aspect-ratio: 16 / 9; }
.tpl-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tpl-pick.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.tpl-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.screen-ticks { display: flex; flex-wrap: wrap; gap: 4px 16px; padding-left: 4px; }
@media (max-width: 820px) {
  .template-edit { grid-template-columns: 1fr; }
  .row.event { grid-template-columns: 1fr; }
  .event-thumb { width: 100%; max-width: 320px; }
}

/* ---- Home: the everyday controls, large enough for a thumb */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 26px; }
.tile { display: grid; gap: 4px; justify-items: start; text-align: left; padding: 16px; border-radius: var(--radius); background: var(--panel);
  border: 1px solid var(--line); color: inherit; text-decoration: none; font: inherit; cursor: pointer; }
.tile:hover, .tile:focus-visible { border-color: var(--accent); }
.tile svg { width: 26px; height: 26px; color: var(--accent); margin-bottom: 6px; }
.tile strong { font-size: 16px; }
.tile span { color: var(--muted); font-size: 13px; }
.sub-head { margin-bottom: 12px; }
.sub-head h2 { margin: 0; font-size: 18px; }
.warn-text { color: var(--danger) !important; }
.home-card .row-name { font-size: 18px; }
.home-card .quick-select { width: 100%; min-height: 46px; font-size: 16px; }
.home-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.home-buttons .btn { min-height: 46px; justify-content: center; padding: 0 8px; }
@media (max-width: 520px) { .home-buttons { grid-template-columns: repeat(2, 1fr); } }
/* installed as an app: no browser bars, so keep clear of the phone's own bars */
@media (display-mode: standalone) { .topbar { padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); } }
@media (max-width: 720px) { .tabs { overflow-x: auto; justify-content: flex-start; scrollbar-width: none; } .tab { flex: 1 0 64px; } }

/* ---- More page, Play on screen, the guide */
.row-with-action { display: flex; gap: 10px; align-items: stretch; }
.row-with-action > .row { flex: 1; min-width: 0; }
.row-with-action > .btn { align-self: center; flex: none; }
.btn.play-on svg, .icon-btn.play-on svg { color: var(--accent); }
.choice-list { display: grid; gap: 8px; margin: 12px 0; }
.btn.choice { justify-content: flex-start; min-height: 48px; }
.dot-status.on { background: var(--ok); }
.starter { background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 18px; margin-bottom: 26px; display: grid; gap: 12px; }
.starter h2 { margin: 0; font-size: 18px; }
.step { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.step-no { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--panel-2); border: 1px solid var(--line); flex: none; }
.step.done .step-no { background: var(--ok); border-color: var(--ok); color: #06130d; }
.step.done .step-text { opacity: .6; }
.step-text { flex: 1 1 220px; display: grid; }
.step-text span { color: var(--muted); font-size: 13px; }
@media (max-width: 720px) { .row-with-action { flex-direction: column; } .row-with-action > .btn { align-self: stretch; } }

/* ---- polish: a little larger and calmer everywhere */
body { font-size: 16px; }
.btn { min-height: 42px; font-weight: 600; }
.box, .screen-card, .tile, .card { box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.main { animation: page-in .16s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .main { animation: none; } }

/* ---- light colours (Settings > Appearance) */
:root[data-theme=light] {
  --bg: #f4f6f9; --panel: #ffffff; --panel-2: #eef1f5; --line: #d5dbe3; --text: #18202b; --muted: #5d6877;
  --accent: #c97a00; --accent-ink: #ffffff; --danger: #c62828; --ok: #128a55; color-scheme: light;
}
:root[data-theme=light] .notice { color: #8e1c1c; background: rgba(198, 40, 40, .08); }
:root[data-theme=light] .toast, :root[data-theme=light] .ctx-menu { background: #ffffff; box-shadow: 0 10px 40px rgba(20, 30, 45, .18); }
@media (max-width: 720px) { :root[data-theme=light] .tabs { background: rgba(255, 255, 255, .97); } }
:root[data-theme=light] .topbar { background: var(--bg); }
:root[data-theme=light] .box, :root[data-theme=light] .screen-card, :root[data-theme=light] .tile, :root[data-theme=light] .card { box-shadow: 0 1px 2px rgba(20, 30, 45, .08); }
:root[data-theme=light] a.row.link:hover, :root[data-theme=light] a.layout-card:hover, :root[data-theme=light] .template:hover { border-color: #aab4c1; }
:root[data-theme=light] dialog { box-shadow: 0 24px 80px rgba(20, 30, 45, .3); }
:root[data-theme=light] .working.failed { color: #ffd0d0; }
:root[data-theme=light] .step.done .step-no { color: #fff; }

/* Settings: what a screen shows when nothing plays (always dark: it is a picture of the TV) */
.wallpaper-preview { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; margin: 4px 0 8px; border: 1px solid var(--line); container-type: inline-size; }
.wallpaper-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wallpaper-preview .mark { position: absolute; right: 3cqw; bottom: 3cqw; padding: 1cqw 1.6cqw; border-radius: 1cqw; background: rgba(0, 0, 0, .45); color: #e6eaf0; font-size: max(9px, 2cqw); text-align: right; line-height: 1.4; }
.wallpaper-preview .mark b { color: #fff; }
.wallpaper-preview.logo { display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, #1b2230, #0b0e13 70%); }
.wallpaper-preview .logo-mark { display: grid; justify-items: center; gap: 1.4cqw; color: #fff; }
.wallpaper-preview .logo-mark img { width: 11cqw; height: 11cqw; }
.wallpaper-preview .logo-mark strong { font-size: 5.6cqw; letter-spacing: -0.02em; line-height: 1; }
.wallpaper-preview .logo-mark strong b { color: #ffb020; }
.wallpaper-preview .logo-mark span { font-size: max(9px, 1.9cqw); color: #b9c2cf; letter-spacing: .08em; padding-top: 1.4cqw; border-top: 1px solid rgba(255, 255, 255, .14); min-width: 19cqw; text-align: center; }

/* Designer: "Add a zone" by shape */
.add-shapes .btn { flex: 1; justify-content: center; gap: 10px; }
.add-shapes .shape { display: inline-block; border: 2px solid currentColor; border-radius: 3px; }
.add-shapes .shape.wide { width: 24px; height: 13.5px; }
.add-shapes .shape.tall { width: 13.5px; height: 24px; }

/* ================================================================ finish: one calm, consistent look
   (kept in one place at the end so the rules above stay as they were written, stage by stage) */
:root { --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .18); --ring: rgba(255, 176, 32, .28); --hover-line: #3b4654; }
:root[data-theme=light] { --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 8px 24px rgba(20, 30, 45, .07); --ring: rgba(201, 122, 0, .22); --hover-line: #aab4c1; }
body { background-image: radial-gradient(1200px 420px at 50% -160px, rgba(255, 176, 32, .07), transparent 70%); background-repeat: no-repeat; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
:root[data-theme=light] body { background-image: radial-gradient(1200px 420px at 50% -160px, rgba(201, 122, 0, .06), transparent 70%); }
::selection { background: var(--ring); }
* { scrollbar-color: var(--line) transparent; }

/* the page fills the window: sign-in sits in the middle, the footer at the bottom */
.shell, .login { min-height: 100vh; min-height: 100dvh; }
.footer { opacity: .85; }

/* headings */
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h2 { font-size: 17px; letter-spacing: -0.01em; }
.page-head { margin-bottom: 20px; min-height: 44px; }
.page-head .count { padding-top: 6px; }

/* buttons */
a.btn { text-decoration: none; }
.btn { border-radius: 10px; transition: background-color .15s, border-color .15s, box-shadow .15s, transform .08s, filter .15s; }
.btn:hover { border-color: var(--hover-line); background: color-mix(in srgb, var(--panel-2) 86%, var(--text)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent)); border-color: var(--accent); box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 6px 18px -8px var(--accent); }
.btn.primary:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 84%, #fff), color-mix(in srgb, var(--accent) 94%, #fff)); border-color: var(--accent); filter: none; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: var(--danger); }
.btn[disabled] { transform: none; box-shadow: none; }
.btn.sound.off:hover { border-color: var(--danger); }
.icon-btn { transition: background-color .15s, color .15s; }
.link-btn { text-underline-offset: 3px; }
a { text-underline-offset: 3px; }

/* fields */
input[type=text], input[type=password], input[type=url], input[type=date], input[type=number], input[type=time], select, textarea {
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:hover, input[type=password]:hover, input[type=url]:hover, input[type=date]:hover, input[type=number]:hover, select:hover, textarea:hover { border-color: var(--hover-line); }
input[type=text]:focus, input[type=password]:focus, input[type=url]:focus, input[type=date]:focus, input[type=number]:focus, input[type=time]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input[type=checkbox]:focus-visible, input[type=range]:focus-visible, input[type=color]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.title-input:focus { box-shadow: 0 0 0 3px var(--ring) !important; }
select {
  -webkit-appearance: none; appearance: none; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a96a6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px !important;
}
label { letter-spacing: .01em; }
::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }

/* top bar */
.topbar { gap: 26px; }
.brand img { border-radius: 7px; }
.tab { transition: background-color .15s, color .15s; }
.who { display: inline-flex; align-items: center; gap: 9px; max-width: 240px; padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 99px; background: var(--panel); color: var(--text); font-weight: 600; }
.who > span { overflow: hidden; text-overflow: ellipsis; }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--accent); color: var(--accent-ink); font-style: normal; font-weight: 700; font-size: 13px; text-transform: uppercase; }
@media (max-width: 720px) { .who { display: none; } }

/* surfaces */
.box, .side-box, .screen-card, .tile, .card, .row, .layout-card, .tpl-card, .pl-item, .disk, .upload, .starter { box-shadow: var(--shadow); }
.tile, a.row.link, a.layout-card, .card { transition: border-color .15s, transform .15s, box-shadow .15s; }
.tile:hover, a.layout-card:hover, a.row.link:hover { transform: translateY(-2px); }
.tile:hover { box-shadow: var(--shadow), 0 0 0 3px var(--ring); }
.tile:active, a.layout-card:active, a.row.link:active { transform: none; }
.tile { padding: 18px; gap: 5px; }
.tile svg { width: 40px; height: 40px; padding: 8px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 14%, transparent); margin-bottom: 8px; }
.card:hover { border-color: var(--hover-line); }
.thumb img { transition: transform .25s; }
.thumb:hover img { transform: scale(1.03); }
.box { padding: 22px; }
.box h2, .side-box h2 { margin-bottom: 12px; }
.starter { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, var(--panel)), var(--panel) 60%); padding: 20px; }
.empty { background: color-mix(in srgb, var(--panel) 60%, transparent); border-width: 1.5px; }
.pill { padding: 3px 10px; }
.bar { height: 8px; }
.notice { box-shadow: var(--shadow); }

/* media cards: the name gets the whole width, the buttons sit beside the details */
.card-body { flex-wrap: wrap; align-items: center; padding: 10px 6px 6px 12px; }
.card-text { display: contents; }
.card-name { flex: 1 0 100%; padding-right: 6px; }
.card-meta { flex: 1; min-width: 0; }

/* screens */
.screen-card { padding: 18px; }
.screen-card.online { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.dot-status { transition: background-color .3s, box-shadow .3s; }
.qr { padding: 6px; box-shadow: var(--shadow); }

/* dialogs and messages */
dialog { border-radius: 18px; padding: 24px; }
dialog[open] { animation: dialog-in .18s ease-out; }
dialog::backdrop { background: rgba(5, 8, 12, .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.toast { border-radius: 12px; padding: 12px 16px 12px 14px; border-left: 3px solid var(--ok); animation: toast-in .2s ease-out; font-weight: 500; }
.toast.error { border-color: var(--line); border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ctx-menu { animation: toast-in .12s ease-out; }

/* sign-in */
.login { background: radial-gradient(700px 380px at 50% 38%, rgba(255, 176, 32, .10), transparent 70%); }
.login-card { width: min(400px, 100%); padding: 34px 32px 32px; border-radius: 20px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .55); }
:root[data-theme=light] .login-card { box-shadow: 0 30px 80px -30px rgba(20, 30, 45, .35); }
.login-card .brand { font-size: 24px; margin-bottom: 6px; }
.login-card .brand img { width: 42px; height: 42px; border-radius: 10px; }
.login-card > .muted { margin-bottom: 22px; }
.login-card .btn { min-height: 46px; margin-top: 4px; }

/* settings: two columns on a wide window */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; max-width: 960px; }
.settings-grid .box { max-width: none; margin: 0; }
.settings-col { display: grid; gap: 18px; min-width: 0; }
.version { margin-top: 18px; }

@media (max-width: 720px) {
  h1 { font-size: 24px; }
  .tile:hover, a.layout-card:hover, a.row.link:hover { transform: none; }
  dialog { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .tile, a.row.link, a.layout-card, .thumb img { transition: none; }
  dialog[open], .toast, .ctx-menu { animation: none; }
}

/* small things seen in review */
input[type=time], input[type=datetime-local] { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
input[type=time]:hover, input[type=datetime-local]:hover { border-color: var(--hover-line); }
.quick + .field, .quick + label, .quick + .side-label { margin-top: 16px; }
.card .icon-btn { width: 32px; height: 32px; }

/* Screens: a screenshot from the TV */
dialog.shot.landscape { width: min(1100px, calc(100vw - 24px)); }
dialog.shot.portrait { width: min(560px, calc(100vw - 24px)); }
.shot-stage { position: relative; min-height: 240px; }
.shot.landscape .shot-stage { aspect-ratio: 16 / 9; min-height: 0; }
.shot.portrait .shot-stage { aspect-ratio: 9 / 16; max-height: calc(100vh - 190px); margin: 0 auto; min-height: 0; }
.shot-stage img { width: 100%; height: 100%; object-fit: contain; max-height: none; }
.shot-wait { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; color: #c3ccd8; background: rgba(0, 0, 0, .55); z-index: 1; }
.shot-wait .spinner { display: none; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .18); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.shot-wait.busy .spinner { display: block; }
.shot-wait span { max-width: 460px; }
@keyframes spin { to { transform: rotate(360deg); } }
.shot-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.shot-foot .spacer { flex: 1; }
.shot-hint { margin: 8px 0 0; }

/* admin: a client's numbers above their screens */
.client-pick select { min-width: 280px; min-height: 42px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stats:empty { display: none; }
.stat { display: grid; gap: 3px; align-content: start; padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.stat strong { font-size: 20px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.stat .bar { display: block; height: 5px; margin-top: 6px; }
@media (max-width: 720px) { .client-pick { width: 100%; } .client-pick select { width: 100%; min-width: 0; } .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.badge.live { background: #dc2626; }
.badge.live::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: #fff; vertical-align: 1px; }

/* ticker settings: how the chosen font looks */
.font-sample { width: 0; min-width: 100%; box-sizing: border-box; margin: 8px 0 12px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line, rgba(127,127,127,.3)); font-size: 22px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.style-ticks { display: flex; gap: 18px; margin: 2px 0 4px; }

/* IPTV channel picker */
dialog.iptv { width: min(860px, calc(100vw - 32px)); }
.iptv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.iptv-head h2 { margin: 0; }
.iptv-filters { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.iptv-cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; }
.iptv-results { height: min(46vh, 380px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #0a0d11; }
.iptv-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.iptv-row:hover, .iptv-row:focus-visible { background: rgba(127, 127, 127, .12); outline: none; }
.iptv-row.on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.iptv-row b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iptv-row span { flex: none; max-width: 45%; color: var(--muted, #8b97a7); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iptv-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.iptv-foot p { margin: 0; }
.iptv-side video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; display: block; }
.iptv-manage { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.iptv-manage h3 { margin: 6px 0 4px; font-size: 15px; }
.iptv-list { display: flex; align-items: center; gap: 8px; padding: 6px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.iptv-list > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.z-iptv { --zc: #e11d48; }
@media (max-width: 700px) { .iptv-cols, .iptv-filters { grid-template-columns: 1fr; } .iptv-results { height: 34vh; } }
dialog.iptv .btn.small { padding: 5px 10px; font-size: 13px; flex: none; }

/* ---- search boxes look like the other fields */
input[type=search] { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; -webkit-appearance: none; appearance: none; transition: border-color .15s, box-shadow .15s; }
input[type=search]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* ---- feels like an app: no grey flash or zoom on a tap, the bars do not select as text, nothing bounces sideways */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }
a, button, .btn, .tab, .tile, select, label, summary, input[type=checkbox], input[type=range] { touch-action: manipulation; }
.topbar, .tabs, .btn, .tab, .tile, .badge, .pill, .page-head h1, .brand { -webkit-user-select: none; user-select: none; }
.tabs a, .brand, .tile, a.layout-card { -webkit-touch-callout: none; }
.brand img, .tab svg, .btn svg { -webkit-user-drag: none; pointer-events: none; }
.steps { margin: 4px 0 12px; padding-left: 22px; display: grid; gap: 6px; }
.share-icon { display: inline-grid; vertical-align: -5px; width: 22px; height: 22px; color: var(--accent); }
.share-icon svg { width: 22px; height: 22px; }
.login-card.offline { text-align: center; display: grid; gap: 12px; justify-items: center; }
.login-card.offline h1 { margin: 6px 0 0; }

/* opened from the home screen: the page starts under the phone's status bar and ends above its home bar */
@media (display-mode: standalone) { .login { padding-top: env(safe-area-inset-top); } }
@media (max-width: 980px) {      /* a phone on its side: keep clear of the notch */
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}
html.standalone .topbar { padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
html.standalone .login { padding-top: env(safe-area-inset-top); }

/* ---- phones */
@media (max-width: 720px) {
  /* iPhones zoom into a field whose text is smaller than 16 px, and do not zoom back */
  input[type=text], input[type=password], input[type=url], input[type=search], input[type=date], input[type=number], input[type=time], select, textarea { font-size: 16px; }
  .btn { min-height: 44px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  /* dialogs come up from the bottom as a sheet, within reach of the thumb */
  dialog:not(.preview):not(.player-preview) {
    width: 100%; max-width: 100%; margin: auto 0 0; box-sizing: border-box;
    border-radius: 20px 20px 0 0; border-width: 1px 0 0;
    max-height: calc(100dvh - 28px - env(safe-area-inset-top)); overflow-y: auto; overscroll-behavior: contain;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    animation: sheet-up .22s ease-out;
  }
  dialog:not(.preview):not(.player-preview)::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 12px; }
  .dialog-actions { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); margin-bottom: calc(-18px - env(safe-area-inset-bottom)); padding: 12px 0 calc(18px + env(safe-area-inset-bottom)); background: var(--panel); }
  .dialog-actions .btn { flex: 1; }
  #toasts { bottom: calc(12px + var(--tabbar)); }
  /* the picker is a tall sheet: its cards scroll, the title and the buttons stay where they are */
  dialog.picker[open] { height: calc(100dvh - 40px - env(safe-area-inset-top)); max-height: none; overflow: hidden; padding-left: 14px; padding-right: 14px; }
  dialog.picker h2 { margin-bottom: 10px; padding: 0 4px; }
  dialog.picker .dialog-actions { position: static; flex: none; margin: 0 -14px calc(-18px - env(safe-area-inset-bottom)); padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .pick-tools { flex-wrap: nowrap; padding: 0 2px; }
  .pick-tools input[type=search] { flex: 1 1 auto; min-width: 0; min-height: 40px; }
  .pick-kinds .chip { padding: 0 10px; }
  .pick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; padding: 2px 2px 10px; }
  .pick-pic { aspect-ratio: 1; }
  .pick-name { font-size: 12px; }
}
@media (max-width: 720px) and (orientation: landscape) {
  .pick-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .pick-pic { aspect-ratio: 16 / 10; }
}
@media (max-width: 380px) { .pick-kinds .chip { padding: 0 8px; font-size: 12px; } }
/* with a dialog open the page behind does not scroll (app.js pins it where it was) */
html.modal-open { overflow: hidden; }
html.modal-open body { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog { animation: none !important; } }
dd.playback.rough { color: var(--danger); font-weight: 600; }

/* ---- Diagnostics of a screen */
dialog.diag { width: min(1100px, calc(100vw - 24px)); padding: 16px 18px; }
.diag-body { display: grid; gap: 14px; max-height: min(72vh, 900px); overflow: auto; padding-right: 4px; }
.diag-verdict { border: 1px solid var(--line); border-left: 4px solid #22c55e; border-radius: 10px; padding: 10px 14px; background: var(--panel-2); }
.diag-verdict.bad { border-left-color: var(--danger); }
.diag-verdict p { margin: 2px 0; }
.diag-sec h3 { font-size: 14px; margin: 0 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.diag-dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 14px; }
.diag-dl dt { color: var(--muted); }
.diag-dl dd { margin: 0; overflow-wrap: anywhere; }
.diag-dl dd.bad, .diag-table tr.bad td { color: var(--danger); }
.diag-scroll { overflow: auto; max-height: 320px; border: 1px solid var(--line); border-radius: 8px; }
.diag-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.diag-table th { position: sticky; top: 0; background: var(--panel-2); text-align: left; font-weight: 600; }
.diag-table th, .diag-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.diag-table td:last-child { overflow-wrap: anywhere; }
.diag-foot { align-items: center; }
dd.fetching { font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .diag-dl { grid-template-columns: 1fr; } .diag-dl dt { margin-top: 6px; } .diag-body { max-height: none; } }
.diag-foot .spacer { flex: 1; }

/* ---- sign-in page: request for pricing, forgot password; e-mail settings; requests under Customers */
.login-links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.linklike { border: 0; background: none; padding: 4px 0; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.login-card.wide { width: min(460px, 100%); }
.login-card h2 { margin: 14px 0 6px; font-size: 20px; }
.login-card textarea { width: 100%; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0 14px; }
.pair { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.requests { margin-bottom: 16px; }
.request { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.request.done { opacity: .55; }
.request-main { flex: 1; min-width: 220px; }
.request-text { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.warn-text { color: var(--danger); }
/* e-mail and phone fields look like the other fields */
input[type=email], input[type=tel] { width: 100%; min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; }
input[type=email]:hover, input[type=tel]:hover { border-color: var(--hover-line); }
input[type=email]:focus, input[type=tel]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
@media (max-width: 720px) { input[type=email], input[type=tel] { font-size: 16px; } }

/* ---- invoices */
.invoice-settings { margin-bottom: 16px; }
.invoice-settings summary { cursor: pointer; font-weight: 700; }
.invoice-settings form { margin-top: 12px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 18px; }
.invoice-row.void { opacity: .5; }
.invoice-total { font-variant-numeric: tabular-nums; }
.pill.mid { background: rgba(255, 176, 32, .15); color: var(--accent); }
.pill.off { background: rgba(239, 68, 68, .15); color: var(--danger); }
dialog.invoice-dialog { width: min(720px, calc(100vw - 24px)); }
.iv-lines { display: grid; gap: 8px; margin: 4px 0 8px; }
.iv-line { display: grid; grid-template-columns: minmax(0, 1fr) 80px 110px auto; gap: 8px; align-items: center; }
.iv-total { margin: 12px 0 6px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.iv-extend { align-self: end; margin-bottom: 10px; }
details.billing { margin: 6px 0 10px; } details.billing summary { cursor: pointer; color: var(--muted); }
.my-invoice { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
@media (max-width: 720px) { .iv-line { grid-template-columns: minmax(0, 1fr) 64px 90px auto; } }
.invoice-row .pill:not(.mid):not(.off), .my-invoice .pill:not(.mid):not(.off) { background: rgba(34, 197, 94, .15); color: #22c55e; }

/* a screen's "when it is offline" settings */
fieldset.offline-box { margin: 14px 0 4px; padding: 10px 14px 4px; border: 1px solid var(--line); border-radius: 12px; }
fieldset.offline-box legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
fieldset.offline-box .field[hidden] { display: none; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type=range] { flex: 1; min-width: 0; }
.range-value { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.color-row select { flex: 1; min-width: 0; }
.btn.update { margin-left: 8px; padding: 2px 10px; min-height: 26px; font-size: 12px; }
/* a layout with a size of its own (for a wall of screens): its ratio is set on the element */
.schematic.custom { width: 100%; max-width: 240px; }
.schematic.custom.tall { width: auto; height: 100%; max-height: 140px; }
.template .schematic.custom { width: 100%; }
.canvas.custom { width: 100%; }
.canvas.custom.tall { width: auto; height: min(72vh, 760px); max-width: 100%; }
.seam { position: absolute; pointer-events: none; z-index: 1; opacity: .85; }
.seam.v { top: 0; bottom: 0; border-left: 2px dashed #ffb020; }
.seam.h { left: 0; right: 0; border-top: 2px dashed #ffb020; }
/* walls: several screens as one */
#walls { margin-bottom: 16px; }
.wall-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.wall-row .row-main { flex: 1 1 220px; min-width: 0; }
.wall-row .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.wall-grid { display: grid; gap: 4px; }
.wall-grid.small { flex: none; width: min(220px, 100%); }
.wall-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; aspect-ratio: 16 / 9; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); text-align: center; font-size: 12px; }
.wall-grid.portrait .wall-cell { aspect-ratio: 9 / 16; }
.wall-cell b { font-size: 13px; color: var(--muted); }
.wall-cell span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wall-cell.on { border-color: #22c55e; }
.wall-cell.off { border-color: #f59e0b; }
.wall-cell.empty span { color: var(--muted); }
.wall-grid.edit { gap: 8px; margin-bottom: 8px; }
.wall-grid.edit .wall-cell { aspect-ratio: auto; min-height: 84px; padding: 8px; font-size: 14px; }
.wall-grid.edit.portrait .wall-cell { min-height: 120px; }
.wall-grid.edit select { width: 100%; min-width: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
/* the device behind a screen: addresses, restart, Wi-Fi, commands */
.device-dialog h3 { margin: 18px 0 6px; font-size: 15px; }
.device-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.device-out { min-height: 1.4em; margin: 12px 0 0; color: #7ee2a8; }
.device-out.bad { color: #f87171; }
.wifi-list { display: grid; gap: 4px; margin-top: 8px; max-height: 260px; overflow: auto; }
.wifi-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.wifi-row:hover, .wifi-row:focus-visible { border-color: var(--accent); outline: none; }
.wifi-row.on { border-color: #22c55e; }
.wifi-row span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.wifi-join { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.shell-line { display: flex; gap: 8px; }
.shell-line input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; }
.shell-out { margin: 8px 0 0; min-height: 90px; max-height: 280px; overflow: auto; padding: 10px 12px; border-radius: 8px; background: #05070a; border: 1px solid var(--line);
  color: #d1fae5; font: 13px/1.45 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
/* the server was updated while the panel stayed open */
.newer-panel { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 24px);
  padding: 10px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--accent); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
/* extras on top of a plan (customer dialog), and what the extras cost (Plans page) */
fieldset.extras { margin: 0 0 14px; padding: 10px 14px 4px; border: 1px solid var(--line); border-radius: 10px; }
fieldset.extras legend { padding: 0 6px; font-size: 13px; color: var(--muted); }
#addon-prices { margin-top: 18px; }
.price-table { border-collapse: collapse; margin: 6px 0 12px; }
.price-table th { text-align: left; font-weight: 500; padding: 4px 14px 4px 0; font-size: 14px; }
.price-table thead th { color: var(--muted); font-size: 12px; }
.price-table td { padding: 3px 8px 3px 0; }
.price-table input { width: 110px; }
/* events: the kinds (birthday, anniversary, other), each with its own templates */
.kind-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.kind-tab { padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.kind-tab.on { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.kind-field { margin-top: 10px; }

/* ---- corner logo (branding.js) and background removal */
.checker { background-color: #fff; background-image: linear-gradient(45deg, #d5d9df 25%, transparent 25%), linear-gradient(-45deg, #d5d9df 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #d5d9df 75%), linear-gradient(-45deg, transparent 75%, #d5d9df 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.badge-sample { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; margin: 4px 0 8px; border: 1px solid var(--line);
  background: linear-gradient(90deg, #12161d 0 50%, #e9edf2 50% 100%); }
.badge-sample::after { content: ''; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(255, 176, 32, .18), transparent 40%, rgba(60, 120, 255, .16)); pointer-events: none; }
.badge-sample img { position: absolute; object-fit: contain; z-index: 1; }
.badge-sample.empty::before { content: 'Your logo shows in the corner'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; z-index: 2; }
.corner-pick { position: relative; width: 132px; aspect-ratio: 16 / 9; border: 2px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.corner-pick .corner { position: absolute; width: 40px; height: 28px; padding: 0; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; border-radius: 6px; }
.corner-pick .corner i { width: 22px; height: 12px; border-radius: 3px; border: 2px solid var(--muted); }
.corner-pick .corner.on i { background: var(--accent); border-color: var(--accent); }
.corner-pick .corner:hover i, .corner-pick .corner:focus-visible i { border-color: var(--text); }
.corner-pick .c-tl { left: 2px; top: 2px; } .corner-pick .c-tr { right: 2px; top: 2px; }
.corner-pick .c-bl { left: 2px; bottom: 2px; } .corner-pick .c-br { right: 2px; bottom: 2px; }
.slider-field input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-field output { color: var(--accent); font-variant-numeric: tabular-nums; margin-left: 4px; }
.canvas .badge-preview { position: absolute; z-index: 6; pointer-events: none; outline: 1px dashed rgba(255, 176, 32, .7); outline-offset: 2px; }
.canvas .badge-preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.badge-logo-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.badge-thumb { width: 64px; height: 40px; border-radius: 6px; overflow: hidden; display: grid; place-items: center; flex: none; }
.badge-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.side-title .switch { margin-left: auto; }
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .switch-ui { width: 42px; height: 24px; border-radius: 12px; background: var(--line); position: relative; transition: background .15s; }
.switch .switch-ui::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { box-shadow: 0 0 0 2px var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
dialog.cutout-dialog { width: min(860px, calc(100vw - 24px)); }
.cut-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.cut-compare figure { margin: 0; display: grid; gap: 6px; }
.cut-compare figcaption { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cut-pic { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; display: grid; place-items: center; border: 1px solid var(--line); }
.cut-pic.dark { background: #111418; } .cut-pic.light { background: #f3f5f8; }
.cut-pic img { max-width: 92%; max-height: 92%; object-fit: contain; }
.cut-backs { display: inline-flex; gap: 4px; }
.cut-backs .chip { padding: 2px 8px; font-size: 12px; }
.cut-wait { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; background: rgba(14, 17, 22, .72); color: #e8ecf1; font-size: 13px; text-align: center; padding: 12px; }
.cut-wait .spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-top-color: var(--accent); animation: cut-spin .9s linear infinite; }
@keyframes cut-spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) { .cut-compare { grid-template-columns: 1fr; } }
