@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("vendor/fonts/barlow-semi-condensed-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Barlow Semi Condensed";
  src: url("vendor/fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  --rack: #cfcdc6;
  --ink: #1f1f1f;
  --muted: #55534e;
  --line: #aeaba3;
  --bezel: #000;
  --signal: #0000bf;
  --tally: #bf0000;
  --warn: #a30000;
  --done: #007a00;
  --alert-bg: #e2dfd7;
  --bars: linear-gradient(90deg, #bfbfbf 0 14.2857%, #bfbf00 0 28.5714%, #00bfbf 0 42.8571%,
    #00bf00 0 57.1429%, #bf00bf 0 71.4286%, #bf0000 0 85.7143%, #0000bf 0);
  --radius-device: 10px;
  --radius-control: 4px;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --rack: #22231f;
    --ink: #e8e6e0;
    --muted: #a8a59d;
    --line: #45453f;
    --alert-bg: #2e2e29;
    --done: #3fbf3f;
    --warn: #ff7a6b;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--rack);
  color: var(--ink);
  font-family: "Barlow Semi Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
}

.app {
  max-width: 30rem;
  margin: 0 auto;
  padding: 1.25rem max(1rem, env(safe-area-inset-right, 0px)) 2.5rem max(1rem, env(safe-area-inset-left, 0px));
}

.head h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.lede {
  margin: 0.375rem 0 1.25rem;
  color: var(--muted);
  max-width: 34ch;
}

/* Monitor: el elemento protagonista */
.monitor {
  position: relative;
  background: var(--bezel);
  border-radius: var(--radius-device);
  padding: 8px;
  aspect-ratio: var(--ar, 16 / 9);
  width: min(100%, calc(58vh * var(--ar, 16 / 9)));
  margin-inline: auto;
}
.bars, .monitor video {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
}
.monitor video { object-fit: contain; background: #000; }
.bars { display: grid; grid-template-rows: 67fr 8fr 25fr; overflow: hidden; }
.bars-main { background: var(--bars); }
.bars-castle {
  background: linear-gradient(90deg, #0000bf 0 14.2857%, #131313 0 28.5714%, #bf00bf 0 42.8571%,
    #131313 0 57.1429%, #00bfbf 0 71.4286%, #131313 0 85.7143%, #bfbfbf 0);
}
.bars-pluge {
  background: linear-gradient(90deg, #00214c 0 17.857%, #ffffff 0 35.714%, #32006a 0 53.571%,
    #131313 0 71.4286%, #090909 0 76.19%, #131313 0 80.95%, #1d1d1d 0 85.714%, #131313 0);
}

/* Medidor de progreso con las mismas barras */
.meter {
  height: 10px;
  margin-top: 10px;
  background: var(--bezel);
  border-radius: 2px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  background: var(--bars);
  clip-path: inset(0 calc(100% - var(--p, 0%)) 0 0);
  transition: clip-path 400ms linear;
}

.status { margin: 1rem 0 0.25rem; min-height: 4.25rem; }
.status-main {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.status-main.is-live::before {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-right: 0.4em;
  border-radius: 50%;
  background: var(--tally);
  vertical-align: 0.12em;
}
.status-main.is-done { color: var(--done); }
.status-sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin: 1rem 0 0.5rem;
}
.actions[hidden] { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.25rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary {
  background: var(--signal);
  border-color: var(--signal);
  color: #fff;
  flex: 1 1 8rem;
}
.btn-ghost { flex: 1 1 8rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; }
.btn-text {
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  padding: 0.5rem 0.25rem;
  min-height: 44px;
  cursor: pointer;
}
.btn:focus-visible, .btn-text:focus-visible, summary:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 2px;
}
.btn-primary:focus-visible { outline-color: var(--ink); }

.alert {
  margin: 0.75rem 0;
  padding: 0.75rem 0.875rem;
  background: var(--alert-bg);
  border-left: 4px solid var(--tally);
}

.spec {
  width: 100%;
  margin-top: 1.5rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.spec caption {
  text-align: left;
  font-weight: 600;
  font-size: 1.125rem;
  padding-bottom: 0.375rem;
}
.spec th, .spec td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.5rem 0.5rem 0;
  border-top: 1px solid var(--line);
}
.spec thead th { color: var(--muted); font-weight: 400; border-top: 0; padding-top: 0; }
.spec tbody th { color: var(--muted); font-weight: 400; width: 28%; }
.spec td { width: 36%; }
.spec td.changed { font-weight: 600; }

/* Ajustes de salida */
.settings { margin: 0.5rem 0 0; }
.field { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.625rem; flex: 1 1 8rem; }
.field label { color: var(--muted); font-size: 0.875rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 0 0.625rem; }
.field-row[hidden] { display: none; }
.field select {
  min-height: 44px;
  padding: 0 2rem 0 0.75rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-control);
  background: var(--rack) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 0.75rem center / 0.625rem;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
}
.field select:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.field select:disabled { opacity: 0.4; }
.hint { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.9375rem; }
.notes { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.9375rem; }
.notes li { margin: 0.125rem 0; }
.notes li.warn { color: var(--warn); font-weight: 600; }

.checks { margin-top: 1.25rem; }
.checks h2 { font-size: 1.125rem; font-weight: 600; margin: 0 0 0.375rem; }
.checks ul { list-style: none; margin: 0; padding: 0; font-variant-numeric: tabular-nums; }
.checks li { display: flex; gap: 0.5rem; padding: 0.375rem 0; border-top: 1px solid var(--line); }
.checks li::before { content: "✓"; color: var(--done); font-weight: 600; width: 1em; flex: none; }
.checks li.bad::before { content: "✗"; color: var(--tally); }
.checks li.info::before { content: "!"; color: var(--muted); }
.checks li span { color: var(--muted); margin-left: auto; text-align: right; }

.foot { margin-top: 1.75rem; color: var(--muted); }
.engine { margin: 0 0 0.5rem; }
.log summary { cursor: pointer; padding: 0.5rem 0; min-height: 44px; }
.log pre {
  margin: 0;
  max-height: 16rem;
  overflow: auto;
  padding: 0.75rem;
  background: var(--bezel);
  color: #d6d6d6;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-all;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .meter-fill { transition: none; }
}
