/* ============================================================
   PUBLISH KIT — packaging desk for the whole content shelf
   clean neutral-dark console · per-family accent
   ============================================================ */

:root {
  /* palette matched to library.mikesailab.com design tokens */
  --bg: #060606;
  --bg-raise: #0d0d0f;
  --panel: #141417;
  --panel-2: #141417;
  --panel-edge: #26262b;
  --panel-edge-soft: #1e1e22;
  --inset: #0a0a0c;
  --ink: #ebebf0;        /* body text (fg0/fg1) */
  --ink-dim: #9a9aa4;    /* fg2 */
  --ink-faint: #6b6b74;  /* fg3 */
  /* accent variables keep the --amber* names but carry the site's emerald */
  --amber: #10b981;
  --amber-deep: #059669;
  --amber-soft: rgba(16, 185, 129, 0.12);
  --signal: #ff5c48;
  --ready: #34d399;
  --pending: #f4b942;
  --tiktok: #4de8e0;
  --reels: #ff7ab8;
  --shorts: #ff5d5d;
  --mono: "Martian Mono", ui-monospace, monospace;
  --display: "Bricolage Grotesque", "Arial Narrow", sans-serif;
  --radius: 14px;
  --radius-sm: 9px;
  --head-h: 66px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  font-family: var(--display);
  background:
    radial-gradient(1000px 480px at 88% -14%, rgba(16, 185, 129, 0.05), transparent 62%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.03 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--panel-edge);
  background: rgba(13, 13, 15, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.masthead__brand { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }

/* The brand's inner text block is the one that has to be allowed to shrink —
   without min-width:0 it floors at its own content width and the nowrap
   subtitle below pushes the whole masthead past the viewport on narrow phones. */
.masthead__brand > div { min-width: 0; }

.masthead__title {
  font-size: 1.55rem;
  font-weight: 800;
  font-variation-settings: "opsz" 96;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  line-height: 1;
}

.masthead__sub {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--ink-dim);
  letter-spacing: 0.08em;
  margin-top: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lamp {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber), 0 0 22px rgba(16, 185, 129, 0.5);
  animation: lampPulse 2.4s ease-in-out infinite;
  flex: none;
}

@keyframes lampPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.masthead__meter {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
  display: flex;
  gap: 1.4rem;
  margin-left: auto;
}

.masthead__meter b { color: var(--amber); font-weight: 600; }

.masthead__actions { display: flex; gap: 0.6rem; align-items: center; }

.search {
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.55rem 0.95rem;
  width: 200px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, width 0.25s ease;
}

.search::placeholder { color: var(--ink-faint); }
.search:focus {
  border-color: var(--amber-deep);
  box-shadow: 0 0 0 3px var(--amber-soft);
  width: 240px;
}

/* ---------- buttons / chips ---------- */

.btn {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  border: 1px solid rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.08);
  color: var(--amber);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s, background 0.2s, color 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover {
  background: rgba(16, 185, 129, 0.14);
  border-color: var(--amber-deep);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn--ghost { background: transparent; border-color: var(--panel-edge); color: var(--ink-dim); }
.btn--ghost:hover { color: var(--amber); border-color: var(--amber-deep); background: transparent; box-shadow: none; }

.btn--solid {
  background: var(--amber);
  color: #04160f;
  font-weight: 600;
  border-color: transparent;
}
.btn--solid:hover { background: #14c48a; border-color: transparent; }

.btn--wide { width: 100%; justify-content: center; text-align: center; padding: 0.75rem; }

.btn--mini { padding: 0.35rem 0.6rem; font-size: 0.56rem; }

.btn__icon { font-size: 0.8em; }

.chip {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover { color: var(--ink); border-color: var(--ink-faint); }

.chip--active {
  color: #04160f;
  background: var(--amber);
  border-color: var(--amber);
  font-weight: 600;
}

/* ---------- console layout ---------- */

.console {
  display: grid;
  grid-template-columns: 324px 1fr;
  min-height: calc(100vh - var(--head-h));
}

/* ---------- catalog rail ---------- */

.rail {
  border-right: 1px solid var(--panel-edge-soft);
  background: var(--bg-raise);
  overflow-y: auto;
  max-height: calc(100vh - var(--head-h));
  position: sticky;
  top: var(--head-h);
}

.rail__filters {
  display: flex;
  gap: 0.4rem;
  padding: 0.85rem;
  border-bottom: 1px solid var(--panel-edge-soft);
  position: sticky;
  top: 0;
  background: var(--bg-raise);
  z-index: 5;
}

.rail__category {
  padding: 0 0.85rem 0.85rem;
  border-bottom: 1px solid var(--panel-edge-soft);
}

.rail__category select {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.62rem;
  padding: 0.5rem 0.6rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.rail__category select:focus {
  border-color: var(--amber-deep);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.rail__group {
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0.95rem 0.95rem 0.4rem;
}

.card {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 0.75rem;
  padding: 0.7rem 0.95rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.card:hover { background: rgba(255, 255, 255, 0.035); }

.card--active {
  background: var(--amber-soft);
  border-left-color: var(--amber);
}

.card__art {
  width: 52px;
  height: 66px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
}

.card__title {
  font-size: 0.84rem;
  font-weight: 650;
  line-height: 1.22;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  font-family: var(--mono);
  font-size: 0.53rem;
  color: var(--ink-dim);
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.badge {
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.06em;
  padding: 0.16rem 0.44rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge--ready { background: rgba(74, 222, 128, 0.12); color: var(--ready); border: 1px solid rgba(74, 222, 128, 0.35); }
.badge--pending { background: rgba(244, 185, 66, 0.1); color: var(--pending); border: 1px solid rgba(244, 185, 66, 0.3); }

/* ---------- desk ---------- */

.desk { padding: 1.6rem 1.9rem 3.5rem; min-width: 0; }

.desk__header { margin-bottom: 1.6rem; animation: rise 0.45s ease both; }

.desk__kicker {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.desk__title {
  font-size: clamp(1.8rem, 3.4vw, 2.8rem);
  font-weight: 800;
  font-variation-settings: "opsz" 96;
  letter-spacing: -0.03em;
  line-height: 1.03;
  margin: 0.5rem 0 0.7rem;
  max-width: 26ch;
}

.desk__stats {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink-dim);
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
}

.desk__stats b { color: var(--ink); font-weight: 600; }

/* ---------- desk grid: preview (sticky) | work ---------- */

.desk__grid {
  display: grid;
  grid-template-columns: clamp(320px, 30vw, 384px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.desk__work {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.2rem;
  align-content: start;
}

.panel--script { grid-column: 1 / -1; }

.panel--preview {
  position: sticky;
  top: calc(var(--head-h) + 1.2rem);
}

/* ---------- panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  animation: rise 0.5s ease both;
}

.panel--script { animation-delay: 0.04s; }
.panel--copy { animation-delay: 0.08s; }
.panel--ship { animation-delay: 0.12s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel__label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.panel__label span { color: var(--amber); }

.panel__label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--panel-edge) 0 5px, transparent 5px 9px);
}

.panel__label--gap { margin-top: 1.5rem; }

/* ---------- stage (9:16 preview — height-driven so it always fits) ---------- */

.stage {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(64vh, 620px);
  width: auto;
  max-width: 100%;
  margin-inline: auto;
  border-radius: 14px;
  overflow: hidden;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.stage__frame, .stage__frame video, .stage__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stage__frame { position: absolute; inset: 0; }

/* Shown only when the <video> fires `error` — a failed inline render is
   otherwise an unexplained black rectangle. */
.stage__error {
  position: absolute;
  inset: auto 0 0 0;
  margin: 0;
  padding: 2rem 0.9rem 0.9rem;
  background: linear-gradient(transparent, rgba(5, 6, 8, 0.94));
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--ink-dim, #a1a1aa);
}
.stage__error[hidden] { display: none; }
.stage__error a { color: var(--accent, #38bdf8); }

.stage__pending {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2.4rem 1rem 1rem;
  background: linear-gradient(transparent, rgba(5, 6, 8, 0.92));
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.stage__pending .badge { align-self: flex-start; }

.stage__pending audio { width: 100%; height: 34px; filter: saturate(0.4) brightness(0.9); }

.stage__safe { position: absolute; inset: 0; pointer-events: none; }

.safe {
  position: absolute;
  border: 1px dashed rgba(255, 92, 72, 0.75);
  background: rgba(255, 92, 72, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.safe i {
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.46rem;
  letter-spacing: 0.08em;
  color: rgba(255, 140, 120, 0.95);
  text-transform: uppercase;
  writing-mode: initial;
}

.safe--top { inset: 0 0 auto 0; height: 9%; }
.safe--rail { inset: 42% 0 18% auto; width: 17%; }
.safe--rail i { writing-mode: vertical-rl; }
.safe--bottom { inset: auto 0 0 0; height: 16%; }

.stage__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  gap: 0.6rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--ink-dim);
  cursor: pointer;
  user-select: none;
}

.toggle input { accent-color: var(--amber); }

.stage__meta { font-family: var(--mono); font-size: 0.58rem; color: var(--ink-faint); text-align: right; }

/* ---------- thumbnails ---------- */

.thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--inset);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.15s, transform 0.15s;
}

.thumb:hover { transform: translateY(-2px); }

.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.thumb--active { border-color: var(--amber); box-shadow: 0 0 12px rgba(16, 185, 129, 0.35); }

.thumb__tag {
  position: absolute;
  bottom: 3px;
  left: 3px;
  right: 3px;
  font-family: var(--mono);
  font-size: 0.44rem;
  color: var(--ink);
  background: rgba(5, 6, 8, 0.75);
  border-radius: 4px;
  padding: 0.1rem 0.25rem;
  text-align: center;
  letter-spacing: 0.04em;
}

.hint {
  font-family: var(--mono);
  font-size: 0.56rem;
  line-height: 1.65;
  color: var(--ink-faint);
  margin-top: 0.7rem;
}

.hint a { color: var(--amber); }

/* ---------- narration script ---------- */

.script__toggle {
  order: 1;
  margin-left: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  background: var(--inset);
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.script__toggle:hover { color: var(--amber); border-color: var(--amber-deep); }

.script__chev { font-size: 0.7rem; line-height: 1; transition: transform 0.22s ease; }

.script__toggle[aria-expanded="true"] .script__chev { transform: rotate(180deg); }

.script__body {
  max-height: 300px;
  overflow: auto;
  padding: 1rem 1.1rem;
  background: var(--inset);
  border: 1px solid var(--panel-edge-soft);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  line-height: 1.72;
  color: var(--ink);
  scrollbar-width: thin;
  scrollbar-color: var(--panel-edge) transparent;
  transition: max-height 0.25s ease;
}

/* collapsed: show a short teaser with a fade, hide the action row */
.script--collapsed .script__body {
  max-height: 4.2em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 45%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 45%, transparent 100%);
}

.script--collapsed .script__actions { display: none; }

.script__body p { margin-bottom: 0.85rem; }
.script__body p:last-child { margin-bottom: 0; }

.script__body::-webkit-scrollbar { width: 8px; }
.script__body::-webkit-scrollbar-thumb { background: var(--panel-edge); border-radius: 8px; }

.script__empty { color: var(--ink-faint); font-family: var(--mono); font-size: 0.7rem; }

.script__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.script__stat { font-family: var(--mono); font-size: 0.56rem; color: var(--ink-faint); letter-spacing: 0.04em; }

/* ---------- caption editor ---------- */

.tabs { display: flex; gap: 0.45rem; margin-bottom: 0.9rem; }

.tab {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  padding: 0.55rem 0;
  background: var(--inset);
  color: var(--ink-dim);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}

.tab:hover { color: var(--ink); }

.tab--active[data-platform="tiktok"] { color: var(--tiktok); border-color: var(--tiktok); box-shadow: inset 0 0 18px rgba(77, 232, 224, 0.09); }
.tab--active[data-platform="reels"] { color: var(--reels); border-color: var(--reels); box-shadow: inset 0 0 18px rgba(255, 122, 184, 0.09); }
.tab--active[data-platform="shorts"] { color: var(--shorts); border-color: var(--shorts); box-shadow: inset 0 0 18px rgba(255, 93, 93, 0.09); }

.field { margin-bottom: 0.9rem; }

.field__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  gap: 0.6rem;
}

.field__name {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.field__count { font-family: var(--mono); font-size: 0.54rem; color: var(--ink-faint); white-space: nowrap; }
.field__count--over { color: var(--signal); font-weight: 600; }

.field textarea, .field input[type="text"] {
  width: 100%;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 0.7rem 0.8rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field textarea:focus, .field input[type="text"]:focus {
  border-color: var(--amber-deep);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.field__actions { display: flex; gap: 0.45rem; margin-top: 0.5rem; flex-wrap: wrap; }

.tagcloud { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }

.tag {
  font-family: var(--mono);
  font-size: 0.57rem;
  color: var(--tiktok);
  background: rgba(77, 232, 224, 0.07);
  border: 1px solid rgba(77, 232, 224, 0.2);
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

.tag:hover { background: rgba(77, 232, 224, 0.16); }

.tag--off { opacity: 0.32; text-decoration: line-through; }

/* ---------- sidecar ---------- */

.sidecar__pre {
  background: var(--inset);
  border: 1px solid var(--panel-edge-soft);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.58rem;
  line-height: 1.7;
  color: var(--ink-dim);
  padding: 0.8rem;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  margin-bottom: 0.6rem;
}

.sidecar__pre b { color: var(--amber); font-weight: 400; }

.sidecar__row { display: flex; gap: 0.45rem; flex-wrap: wrap; }

/* ---------- checklist ---------- */

.checklist { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }

.checklist li {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 0.6rem;
  align-items: baseline;
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 0.55rem 0.65rem;
  background: var(--inset);
  border: 1px solid var(--panel-edge-soft);
  border-radius: var(--radius-sm);
}

.checklist .ok { color: var(--ready); }
.checklist .warn { color: var(--pending); }
.checklist .bad { color: var(--signal); }

.checklist small {
  font-family: var(--mono);
  font-size: 0.52rem;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* ---------- ship ---------- */

.ship { display: flex; flex-direction: column; gap: 0.55rem; }

.ship__note { font-family: var(--mono); font-size: 0.56rem; color: var(--ink-faint); line-height: 1.65; }

/* ---------- sources ---------- */

.sources {
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--ink-dim);
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.sources a { color: var(--ink-dim); text-decoration-color: var(--panel-edge); transition: color 0.15s; }
.sources a:hover { color: var(--amber); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translate(-50%, 20px);
  background: var(--amber);
  color: #04160f;
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 60;
}

.toast--show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- empty ---------- */

.empty {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-faint);
  padding: 3rem 1rem;
  text-align: center;
  letter-spacing: 0.05em;
}

/* ---------- responsive ---------- */

/* Collapse the work column to a single stack, unpin the preview. */
@media (max-width: 1180px) {
  .desk__grid { grid-template-columns: 1fr; }
  .panel--preview { position: static; }
  .desk__work { grid-template-columns: 1fr; }
  .stage { height: min(70vh, 600px); }
}

/* Rail collapses above the desk. */
@media (max-width: 900px) {
  .console { grid-template-columns: 1fr; }
  .rail { position: static; max-height: 320px; border-right: none; border-bottom: 1px solid var(--panel-edge-soft); }
  .masthead { flex-wrap: wrap; gap: 0.75rem; padding: 0.8rem 1.1rem; }
  .masthead__meter { margin-left: 0; order: 3; gap: 1.1rem; }
  .masthead__actions {
    order: 4;
    width: 100%;
    gap: 0.5rem;
  }
  .search { flex: 1 1 auto; width: auto; min-width: 0; }
  .search:focus { width: auto; }
  .btn--batch { flex: none; }
}

/* Phones: keep the action row tidy, shrink the batch button to its icon-ish label. */
@media (max-width: 560px) {
  .desk { padding: 1.2rem 1.05rem 3rem; }
  .panel { padding: 1rem; }
  .masthead { padding-inline: 1rem; }
  .masthead__title { font-size: 1.3rem; }
  .masthead__meter { font-size: 0.56rem; gap: 0.9rem; flex-wrap: wrap; }
  .btn--batch .btn__label { display: none; }
  #schedBtn::after { content: "schedule .csv"; }
  #batchExportBtn::after { content: "batch .json"; }
  .stage { height: min(74vh, 560px); }
  .thumbs { grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
  .script__body { max-height: 260px; font-size: 0.88rem; }
}

/* Below ~420px the subtitle can't ellipsize down far enough to be worth the
   row it costs — the title and the lamp already identify the app. */
@media (max-width: 420px) {
  .masthead__sub { display: none; }
}

/* ============================================================
   PUBLISH KIT ADDITIONS — four families in one desk
   ============================================================ */

/* --- family filter chips: each carries its family's accent ---------------- */
.rail__filters--family { flex-wrap: wrap; }
.rail__filters--family .chip[data-family]:hover { color: var(--fam, var(--ink)); border-color: var(--fam, var(--ink-faint)); }
.rail__filters--family .chip--active[data-family] {
  color: var(--fam, var(--amber));
  border-color: var(--fam, var(--amber-deep));
  background: color-mix(in srgb, var(--fam, var(--amber)) 12%, transparent);
}

/* Catalog cards tint their active edge with the family accent, so the rail
   still reads as four shelves once the family filter is off. */
.card--active { border-left-color: var(--fam, var(--amber)); }
.card__art { border-color: color-mix(in srgb, var(--fam, var(--panel-edge)) 40%, var(--panel-edge)); }

.badge--plan {
  background: rgba(167, 139, 250, 0.12);
  color: #c4b5fd;
  border: 1px solid rgba(167, 139, 250, 0.35);
}

/* --- desk header ---------------------------------------------------------- */
.desk__family {
  color: var(--fam, var(--amber));
  font-weight: 600;
  letter-spacing: 0.1em;
}

.desk__premise {
  margin: 0.55rem 0 0.9rem;
  max-width: 62ch;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink-dim);
}

/* --- stage: 2:3 scene art needs a taller-but-wider frame than 9:16 -------- */
/* Scene stills and plan covers are 16:9; only the voiceover renders are 9:16.
   The 9:16 stage is sized off its HEIGHT (a tall box in a narrow column); a
   landscape one has to flip to width-driven or it overflows the column. */
.stage--wide {
  aspect-ratio: 16 / 9;
  width: 100%;
  height: auto;
}

.carousel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: linear-gradient(to top, rgba(6, 6, 6, 0.92), transparent);
}

.carousel__nav {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  border: 1px solid var(--panel-edge);
  background: rgba(10, 10, 12, 0.8);
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.carousel__nav:hover { color: var(--amber); border-color: var(--amber-deep); }

.carousel__cap {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.55rem;
  line-height: 1.4;
  color: var(--ink-dim);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The narration player sits UNDER the stage, not over the art: a 16:9 still is
   short enough that an overlaid player covers a third of the scene, and the
   stage frame is inset-0 inside an overflow:hidden box, so anything appended
   after the art is clipped away entirely. */
.stage__aside:empty { display: none; }

.stage__audio {
  display: block;
  width: min(100%, 620px);
  height: 34px;
  margin: 0.6rem auto 0;
  filter: saturate(0.4) brightness(0.9);
}

/* --- source-text panel: plan families are structured, not prose ----------- */
.script__h {
  margin: 1.1rem 0 0.45rem;
  font-family: var(--mono);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}
.script__body > .script__h:first-child { margin-top: 0; }

.script__hook {
  padding-left: 0.7rem;
  border-left: 2px solid var(--amber-deep);
  color: var(--ink);
  font-style: italic;
}

.script__list {
  margin: 0 0 0.4rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.script__list li { padding-left: 0.2rem; }

/* --- the three platform tabs the original kit never had ------------------- */
.tabs { flex-wrap: wrap; }
.tab--active[data-platform="x"] { color: var(--ink); border-color: var(--ink-dim); box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.06); }
.tab--active[data-platform="linkedin"] { color: #6cb2ff; border-color: #3a7fd5; box-shadow: inset 0 0 18px rgba(108, 178, 255, 0.09); }
.tab--active[data-platform="carousel"] { color: #c4b5fd; border-color: #8b76e0; box-shadow: inset 0 0 18px rgba(196, 181, 253, 0.09); }

.btn[disabled] { opacity: 0.55; cursor: progress; }

.toggle[hidden] { display: none; }

/* ============================================================
   POST LOG · STATE METER · SCHEDULER · DRAWER · SHORTCUTS
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- masthead: the meter IS the status filter ---------------------------- */

.masthead__meter { align-items: center; gap: 0.9rem; }

.meter {
  font: inherit;
  font-family: var(--mono);
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.meter:hover { color: var(--ink); border-color: var(--panel-edge); }

.meter--on {
  color: var(--amber);
  border-color: var(--amber-deep);
  background: var(--amber-soft);
}

.meter b { color: var(--amber); font-weight: 600; }
.meter--on b { color: var(--amber); }

/* Half-credit for partials, so the bar moves as a shelf drains rather than
   snapping only when an artifact's last platform lands. */
.meter__bar {
  width: 84px;
  height: 4px;
  border-radius: 999px;
  background: var(--panel-edge);
  overflow: hidden;
  flex: none;
}

.meter__bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--amber-deep), var(--amber));
  transition: width 0.35s ease;
}

.btn--icon { padding: 0.5rem 0.65rem; font-size: 0.85rem; line-height: 1; }

/* --- catalog: post pip --------------------------------------------------- */

.card__post {
  align-self: center;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  border: 1px solid var(--panel-edge);
  background: transparent;
}

.card__post--partial { background: var(--pending); border-color: var(--pending); opacity: 0.55; }
.card__post--posted { background: var(--ready); border-color: var(--ready); box-shadow: 0 0 8px rgba(52, 211, 153, 0.5); }

/* --- post log ------------------------------------------------------------ */

.postlog__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.posted {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "mark name" "mark when";
  align-items: center;
  gap: 0 0.55rem;
  text-align: left;
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.posted:hover { border-color: var(--ink-faint); color: var(--ink); }

.posted--on {
  color: var(--ready);
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.08);
}

.posted__mark { grid-area: mark; font-size: 0.9rem; line-height: 1; }
.posted__name { grid-area: name; font-family: var(--display); font-size: 0.78rem; font-weight: 600; letter-spacing: -0.01em; }
.posted__when { grid-area: when; font-family: var(--mono); font-size: 0.5rem; letter-spacing: 0.06em; color: var(--ink-faint); }
.posted--on .posted__when { color: rgba(52, 211, 153, 0.75); }

/* --- dialogs (scheduler + shortcuts) ------------------------------------- */

.sheet {
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  /* The sheet-wide `* { margin: 0 }` reset also hits <dialog>, killing the UA
     stylesheet's `margin: auto` — without this the modal pins to the top-left
     corner and scrolls its own title off-screen. */
  margin: auto;
  width: min(520px, calc(100vw - 2rem));
  max-height: min(90vh, 46rem);
  overflow-y: auto;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}

.sheet::backdrop { background: rgba(4, 4, 6, 0.72); backdrop-filter: blur(3px); }

.sheet__form { display: flex; flex-direction: column; gap: 0.85rem; padding: 1.4rem; }

.sheet__title {
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet__sub { font-family: var(--mono); font-size: 0.56rem; color: var(--ink-faint); letter-spacing: 0.06em; }

.sheet__grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }

.sheet__field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }

.sheet__field span {
  font-family: var(--mono);
  font-size: 0.54rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sheet__field input {
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.55rem 0.65rem;
  outline: none;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sheet__field input:focus { border-color: var(--amber-deep); box-shadow: 0 0 0 3px var(--amber-soft); }

.toggle--block { justify-content: flex-start; }

.sheet__actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.3rem; }

.keys {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.45rem 0.9rem;
  align-items: baseline;
}

.keys dt {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--amber);
  background: var(--inset);
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  padding: 0.22rem 0.4rem;
  text-align: center;
}

.keys dd { font-size: 0.82rem; color: var(--ink-dim); }

/* --- mobile catalog drawer ----------------------------------------------- */

/* Desktop keeps the rail in the grid; the toggle and scrim are dead weight. */
.railtoggle { display: none; }
.rail__scrim { display: none; }

@media (max-width: 900px) {
  .railtoggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: none;
    background: var(--inset);
    border: 1px solid var(--panel-edge);
    border-radius: var(--radius-sm);
    color: var(--ink-dim);
    font-size: 0.95rem;
    cursor: pointer;
  }

  .railtoggle[aria-expanded="true"] { color: var(--amber); border-color: var(--amber-deep); }

  /* Off-canvas, not a 320px letterbox stacked above a very tall desk. */
  .rail {
    position: fixed;
    inset: var(--head-h) auto 0 0;
    width: min(330px, 86vw);
    max-height: none;
    z-index: 25;
    border-right: 1px solid var(--panel-edge);
    border-bottom: none;
    transform: translateX(-102%);
    transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.45);
  }

  .rail-open .rail { transform: none; }

  .rail__scrim {
    display: block;
    position: fixed;
    inset: var(--head-h) 0 0 0;
    z-index: 20;
    background: rgba(4, 4, 6, 0.6);
    backdrop-filter: blur(2px);
    animation: fade 0.2s ease both;
  }

  .rail__scrim[hidden] { display: none; }

  /* The drawer owns the viewport while it's open. */
  .rail-open { overflow: hidden; }

  .masthead__meter { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .masthead__meter::-webkit-scrollbar { display: none; }
  .sheet__grid { grid-template-columns: 1fr 1fr; }

  /* The action row has to wrap: `nowrap` squeezed the share bar to 41px, and
     .ts-bar wraps internally, so its six icons stacked into a six-row column
     that alone made the masthead 380px tall. */
  .masthead__actions { flex-wrap: wrap; }
  .masthead__actions .ts-bar { flex: none; flex-wrap: nowrap; }
  .search { flex: 1 0 150px; }
}

@media (max-width: 560px) {
  /* The masthead is sticky, so every row it wraps to is permanent chrome. The
     six-icon share bar cost a whole row on a phone that already has a native
     share sheet in its URL bar — the desktop bar is untouched. */
  .masthead__actions .ts-bar { display: none; }
  .masthead { gap: 0.5rem 0.9rem; }

  .postlog__grid { grid-template-columns: 1fr 1fr; }
  .meter { padding: 0.24rem 0.45rem; }
  .meter__bar { width: 56px; }
  .btn--icon { display: none; } /* no hardware keyboard to teach */
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .rail { transition: none; }
  .meter__bar i { transition: none; }
}
