:root {
  --grafite: #191919;
  --texto: #2b2b2b;
  --suave: #666;
  --linha: #e2e2e2;
  --fundo: #f4f4f4;
  --branco: #fff;
  --marrom: #865835;
  --marrom-escuro: #6d4629;
  --marrom-claro: #f3ece6;
  --vinho: #691916;
  --verde: #2f7d4f;
  --raio: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 400 16px/1.5 "Poppins", system-ui, sans-serif;
}
h1, h2, h3 { color: var(--grafite); line-height: 1.25; }
h2 { font-family: "Alegreya", Georgia, serif; font-weight: 500; font-size: 1.75rem; margin: 0; }
h3 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
small, .muted { color: var(--suave); }
.hint { color: var(--suave); font-size: .9rem; margin: .5rem 0 1rem; max-width: 70ch; }
.empty { color: var(--suave); font-size: .95rem; padding: 1rem; border: 1px dashed var(--linha); border-radius: var(--raio); text-align: center; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--marrom); outline-offset: 2px; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .55rem 1.1rem;
  border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer;
  background: none; color: var(--grafite);
  touch-action: manipulation;
}
.btn-primary { background: var(--marrom); color: var(--branco); }
.btn-primary:hover { background: var(--marrom-escuro); }
.btn-secondary { border-color: var(--marrom); color: var(--marrom); background: var(--branco); }
.btn-secondary:hover { background: var(--marrom-claro); }
.btn-quiet { color: var(--suave); }
.btn-quiet:hover { color: var(--grafite); background: rgba(0, 0, 0, .04); }
.btn-danger { color: var(--vinho); }
.btn-danger:hover { background: #f7e9e8; }
.btn-block { width: 100%; }
.btn-icon { min-width: 44px; padding: .4rem; }
.btn[disabled] { opacity: .45; cursor: default; }

input, select {
  font: inherit; color: var(--texto);
  width: 100%; min-height: 44px; padding: .5rem .75rem;
  border: 1px solid #cfcfcf; border-radius: 8px; background: var(--branco);
}
input[type="number"] { width: 7rem; }
label { font-weight: 500; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card {
  width: 100%; max-width: 380px; background: var(--branco);
  border: 1px solid var(--linha); border-radius: 14px; padding: 2rem 1.5rem;
  display: flex; flex-direction: column; gap: .35rem;
}
.login-logo { width: 190px; margin: 0 auto .75rem; }
.login-card h1 { font: 500 1.5rem/1.3 "Alegreya", Georgia, serif; text-align: center; margin: 0 0 1rem; }
.login-card input { margin-bottom: .75rem; }
.form-error { color: var(--vinho); margin: 0 0 .75rem; font-size: .95rem; }
.login-card .hint { margin: -.5rem 0 1rem; text-align: center; }
.login-card small { display: block; margin: -.5rem 0 .75rem; font-size: .85rem; }
.login-card .btn-quiet { margin-top: .25rem; }

/* Topo */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem 1rem; background: var(--branco); border-bottom: 1px solid var(--linha);
}
.topbar-logo { height: 34px; }
.topbar-title { font: 600 1rem/1.5 "Poppins", system-ui, sans-serif; margin: 0 auto 0 0; padding-left: .75rem; border-left: 1px solid var(--linha); }
.topbar-user { color: var(--suave); font-size: .9rem; }

.content { max-width: 920px; margin: 0 auto; padding: 1.25rem 1rem 7rem; display: flex; flex-direction: column; gap: 1.25rem; }
.card { background: var(--branco); border: 1px solid var(--linha); border-radius: 14px; padding: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Status */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: 1rem 0 0; }
.stats div { background: var(--fundo); border-radius: var(--raio); padding: .75rem 1rem; }
.stats dt { font-size: .85rem; color: var(--suave); }
.stats dd { margin: .15rem 0 0; font-size: 1.15rem; font-weight: 600; color: var(--grafite); font-variant-numeric: tabular-nums; }
.alert { border-radius: var(--raio); padding: .75rem 1rem; margin: 1rem 0 0; font-size: .95rem; }
.alert-warn { background: #fbf3e8; border: 1px solid #ecd3ad; }
.alert-error { background: #f9eceb; border: 1px solid #e7c2bf; color: var(--vinho); }
.screens { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.screen { display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem; border: 1px solid var(--linha); border-radius: var(--raio); }
.screen-dot { width: 10px; height: 10px; border-radius: 50%; background: #bbb; flex: none; }
.screen.online .screen-dot { background: var(--verde); }
.screen-main { flex: 1; min-width: 0; }
.screen-name { font-weight: 600; }
.screen-detail { font-size: .85rem; color: var(--suave); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-error {
  font-size: .85rem; color: var(--vinho);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere;
}

/* Upload e vídeos */
.upload { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; padding: .85rem 1rem; background: var(--marrom-claro); border-radius: var(--raio); margin-bottom: 1rem; }
.upload-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-pct { font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / -1; height: 8px; background: rgba(0, 0, 0, .08); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--marrom); transition: width .2s; }

.videos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.video {
  display: grid; grid-template-columns: auto 132px 1fr auto; align-items: center; gap: .85rem;
  padding: .6rem; border: 1px solid var(--linha); border-radius: var(--raio); background: var(--branco);
}
.video.is-off { background: var(--fundo); }
.video.is-off .video-thumb { opacity: .45; }
.video.dragging { opacity: .5; }
.video-pos { width: 2rem; text-align: center; font-weight: 600; color: var(--marrom); font-variant-numeric: tabular-nums; }
.video-thumb { width: 132px; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; object-fit: cover; display: block; }
.video-info { min-width: 0; }
.video-title { width: 100%; min-height: 40px; font-weight: 500; border-color: transparent; padding: .35rem .5rem; margin-left: -.5rem; }
.video-title:hover, .video-title:focus { border-color: #cfcfcf; }
.video-meta { font-size: .85rem; color: var(--suave); }
.video-actions { display: flex; align-items: center; gap: .15rem; }

/* Escolhas (radio em cartões) */
fieldset { border: 0; margin: 1.25rem 0 0; padding: 0; min-width: 0; }
legend { font-weight: 600; margin-bottom: .6rem; padding: 0; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.choices legend { grid-column: 1 / -1; }
.choices.compact { grid-template-columns: repeat(2, 1fr); max-width: 520px; }
.choice { position: relative; display: block; cursor: pointer; font-weight: 400; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice > span { display: flex; flex-direction: column; gap: .1rem; height: 100%; padding: .75rem .9rem; border: 1px solid #d6d6d6; border-radius: var(--raio); background: var(--branco); }
.choice strong { font-weight: 600; color: var(--grafite); }
.choice small { font-size: .85rem; }
.choice input:checked + span { border-color: var(--marrom); box-shadow: inset 0 0 0 1px var(--marrom); background: var(--marrom-claro); }
.choice input:focus-visible + span { outline: 3px solid var(--marrom); outline-offset: 2px; }
#layout-choices { grid-template-columns: repeat(2, 1fr); max-width: 620px; }

.mini { display: flex; gap: 4px; height: 54px; padding: 6px; margin-bottom: .5rem; border-radius: 6px; background: var(--branco); border: 1px solid var(--linha); }
.mini i { display: block; background: #d9d2cb; border-radius: 3px; }
.mini b { display: block; flex: 1; background: linear-gradient(var(--grafite) 0 0) 6px 10px / 50% 5px no-repeat, linear-gradient(var(--marrom) 0 0) 6px 24px / 30% 4px no-repeat; }
.mini-destaque i { width: 30%; }
.mini-trio i { flex: 1; }

.source-panel { margin-top: 1rem; padding: 1rem; border-radius: var(--raio); background: var(--fundo); }
.source-panel > label { display: block; margin-bottom: .35rem; }
.inline { display: flex; align-items: center; gap: .5rem; }
.check-list { list-style: none; margin: .75rem 0 0; padding: 0; max-height: 340px; overflow: auto; background: var(--branco); border: 1px solid var(--linha); border-radius: 8px; }
.check-list li { border-bottom: 1px solid #f0f0f0; }
.check-list label { display: flex; align-items: center; gap: .65rem; padding: .55rem .8rem; font-weight: 400; cursor: pointer; min-height: 44px; }
.check-list input { width: 20px; height: 20px; min-height: 0; accent-color: var(--marrom); flex: none; }
.check-list .count { margin-left: auto; color: var(--suave); font-size: .85rem; font-variant-numeric: tabular-nums; }
.check-list .depth-1 label { padding-left: 2rem; }
.check-list .depth-2 label { padding-left: 3.25rem; }
.check-list .top label { font-weight: 600; }

.prod-list { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.prod { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: .75rem; padding: .4rem .5rem; background: var(--branco); border: 1px solid var(--linha); border-radius: 8px; }
.prod img { width: 48px; height: 64px; object-fit: cover; border-radius: 4px; background: var(--fundo); }
.prod-name { font-size: .95rem; line-height: 1.3; }
.prod-sub { font-size: .8rem; color: var(--suave); }
.prod-actions { display: flex; gap: .1rem; }

.preview { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--linha); }
.preview-count { font-weight: 600; margin: 0 0 .75rem; }
.preview-count.warn { color: var(--vinho); }
.preview-sample { display: flex; gap: .5rem; overflow: hidden; }
.preview-sample img { width: 72px; height: 104px; object-fit: cover; border-radius: 6px; background: var(--fundo); flex: none; }

/* Tempos e chaves */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.25rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.switches { display: flex; flex-direction: column; gap: .25rem; margin-top: 1.25rem; }
.switch { display: flex; align-items: center; gap: .75rem; min-height: 44px; font-weight: 400; cursor: pointer; }
.switch input {
  -webkit-appearance: none; appearance: none; flex: none;
  width: 46px; height: 26px; min-height: 0; padding: 0; border: 0; border-radius: 13px;
  background: #c9c9c9; position: relative; cursor: pointer; transition: background .15s;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--branco); transition: transform .15s;
}
.switch input:checked { background: var(--marrom); }
.switch input:checked::after { transform: translateX(20px); }

/* Barra de salvar e avisos */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; justify-content: flex-end; gap: .75rem;
  padding: .75rem 1rem; background: var(--grafite); color: var(--branco);
}
.savebar span { margin-right: auto; }
.savebar .btn-quiet { color: #ddd; }
.savebar .btn-quiet:hover { background: rgba(255, 255, 255, .08); color: var(--branco); }
.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); z-index: 7;
  background: var(--grafite); color: var(--branco); padding: .7rem 1.1rem; border-radius: 8px;
  max-width: calc(100% - 2rem); font-size: .95rem;
}
.toast.error { background: var(--vinho); }

@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr; }
  .choices, .choices.compact, #layout-choices { grid-template-columns: 1fr 1fr; }
  .fields { grid-template-columns: 1fr; }
  .video { grid-template-columns: auto 96px 1fr; }
  .video-thumb { width: 96px; }
  .video-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .topbar-user { display: none; }
  h2 { font-size: 1.5rem; }
}
@media (max-width: 420px) {
  .choices, .choices.compact, #layout-choices { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
