:root {
  color-scheme: light;
  --bg: #f5f3ed;
  --panel: #fffdf8;
  --ink: #22231d;
  --muted: #625f53;
  --line: #e2ded2;
  --soft: #f4f0e7;
  --gold: #846633;
  --dark: #20211c;
  font: 16px/1.45 "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: .55rem .9rem; font-size: .88rem; font-weight: 650; min-height: 38px; white-space: nowrap; }
button:hover { background: #eae5d9; }
button:disabled { opacity: .54; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.primary { background: var(--dark); border-color: var(--dark); color: #fffaf0; }
.primary:hover { background: #424131; }
.soft { background: var(--soft); }
.top { background: #171815; color: #f9f3e5; }
.top-inner { width: min(1320px, calc(100% - 64px)); height: 66px; margin: auto; display: flex; align-items: center; gap: 18px; }
.wordmark { color: inherit; font: 25px Georgia, serif; letter-spacing: .2em; text-decoration: none; }
.top-label { color: #c9bfa9; border-left: 1px solid #544f44; padding-left: 16px; letter-spacing: .12em; font-size: .76rem; white-space: nowrap; }
.spacer { flex: 1; }
.quiet { padding: .3rem .55rem; color: inherit; border-color: #5d584d; background: transparent; }
.quiet:hover { background: #332e26; }
.shell { width: min(1320px, calc(100% - 64px)); margin: auto; padding: 33px 0 42px; }
.page-heading, .section-heading, .preview-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.page-heading { margin-bottom: 25px; }
h1 { font: 400 clamp(2.05rem, 4vw, 3.1rem)/1.08 Georgia, "Times New Roman", serif; margin: 0 0 9px; letter-spacing: -.035em; }
h2 { font: 500 1.55rem Georgia, "Times New Roman", serif; margin: 0 0 4px; }
p { margin: 0; }
.page-heading p, .section-heading p, .preview-head p { color: var(--muted); font-size: .88rem; }
.actions { display: flex; gap: 9px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.58fr) minmax(312px, 1fr); gap: 21px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px #2b221106; min-width: 0; }
.tabs { display: flex; padding: 0 20px; gap: 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: transparent; border-radius: 0; color: var(--muted); padding: 15px 3px 13px; border-bottom: 2px solid transparent; }
.tabs button[aria-current="page"] { color: var(--ink); border-bottom-color: #927445; }
#device-count { margin-left: 3px; font-variant-numeric: tabular-nums; font-weight: 500; }
.tab-body { padding: 23px; min-height: 395px; }
.section-heading { margin-bottom: 19px; }
.dropzone { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 13px 14px; margin: 0 0 15px; border: 1px dashed #cfc4ac; border-radius: 8px; background: #faf7ef; color: #725a36; }
.dropzone.dragover { background: #eee4cd; }
.dropzone p { font-weight: 600; font-size: .89rem; }
.dropzone p span { color: var(--muted); font-weight: 400; margin-left: 8px; }
#upload-status { width: 100%; }
.track { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.track-row { display: grid; grid-template-columns: 24px 37px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; min-height: 64px; }
.track-row.selected { background: #f7f1e4; border-color: #cdbb94; }
.track-row.drop-target { box-shadow: inset 0 3px #927445; }
.grip { text-align: center; color: #74664e; cursor: grab; font-size: 1.05rem; }
.thumb { width: 37px; height: 49px; object-fit: cover; background: #24251e; overflow: hidden; border-radius: 4px; color: #fffaf0; display: grid; place-content: center; font-size: .72rem; }
.clip-select { display: grid; justify-items: start; min-width: 0; border: 0; padding: 4px; background: transparent; }
.clip-select strong { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.clip-select small { color: var(--muted); font-weight: 500; }
.length { font-size: .83rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mini-actions { display: flex; gap: 3px; }
.mini-actions button { padding: 2px 5px; min-height: 29px; min-width: 25px; background: transparent; border-color: transparent; }
.mini-actions button:hover { background: #e9dec9; }
.inspector { margin-top: 19px; border-top: 1px solid var(--line); padding-top: 15px; display: grid; grid-template-columns: minmax(85px, 1fr) 122px minmax(130px, 168px); align-items: end; gap: 12px; }
.inspector strong, .inspector p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.inspector p, .device-meta { color: var(--muted); font-size: .84rem; }
.inspector label, .settings label, form > label:not(.checkbox), .login label { display: grid; gap: 6px; font-size: .88rem; font-weight: 620; }
input:not([type="checkbox"]), select { width: 100%; min-height: 40px; border: 1px solid var(--line); background: #fffefa; color: var(--ink); padding: 8px 10px; border-radius: 6px; min-width: 0; }
.unit { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px; }
.unit > span { color: var(--muted); font-weight: 500; }
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings .full { grid-column: 1 / -1; }
.preview { padding: 16px 18px 11px; }
.preview-head h2 { font-size: 1.42rem; }
.segmented { background: var(--soft); border-radius: 7px; display: flex; padding: 3px; gap: 2px; }
.segmented button { min-height: 31px; background: transparent; border: 1px solid transparent; padding: 3px 8px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--panel); border-color: var(--line); color: var(--ink); }
.viewbox { height: clamp(320px, 54vh, 620px); display: grid; place-content: center; background: radial-gradient(ellipse at 50% 36%, #eae6dd, #e2ddd1); border-radius: 8px; margin-top: 14px; overflow: hidden; }
.frame { display: grid; position: relative; background: #171815; border: 3px solid #2d2d24; border-radius: 7px; overflow: hidden; box-shadow: 0 6px 22px #2e261746; }
.stage, .stage > img, .stage > video, .screen-placeholder { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage img, .stage video { object-fit: contain; }
.screen-placeholder { display: grid; place-content: center; gap: 8px; text-align: center; color: #f9f2e3; padding: 10px; }
.screen-placeholder span { font: 20px Georgia, serif; letter-spacing: .2em; margin-left: .2em; }
.screen-placeholder p { font-size: .8rem; }
.transport { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.transport button { min-height: 32px; padding: 3px 8px; }
#playing-title { flex: 1; color: var(--muted); font-size: .84rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.device-row { display: grid; gap: 6px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.device-line { display: flex; gap: 8px; align-items: center; }
.device-line strong { flex: 1; }
.badge { color: #4a4637; background: #eae5d6; padding: 3px 7px; border-radius: 20px; font-size: .79rem; white-space: nowrap; }
.badge.online { background: #e2eadc; color: #294526; }
.device-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.device-actions button { min-height: 32px; padding: 3px 7px; }
.device-empty { border: 1px dashed var(--line); border-radius: 8px; padding: 19px; color: var(--muted); }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); width: min(495px, calc(100vw - 30px)); padding: 25px; }
dialog::backdrop { background: #161612a0; }
dialog p { color: var(--muted); margin-top: 7px; }
dialog label { margin-top: 12px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 20px; }
.targets { display: grid; max-height: 220px; overflow: auto; gap: 3px; margin: 10px 0; }
.checkbox { display: flex; align-items: center; gap: 7px; }
input[type="checkbox"] { accent-color: #676042; width: 17px; height: 17px; }
#pair-code { display: block; color: var(--ink); background: var(--soft); border-radius: 7px; padding: 14px; margin-top: 15px; font: 600 23px ui-monospace, monospace; letter-spacing: .12em; user-select: all; }
.server-address { overflow-wrap: anywhere; }
#toast { position: fixed; z-index: 3; bottom: 20px; right: 20px; background: #20211c; color: #fffaf0; max-width: min(420px, calc(100vw - 40px)); padding: 12px 16px; border-radius: 6px; box-shadow: 0 4px 20px #1718153f; }
.error { color: #933520; }
.login { min-height: calc(100vh - 66px); display: grid; place-content: center; padding: 24px; }
.login-card { width: min(480px, calc(100vw - 48px)); padding: 33px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.login-card h1 { font-size: clamp(1.85rem, 5vw, 2.45rem); margin-bottom: 18px; }
.login form { display: grid; gap: 8px; }
.login form button { margin-top: 4px; }
@media (max-width: 950px) {
  .workspace { grid-template-columns: minmax(0, 1.3fr) minmax(280px, .9fr); }
  .inspector { grid-template-columns: 1fr 1fr; }
  .inspector > div { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .top-inner, .shell { width: calc(100% - 28px); }
  .workspace { grid-template-columns: 1fr; gap: 14px; }
  .page-heading { align-items: start; flex-direction: column; }
  .tab-body { padding: 15px; }
  .track-row { grid-template-columns: 13px 30px minmax(0, 1fr) auto auto; gap: 5px; }
  .thumb { width: 30px; height: 43px; }
}
