/* Studio UI: Promesa blueprint system (paper + millimeter grid, ink, black borders, accent). */
@font-face { font-family: "Archivo"; src: url("/fonts/archivo-latin-wdth-normal.woff2") format("woff2"); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Architects Daughter"; src: url("/fonts/architects-daughter-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --paper: #F2F9F8;
  --ink: #123B40;
  --line: #111111;
  --accent: #35F2DF;
  --danger: #B42318;
  --grid-minor: rgba(18, 59, 64, 0.06);
  --grid-major: rgba(18, 59, 64, 0.13);
  --font-title: "Archivo", "Arial Narrow", sans-serif;
  --font-body: "Archivo", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-hand: "Architects Daughter", cursive;
  --border: 3px solid var(--line);
  --shadow: 4px 4px 0 var(--line);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(to right, var(--grid-major) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(to bottom, var(--grid-major) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(to right, var(--grid-minor) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(to bottom, var(--grid-minor) 0 1px, transparent 1px 8px);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--line); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); border: var(--border); padding: 6px 10px; z-index: 50; }
.skip:focus { left: 8px; }

.label { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.title { font-family: var(--font-title); font-weight: 900; font-stretch: 66%; line-height: 0.95; letter-spacing: -0.01em; }
.title--lg { font-size: clamp(2.2rem, 8vw, 3.4rem); }
.title--md { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.title--sm { font-size: 1.35rem; font-stretch: 75%; }
.hand { font-family: var(--font-hand); }
.muted { opacity: 0.75; }
.marker { background: linear-gradient(transparent 62%, var(--accent) 62%, var(--accent) 92%, transparent 92%); padding: 0 0.08em; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; padding: 0.55rem 1rem;
  background: var(--paper); border: var(--border); box-shadow: var(--shadow);
  font-weight: 700; cursor: pointer; text-decoration: none; color: var(--line);
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--line); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--line); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }
.btn--primary { background: var(--accent); }
.btn--danger { color: var(--danger); }
.btn--small { min-height: 36px; padding: 0.3rem 0.7rem; font-size: 0.875rem; box-shadow: 3px 3px 0 var(--line); }
.btn--ghost { box-shadow: none; border-width: 2px; }

/* Forms */
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.3rem; }
.field__label { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.field__hint { font-size: 0.8rem; opacity: 0.75; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 0.5rem 0.65rem;
  background: #fff; border: 2px solid var(--line); border-radius: 0;
}
textarea { min-height: 6rem; resize: vertical; line-height: 1.45; }
input[type="checkbox"] { width: 1.2rem; min-height: 1.2rem; accent-color: var(--ink); }
input:disabled, textarea:disabled, select:disabled { background: transparent; border-style: dashed; }
.checks { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.checks label { display: inline-flex; gap: 0.35rem; align-items: center; }
.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.row--end { justify-content: flex-end; }
.grid2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.alert { border: 2px solid var(--danger); color: var(--danger); background: #fff; padding: 0.6rem 0.8rem; font-weight: 600; }
.note { border: 2px dashed var(--ink); padding: 0.6rem 0.8rem; background: rgba(255,255,255,0.6); }

/* Login */
.login__main { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login__card { width: min(420px, 100%); background: var(--paper); border: var(--border); box-shadow: 8px 8px 0 var(--line); padding: 2rem 1.5rem; display: grid; gap: 1.2rem; }
.login__note { font-size: 1.1rem; text-align: right; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.2rem;
  padding: 0.6rem 16px; background: var(--paper); border-bottom: var(--border);
}
.topbar__brand { display: grid; line-height: 1.05; }
.topbar__mark { font-family: var(--font-title); font-weight: 900; font-stretch: 75%; font-size: 1.5rem; }
.topbar__sub { font-size: 0.62rem; }
.topbar__nav { display: flex; flex-wrap: wrap; gap: 0.3rem; flex: 1 1 auto; }
.topbar__nav a { padding: 0.35rem 0.6rem; border: 2px solid transparent; text-decoration: none; color: var(--ink); font-weight: 700; }
.topbar__nav a[aria-current="page"] { border-color: var(--line); background: var(--accent); }
.topbar__user { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.topbar__user form { margin: 0; }
.brand-switch select { min-height: 36px; padding: 0.2rem 0.4rem; }
.badge-link { text-decoration: none; color: inherit; }
.badge { display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 0.4rem; border: var(--border); background: var(--paper); font-weight: 800; }
.badge--hot { background: var(--accent); }

main { padding: 1.2rem 16px 4rem; max-width: 1280px; margin: 0 auto; }
main:focus { outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.panel { background: var(--paper); border: var(--border); box-shadow: var(--shadow); padding: 1rem; }
.stack { display: grid; gap: 1rem; }

/* Progress */
.progress { display: grid; gap: 0.5rem; }
.progress__bar { height: 18px; border: 2px solid var(--line); background: #fff; }
.progress__fill { height: 100%; background: var(--accent); border-right: 2px solid var(--line); transition: width 300ms ease; }

/* Calendar */
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1rem; }
.cal { display: grid; gap: 0.6rem; }
.cal__week { border: var(--border); background: var(--paper); box-shadow: var(--shadow); }
.cal__weekhead { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.4rem 0.6rem; border-bottom: 2px solid var(--line); }
.cal__days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal__day { min-height: 7.5rem; border-right: 1.5px dashed rgba(18,59,64,0.35); padding: 0.35rem; display: grid; align-content: start; gap: 0.3rem; }
.cal__day:last-child { border-right: 0; }
.cal__day--out { background: rgba(18,59,64,0.05); }
.cal__date { font-family: var(--font-mono); font-size: 0.72rem; }
.chip {
  display: grid; gap: 0.15rem; width: 100%; text-align: left; padding: 0.3rem 0.4rem;
  background: #fff; border: 2px solid var(--line); cursor: pointer; font-size: 0.78rem; line-height: 1.2;
}
.chip:hover { background: var(--accent); }
.chip__top { display: flex; justify-content: space-between; gap: 0.3rem; font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; }
.chip__hook { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.state { display: inline-block; padding: 0.05rem 0.35rem; border: 1.5px solid var(--line); font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; background: #fff; white-space: nowrap; }
.state--pendiente_aprobacion, .state--pendiente_aprobacion_final { background: var(--accent); }
.state--cambios_pedidos, .state--cambios_arte, .state--en_produccion { background: #FFF3C4; }
.state--programada { background: var(--ink); color: var(--paper); }
.state--publicada { background: var(--line); color: #fff; }
.chip--error { border-color: var(--danger); }

@media (max-width: 760px) {
  .cal__days { grid-template-columns: 1fr; }
  .cal__day { min-height: 0; border-right: 0; border-bottom: 1.5px dashed rgba(18,59,64,0.35); grid-template-columns: 4.5rem 1fr; align-items: start; }
  .cal__day > .chip { grid-column: 2; }
  .cal__day--empty, .cal__day--out { display: none; }
}

/* List */
.table-wrap { overflow-x: auto; border: var(--border); box-shadow: var(--shadow); background: var(--paper); }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1.5px dashed rgba(18,59,64,0.35); vertical-align: top; }
th { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 2px solid var(--line); }
td button.linklike { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; text-decoration: underline; font-weight: 600; }

/* Detail drawer */
.drawer-back { position: fixed; inset: 0; background: rgba(17,17,17,0.35); z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31; width: min(760px, 100%);
  background: var(--paper); border-left: var(--border); overflow-y: auto; padding: 1rem 16px 3rem;
  display: grid; align-content: start; gap: 1rem;
}
.drawer__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; position: sticky; top: -1rem; background: var(--paper); padding: 1rem 0 0.6rem; margin-top: -1rem; border-bottom: 2px solid var(--line); z-index: 2; }
.section { display: grid; gap: 0.7rem; padding-top: 0.6rem; border-top: 1.5px dashed rgba(18,59,64,0.4); }
.art { display: grid; gap: 0.6rem; }
.art img, .art video { width: 100%; max-width: 420px; border: var(--border); box-shadow: var(--shadow); background: #fff; }
.thumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.thumbs img { width: 110px; border: 2px solid var(--line); }
.issues { margin: 0; padding-left: 1.1rem; }
.history { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.5rem; font-size: 0.88rem; }
.history li { border-left: 3px solid var(--ink); padding-left: 0.6rem; }
.history details summary { cursor: pointer; }
.scene { display: grid; gap: 0.4rem; padding: 0.6rem; border: 2px dashed var(--ink); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 60; max-width: calc(100% - 32px); }
.toast:not(:empty) { background: var(--line); color: #fff; padding: 0.6rem 1rem; border: 2px solid var(--line); box-shadow: 4px 4px 0 var(--accent); font-weight: 600; }

.empty { padding: 2rem 1rem; text-align: center; }
.swatches { display: flex; gap: 0.4rem; }
.swatch { width: 1.6rem; height: 1.6rem; border: 2px solid var(--line); }
.row > input:not([type="checkbox"]), .row > select { width: auto; flex: 0 1 auto; }
.toolbar .label { flex: 1 1 auto; }
@media (max-width: 760px) { .topbar { position: static; } }
main > * + * { margin-top: 1rem; }
