:root {
  color-scheme: light;
  --bg: #f4f4f4;
  --surface: #ffffff;
  --surface-2: #ececec;
  --text: #161616;
  --muted: #5f5f5f;
  --border: #d6d6d6;
  --accent: #fede0e;
  --accent-hover: #efcf00;
  --accent-text: #111111;
  --accent-soft: #fff6bd;
  --accent-on-soft: #111111;
  --focus: #111111;
  --danger: #b3261e;
  --ok: #17794a;
  --warn: #8a5a00;
  --ink: #111111;
  --ink-2: #262626;
  --ink-text: #f1f1f1;
  --ink-muted: #a8a8a8;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #171717;
    --surface: #1f1f1f;
    --surface-2: #2c2c2c;
    --text: #efefef;
    --muted: #a9a9a9;
    --border: #3a3a3a;
    --accent-soft: #3a3410;
    --accent-on-soft: #fede0e;
    --focus: #fede0e;
    --danger: #f2877f;
    --ok: #62c994;
    --warn: #e3b35c;
    --ink: #0c0c0c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
p { margin: 0; }
a { color: inherit; }

input, select, button, textarea { font: inherit; color: inherit; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"],
input[type="search"], input[type="time"], input[type="date"], select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; }
textarea { resize: vertical; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--text); }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  white-space: nowrap;
  cursor: pointer;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; padding: 6px 8px; }
button.ghost:hover { background: var(--surface-2); }
button.icon { padding: 0; width: 34px; min-width: 34px; min-height: 34px; }
svg { flex: none; display: block; }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); min-height: 1.2em; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }

/* ---------- login ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--ink); }
.auth-box { width: min(340px, 100%); padding: 24px; background: var(--surface); border-radius: 4px; }
.auth-logo { display: block; width: 132px; height: auto; margin: 0 auto 26px; }
.auth-wrap { width: min(340px, 100%); }
.auth-box form { display: grid; gap: 12px; }
.auth-box h2 { margin-bottom: 4px; }
.auth-box button.primary { width: 100%; min-height: 40px; }
.password-wrap { position: relative; margin-top: 4px; }
.password-wrap input { padding-right: 42px; }
.password-wrap button { position: absolute; top: 1px; right: 1px; }
.caps { color: var(--warn); font-size: 13px; margin-top: 4px; }
.auth-help { margin-top: 12px; text-align: center; color: var(--ink-muted); font-size: 12.5px; }

/* ---------- estrutura ---------- */
.layout { display: grid; grid-template-columns: 188px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 20px 0 12px;
  background: var(--ink);
  color: var(--ink-text);
}
.brand-logo { display: block; width: 104px; height: auto; margin-left: 18px; }
.sidebar nav { display: grid; }
.sidebar nav button {
  justify-content: flex-start;
  width: 100%;
  min-height: 40px;
  padding: 6px 18px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--ink-muted);
}
.sidebar nav button:hover { background: var(--ink-2); color: var(--ink-text); }
.sidebar nav button[aria-current="page"] { border-left-color: var(--accent); color: #fff; font-weight: 600; background: var(--ink-2); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding: 10px 8px 0 18px; border-top: 1px solid var(--ink-2); }
.side-foot .who { flex: 1; min-width: 0; font-size: 12px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot button { background: transparent; border-color: transparent; color: var(--ink-muted); padding: 4px 8px; min-height: 30px; }
.side-foot button:hover { background: var(--ink-2); color: #fff; }

.content { min-width: 0; padding: 20px 26px 40px; }
.page-head { margin-bottom: 14px; }
.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; max-width: 1240px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 14px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 8px 10px 0; gap: 8px; }
  .brand-logo { width: 72px; margin-left: 16px; }
  .sidebar nav {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    grid-template-columns: repeat(6, 1fr);
    background: var(--ink); border-top: 1px solid var(--ink-2);
  }
  .sidebar nav button { justify-content: center; padding: 4px 0; font-size: 11.5px; min-height: 46px; border-left: 0; border-top: 3px solid transparent; }
  .sidebar nav button[aria-current="page"] { border-top-color: var(--accent); }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .side-foot .who { display: none; }
  .content { padding: 16px 14px 76px; }
}

/* ---------- início ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.stat { padding: 12px 16px; border-left: 1px solid var(--border); }
.stat:first-child { border-left: 0; }
.stat .value { font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; color: var(--muted); font-weight: 400; }
.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
}

.row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.row .grow { min-width: 170px; overflow-wrap: anywhere; }
.now-line { font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }

.chip { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.chip.ok { color: var(--ok); font-weight: 600; }
.chip.warn { color: var(--warn); font-weight: 600; }

/* ---------- playlists ---------- */
.pl-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1040px) { .pl-grid { grid-template-columns: minmax(0, 1fr); } }
.pl-side { padding: 0; }
.pl-list { display: grid; }
.pl-list button { display: block; width: 100%; height: auto; text-align: left; white-space: normal; padding: 9px 12px; border: 0; border-left: 3px solid transparent; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; }
.pl-list button:hover { background: var(--surface-2); }
.pl-list button[aria-current="true"] { background: var(--accent-soft); border-left-color: var(--accent); color: var(--accent-on-soft); }
.pl-list button[aria-current="true"] .muted { color: inherit; }
.pl-list strong { display: block; font-weight: 600; overflow-wrap: anywhere; }
.pl-new { display: flex; gap: 6px; padding: 10px 12px; }

.pl-title { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.pl-title input { font-size: 18px; font-weight: 600; border-color: transparent; background: transparent; padding: 2px 6px; margin-left: -6px; }
.pl-title input:hover { border-color: var(--border); }
.pl-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.pl-tools input { width: 104px; }

.item { display: grid; grid-template-columns: auto 88px minmax(0, 1fr) 104px auto; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item .actions { flex-wrap: nowrap; }
.item.off .thumb, .item.off .info { opacity: .55; }
.item.dragging { opacity: .35; }
.grip { color: var(--muted); cursor: grab; display: flex; }
.order { display: none; flex-direction: column; gap: 2px; }
.order button { width: 30px; min-width: 30px; min-height: 24px; }

.thumb { width: 88px; height: 50px; border-radius: 2px; background: var(--surface-2); object-fit: cover; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; overflow: hidden; }
.thumb.cover { position: relative; background: #111; color: #fff; font-weight: 600; text-align: center; }
.thumb.cover span { position: relative; z-index: 1; padding: 0 4px; }
.thumb.cover::after { content: ""; position: absolute; right: -14%; bottom: -26%; width: 52%; height: 62%; border-radius: 999px; background: var(--accent); transform: rotate(-22deg); opacity: .9; }
.thumb.cover-yellow { background: var(--accent); color: #111; }
.thumb.cover-yellow::after { background: #111; opacity: .14; }
.thumb.cover-grey { background: #3a3a3a; }
.thumb.cover-grey::after { background: #fff; opacity: .16; }
.info { min-width: 0; }
.info strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.seconds { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.seconds input { width: 68px; min-height: 32px; padding: 3px 6px; text-align: right; margin: 0; }
@media (max-width: 760px) {
  .item { grid-template-columns: auto 64px minmax(0, 1fr); }
  .grip { display: none; }
  .order { display: flex; }
  .thumb { width: 64px; height: 42px; }
  .item .seconds { grid-column: 2 / -1; }
  .item .actions { grid-column: 1 / -1; justify-content: flex-end; }
}

.empty-state { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 28px 16px; color: var(--muted); }

/* ---------- conteúdos ---------- */
.lib-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lib-tools input { flex: 1 1 200px; width: auto; }
.lib-tools select { flex: 0 1 180px; width: auto; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.lib-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.lib-card .thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 0; }
.lib-card .body { padding: 8px 10px 4px; min-width: 0; }
.lib-card .body strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card .actions { padding: 0 2px 2px; margin-top: auto; }

/* ---------- diálogos ---------- */
dialog.sheet {
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}
dialog.sheet::backdrop { background: rgb(0 0 0 / .6); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); }
.sheet-body { padding: 16px; display: grid; gap: 12px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; }

.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: var(--muted); }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }

.drop { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; min-height: 150px; padding: 16px; border: 1px dashed var(--muted); border-radius: 3px; text-align: center; }
.drop.over { background: var(--accent-soft); }
.upload-row { display: flex; gap: 10px; align-items: center; font-size: 13px; margin-top: 6px; }
.upload-row span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
progress { width: 120px; accent-color: var(--text); }

.pick-list { display: grid; max-height: 320px; overflow: auto; }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 5px; color: var(--text); }
.pick-list label:hover { background: var(--surface-2); }
.pick-list input { width: 16px; height: 16px; margin: 0; accent-color: var(--text); }
.pick-list .thumb { width: 64px; height: 38px; }
.pick-list span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chips button { min-height: 28px; padding: 2px 9px; font-size: 13px; }
.days-pick button { width: 38px; padding: 0; }
.days-pick button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
fieldset { border: 1px solid var(--border); border-radius: 3px; padding: 10px 12px; margin: 0; display: grid; gap: 10px; min-width: 0; }
legend { padding: 0 5px; font-size: 13px; font-weight: 600; }
input[type="range"] { width: 100%; accent-color: var(--text); }
.color-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
input[type="color"] { display: block; width: 100%; height: 36px; padding: 2px; margin-top: 4px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface); cursor: pointer; }
.adj-frame { overflow: hidden; margin: 0 auto; background: #111; cursor: grab; touch-action: none; }
.adj-frame.circle { border-radius: 50%; }
.adj-frame:active { cursor: grabbing; }
.adj-frame img { display: block; width: 100%; height: 100%; pointer-events: none; user-select: none; }
.people-edit { display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.person-row { display: grid; grid-template-columns: 44px minmax(0, 2fr) 76px minmax(0, 1.2fr) auto auto; gap: 6px; align-items: center; }
.person-photo { width: 44px; min-width: 44px; height: 44px; padding: 0; border-radius: 50%; overflow: hidden; font-size: 11px; color: var(--muted); }
.person-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.city-results { display: grid; gap: 1px; }
.city-results button { justify-content: flex-start; white-space: normal; text-align: left; min-height: 32px; border-color: transparent; background: var(--surface-2); }
.search-row { display: flex; gap: 6px; margin-top: 4px; }
.selected-city { font-weight: 600; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- prévia ---------- */
.stage { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.stage video, .stage img { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage iframe { width: 1920px; height: 1080px; border: 0; background: #fff; transform-origin: 0 0; display: block; }
.stage .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; color: #fff; text-align: center; }
/* Mantém a prévia inteira na tela, sobrando espaço para os controles. */
.stage-wrap { position: relative; min-width: 0; width: min(100%, max(480px, calc((100vh - 370px) * 16 / 9))); margin: 0 auto; }
.ticker-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 10.4%; display: flex; align-items: center; background: #e9ecef; color: #fff; font-size: 13px; overflow: hidden; white-space: pre; }
.with-ticker .stage video, .with-ticker .stage img { height: 89.6%; }
.ticker-bar .bar-frame { display: block; width: 100%; height: 100%; border: 0; pointer-events: none; }
.preview-tools { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; }
.preview-tools label:first-child { flex: 0 1 280px; }
.player { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.player .grow { min-width: 180px; overflow-wrap: anywhere; }
.queue { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.queue button { display: block; flex: 0 0 100px; height: auto; padding: 0; border: 2px solid transparent; border-radius: 2px; background: transparent; overflow: hidden; }
.queue button[aria-current="true"] { border-color: var(--accent); }
.queue .thumb { width: 100%; height: 56px; border-radius: 0; }

/* ---------- tvs e ajustes ---------- */
.inline-form { display: grid; grid-template-columns: 1fr 1.4fr 1fr auto; gap: 10px; align-items: end; }
.inline-form.two { grid-template-columns: 1fr 1.6fr auto; }
@media (max-width: 760px) { .inline-form, .inline-form.two { grid-template-columns: 1fr; } }
.tv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.tv-card { display: grid; gap: 8px; align-content: start; }
.tv-card .tv-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tv-card strong { font-size: 15px; overflow-wrap: anywhere; }
.link-box code { display: block; padding: 8px 10px; background: var(--surface-2); overflow-wrap: anywhere; font-size: 13px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  border-radius: 3px;
  background: #111;
  color: #fff;
  z-index: 60;
}
@media (max-width: 860px) { #toast { bottom: 66px; } }

/* escolha de estilo das telas */
.style-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 6px; }
.style-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 0; padding: 8px; text-align: left; border: 1px solid var(--border); background: var(--surface, #fff); white-space: normal; }
.style-card .style-swatch { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 4px; margin-bottom: 4px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.style-card b { font-size: 13.5px; }
.style-card .muted { font-size: 12px; line-height: 1.3; }
.style-card[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--accent); background: var(--accent-soft); }

/* intercalar */
.pick-list { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.pick-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--border); font-weight: 400; cursor: pointer; }
.pick-row:last-child { border-bottom: 0; }
.pick-row span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-row .muted { font-size: 12.5px; }

/* marca da playlist */
.pl-brand { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.pl-brand select { min-height: 36px; }
