/* TouchShow CMS. Colours are tokens; dark mode redefines them (system setting, or the moon/sun button). */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #eef2f7; --hover: #f1f4f8; --line: #dde2ea; --line-strong: #c3cad6;
  --text: #1b2433; --muted: #5f6b7d; --brand: #0d7f8c; --brand-ink: #ffffff; --primary: #2463d6; --primary-ink: #ffffff;
  --primary-soft: rgba(36, 99, 214, .1); --ok: #1f8a4c; --ok-soft: #e3f4ea; --bad: #c8372d; --bad-soft: #fbe7e5;
  --warn: #9a5b0b; --warn-soft: #fdf1e1; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 12px; --top-h: 64px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b; --surface: #1b2029; --surface-2: #232a35; --hover: #252c38; --line: #2e3643; --line-strong: #3d4757;
    --text: #e6e9ef; --muted: #9aa4b4; --brand: #3fc1cc; --brand-ink: #0b1b1e; --primary: #5b93f2; --primary-ink: #0c1424;
    --primary-soft: rgba(91, 147, 242, .16); --ok: #4cc27f; --ok-soft: rgba(76, 194, 127, .14); --bad: #ef6b60; --bad-soft: rgba(239, 107, 96, .14);
    --warn: #f0b35a; --warn-soft: rgba(240, 179, 90, .14); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --surface: #1b2029; --surface-2: #232a35; --hover: #252c38; --line: #2e3643; --line-strong: #3d4757;
  --text: #e6e9ef; --muted: #9aa4b4; --brand: #3fc1cc; --brand-ink: #0b1b1e; --primary: #5b93f2; --primary-ink: #0c1424;
  --primary-soft: rgba(91, 147, 242, .16); --ok: #4cc27f; --ok-soft: rgba(76, 194, 127, .14); --bad: #ef6b60; --bad-soft: rgba(239, 107, 96, .14);
  --warn: #f0b35a; --warn-soft: rgba(240, 179, 90, .14); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; font-weight: 650; } h2 { font-size: 19px; font-weight: 650; } h3 { font-size: 16px; font-weight: 650; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ---------- buttons & inputs ---------- */
button, .btn { font: inherit; font-weight: 600; font-size: 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 1px solid transparent; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-outline { background: transparent; color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-text { background: transparent; color: var(--primary); padding: 8px 10px; }
.btn-text:hover { background: var(--primary-soft); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--hover); }
.icon-btn { background: transparent; color: var(--muted); padding: 7px; border-radius: 50%; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
button:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--muted); }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 12px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
.input-icon { position: relative; }
.input-icon input { padding-right: 42px; }
.input-icon > button, .input-icon > .i { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.input-icon > .i { right: 12px; color: var(--muted); pointer-events: none; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; cursor: pointer; }
.feat { display: flex; flex-direction: column; gap: 2px; min-width: 220px; }
.feat .field { margin: 0; }

/* ---------- login ---------- */
.login { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-form { display: flex; flex-direction: column; justify-content: center; padding: 48px 24px; background: var(--bg); }
.login-form .inner { width: 100%; max-width: 440px; margin: 0 auto; }
.login-form .logo { justify-content: center; font-size: 28px; margin-bottom: 36px; }
.login-form h1 { text-align: center; font-size: 22px; margin-bottom: 26px; }
.login-form .btn-primary { width: 100%; padding: 12px; font-size: 15px; margin-top: 6px; }
.login-form .center { text-align: center; margin-top: 22px; }
.login-art { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px; color: #fff; text-align: center;
  background: radial-gradient(1200px 600px at 110% -10%, rgba(255,255,255,.18), transparent 60%), linear-gradient(140deg, #0b5f6a 0%, #0d7f8c 38%, #2463d6 100%); }
.login-art h2 { font-size: clamp(28px, 3.4vw, 46px); font-weight: 750; letter-spacing: -.01em; max-width: 620px; }
.login-art p { font-size: 18px; opacity: .9; max-width: 560px; margin: 16px 0 36px; }
.mock-tv { width: min(360px, 70%); aspect-ratio: 16 / 10; border-radius: 14px; background: #0c0f14; padding: 10px; box-shadow: 0 30px 60px rgba(0,0,0,.35); }
.mock-tv .scr { width: 100%; height: 100%; border-radius: 6px; overflow: hidden; position: relative; background: linear-gradient(120deg, #ffb457, #ff6f61 45%, #8a5cf6); }
.mock-tv .scr::before { content: ""; position: absolute; inset: 18% 12% auto; height: 22%; border-radius: 6px; background: rgba(255,255,255,.85); }
.mock-tv .scr::after { content: ""; position: absolute; left: 12%; right: 40%; bottom: 18%; height: 10%; border-radius: 6px; background: rgba(255,255,255,.55); }
.mock-stand { width: 90px; height: 10px; border-radius: 0 0 8px 8px; background: #0c0f14; margin: 0 auto; opacity: .7; }

/* ---------- top bar ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 21px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; }
.logo .mark svg { width: 22px; height: 22px; }
.logo small { font-weight: 600; color: var(--brand); }
.topbar { position: sticky; top: 0; z-index: 40; height: var(--top-h); display: flex; align-items: center; gap: 28px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--text); text-decoration: none; font-weight: 500; padding: 8px 14px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: var(--hover); }
.nav a.on { color: var(--brand); font-weight: 650; }
.top-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.menu-btn { background: transparent; color: var(--text); font-weight: 500; font-size: 15px; padding: 8px 10px; }
.menu-btn:hover { background: var(--hover); }
.dot { min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; padding: 0 5px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 650; font-size: 17px; display: grid; place-items: center; border: 0; padding: 0; }
.avatar.lg { width: 52px; height: 52px; font-size: 21px; }

.dropdown { position: absolute; z-index: 60; display: grid; width: max-content; min-width: 150px; max-width: calc(100vw - 16px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px 0; }
.dropdown .head { display: flex; gap: 12px; align-items: center; padding: 10px 16px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown .head b { display: block; } .dropdown .head span { color: var(--muted); font-size: 14px; word-break: break-all; }
.dropdown button, .dropdown a { display: flex; width: auto; justify-content: flex-start; gap: 12px; padding: 9px 16px; white-space: nowrap; background: transparent; color: var(--text); font-weight: 450; font-size: 15px; border-radius: 0; text-decoration: none; }
.dropdown button:hover, .dropdown a:hover { background: var(--hover); }
.dropdown .i { color: var(--muted); }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- page ---------- */
main { padding: 24px; max-width: 1480px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; margin: 4px 0 22px; }
.page-head .grow { flex: 1; }
.biz .ctrls .grow { flex: 1; }
.tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.search { width: 260px; max-width: 100%; }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-radius: 10px; margin-bottom: 18px; background: var(--warn-soft); color: var(--text); }
.banner .i { color: var(--warn); margin-top: 1px; }
.banner.info { background: var(--primary-soft); } .banner.info .i { color: var(--primary); }
.banner.error { background: var(--bad-soft); } .banner.error .i { color: var(--bad); }
.banner.ok { background: var(--ok-soft); } .banner.ok .i { color: var(--ok); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.empty { text-align: center; color: var(--muted); padding: 64px 16px; }
.hero-empty { display: flex; gap: 32px; align-items: center; justify-content: center; padding: 64px 16px; flex-wrap: wrap; }
.hero-empty .art { width: 240px; color: var(--muted); }
.hero-empty .txt { max-width: 400px; border-left: 1px solid var(--line); padding-left: 28px; }
.hero-empty .txt p { margin: 10px 0 18px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.badge.on { background: var(--ok); color: #fff; } .badge.off { background: var(--bad); color: #fff; } .badge.wait { background: var(--muted); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }

/* ---------- screen / group / file cards ---------- */
.tile { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.tile:hover { box-shadow: var(--shadow); }
.tile .tile-link { position: absolute; inset: 0; z-index: 1; }
.tile .media { position: relative; padding: 24px 24px 14px; display: flex; justify-content: center; }
.tile .body { padding: 6px 16px 16px 20px; display: flex; align-items: flex-end; gap: 8px; }
.tile .body .t { flex: 1; min-width: 0; }
.tile .body b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .body span { font-size: 14px; color: var(--muted); }
.tile .more { position: relative; z-index: 2; }
.tv-frame { width: 72%; aspect-ratio: 16 / 9; background: #111; border: 4px solid #2a2a2a; border-radius: 3px; overflow: hidden; position: relative; }
.tv-frame.portrait { width: auto; height: 150px; aspect-ratio: 9 / 16; }
.tv-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tv-frame .ph { width: 100%; height: 100%; background: linear-gradient(110deg, #2b2b2b, #bdbdbd); }
/* v8: the Online / Offline badge sits to the right of the screen name (it used to be hidden over the picture) */
.nm { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nm b { flex: 0 1 auto; min-width: 0; }
.tile .body .nm .badge { flex: none; padding: 2px 9px; font-size: 12px; color: #fff; }
.detail-top .meta h1.nm { flex-wrap: wrap; }
.detail-top .meta h1.nm .badge { font-size: 13px; color: #fff; }
.file-tile .thumb { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); overflow: hidden; position: relative; }
.file-tile .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-tile .thumb .kind { position: absolute; left: 8px; top: 8px; }
.file-tile .thumb .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.file-tile .body { padding: 10px 10px 12px 14px; align-items: center; }
.file-tile .body b { font-size: 14px; }
.grid.files { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }

/* ---------- screen / group detail ---------- */
.detail-head { background: var(--surface-2); margin: -24px -24px 0; padding: 22px 24px 0; border-bottom: 1px solid var(--line); }
.detail-top { display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-start; }
.detail-top .tv-frame { width: 200px; flex: none; }
.detail-top .tv-frame.portrait { width: auto; height: 130px; }
.detail-top .meta { flex: 1; min-width: 220px; }
.frame-wrap { position: relative; flex: none; }
.frame-wrap.portrait { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.detail-top .meta h1 { font-size: 24px; }
.detail-top .meta .line { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 10px; color: var(--muted); }
.detail-top .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.detail-top .side .actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.subtabs { display: flex; gap: 6px; margin-top: 16px; }
.subtabs span { padding: 10px 22px; border-bottom: 3px solid var(--primary); color: var(--primary); font-weight: 600; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; margin-top: 22px; }
.pane-head { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; min-height: 46px; }
.pane-head h2 { margin-right: 6px; }
.pane-head .grow { flex: 1; }
.dropzone { border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px; text-align: center; color: var(--text); background: var(--surface); }
.playlist { min-height: 320px; border-radius: 12px; padding: 4px; }
.playlist.over { outline: 2px dashed var(--primary); outline-offset: 2px; background: var(--primary-soft); }
.drop-art { display: grid; place-items: center; padding: 60px 0; }
.drop-art div { width: 150px; height: 150px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.drop-art svg { width: 56px; height: 56px; }
.pl-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.pl-row.dragging { opacity: .4; }
.pl-row.before { box-shadow: 0 -3px 0 var(--primary); } .pl-row.after { box-shadow: 0 3px 0 var(--primary); }
.pl-row .grip { cursor: grab; color: var(--muted); padding: 4px; display: flex; }
.pl-row .num { width: 26px; color: var(--muted); font-size: 13px; text-align: right; }
.pl-row img, .pl-row .noimg { width: 72px; height: 46px; border-radius: 6px; object-fit: cover; background: var(--surface-2); flex: none; display: grid; place-items: center; color: var(--muted); }
.pl-row .name { flex: 1; min-width: 0; }
.pl-row .name b { display: block; font-weight: 550; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-row .name span { font-size: 13px; color: var(--muted); }
.pl-row.missing { border-color: var(--bad); }
.noimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pl-row .secs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.pl-row .secs input { width: 64px; padding: 6px 8px; text-align: center; }
.pl-row .mv { display: none; }
.lib-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: calc(100vh - 300px); overflow-y: auto; padding: 2px; }
.lib-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: grab; position: relative; }
.lib-item:active { cursor: grabbing; }
.lib-item.in { opacity: .55; }
.lib-item .thumb { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); position: relative; }
.lib-item .thumb img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.lib-item .thumb .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px; padding: 0 5px; border-radius: 4px; }
.lib-item .cap { padding: 6px 8px; font-size: 13px; display: flex; align-items: center; gap: 4px; }
.lib-item .cap span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item .add { position: absolute; top: 6px; right: 6px; background: var(--surface); color: var(--primary); border-radius: 50%; padding: 4px; box-shadow: var(--shadow); }
.save-bar { display: flex; gap: 10px; align-items: center; }

/* ---------- modal, toast, preview ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(10, 14, 20, .55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 22px 24px 20px; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.modal-head h2 { flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.pick-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; }
.toasts { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100% - 32px)); }
.toast { background: #1f2733; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.toast.err { background: #8f241c; } .toast.ok { background: #1c6b3e; }
.preview { position: fixed; inset: 0; z-index: 85; background: #000; display: flex; align-items: center; justify-content: center; }
.preview .stage { width: min(92vw, calc(84vh * 16 / 9)); aspect-ratio: 16 / 9; background: #000; position: relative; overflow: hidden; }
.preview .stage.portrait { width: auto; height: 84vh; aspect-ratio: 9 / 16; }
.preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity .5s; }
.preview img.stretch { object-fit: fill; }
.preview .bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 20px; color: #fff; display: flex; justify-content: space-between; background: linear-gradient(transparent, rgba(0,0,0,.7)); font-size: 14px; }
.preview .close { position: absolute; top: 16px; right: 16px; color: #fff; background: rgba(255,255,255,.12); }
.stat { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stat .v { font-size: 26px; font-weight: 700; } .stat .l { color: var(--muted); font-size: 13px; }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--primary); } .meter i.bad { background: var(--bad); }
.alert-row { display: flex; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .i { margin-top: 2px; }
.alert-row.error .i { color: var(--bad); } .alert-row.warn .i { color: var(--warn); } .alert-row.info .i { color: var(--primary); }
.log-row { display: flex; gap: 16px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.log-row time { color: var(--muted); font-size: 13px; width: 150px; flex: none; }
.biz { padding: 18px 20px; }
.biz .top { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; justify-content: space-between; }
.biz .ctrls { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-top: 14px; }
.biz .ctrls .field { margin: 0; }
.loading { display: grid; place-items: center; padding: 80px 0; color: var(--muted); }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- small screens ---------- */
.narrow-only { display: none; }
@media (max-width: 1000px) {
  .wide-only { display: none; } .narrow-only { display: inline; }
  .split { grid-template-columns: 1fr; }
  .lib-list { max-height: none; }
  .pl-row .mv { display: flex; gap: 2px; }
}
@media (max-width: 760px) {
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .topbar { gap: 4px 10px; padding: 8px 12px 0; height: auto; flex-wrap: wrap; }
  .topbar .nav { order: 3; flex-basis: 100%; }
  .wide-only { display: none; }
  .logo .word { display: none; }
  main { padding: 16px; }
  .detail-head { margin: -16px -16px 0; padding: 16px 16px 0; }
  .detail-top .side { align-items: flex-start; }
  .detail-top .tv-frame { width: 140px; }
  .search { width: 100%; }
  .hero-empty .txt { border-left: 0; padding-left: 0; }
  .pl-row { flex-wrap: wrap; }
  .pl-row .name { flex-basis: 40%; }
  .log-row { flex-direction: column; gap: 2px; }
}

/* ---------- v6: zones, ticker, schedules ---------- */
.zone-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.zone-bar .grow { flex: 1; }
.zone-tabs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.zone-tab { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: 99px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.zone-tab span { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px; background: var(--surface-2); color: var(--muted); font-size: 11px; }
.zone-tab.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.zone-tab.on span { background: rgba(255,255,255,.25); color: inherit; }
.lay-mini { position: relative; display: inline-block; width: 64px; aspect-ratio: 16 / 9; background: #111; border: 2px solid #2a2a2a; border-radius: 3px; overflow: hidden; flex: none; }
.lay-mini.portrait { width: auto; height: 56px; aspect-ratio: 9 / 16; }
.lay-mini .area { position: absolute; left: 0; right: 0; }
.lay-mini i { position: absolute; display: block; box-sizing: border-box; border: 1px solid #111; background: #6f8db8; }
.lay-mini i.on { background: #5b93f2; box-shadow: inset 0 0 0 1px #fff; }
.lay-mini i.tk { left: 0; right: 0; background: #22d3ee; border: 0; }
.lay-wrap { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.lay-canvas { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0b0f15; border: 6px solid #232a35; border-radius: 6px; overflow: hidden; touch-action: none; user-select: none; }
.lay-canvas.portrait { width: auto; height: min(62vh, 520px); aspect-ratio: 9 / 16; margin: 0 auto; }
.lay-area { position: absolute; left: 0; right: 0; }
.lay-box { position: absolute; box-sizing: border-box; border: 2px solid var(--zc); background: color-mix(in srgb, var(--zc) 30%, #0b0f15); cursor: move; overflow: hidden; }
.lay-box img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; pointer-events: none; }
.lay-box .lbl { position: absolute; left: 6px; top: 5px; background: var(--zc); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 6px; pointer-events: none; }
.lay-box.on { box-shadow: 0 0 0 2px #fff inset; }
.lay-box .hd { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid var(--zc); border-radius: 3px; box-sizing: border-box; }
.lay-box .hd.n { top: -2px; left: calc(50% - 6px); cursor: ns-resize; } .lay-box .hd.s { bottom: -2px; left: calc(50% - 6px); cursor: ns-resize; }
.lay-box .hd.e { right: -2px; top: calc(50% - 6px); cursor: ew-resize; } .lay-box .hd.w { left: -2px; top: calc(50% - 6px); cursor: ew-resize; }
.lay-box .hd.ne { right: -2px; top: -2px; cursor: nesw-resize; } .lay-box .hd.sw { left: -2px; bottom: -2px; cursor: nesw-resize; }
.lay-box .hd.nw { left: -2px; top: -2px; cursor: nwse-resize; } .lay-box .hd.se { right: -2px; bottom: -2px; cursor: nwse-resize; }
.lay-tk { position: absolute; left: 0; right: 0; z-index: 9; overflow: hidden; display: flex; align-items: center; white-space: nowrap; }
.lay-tk span { display: inline-block; padding-left: 100%; font-weight: 600; animation: tk-move linear infinite; }
.lay-tk.still { justify-content: center; }
.lay-tk.still span { padding-left: 0; animation: none; transform: none; white-space: nowrap; }
@keyframes tk-move { from { transform: translateX(0); } to { transform: translateX(-100%); } }
.lay-side { display: flex; flex-direction: column; gap: 10px; }
.lay-h { display: flex; gap: 8px; align-items: center; margin: 12px 0 0; font-size: 16px; }
.lay-z { border: 1px solid var(--line); border-left: 4px solid var(--zc); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.lay-z.on { border-color: var(--zc); background: color-mix(in srgb, var(--zc) 7%, var(--surface)); }
.lay-zh { display: flex; align-items: center; gap: 8px; } .lay-zh .grow { flex: 1; } .lay-zh .btn-text { padding: 4px 6px; font-size: 13px; }
.lay-zh .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--zc); }
.lay-nums { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; margin-top: 6px; }
.lay-nums label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.lay-nums label span { width: 50px; color: var(--muted); }
.lay-nums input { width: 76px; padding: 5px 8px; }
.lay-nums em { font-style: normal; color: var(--muted); }
.pl-row .sched { display: flex !important; align-items: center; gap: 4px; margin-top: 2px; font-size: 12px; color: var(--primary) !important; font-weight: 600; }
.pl-row .sched svg { width: 14px; height: 14px; }
.pl-row .sched.ended { color: var(--bad) !important; }
.icon-btn.on { color: var(--primary); background: var(--primary-soft); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day { display: inline-flex; align-items: center; cursor: pointer; }
.day input { position: absolute; opacity: 0; pointer-events: none; }
.day span { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line-strong); font-size: 13px; font-weight: 600; color: var(--muted); }
.day input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.day input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.modal.xwide { max-width: 1080px; }
.info-tip { display: inline-flex; vertical-align: middle; color: var(--muted); cursor: help; position: relative; }
.info-tip svg { width: 16px; height: 16px; }
.info-tip .tip { display: none; position: absolute; z-index: 30; left: 50%; top: 22px; transform: translateX(-50%); width: 280px; padding: 10px 12px; border-radius: 10px; background: #1f2733; color: #fff; font-size: 12.5px; font-weight: 400; line-height: 1.45; box-shadow: var(--shadow); text-align: left; }
.info-tip:hover .tip, .info-tip:focus .tip, .info-tip.open .tip { display: block; }
@media (max-width: 760px) {
  .lay-wrap { grid-template-columns: 1fr; }
  .lay-box .hd { width: 16px; height: 16px; }
}
.tv-frame .tf-area { position: absolute; left: 0; right: 0; }
.tv-frame .tf-z { position: absolute; overflow: hidden; box-shadow: 0 0 0 1px #111 inset; }
.tv-frame .tf-tk { position: absolute; left: 0; right: 0; display: block; z-index: 9; }
input[type="color"] { padding: 3px; height: 42px; cursor: pointer; }
input[type="range"] { padding: 0; border: 0; accent-color: var(--primary); }

/* v7: web pages */
.file-tile .thumb.web { background: linear-gradient(135deg, var(--surface-2), var(--surface)); }
.file-tile .thumb.web > svg { width: 48px; height: 48px; stroke-width: 1.3; }
.file-tile .thumb .host { position: absolute; left: 8px; right: 8px; bottom: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.web-prev { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; background: #fff; }
.web-prev iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- v8: Overview tab, announcement banner ---------- */
.ov-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat.ov-on .v { color: var(--ok); } .stat.ov-off .v { color: var(--bad); }
.announce { display: flex; gap: 12px; align-items: flex-start; margin: 0; padding: 12px 24px; background: var(--primary-soft); border-bottom: 1px solid var(--line); color: var(--text); }
.announce svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--primary); }
.announce .txt { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.announce button { flex: none; }
