/* ============================================================================
   Montarium Studio · sistema de diseño
   Tinta #1B2440 y ámbar #F2A33C. El ámbar nunca lleva letra blanca encima
   (2,1:1): en claro los botones son tinta; en oscuro, ámbar con letra tinta.
   Móvil primero. Modo claro y oscuro según el sistema.
   ========================================================================== */

:root {
  --bg: #f9f9f9;
  --surface: #ffffff;
  --surface-2: #f2f2f2;
  --surface-3: #e8e8e8;
  --border: #e5e5e5;
  --border-strong: #cfcfcf;
  --text: #0f0f0f;
  --text-2: #3a3a3a;
  --muted: #606060;

  --primary: #1b2440;
  --primary-hover: #2b3a67;
  --primary-soft: #eceef5;
  --primary-text: #24345f;
  --on-primary: #ffffff;
  --accent: #f2a33c;
  --accent-soft: #fdf1e0;
  --accent-text: #a55a06;
  --gradient: linear-gradient(135deg, #1b2440 0%, #2b3a67 100%);

  --ok: #15803d;      --ok-soft: #dcfce7;
  --warn: #b45309;    --warn-soft: #fef3c7;
  --bad: #dc2626;     --bad-soft: #fee2e2;
  --work: #0369a1;    --work-soft: #e0f2fe;
  --action: #b45309;  --action-soft: #fff4e5;
  --neutral: #475569; --neutral-soft: #eef1f5;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 41, .06);
  --shadow: 0 1px 3px rgba(15, 23, 41, .06), 0 8px 24px -12px rgba(15, 23, 41, .12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 41, .35);
  --ring: 0 0 0 3px rgba(242, 163, 60, .45);
  --glow: rgba(27, 36, 64, .45);

  --sidebar-w: 252px;
  --tabbar-h: 64px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1320;
    --surface: #161b2b;
    --surface-2: #1d2335;
    --surface-3: #252c41;
    --border: #2a3147;
    --border-strong: #3a4360;
    --text: #e8eaf2;
    --text-2: #c3c8d6;
    --muted: #8f98ad;
    --primary: #f2a33c;
    --primary-hover: #f5b562;
    --primary-soft: rgba(242, 163, 60, .15);
    --primary-text: #f5b562;
    --on-primary: #12172a;
    --accent: #f2a33c;
    --accent-soft: rgba(242, 163, 60, .15);
    --accent-text: #f5b562;
    --gradient: linear-gradient(135deg, #f2a33c 0%, #f5b562 100%);
    --ok: #4ade80;      --ok-soft: rgba(74, 222, 128, .13);
    --warn: #fbbf24;    --warn-soft: rgba(251, 191, 36, .13);
    --bad: #f87171;     --bad-soft: rgba(248, 113, 113, .14);
    --work: #38bdf8;    --work-soft: rgba(56, 189, 248, .13);
    --action: #fbbf24;  --action-soft: rgba(251, 191, 36, .14);
    --neutral: #94a3b8; --neutral-soft: rgba(148, 163, 184, .12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px -14px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .75);
    --ring: 0 0 0 3px rgba(242, 163, 60, .4);
    --glow: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* --- Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
code { font-family: var(--mono); font-size: .85em; background: var(--surface-3); padding: .1rem .35rem; border-radius: 5px; }
pre { font-family: inherit; margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

.icon {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-fill { fill: currentColor; stroke: none; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* --- Estructura -------------------------------------------------------------- */

.main { min-height: 100vh; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 1rem 1rem calc(var(--tabbar-h) + 2rem); }
.container.narrow { max-width: 760px; }
body.bare .container { padding-bottom: 2rem; }

.sidebar { display: none; }
.mobile-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: .55rem 1rem; padding-top: calc(.55rem + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.mobile-bar-actions { display: flex; align-items: center; gap: .25rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 750; font-size: 1.1rem; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 9px; box-shadow: 0 6px 16px -6px var(--glow); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar .nav-link {
  flex-direction: column; gap: .15rem; justify-content: center; padding: .35rem .2rem; margin: 0 .15rem;
  font-size: .68rem; font-weight: 600; position: relative;
}
.tabbar .nav-link .icon { width: 1.35rem; height: 1.35rem; }
.tabbar .nav-link.active { background: transparent; color: var(--primary-text); }
.tabbar .nav-count { position: absolute; top: .1rem; left: calc(50% + .35rem); }
.tabbar-add {
  justify-self: center; width: 48px; height: 48px; border-radius: 16px; border: 0; cursor: pointer;
  background: var(--gradient); color: var(--on-primary); display: grid; place-items: center;
  box-shadow: 0 10px 24px -10px var(--glow);
}
.tabbar-add .icon { width: 1.5rem; height: 1.5rem; stroke-width: 2.4; }

.nav-link {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px;
  color: var(--text-2); font-weight: 550;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary-text); }
.nav-label { flex: 1; }
.nav-count {
  min-width: 1.35rem; height: 1.35rem; padding: 0 .4rem; border-radius: 999px;
  background: var(--action); color: #fff; font-size: .72rem; font-weight: 700; display: inline-grid; place-items: center;
}
.nav-section { margin: 1.2rem .75rem .35rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.system-status { display: inline-flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--text-2); }
.status-dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); flex: none; }
.status-ok .status-dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.status-busy .status-dot { background: #0ea5e9; animation: pulse 1.6s infinite; }
.status-waiting .status-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .2); }
.status-error .status-dot { background: #ef4444; animation: pulse 1.6s infinite; }
.system-status.compact { padding: .5rem; }

@media (min-width: 960px) {
  body.with-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 1rem;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 1.25rem 1rem; background: var(--surface); border-right: 1px solid var(--border);
  }
  .sidebar .brand { padding: .25rem .5rem .5rem; }
  .sidebar .nav { display: flex; flex-direction: column; gap: .15rem; }
  .sidebar-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .75rem .5rem 0; border-top: 1px solid var(--border); }
  .sidebar-foot .lang-picker { flex-basis: 100%; }
  .mobile-bar, .tabbar { display: none; }
  .container { padding: 2rem 2.5rem 3rem; }
  body.bare { display: block; }
}

/* --- Cabecera de página ----------------------------------------------------- */

.page-header { margin: .25rem 0 1.25rem; }
.page-header-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; }
.page-header-text { min-width: 0; }
.page-header h1 { font-size: 1.45rem; overflow-wrap: anywhere; }
.page-subtitle { margin-top: .3rem; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.back-link { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .88rem; font-weight: 550; margin-bottom: .6rem; }
.back-link:hover { color: var(--text); text-decoration: none; }
@media (min-width: 960px) { .page-header h1 { font-size: 1.75rem; } }

.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-top: .55rem; color: var(--muted); font-size: .85rem; }
.meta-row .sep { opacity: .5; }

/* --- Botones ---------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 40px; padding: .5rem .95rem; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .92rem; line-height: 1.2; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 16px -8px var(--glow); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-gradient { background: var(--gradient); color: var(--on-primary); box-shadow: 0 8px 20px -10px var(--glow); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-sm { min-height: 32px; padding: .3rem .65rem; font-size: .84rem; border-radius: 8px; }
.btn-lg { min-height: 48px; padding: .7rem 1.2rem; font-size: 1rem; }
.btn-icon { min-height: 38px; width: 38px; padding: 0; }
.btn-block { width: 100%; }
.btn.is-loading::after {
  content: ""; width: .9em; height: .9em; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite;
}
.link-danger { color: var(--bad); }

/* --- Tarjetas --------------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card + .card, .stack-lg > * + * { margin-top: 1rem; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem .75rem; padding: 1rem 1.1rem .25rem; }
.card-head h2 { display: flex; align-items: center; gap: .5rem; }
.card-head h2 .icon { color: var(--muted); }
.card-head .card-link { font-size: .87rem; font-weight: 600; display: inline-flex; align-items: center; gap: .2rem; }
.card-body { padding: 1rem 1.1rem 1.1rem; }
.card-body > * + * { margin-top: .85rem; }
.card-foot { padding: .85rem 1.1rem; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
@media (min-width: 720px) {
  .card-head { padding: 1.2rem 1.4rem .3rem; }
  .card-body { padding: 1.1rem 1.4rem 1.4rem; }
  .card-foot { padding: .9rem 1.4rem; }
}

.grid { display: grid; gap: 1rem; }
.grid > *, .grid-2 > *, .grid-3 > *, .grid-4 > * { margin-top: 0 !important; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.layout-main-side { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1080px) { .layout-main-side { grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; } .sticky-side { position: sticky; top: 1.5rem; } }

/* --- Estadísticas de portada ------------------------------------------------ */

.stat-card {
  display: flex; flex-direction: column; gap: .35rem; padding: 1rem; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.stat-card:hover { text-decoration: none; border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.stat-value { font-size: 1.85rem; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.stat-hint { font-size: .78rem; color: var(--muted); }
.tone-bg-action { background: var(--action-soft); color: var(--action); }
.tone-bg-work { background: var(--work-soft); color: var(--work); }
.tone-bg-ok { background: var(--ok-soft); color: var(--ok); }
.tone-bg-bad { background: var(--bad-soft); color: var(--bad); }
.tone-bg-wait { background: var(--warn-soft); color: var(--warn); }
.tone-bg-muted { background: var(--neutral-soft); color: var(--neutral); }
.stat-card.highlight { border-color: color-mix(in srgb, var(--action) 45%, var(--border)); background: linear-gradient(180deg, var(--action-soft), var(--surface) 70%); }

.hero {
  position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 1.4rem;
  background: var(--gradient); color: var(--on-primary); box-shadow: var(--shadow);
}
.hero h1, .hero h2 { color: var(--on-primary); }
.hero p { color: rgba(255, 255, 255, .88); margin-top: .4rem; max-width: 60ch; }
.hero .btn-secondary { background: #fff; color: #312e81; border-color: transparent; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(255, 255, 255, .12); }

/* --- Badges ----------------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: .38rem; padding: .18rem .6rem .18rem .5rem; border-radius: 999px;
  font-size: .76rem; font-weight: 650; white-space: nowrap; line-height: 1.4;
}
.badge-dot { width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; flex: none; }
.badge-dot.pulse { animation: pulse 1.4s infinite; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-work { background: var(--work-soft); color: var(--work); }
.badge-action { background: var(--action-soft); color: var(--action); }
.badge-wait { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: var(--neutral-soft); color: var(--neutral); }
.badge-plain { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge-plain .badge-dot { display: none; }

/* --- Listas ----------------------------------------------------------------- */

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .85rem;
  padding: .85rem 1.1rem; color: var(--text); border-top: 1px solid var(--border);
}
.list > li:first-child > .list-item, .list > .list-item:first-child { border-top: 0; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item.compact { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; padding: .7rem .9rem; }
.list-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.list-main { min-width: 0; }
.list-title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-title.wrap { white-space: normal; overflow-wrap: anywhere; }
.list-sub { display: flex; flex-wrap: wrap; gap: .15rem .6rem; margin-top: .15rem; font-size: .8rem; color: var(--muted); }
.list-end { display: flex; align-items: center; gap: .5rem; }
.list-end .icon { color: var(--muted); }
@media (min-width: 720px) { .list-item { padding: .9rem 1.4rem; } }
@media (max-width: 560px) {
  .list-item.stackable { grid-template-columns: auto minmax(0, 1fr); }
  .list-item.stackable .list-end { grid-column: 2; justify-content: flex-start; }
}

.empty-state { text-align: center; padding: 2.2rem 1rem; }
.empty-icon { width: 54px; height: 54px; margin: 0 auto .8rem; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.empty-icon .icon { width: 1.6rem; height: 1.6rem; }
.empty-title { font-weight: 650; }
.empty-text { color: var(--muted); margin-top: .3rem; max-width: 46ch; margin-left: auto; margin-right: auto; }
.empty-actions { margin-top: 1rem; display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; }

/* --- Filtros ---------------------------------------------------------------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; justify-content: space-between; margin-bottom: 1rem; }
.segmented {
  display: flex; gap: .25rem; padding: .25rem; border-radius: 12px; background: var(--surface-3);
  overflow-x: auto; scrollbar-width: none; max-width: 100%;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: .4rem; padding: .42rem .75rem; border-radius: 9px; border: 0;
  background: transparent; color: var(--text-2); font: inherit; font-size: .86rem; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.segmented a:hover, .segmented button:hover { color: var(--text); text-decoration: none; }
.segmented .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented .count { font-size: .72rem; padding: 0 .38rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.segmented .active .count { background: var(--primary-soft); color: var(--primary-text); }
@media (max-width: 720px) {
  /* En móvil, todas las opciones a la vista: varias filas en vez de desplazamiento oculto. */
  .toolbar { flex-direction: column; align-items: stretch; }
  .segmented { flex-wrap: wrap; overflow: visible; }
  .segmented a, .segmented button { flex: 1 1 auto; justify-content: center; }
  .toolbar .search { max-width: none; flex: none; }
  .tabs { overflow: visible; }
  .tab { flex: 1 1 0; justify-content: center; padding: .7rem .35rem; font-size: .86rem; text-align: center; white-space: normal; line-height: 1.2; }
  .tab .icon { display: none; }
}
.filters { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1 1 320px; justify-content: flex-end; }
.filters .select { width: auto; min-width: 180px; }
.filters .search { flex: 1 1 200px; }
@media (max-width: 720px) { .filters { flex: none; } .filters .select { flex: 1 1 100%; } }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-size: .86rem; color: var(--muted); margin-bottom: .6rem; }
.breadcrumb a { color: var(--muted); font-weight: 550; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .icon { width: .9rem; height: .9rem; opacity: .6; }
.breadcrumb span { color: var(--text-2); font-weight: 600; }
.series-chip { display: inline-flex; align-items: center; gap: .25rem; color: var(--primary-text); font-weight: 600; }
.series-chip .icon { width: .85rem; height: .85rem; }
.search { position: relative; flex: 1 1 220px; max-width: 360px; }
.search .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 2.3rem; }

/* --- Formularios ------------------------------------------------------------ */

.field { display: flex; flex-direction: column; gap: .4rem; }
.field-label { font-size: .86rem; font-weight: 600; color: var(--text); }
.field-label .optional { font-weight: 500; color: var(--muted); }
.help { font-size: .8rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: .6rem .8rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 2.2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2369738a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; background-size: 1rem; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .8; }
.form-stack > * + * { margin-top: 1rem; }
.form-row { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; align-items: center; }
.form-actions.start { justify-content: flex-start; }

.switch { display: flex; align-items: flex-start; gap: .75rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); flex: none; transition: background .2s; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch-text strong { display: block; font-weight: 600; }
.switch-text span { font-size: .82rem; color: var(--muted); }

.voice-picker { display: flex; gap: .5rem; }
.voice-picker .select { flex: 1; min-width: 0; }
@media (max-width: 480px) { .voice-picker { flex-direction: column; } }

/* --- Avisos ----------------------------------------------------------------- */

.alert { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent; }
.alert > .icon { margin-top: .15rem; width: 1.2rem; height: 1.2rem; }
.alert p { margin-top: .2rem; color: inherit; opacity: .95; }
.alert strong { font-weight: 650; }
.alert-danger { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info { background: var(--work-soft); color: var(--work); border-color: color-mix(in srgb, var(--work) 22%, transparent); }
.alert-action { background: var(--action-soft); color: var(--action); border-color: color-mix(in srgb, var(--action) 22%, transparent); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.alert code { background: rgba(0, 0, 0, .08); color: inherit; }
.alert .btn { margin-top: .6rem; }
.alert pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .78rem; margin-top: .5rem; max-height: 220px; overflow: auto; }

.toast-region { position: fixed; z-index: 100; left: 1rem; right: 1rem; top: calc(.75rem + env(safe-area-inset-top)); display: flex; justify-content: center; pointer-events: none; }
@media (min-width: 960px) { .toast-region { left: auto; right: 1.5rem; top: 1.25rem; justify-content: flex-end; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: .6rem; max-width: 520px; padding: .75rem .8rem .75rem 1rem;
  border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-size: .9rem; font-weight: 550;
  animation: toast-in .25s ease-out;
}
.toast .icon { width: 1.15rem; height: 1.15rem; }
.toast-ok .icon { color: #4ade80; }
.toast-bad { background: #b91c1c; color: #fff; }
.toast-close { border: 0; background: transparent; color: inherit; opacity: .7; cursor: pointer; padding: .2rem; border-radius: 6px; display: grid; }
.toast-close:hover { opacity: 1; }
.toast.leaving { animation: toast-out .2s ease-in forwards; }

/* --- Diálogos --------------------------------------------------------------- */

.dialog {
  width: min(560px, calc(100vw - 1.5rem)); padding: 0; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 12, 20, .55); backdrop-filter: blur(3px); }
.dialog[open] { animation: dialog-in .2s ease-out; }
.dialog-body { padding: 1.3rem; }
.dialog-body > * + * { margin-top: 1rem; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dialog-head p { margin-top: .3rem; font-size: .88rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .25rem; }
@media (max-width: 560px) {
  .dialog { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; }
  .dialog-body { padding-bottom: calc(1.3rem + env(safe-area-inset-bottom)); }
  .dialog-actions .btn { flex: 1; }
}

/* --- Pasos del episodio ------------------------------------------------------ */

.stepper { display: flex; gap: .35rem; list-style: none; margin: 1.1rem 0 0; padding: 0; overflow-x: auto; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.step { flex: 1 0 auto; display: flex; align-items: center; gap: .5rem; min-width: 104px; padding: .55rem .7rem; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: .82rem; font-weight: 600; }
.step-icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); flex: none; }
.step-icon .icon { width: 1rem; height: 1rem; }
.step.done { color: var(--ok); background: var(--ok-soft); }
.step.done .step-icon { background: var(--ok); color: #fff; }
.step.current { color: var(--primary-text); background: var(--primary-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent); }
.step.current .step-icon { background: var(--primary); color: var(--on-primary); }

.working-card { display: flex; align-items: center; gap: 1rem; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--primary-soft); border-top-color: var(--primary); animation: spin 1s linear infinite; flex: none; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }

/* --- Editor de guion -------------------------------------------------------- */

.scene-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .75rem; counter-reset: scene; }
.scene { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; transition: opacity .2s, border-color .2s; }
.scene:focus-within { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.scene.removed { opacity: .45; }
.scene.removed .scene-text { text-decoration: line-through; }
.scene-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.scene-num { display: inline-flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 650; color: var(--muted); }
.scene-num b { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); font-size: .8rem; }
.scene-words { font-size: .75rem; color: var(--muted); }
.scene-remove { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--muted); cursor: pointer; padding: .25rem .5rem; border-radius: 7px; }
.scene-remove:hover { background: var(--bad-soft); color: var(--bad); }
.scene-remove input { accent-color: var(--bad); }
.scene-text { font-size: 1rem; min-height: 64px; border-color: var(--border); }
.scene-details { margin-top: .5rem; }
/* `flex` y no `inline-flex`: en linea el summary crece con su contenido, asi que
   el `max-width: 100%` del adelanto no limitaba nada y la frase se salia de la
   tarjeta en vez de cortarse. */
.scene-details summary { font-size: .8rem; color: var(--muted); font-weight: 600; cursor: pointer; list-style: none; display: flex; align-items: center; gap: .35rem; padding: .25rem .1rem; white-space: nowrap; }
.scene-details summary::-webkit-details-marker { display: none; }
.scene-details summary .icon { width: .95rem; height: .95rem; transition: transform .2s; flex: none; }
.scene-details[open] summary .icon.chev { transform: rotate(90deg); }
.scene-details .form-row { margin-top: .5rem; gap: .6rem; }
.scene-details .input, .scene-details .select { min-height: 38px; font-size: .88rem; }
/* `min-width: 0` es lo que permite que un hijo flex se encoja por debajo de su
   contenido; sin eso `text-overflow` no llega a aplicarse nunca. */
.visual-preview { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }

.duration-card .meter { position: relative; height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: .8rem 0 .4rem; }
.meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--bad); transition: width .25s, background .25s; }
.meter-fill.ok { background: #22c55e; }
.meter-fill.long { background: #f59e0b; }
.meter-target { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--ok) 18%, transparent); border-left: 2px dashed color-mix(in srgb, var(--ok) 70%, transparent); border-right: 2px dashed color-mix(in srgb, var(--ok) 70%, transparent); }
.duration-big { font-size: 2rem; font-weight: 750; letter-spacing: -.03em; }
.duration-stats { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .85rem; color: var(--muted); }
.duration-stats strong { color: var(--text); }

.action-bar {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + .5rem); z-index: 20;
  display: flex; align-items: center; gap: .5rem; margin-top: 1rem; padding: .6rem; border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.action-bar .action-bar-info { flex: 1; min-width: 0; font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: .5rem; }
.action-bar .btn { flex: none; }
@media (min-width: 960px) { .action-bar { bottom: 1rem; } }
@media (min-width: 1080px) { .action-bar.mobile-only { display: none; } }
@media (max-width: 1079px) { .desktop-only { display: none !important; } }

/* --- Vídeo ------------------------------------------------------------------ */

.video-layout { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 820px) { .video-layout { grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); align-items: start; } }
.video-frame { background: #000; border-radius: 16px; overflow: hidden; aspect-ratio: 9 / 16; max-width: 340px; width: 100%; margin: 0 auto; box-shadow: var(--shadow); }
.video-frame video { width: 100%; height: 100%; display: block; }
.copy-field { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); overflow: hidden; }
.copy-field-head { display: flex; align-items: center; justify-content: space-between; padding: .35rem .4rem .35rem .8rem; border-bottom: 1px solid var(--border); }
.copy-field pre { padding: .7rem .8rem; white-space: pre-wrap; word-break: break-word; font-size: .9rem; }
.copy-field .field-label { font-size: .78rem; color: var(--muted); }
/* La hoja de publicacion son setenta lineas de ancho fijo: se deja con
   su propio scroll para que no empuje la pagina, y sin ajuste de linea
   para que los recuadros no se deshagan en el movil. */
.copy-field.sheet pre { max-height: 24rem; overflow: auto; white-space: pre; font-size: .82rem; line-height: 1.45; }

/* --- Detalles plegables ----------------------------------------------------- */

.disclosure > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.1rem; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary h2 { display: flex; align-items: center; gap: .5rem; }
.disclosure > summary h2 .icon { color: var(--muted); }
.disclosure > summary .chev { color: var(--muted); transition: transform .2s; }
.disclosure[open] > summary .chev { transform: rotate(90deg); }
.disclosure > .card-body { padding-top: 0; }
@media (min-width: 720px) { .disclosure > summary { padding: 1.1rem 1.4rem; } }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.35rem; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; left: .3rem; top: .45rem; bottom: -.2rem; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: .3rem; width: .7rem; height: .7rem; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); }
.timeline time { display: block; font-size: .75rem; color: var(--muted); }

/* --- Pestañas --------------------------------------------------------------- */

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: .45rem; padding: .7rem .9rem; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary-text); border-bottom-color: var(--primary); }
.tab .count { font-size: .72rem; padding: 0 .4rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); }

/* --- Series y planes -------------------------------------------------------- */

article.card:has(> .series-card) { display: flex; flex-direction: column; }
.series-card { display: flex; flex: 1; flex-direction: column; gap: .75rem; padding: 1.1rem; color: var(--text); }
.series-card:hover { text-decoration: none; }
.series-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.series-avatar { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--gradient); color: var(--on-primary); font-weight: 750; font-size: 1.1rem; flex: none; }
.series-card h3 { font-size: 1.05rem; }
.series-card p { color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.series-card-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
a.card.interactive { transition: border-color .15s, box-shadow .15s, transform .15s; }
a.card.interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); text-decoration: none; }
.card-new { border-style: dashed; background: transparent; box-shadow: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center; min-height: 170px; color: var(--muted); cursor: pointer; font: inherit; width: 100%; }
.card-new > span { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.card-new:hover { border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }
.card-new .icon { width: 1.6rem; height: 1.6rem; }

.rationale { padding: .9rem 1rem; border-radius: var(--radius); background: var(--surface-2); border-left: 3px solid var(--primary); font-size: .92rem; color: var(--text-2); }
.rationale strong { display: block; color: var(--text); margin-bottom: .25rem; }

.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: flex; }
.progress span { height: 100%; }
.progress .p-approved { background: #22c55e; }
.progress .p-scheduled { background: var(--primary); }
.progress .p-proposed { background: #f59e0b; }
.progress .p-discarded { background: var(--border-strong); }
.legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .8rem; color: var(--muted); margin-top: .55rem; }
.legend i { display: inline-block; width: .6rem; height: .6rem; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }

.week-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.week-list li { display: grid; grid-template-columns: auto 1fr; gap: .1rem .75rem; padding: .6rem .75rem; border-radius: 10px; background: var(--surface-2); font-size: .88rem; }
.week-list .week-n { grid-row: span 2; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); font-weight: 700; font-size: .8rem; }
.week-list .week-dates { font-size: .75rem; color: var(--muted); }

.day-group + .day-group { margin-top: 1.25rem; }
.day-title { display: flex; align-items: center; gap: .5rem; margin: 0 0 .55rem .15rem; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.day-group.past { opacity: .65; }
.topic-card { padding: 1rem; scroll-margin-top: 1rem; }
.topic-card + .topic-card { margin-top: .6rem; }
.topic-card:target { box-shadow: var(--ring); }
.topic-card.status-discarded { opacity: .6; }
.topic-card.status-discarded .topic-title { text-decoration: line-through; }
.topic-top { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.topic-title { font-size: 1.02rem; font-weight: 650; margin-top: .5rem; overflow-wrap: anywhere; }
.topic-hook { margin-top: .35rem; font-style: italic; color: var(--text-2); }
.topic-angle { margin-top: .35rem; font-size: .88rem; color: var(--muted); }
.topic-why { margin-top: .55rem; font-size: .84rem; color: var(--ok); display: flex; gap: .4rem; align-items: flex-start; }
.topic-why .icon { margin-top: .15rem; width: 1rem; height: 1rem; }
.topic-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .8rem; }
.inline-panel { margin-top: .75rem; padding: .85rem; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.inline-panel > * + * { margin-top: .75rem; }
.research-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.research-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: .5rem; border-bottom: 1px solid var(--border); }
.research-table td { padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.research-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* --- Personajes ------------------------------------------------------------- */

.checker {
  background-color: var(--surface);
  background-image: linear-gradient(45deg, var(--surface-3) 25%, transparent 25%), linear-gradient(-45deg, var(--surface-3) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--surface-3) 75%), linear-gradient(-45deg, transparent 75%, var(--surface-3) 75%);
  background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.character-card { padding: .75rem; color: var(--text); display: flex; flex-direction: column; gap: .6rem; }
.character-card:hover { text-decoration: none; }
.character-thumb { aspect-ratio: 1; border-radius: 12px; overflow: hidden; display: grid; place-items: center; }
.character-thumb img { width: 100%; height: 100%; object-fit: contain; }
.character-thumb.small { width: 64px; flex: none; }
.expression-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.expression { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; scroll-margin-top: 1rem; background: var(--surface); }
.expression:target { box-shadow: var(--ring); }
.expression.missing { border-style: dashed; }
.expression-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .6rem; }
.expression-slot { margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.expression-slot figcaption { font-size: .74rem; color: var(--muted); font-weight: 650; }
.expression-image { aspect-ratio: 1; border-radius: 9px; overflow: hidden; display: grid; place-items: center; font-size: .8rem; color: var(--muted); }
.expression-image img { width: 100%; height: 100%; object-fit: contain; }
.expression-body { padding: 0 .8rem .8rem; }
.expression-body > * + * { margin-top: .35rem; }
.pose code { display: block; white-space: normal; font-size: .76rem; margin-top: .25rem; padding: .4rem .5rem; }
.upload { display: flex; flex-direction: column; gap: .3rem; }
.upload input[type="file"] { font-size: .74rem; width: 100%; color: var(--muted); }
.upload input[type="file"]::file-selector-button { font: inherit; font-size: .74rem; font-weight: 600; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 7px; padding: .25rem .5rem; margin-right: .4rem; cursor: pointer; }

/* --- Login ------------------------------------------------------------------ */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background:
  radial-gradient(800px 400px at 10% -10%, rgba(242, 163, 60, .20), transparent 60%),
  radial-gradient(700px 400px at 110% 110%, rgba(236, 72, 153, .18), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; padding: 2rem 1.6rem; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: .7rem; text-align: center; margin-bottom: 1.6rem; }
.auth-logo img { width: 68px; height: 68px; border-radius: 20px; box-shadow: 0 16px 34px -14px var(--glow); }
.auth-logo h1 { font-size: 1.6rem; letter-spacing: -.03em; }
.auth-logo p { color: var(--muted); font-size: .92rem; }
.auth .form-stack .btn { width: 100%; }
.auth-foot { margin-top: 1.2rem; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; font-size: .78rem; color: var(--muted); }
body.bare .container { max-width: none; padding: 0; }

/* Aviso de reintento: el boton y la hora del automatico, en una fila. */
.retry-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem; margin-top: .7rem; }

/* Musica: fila de subida y reproductor de cada pista. */
.upload-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.track-player { width: 100%; max-width: 420px; height: 34px; margin-top: .35rem; }
.track-previews { margin-top: .6rem; display: grid; gap: .5rem; }
.track-previews summary { cursor: pointer; font-size: .8rem; color: var(--muted); }

/* --- Selector de idioma ------------------------------------------------------ */

.lang-picker { display: inline-flex; align-items: center; gap: .35rem; min-width: 0; }
.lang-picker .icon { width: 16px; height: 16px; color: var(--muted); flex: none; }
.lang-picker .select {
  padding: .3rem 1.6rem .3rem .45rem; font-size: .78rem; font-weight: 600;
  height: auto; min-height: 0; background-position: right .35rem center;
}
.lang-picker.compact .icon { display: none; }
.lang-picker.compact .select { max-width: 6.5rem; }

/* --- Ayuda ------------------------------------------------------------------- */

.help-toc ul { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .15rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.help-toc a { display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem; border-radius: var(--radius-sm); color: var(--text); font-size: .86rem; }
.help-toc a:hover { background: var(--surface-2); text-decoration: none; }
.help-toc .icon { color: var(--primary); flex: none; }
.help-section { margin-top: 1rem; scroll-margin-top: 5rem; }
.help-section p { margin: 0 0 .7rem; line-height: 1.65; }
.help-section p:last-child { margin-bottom: 0; }
.help-chain {
  display: inline-block; padding: .35rem .7rem; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-weight: 650; font-size: .85rem;
}
.help-list { margin: .2rem 0 .8rem; padding-left: 1.1rem; display: grid; gap: .5rem; }
.help-list li { line-height: 1.6; }
.help-steps { margin: 0; padding-left: 1.3rem; display: grid; gap: .6rem; }
.help-steps li { line-height: 1.6; }
.help-states { margin: .4rem 0 0; display: grid; gap: .5rem; }
.help-states > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; }
.help-states dt { flex: none; }
.help-states dd { margin: 0; color: var(--muted); font-size: .9rem; flex: 1; min-width: 180px; }
.faq { border-top: 1px solid var(--border); padding: .2rem 0; }
.faq:first-of-type { border-top: 0; }
.faq > summary { display: flex; align-items: center; gap: .5rem; padding: .7rem 0; cursor: pointer; font-weight: 650; list-style: none; }
.faq > summary::-webkit-details-marker { display: none; }
.faq > summary .chev { margin-left: auto; transition: transform .18s ease; color: var(--muted); }
.faq[open] > summary .chev { transform: rotate(90deg); }
.faq > p { margin: 0 0 .8rem; color: var(--muted); line-height: 1.6; }

/* --- Animaciones ------------------------------------------------------------ */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* --- Estudio --------------------------------------------------------------- */
.list-item.flex { display: flex; align-items: center; justify-content: space-between; gap: .85rem; }
.list-item.flex .list-main { flex: 1; display: flex; flex-direction: column; gap: .15rem; }
ol.escaleta { margin: 0; padding-left: 1.4rem; display: grid; gap: .55rem; }
ol.escaleta li { line-height: 1.45; }

/* --- Estudio: canales, asistente y pasos -------------------------------------- */
.estudio-grid > .card { margin: 0; }
.estudio-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.canal-card { display: flex; flex-direction: column; gap: .7rem; padding: 1.1rem; color: var(--text); }
.canal-card:hover { text-decoration: none; border-color: var(--primary); }
.canal-top { display: flex; align-items: center; gap: .75rem; }
.canal-avatar { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--gradient); color: var(--on-primary); font-weight: 800; font-size: 1.15rem; flex: none; overflow: hidden; }
.canal-avatar img { width: 100%; height: 100%; object-fit: cover; }
.canal-avatar.redondo { border-radius: 50%; background: none; }
.avatar-fila { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.avatar-mini { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-texto { display: flex; flex-direction: column; gap: .3rem; flex: 1 1 16rem; min-width: 0; }
.canal-card h3 { font-size: 1.05rem; margin: 0; }
/* Nombre y linea de debajo, en un renglon cada uno: con dos, el bloque
   crecia y la foto, centrada con el, bajaba respecto a las otras tarjetas. */
.canal-top > div { min-width: 0; }
.canal-top h3, .canal-top .small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.canal-card p { margin: 0; color: var(--muted); font-size: .88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.canal-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.paleta { display: inline-flex; gap: 3px; }
.paleta i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border-strong); display: inline-block; }

.pasos-titulo { display: flex; align-items: center; gap: .6rem; margin: 0 0 .9rem; font-size: 1.1rem; }
.pasos-titulo .num { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: .95rem; flex: none; }

.eleccion { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.eleccion-op { position: relative; display: flex; flex-direction: column; gap: .45rem; padding: 1.1rem; border: 1.5px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s; }
.eleccion-op:hover { border-color: var(--border-strong); }
.eleccion-op input { position: absolute; top: 1rem; right: 1rem; accent-color: var(--primary); width: 1.1rem; height: 1.1rem; }
.eleccion-op .eleccion-icono { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.eleccion-op strong { font-size: 1rem; padding-right: 1.6rem; }
.eleccion-op span.muted { font-size: .86rem; line-height: 1.45; }
.eleccion-op:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--ring); }
.eleccion-panel { margin-top: 1rem; }
.eleccion-panel[hidden] { display: none; }

.tema-op { display: flex; align-items: flex-start; gap: .7rem; padding: .75rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.tema-op:hover { border-color: var(--border-strong); }
.tema-op input { margin-top: .2rem; accent-color: var(--primary); width: 1.05rem; height: 1.05rem; flex: none; }
.tema-op:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.tema-op .tema-texto { flex: 1; line-height: 1.45; }
.temas { display: grid; gap: .55rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.puntos { display: inline-flex; gap: 4px; align-items: center; }
.puntos i { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-3); display: inline-block; }
.puntos i.hecho { background: var(--ok); }
.puntos i.pendiente { background: var(--warn); }
.puntos i.ahora { background: var(--primary); animation: pulse 1.6s infinite; }

.video-fila { display: flex; align-items: center; gap: .85rem; padding: .85rem 1rem; border-top: 1px solid var(--border); color: var(--text); }
.video-fila:first-child { border-top: 0; }
.video-fila:hover { background: var(--surface-2); text-decoration: none; }
.video-fila .video-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.video-fila .video-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.accion-grande { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding: 1.2rem; border-radius: var(--radius-lg); background: var(--primary-soft); }
.accion-grande .accion-texto { flex: 1; min-width: 220px; }
.accion-grande .accion-texto strong { display: block; font-size: 1.05rem; margin-bottom: .2rem; }
.muestrario { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
details.mas { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: .4rem; }
details.mas > summary { cursor: pointer; font-weight: 650; color: var(--muted); padding: .5rem 0; }
@media (max-width: 640px) { .temas { grid-template-columns: 1fr; } .accion-grande .btn { width: 100%; justify-content: center; } }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
/* Un nicho largo en una pastilla: que parta en lineas, no que se salga. */
.chips .badge { white-space: normal; max-width: 100%; }
.chips.abajo { align-items: flex-end; gap: 1rem; }

/* Las paredes del plato: una miniatura por opcion. */
.paredes { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.paredes .eleccion-op { padding: .6rem; gap: .5rem; }
.paredes .eleccion-op img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; display: block; }
.paredes .eleccion-op input[type=radio] { top: .9rem; right: .9rem; }
.paredes .eleccion-op strong { display: flex; align-items: center; gap: .45rem; font-size: .9rem; }
.paredes .muestra { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); flex: none; }
.paredes .eleccion-op input[type=color] { position: static; width: 28px; height: 22px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: none; cursor: pointer; }

/* Una casilla con su explicacion debajo, cada una en su linea. */
.casilla { display: flex; flex-direction: column; gap: .2rem; }
.casilla .help { padding-left: 1.5rem; }

/* Paso 0: lo que hay que dejar listo antes del primer video. */
.prep > summary { cursor: pointer; display: flex; align-items: center; gap: .6rem; list-style: none; }
.prep > summary::-webkit-details-marker { display: none; }
.prep-item { display: flex; gap: .85rem; padding: .9rem 0; border-top: 1px solid var(--border); }
.prep-item:first-of-type { margin-top: .9rem; }
.prep-estado { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; background: var(--action-soft); color: var(--action); }
.prep-item.hecho .prep-estado { background: var(--ok-soft); color: var(--ok); }
.prep-estado .icon { width: 16px; height: 16px; }
.prep-cuerpo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .45rem; }
.prep-item.hecho .prep-cuerpo { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: .6rem; }
.muestra-linea { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; border: 1px solid var(--border); }
.resumen-crear { margin: 0; color: var(--muted); }
.resumen-crear .ok { color: var(--ok); font-weight: 600; }
.resumen-crear .falta { color: var(--action); font-weight: 600; }

/* El kit y los prompts de las poses: cada recuadro separado, y su nota pegada
   a el, no al siguiente. (Colgaban de un `.prep` que la pagina ya no tiene.) */
details.mas .copy-field { margin-top: 1.6rem; }
details.mas > .help:not(.kit-nota) + .copy-field, details.mas > summary + .copy-field { margin-top: .8rem; }
details.mas .kit-nota { margin: .55rem 0 0 .2rem; line-height: 1.55; }
details.mas > form { margin-top: 1.6rem; }

/* Cada cancion: el nombre arriba y, debajo, el reproductor y «Quitar». Todas
   iguales, sea cual sea lo largo del nombre. */
.musica-fila { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .35rem .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.musica-fila .musica-nombre { grid-column: 1 / -1; font-weight: 600; overflow-wrap: anywhere; }
.musica-fila audio { width: 100%; height: 2.2rem; }
.musica-fila form { margin: 0; }
.musica-receta { border: 1px solid var(--border); border-radius: .6rem; padding: .7rem .9rem; }
.musica-receta ol { margin: .4rem 0 0; padding-left: 1.2rem; display: grid; gap: .35rem; }

/* --- Rediseño 2026-11: inicio con «te toca», canal por pestañas -------------- */
.seccion-titulo { font-size: 1.05rem; margin: 1.4rem 0 .7rem; }
.toca-lista { display: flex; flex-direction: column; gap: .55rem; padding: .6rem 1.1rem 1.1rem; }
.toca-fila { display: flex; align-items: center; gap: .85rem; padding: .8rem 1rem; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--action) 30%, transparent); background: var(--action-soft); color: var(--text); text-decoration: none; }
.toca-fila:hover { border-color: var(--action); }
.toca-fila.toca-fallo { border-color: color-mix(in srgb, var(--bad) 30%, transparent); background: var(--bad-soft); }
.toca-icono { width: 36px; height: 36px; flex: none; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--action) 18%, transparent); color: var(--action); }
.toca-fallo .toca-icono { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.toca-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.toca-texto .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toca-accion { font-weight: 650; font-size: .9rem; color: var(--action); white-space: nowrap; }
.toca-fallo .toca-accion { color: var(--bad); }
.ver-mas { display: inline-block; padding: 0 1.1rem 1rem; }

.pestanas { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); margin: 0 0 1.1rem; }
.pestana { padding: .7rem 1rem; min-height: 44px; display: inline-flex; align-items: center; gap: .4rem; font-weight: 650;
  color: var(--muted); border-bottom: 3px solid transparent; text-decoration: none; }
.pestana:hover { color: var(--text); }
.pestana[aria-selected="true"] { color: var(--primary-text); border-bottom-color: var(--primary); }
.pestana .nav-count { margin-left: .15rem; }
[data-panel][hidden] { display: none !important; }

.puesta { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .85rem 1.1rem; margin: 0 0 1rem;
  border-radius: var(--radius); background: var(--action-soft); border: 1px solid color-mix(in srgb, var(--action) 30%, transparent); }
.puesta strong { white-space: nowrap; }
.puesta .puesta-faltan { flex: 1; min-width: 14rem; color: var(--text-2); font-size: .92rem; }

.ajustes-filas { display: grid; gap: 1rem; grid-template-columns: 1fr; align-items: stretch; }
@media (min-width: 900px) { .ajustes-filas { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ajustes-filas > .card { margin: 0; }
.ajustes-filas .card-body > h2 { font-size: 1.02rem; margin: 0 0 .9rem; display: flex; align-items: center; gap: .45rem; }
.ajustes-guardar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  margin-top: 1rem; padding: .8rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
@media (max-width: 959px) { .ajustes-guardar { bottom: calc(var(--tabbar-h) + .5rem); } }

/* La tarjeta de la revision: la miniatura arriba y, con aire, el titulo, la
   lista y la nota; nada pegado a lo de encima. */
.revision .revision-titulo { font-size: 1.02rem; margin: 1.25rem 0 0; }
.revision ul { list-style: none; margin: .7rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.revision .revision-nota { margin: 1rem 0 0; }
.revision li { display: flex; gap: .5rem; align-items: flex-start; font-size: .93rem; }
.revision .si { color: var(--ok); } .revision .no { color: var(--action); }
.conexion { display: flex; align-items: center; gap: .8rem; padding: .75rem 0; border-top: 1px solid var(--border); }
.conexion:first-of-type { border-top: 0; }
.conexion-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }

.quiz-yt { display: flex; flex-direction: column; gap: .4rem; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
.quiz-opciones { margin: 0; padding-left: 1.4rem; display: flex; flex-direction: column; gap: .2rem; font-size: .93rem; }
.quiz-opciones .correcta { font-weight: 650; }

.conexion-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: -.2rem 0 .6rem; }
.conexion-form .input { flex: 1 1 14rem; min-width: 0; }
.eleccion-modo { display: flex; flex-direction: column; gap: .5rem; }
.modo-op { display: flex; flex-direction: column; gap: .15rem; text-align: left; padding: .75rem .9rem; min-height: 44px; cursor: pointer;
  border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; }
.modo-op:hover { border-color: var(--border-strong); }
.modo-op.elegido { border-color: var(--primary); background: var(--primary-soft); }

/* Una tarea en marcha: neutra, con el rojo de la marca en la barra. */
.progreso { display: flex; flex-direction: column; gap: .7rem; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.progreso-cabeza { display: flex; align-items: center; gap: .6rem; }
.progreso-cabeza strong { font-size: .98rem; }
.progreso-cuenta { margin-left: auto; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.progreso-giro { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--primary) 22%, transparent); border-top-color: var(--primary); animation: progreso-gira .9s linear infinite; }
.progreso-barra { position: relative; height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; }
.progreso-barra span { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .6s ease; }
.progreso-barra.sin-total span { position: absolute; width: 35% !important; animation: progreso-va 1.4s ease-in-out infinite; }
.progreso-pasos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; font-size: .86rem; }
.progreso-pasos li { display: flex; align-items: flex-start; gap: .5rem; line-height: 1.4; }
.progreso-pasos li.hecho { color: var(--muted); }
.progreso-pasos li.hecho svg { width: 15px; height: 15px; flex: none; margin-top: .12rem; color: var(--ok, #1a7f37); }
.progreso-pasos li.ahora { color: var(--text); font-weight: 600; }
.progreso-pasos .punto { width: 15px; height: 15px; flex: none; margin-top: .12rem; display: grid; place-items: center; }
.progreso-pasos .punto::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: progreso-late 1.2s ease-in-out infinite; }
@keyframes progreso-gira { to { transform: rotate(360deg); } }
@keyframes progreso-va { 0% { left: -35%; } 100% { left: 100%; } }
@keyframes progreso-late { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .progreso-giro, .progreso-barra.sin-total span, .progreso-pasos .punto::before { animation: none; } }

/* «Borrar canal»: aparte, al final de los ajustes, para no darle sin querer. */
.borrar-canal { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* El tiempo de produccion, separado de los botones de descarga. */
.tiempo-produccion { display: flex; align-items: center; gap: .45rem; margin: 1.1rem 0 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.tiempo-produccion .icon { width: 16px; height: 16px; flex: none; }

/* Primeros pasos */
.pp-grupo { font-size: 1.05rem; margin: .4rem 0 .7rem; }
.pp-pasos { margin: 0 0 .3rem; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .3rem; font-size: .92rem; }
.probar-form { margin-top: -.3rem; }

/* Marca: «Montarium» y, debajo o al lado, «studio» en ambar. */
.brand-name { display: inline-flex; align-items: baseline; gap: .3rem; }
.brand-name small { font-size: .62em; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); }
