:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f24;
  --muted: #69707d;
  --line: #e3e6eb;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e5f5ec;
  --bad: #c0392b;
  --bad-bg: #fbe9e7;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --work: #2f5bea;
  --work-bg: #e8eeff;
  --action: #8a3ffc;
  --action-bg: #f1e8ff;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; margin-top: 1.25rem; }
h2.inline { display: inline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: #151821; color: #fff;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.topbar .link { color: #cfd3dc; }

.page { max-width: 980px; margin: 0 auto; padding: 1rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1rem;
}
.card.narrow { max-width: 380px; margin: 3rem auto; }

.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.meta, .hint, .hint-inline, .empty, .back { color: var(--muted); }
.hint { font-size: .9rem; margin: .5rem 0 0; }
.hint-inline { font-weight: normal; font-size: .85rem; }
.back { margin: 0 0 .5rem; }

label { display: block; font-weight: 600; font-size: .9rem; }
input[type="text"], input[type="password"], select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .65rem;
  border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button, .button {
  display: inline-block; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { border-color: #c5cad3; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.primary:hover { filter: brightness(1.07); }
.small { padding: .3rem .65rem; font-size: .85rem; }
.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: normal; }
.danger { color: var(--bad); }

.stack > * + * { margin-top: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions.sticky {
  position: sticky; bottom: 0; background: var(--card); padding: .75rem 0; border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.new-episode { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.new-episode .grow { flex: 1 1 320px; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-bad { background: var(--bad-bg); color: var(--bad); }
.error { color: var(--bad); }
.error-box { background: var(--bad-bg); color: var(--bad); padding: .9rem 1rem; border-radius: 8px; margin-top: 1rem; }
.error-box p { margin: .35rem 0 .75rem; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.alert { background: var(--bad-bg); color: var(--text); border: 1px solid #f0b9b1; padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert strong { color: var(--bad); }
.warn { background: var(--warn-bg); color: var(--warn); padding: .6rem .9rem; border-radius: 8px; }

.pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-work { background: var(--work-bg); color: var(--work); }
.tone-action { background: var(--action-bg); color: var(--action); }
.tone-wait { background: var(--warn-bg); color: var(--warn); }
.tone-muted { background: #eceef2; color: var(--muted); }
.counts { display: flex; flex-wrap: wrap; gap: .35rem; }

.job-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.job-row {
  display: grid; grid-template-columns: 3.2rem 1fr auto 6.5rem; gap: .75rem; align-items: center;
  padding: .7rem .4rem; border-top: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.job-row:hover { background: #f8f9fb; }
.job-id, .job-date { color: var(--muted); font-size: .85rem; }
.job-topic { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.steps { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; padding: 0; margin: 1rem 0 0; }
.steps li { padding: .25rem .7rem; border-radius: 999px; background: #eceef2; color: var(--muted); font-size: .82rem; }
.steps li.done { background: var(--ok-bg); color: var(--ok); }
.steps li.current { background: var(--accent); color: #fff; }
.working::before {
  content: ""; display: inline-block; width: .7rem; height: .7rem; margin-right: .4rem; vertical-align: -1px;
  border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stats { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; font-size: .9rem; color: var(--muted); }
.stats strong { color: var(--text); }

.scenes { list-style: none; padding: 0; margin: 1rem 0 0; }
.scene { border: 1px solid var(--line); border-radius: 8px; padding: .75rem; margin-bottom: .6rem; background: #fcfcfd; }
.scene.removed { opacity: .45; }
.scene-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .35rem; }
.scene-number {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: .8rem; font-weight: 700;
}
.delete { font-weight: normal; color: var(--muted); font-size: .85rem; }
.scene-text { font-size: 1rem; }
.scene-visuals { display: grid; grid-template-columns: 1fr 1fr 8rem; gap: .5rem; margin-top: .5rem; }
.scene-visuals label { font-weight: normal; color: var(--muted); font-size: .8rem; }
.scene-visuals input { font-size: .85rem; padding: .4rem .5rem; }

.video-card { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 1.5rem; }
.video-frame { background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 9 / 16; }
.video-frame video { width: 100%; height: 100%; display: block; }
.copy-block { position: relative; margin-top: .6rem; }
.copy-label { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
.copy-block pre {
  margin: .25rem 0 0; padding: .6rem 4.5rem .6rem .7rem; background: #f6f7f9; border: 1px solid var(--line);
  border-radius: 8px; white-space: pre-wrap; word-break: break-word; font: inherit; font-size: .9rem;
}
.copy-block button { position: absolute; right: .4rem; bottom: .4rem; }

.script-read { padding-left: 1.2rem; }
.script-read li { margin: .25rem 0; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--muted); }
details[open] summary::before { content: "▾ "; }
.events { list-style: none; padding: 0; margin: .75rem 0 0; font-size: .9rem; }
.events li { padding: .35rem 0; border-top: 1px solid var(--line); }
.event-time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: .35rem; }
.discard { margin-top: 1rem; text-align: right; }

/* --- Navegación ------------------------------------------------------------ */
.topbar { gap: 1rem; }
.nav { display: flex; gap: .25rem; margin-right: auto; margin-left: 1rem; }
.nav a { color: #cfd3dc; text-decoration: none; padding: .3rem .6rem; border-radius: 6px; font-size: .92rem; }
.nav a:hover { color: #fff; }
.nav a.active { background: #2a2f3c; color: #fff; }

/* --- Series y planes ---------------------------------------------------------- */
.lead { font-size: 1.02rem; margin: .25rem 0 .5rem; }
.callout { border-color: #c9d6ff; background: linear-gradient(180deg, #f4f7ff, #fff); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; }
.stack .grid-2 > *, .stack .grid-3 > * { margin-top: 0; }
.series-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: .75rem; align-items: center;
  padding: .7rem .4rem; border-top: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.series-row:hover { background: #f8f9fb; }
.series-item { display: flex; align-items: center; gap: .5rem; border-top: 1px solid var(--line); }
.series-item .series-row { flex: 1; border-top: none; min-width: 0; }
.series-item form { flex: none; padding-right: .4rem; }
.rationale { background: #f6f7f9; border-left: 3px solid var(--accent); padding: .7rem .9rem; border-radius: 6px; margin-top: .75rem; }
.rationale p { margin: .3rem 0 0; }
.new-plan { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .75rem; }
.weeks { padding-left: 1.2rem; margin: .75rem 0 0; }
.weeks li { margin: .2rem 0; }
.plan-summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-top: 1rem; }
.table-wrap { overflow-x: auto; margin-top: .75rem; }
.research { width: 100%; border-collapse: collapse; font-size: .88rem; }
.research th, .research td { text-align: left; padding: .45rem .5rem; border-top: 1px solid var(--line); vertical-align: top; }
.research .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.day-card h2 { display: flex; align-items: center; gap: .5rem; }
.day-card.past { opacity: .7; }
.plan-items { list-style: none; margin: .5rem 0 0; padding: 0; }
.plan-item { border-top: 1px solid var(--line); padding: .8rem 0; scroll-margin-top: 1rem; }
.plan-item:target { background: #f4f7ff; }
.plan-item.status-discarded .plan-topic, .plan-item.status-discarded .plan-hook { text-decoration: line-through; color: var(--muted); }
.plan-item-head { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.plan-item-head a.pill { text-decoration: none; }
.plan-topic { font-weight: 700; font-size: 1.02rem; margin: .4rem 0 .2rem; }
.plan-hook { margin: .15rem 0; font-style: italic; }
.plan-why { margin: .25rem 0 0; font-size: .88rem; color: var(--ok); }
.plan-item p.meta { margin: .15rem 0; font-size: .9rem; }
.plan-item-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: flex-start; margin-top: .55rem; }
.inline-form summary { list-style: none; }
.inline-form summary::before { content: none; }
.inline-form[open] { flex-basis: 100%; order: 10; }
.inline-form[open] summary { margin-bottom: .5rem; }
.inline-form form { background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: .7rem; }
.plan-badge { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .5rem 0 0; }
.calendar-days { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.calendar-list { list-style: none; padding: 0; margin: .25rem 0 0; }
.calendar-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem 0; border-top: 1px solid var(--line); }
/* --- Personajes ---------------------------------------------------------------- */
.checker {
  background-color: #fff;
  background-image: linear-gradient(45deg, #e9ebef 25%, transparent 25%), linear-gradient(-45deg, #e9ebef 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e9ebef 75%), linear-gradient(-45deg, transparent 75%, #e9ebef 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.character-grid { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
.character-card { display: flex; flex-direction: column; gap: .35rem; color: var(--text); text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: .6rem; }
.character-card:hover { border-color: #c5cad3; }
.character-thumb { aspect-ratio: 1; border-radius: 8px; overflow: hidden; display: grid; place-items: center; }
.character-thumb img { width: 100%; height: 100%; object-fit: contain; }
.character-thumb.small { width: 72px; flex: none; }
.character-inline { display: flex; align-items: center; gap: .8rem; }
.expression-grid { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.expression { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; scroll-margin-top: 1rem; }
.expression.missing { border-style: dashed; border-color: #d3a54a; }
.expression:target { outline: 2px solid var(--accent); }
.expression-image { aspect-ratio: 1; display: grid; place-items: center; }
.expression-image img { width: 100%; height: 100%; object-fit: contain; }
.expression-body { padding: .7rem; display: flex; flex-direction: column; gap: .4rem; }
.expression-body p { margin: 0; }
.pose code { display: block; margin-top: .2rem; white-space: normal; font-size: .8rem; }
.voice-picker { display: flex; gap: .5rem; align-items: center; margin-top: .3rem; }
.voice-picker select { margin-top: 0; flex: 1; min-width: 0; }
.voice-picker button { flex: none; white-space: nowrap; }
.upload { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.upload input[type="file"] { font-size: .8rem; max-width: 100%; }
.prompt-help { margin-top: .6rem; }
.prompt { white-space: pre-wrap; background: #f6f7f9; border: 1px solid var(--line); border-radius: 8px; padding: .6rem; font-size: .85rem; }

code { background: #eceef2; padding: .05rem .3rem; border-radius: 4px; font-size: .88em; }

@media (max-width: 700px) {
  .grid-2, .grid-3, .calendar-days { grid-template-columns: 1fr; }
  .series-row { grid-template-columns: 1fr auto; }
  .series-row > .meta { display: none; }
  .nav { margin-left: .25rem; }
  .job-row { grid-template-columns: 2.6rem 1fr; }
  .job-row .pill { justify-self: start; }
  .job-date { display: none; }
  .scene-visuals { grid-template-columns: 1fr; }
  .video-card { grid-template-columns: 1fr; }
  .video-frame { max-width: 320px; margin: 0 auto; }
  .actions.sticky { justify-content: stretch; }
  .actions.sticky button { flex: 1; }
}
