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

/* ZipCast brand palette (zipcast.media): IndigoBlue primary, Cerise→orange
   gradient CTAs, deep navy text, lavender-tinted neutrals, Merriweather Sans */
:root {
  --bg: #f7f7fd;
  --panel: #ffffff;
  --card: #ffffff;
  --card-hover: #f5f5fd;
  --border: #d5d6eb;
  --border-soft: #e3e4f4;
  --text: #1e1f34;
  --muted: #535468;
  --blue: #4e59ee;
  --blue-dark: #3a45d9;
  --orange: #fe8646;
  --teal: #4386c5;
  --danger: #e2474d;
  --wave-bg: #f4f4fb;
  --cerise: #fb5b62;
  --grad: linear-gradient(95deg, #fb5b62 0.59%, #fe8646 174.04%);
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Merriweather Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo-img { height: 26px; display: block; }
.app-name {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.export-controls { display: flex; gap: 8px; align-items: center; }

.master-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  margin-right: 4px;
}
.master-toggle input { accent-color: var(--blue); width: 15px; height: 15px; margin: 0; }

input[type="text"], select {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
}
input[type="text"] { width: 160px; }
input[type="text"]:focus, select:focus { outline: none; border-color: var(--blue); }

button {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
button:hover { background: var(--card-hover); border-color: var(--blue); color: var(--blue); }
button.primary {
  background: var(--grad);
  border-color: var(--cerise);
  color: #fff;
}
button.primary:hover { background: var(--grad); border-color: var(--cerise); color: #fff; filter: brightness(1.07); }
button:disabled { opacity: 0.5; cursor: default; }
.ctl-del { color: var(--danger); }
.ctl-del:hover { border-color: var(--danger); background: #fdf1f1; color: var(--danger); }

main { display: flex; flex-direction: column; flex: 1; min-height: 0; }

#workspace { display: flex; flex: 1; min-height: 0; }

/* ---- library ---- */

#library {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 14px;
  overflow-y: auto;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#dropzone {
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
}
#dropzone.drag { border-color: var(--blue); background: #edeefd; }
#dropzone strong { color: var(--blue); }

#clip-list { display: flex; flex-direction: column; gap: 10px; }

.clip-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 10px;
  cursor: grab;
}
.clip-card:hover { border-color: var(--blue); }
.clip-card.dragging { opacity: 0.4; }

.clip-card img, .seg-card img {
  width: 100%;
  height: 36px;
  object-fit: fill;
  border-radius: 4px;
  background: var(--wave-bg);
  pointer-events: none;
  display: block;
}

.clip-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  align-items: baseline;
}
.clip-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clip-dur {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.rename-input {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  border: 1px solid var(--blue);
  border-radius: 4px;
  padding: 1px 5px;
}
.rename-input:focus { outline: none; }

.clip-actions { display: flex; gap: 6px; margin-top: 8px; }
.clip-actions button { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.clip-actions .del { margin-left: auto; color: var(--danger); }
.clip-actions .del:hover { border-color: var(--danger); background: #fdf1f1; color: var(--danger); }

/* ---- clip processing states ---- */

.clip-card.pending { cursor: default; }
.clip-card.pending:hover { border-color: var(--border); }

.wave-placeholder {
  height: 36px;
  border-radius: 4px;
  background: var(--wave-bg);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 8px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.wave-placeholder.err { color: var(--danger); background: #fdf1f1; }

/* ---- segment transcripts ---- */

.seg-entry {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  min-height: 0;
}
.seg-entry.dragging { opacity: 0.4; }

.seg-transcript {
  flex: 0 1 auto;
  min-height: 44px;
  min-width: 230px;
  max-width: 680px;
  overflow-y: auto;
  overflow-x: hidden;
  resize: horizontal;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 8px 10px;
  font-size: 13px;
}
.seg-transcript .hint { color: var(--muted); text-align: center; margin: 8px 0; }
.seg-transcript .hint.error { color: var(--danger); }

.tr-toggle { padding: 2px 8px; font-size: 10px; flex-shrink: 0; }

.tr-line {
  display: flex;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 6px;
}
.tr-time {
  flex-shrink: 0;
  width: 34px;
  text-align: right;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.tr-text { flex: 1; user-select: none; }

.tr-word {
  cursor: pointer;
  padding: 1px 2px;
  margin: 0 -1px;
  border-radius: 4px;
}
.tr-word:hover { background: #edeefd; }
.tr-word.dim { opacity: 0.35; }
.tr-word.playing { background: #edeefd; box-shadow: inset 0 -2px 0 var(--blue); }
.tr-word.cut {
  color: var(--danger);
  background: #fdf1f1;
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.tr-word.cut:hover { background: #fbe3e3; }

.tr-tools {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 0 2px 6px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 6px;
}
.tr-tools .tr-cutinfo {
  color: var(--muted);
  font-size: 11px;
  margin-right: auto;
}
.tr-tools button { padding: 2px 8px; font-size: 11px; }

/* ---- timeline ---- */

#timeline-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  gap: 14px;
  min-width: 0;
}

.timeline-meta { display: flex; gap: 12px; align-items: center; }
#total-duration {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
#preview-btn { padding: 4px 12px; font-size: 12px; }

#timeline {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  transition: border-color 0.15s, background 0.15s;
}
#timeline.drag { border-color: var(--blue); background: #f4f4fd; }
#timeline .hint { color: var(--muted); width: 100%; text-align: center; margin: auto; }
#timeline.empty .hint { display: block; }
#timeline:not(.empty) .hint { display: none; }

.seg-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 10px;
  cursor: grab;
  position: relative;
}
.seg-card:hover { border-color: var(--blue); }
.seg-card.playing { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }

.seg-index {
  position: absolute;
  top: -8px;
  left: -6px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seg-trims {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}
.seg-trims input {
  width: 58px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 11px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.seg-trims input:focus { outline: none; border-color: var(--blue); }
.seg-trims .seg-play { padding: 3px 8px; font-size: 11px; }
.seg-trims .rm { margin-left: auto; color: var(--danger); padding: 3px 8px; font-size: 11px; }
.seg-trims .rm:hover { border-color: var(--danger); background: #fdf1f1; color: var(--danger); }

.drop-marker {
  width: 3px;
  flex-shrink: 0;
  align-self: stretch;
  background: var(--blue);
  border-radius: 2px;
}

/* ---- export result & toast ---- */

#export-result[hidden] { display: none; }

#export-result {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 10px 16px;
}
#export-summary { font-variant-numeric: tabular-nums; }
#export-result a { color: var(--blue); font-weight: 700; }
#export-audio { height: 34px; flex: 1; max-width: 420px; }

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  box-shadow: 0 4px 16px rgba(46, 53, 59, 0.12);
  z-index: 10;
}
#toast.error { border-color: var(--danger); color: var(--danger); }

/* ---- auth + episodes ---------------------------------------------------- */

#auth-view[hidden] { display: none; } /* the flex rule below outranks the UA [hidden] rule */
#auth-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 20;
}
#auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 320px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(46, 53, 59, 0.08);
}
#auth-form h2 {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#auth-form h2 .logo-img { height: 30px; }
#auth-form input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.auth-actions { display: flex; gap: 8px; margin-top: 4px; }
.auth-actions button { flex: 1; }
#auth-error { color: var(--danger); font-size: 13px; }

#episode-select { max-width: 160px; }
#save-state { color: var(--muted); font-size: 12px; min-width: 56px; text-align: right; }
#user-chip {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- nav (surface switcher) ---------------------------------------------- */

#main-nav { display: flex; gap: 2px; margin-left: 14px; }
#main-nav button { border-color: transparent; background: none; color: var(--muted); padding: 6px 12px; }
#main-nav button:hover { background: var(--card-hover); color: var(--blue); }
#main-nav button.on { background: #edeefd; color: var(--blue-dark); }
#episode-controls { display: none; } /* My Studio is parked; schedule is the front door */

/* ---- templates: the Myrtle editor ----------------------------------------
   Details panel overhead, timeline strip below, in-session undo log.
   "vert" flips to the vertical layout (timeline left, details right) that
   the phone apps will mirror; "compact" is the proportional true-timeline. */

#templates-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 24px 20px;
  overflow-y: auto;
}
#templates-view[hidden] { display: none; }

.tpl-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpl-hint {
  flex: 1;
  min-width: 240px;
  font-size: 13.5px;
  background: #edeefd;
  border: 1px solid #cacdfa;
  border-radius: 8px;
  padding: 8px 14px;
}
#template-name { width: 180px; }
#tpl-save-state { color: var(--muted); font-size: 12px; min-width: 56px; text-align: right; }
.tpl-tgl-on { background: #edeefd !important; border-color: #cacdfa !important; color: var(--blue-dark) !important; }

/* accordion: one header per episode format, the editor extends below */
#tpl-list { display: flex; flex-direction: column; gap: 10px; }
.tpl-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
}
.tpl-item.open { border-color: var(--blue); }
.tpl-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.tpl-head:hover .tpl-head-name { color: var(--blue-dark); }
.tpl-head-caret { color: var(--muted); width: 14px; }
.tpl-head-name { font-size: 16px; font-weight: 700; flex: 1; }
.tpl-head-sched { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.tpl-item .tpl-body:not(:empty) {
  border-top: 1px solid var(--border-soft);
  padding: 12px 16px 16px;
}
.tpl-add-row {
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-weight: 700;
  padding: 12px 16px;
  cursor: pointer;
  text-align: left;
}
.tpl-add-row:hover { color: var(--blue-dark); border-color: var(--blue); }
.tpl-add-row input {
  width: 100%;
  font: inherit;
  font-weight: 400;
  border: none;
  outline: none;
  background: none;
  color: var(--text);
}
#tpl-editor { display: flex; flex-direction: column; gap: 12px; }
#tpl-editor[hidden] { display: none; }
.tpl-editor-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpl-sched-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-right: auto;
}
#tpl-dow-wrap { display: inline-flex; align-items: center; gap: 6px; }
#tpl-dow-wrap[hidden] { display: none; }

#tpl-main { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
#tpl-top { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: stretch; }
#tpl-top.log-open { grid-template-columns: 1fr 320px; }
@media (max-width: 900px) { #tpl-top, #tpl-top.log-open { grid-template-columns: 1fr; } }

.tpl-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 16px 18px;
}

/* details panel */
#tpl-details { min-height: 240px; }
.tpl-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  min-height: 200px;
  gap: 8px;
  font-size: 15px;
}
.tpl-empty b { color: var(--text); font-size: 16px; }
.tpl-detail-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.tpl-detail-head h3 { font-size: 17px; font-weight: 900; }
.tpl-detail-head .tpl-done { margin-left: auto; }
.tpl-explain { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.tpl-field { margin-bottom: 14px; }
.tpl-field > label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 5px; }
.tpl-field input[type="text"] { width: 100%; max-width: 380px; font-size: 14px; padding: 9px 11px; }
.tpl-field input.tpl-len { width: 76px; max-width: none; }
.tpl-setline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpl-setval {
  background: var(--wave-bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.tpl-big { padding: 9px 15px; font-size: 13.5px; border-radius: 7px; }
.tpl-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.tpl-remove { margin-left: auto; color: var(--danger); }
.tpl-remove:hover { border-color: var(--danger); background: #fdf1f1; color: var(--danger); }

/* undo log */
#tpl-log { display: flex; flex-direction: column; padding: 13px 15px; }
#tpl-log h3 { font-size: 13.5px; font-weight: 900; margin-bottom: 9px; }
#tpl-log .tpl-undo { width: 100%; margin-bottom: 9px; }
.tpl-entries { flex: 1; overflow-y: auto; max-height: 230px; display: flex; flex-direction: column; gap: 6px; }
.tpl-entry {
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg);
}
.tpl-entry .txt { flex: 1; min-width: 0; }
.tpl-entry time { color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.tpl-entry button { font-size: 11px; padding: 3px 8px; flex-shrink: 0; }
.tpl-entry.none { color: var(--muted); }

/* timeline strip */
#tpl-timeline { display: flex; flex-direction: column; }
.tpl-total { color: var(--muted); font-size: 12px; margin: 0 2px 6px; }
.tpl-ruler {
  position: relative;
  height: 15px;
  margin: 0 14px -8px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.tpl-ruler span { position: absolute; top: 0; border-left: 1px solid #d6dee6; padding-left: 3px; white-space: nowrap; }
.tpl-strip {
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  padding: 18px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.tpl-card {
  width: 176px;
  flex-shrink: 0;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 9px;
  padding: 12px 13px 10px;
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
}
.tpl-card:hover { border-color: var(--blue); background: var(--card-hover); }
.tpl-card.sel { border-color: var(--blue); box-shadow: 0 0 0 3px #edeefd; }
.tpl-card.dragging { opacity: 0.4; }
.tpl-ord {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.tpl-card h4 { font-size: 14px; font-weight: 700; line-height: 1.25; }
.tpl-kind { font-size: 12px; color: var(--muted); line-height: 1.35; }
.tpl-len-tag { margin-top: auto; padding-top: 5px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tpl-tr {
  align-self: center;
  flex-shrink: 0;
  background: #edeefd;
  border: 1px solid #cacdfa;
  color: var(--blue-dark);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}
.tpl-tr:hover { border-color: var(--teal); color: #4386c5; background: #ebf4fb; }
.tpl-trline { align-self: stretch; flex-shrink: 0; width: 4px; border-radius: 2px; background: var(--blue); cursor: pointer; }
.tpl-trline:hover { background: var(--teal); }
.tpl-add {
  flex-shrink: 0;
  width: 130px;
  border: 2px dashed var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.tpl-add-music:hover { color: var(--teal); border-color: var(--teal); }

/* musical interludes read as music at a glance */
.tpl-card.tpl-music { border-style: dashed; border-color: var(--teal); background: #ebf4fb; }
.tpl-card.tpl-music.sel { border-style: solid; }
.tpl-card.tpl-music h4 { color: #4386c5; }
.tpl-add:hover { border-color: var(--blue); color: var(--blue); background: #edeefd; }

/* compact: title-only proportional blocks (true-timeline) */
#tpl-main.compact .tpl-card { width: auto; min-width: 0; padding: 8px 10px; gap: 0; justify-content: center; overflow: hidden; }
#tpl-main.compact .tpl-card h4 { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tpl-main.compact .tpl-strip { padding: 14px 12px; gap: 4px; }
#tpl-main.compact .tpl-add { width: auto; padding: 8px 14px; flex-grow: 0; }

/* vertical (phone-style): timeline left, details out to the right */
#tpl-main.vert { display: grid; grid-template-columns: minmax(260px, 330px) 1fr; grid-template-areas: "strip top"; align-items: start; }
#tpl-main.vert #tpl-timeline { grid-area: strip; }
#tpl-main.vert .tpl-strip { flex-direction: column; align-items: stretch; max-height: 70vh; overflow-y: auto; overflow-x: hidden; }
#tpl-main.vert .tpl-card { width: auto; }
#tpl-main.vert .tpl-add { width: auto; padding: 12px; }
#tpl-main.vert #tpl-top { grid-area: top; display: flex; flex-direction: column; }
#tpl-main.vert.compact .tpl-card h4 { white-space: normal; overflow: visible; }
#tpl-main.vert.compact .tpl-trline { width: auto; height: 4px; align-self: stretch; }
@media (max-width: 800px) { #tpl-main.vert { grid-template-columns: 1fr; grid-template-areas: "strip" "top"; } }

#workspace[hidden] { display: none; }

/* ---- library surface ------------------------------------------------------ */

#library-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 24px 20px;
  overflow-y: auto;
}
#library-view[hidden] { display: none; }
.lib-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#lib-dropzone {
  background: var(--grad);
  border: 1px solid var(--cerise);
  border-radius: 7px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
#lib-dropzone:hover { filter: brightness(1.07); }
#lib-body { display: flex; gap: 14px; align-items: flex-start; min-height: 0; }
#lib-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
#lib-grid { display: flex; flex-direction: column; gap: 10px; }

/* shelves: the same collapsible-card motif as episode formats */
.lib-sec-body {
  border-top: 1px solid var(--border-soft);
  padding: 12px 16px 16px;
}
.lib-sec-body[hidden] { display: none; }
.lib-sec.drop { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); background: #f4f4fd; }
.lib-sec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.lib-card.dragging { opacity: 0.4; }
.clip-actions .sect {
  font-size: 11px;
  padding: 3px 4px;
  max-width: 120px;
  color: var(--muted);
}
.lib-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 10px;
}
.lib-card:hover { border-color: var(--blue); }
.lib-card.clickable { cursor: pointer; }
.lib-card.sel { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.lib-edited { font-size: 11px; color: var(--danger); align-self: center; }
.lib-empty { color: var(--muted); padding: 14px 0; font-size: 13px; }
.bank-low { color: #d0652c; font-weight: 700; }

/* edit pane: the clip's own word-strike edit, docked beside the grid */
#lib-editor {
  width: 400px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 12px;
  max-height: calc(100vh - 170px);
}
#lib-editor[hidden] { display: none; }
.lib-ed-head { display: flex; align-items: center; gap: 8px; }
#lib-ed-name {
  font-weight: 700;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#lib-ed-save { font-size: 11px; color: var(--muted); white-space: nowrap; }
#lib-ed-wave {
  width: 100%;
  height: 36px;
  object-fit: fill;
  border-radius: 4px;
  background: var(--wave-bg);
  display: block;
}
.lib-ed-controls { display: flex; align-items: center; gap: 8px; }
#lib-ed-dur { font-size: 12px; color: var(--muted); }
#lib-ed-transcript {
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
}
#lib-ed-transcript .hint { color: var(--muted); text-align: center; margin: 8px 0; }
#lib-ed-transcript .hint.error { color: var(--danger); }

/* template part picker extras */
#tpl-c-clip { max-width: 340px; }
.tpl-field-note { font-size: 12px; color: var(--muted); margin-top: 5px; }
.tpl-ok { color: #40bf6a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card img {
  width: 100%;
  height: 36px;
  object-fit: fill;
  border-radius: 4px;
  background: var(--wave-bg);
  display: block;
  margin: 4px 0 8px;
}

/* minimized "Your changes" — one history chip, expands on click */
#tpl-log:has(.tpl-log-mini) { padding: 8px; align-self: start; }
.tpl-log-mini {
  font-size: 17px;
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.tpl-log-mini b { font-size: 12px; color: var(--blue-dark); }
.tpl-log-mini:hover { color: var(--blue); }
#tpl-log h3 { display: flex; align-items: center; justify-content: space-between; }
.tpl-log-min { padding: 1px 9px; font-size: 13px; }

/* ---- schedule surface ----------------------------------------------------- */

#schedule-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 20px;
  overflow-y: auto;
}
#schedule-view[hidden], #sched-inst[hidden], #sched-home[hidden] { display: none; }
#sched-home, #sched-inst { display: flex; flex-direction: column; gap: 14px; }

/* cadence controls living inside a format section header */
.sched-head-cadence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
}
.sched-head-cadence select { font-size: 12.5px; padding: 5px 8px; }

#sched-list { display: flex; flex-direction: column; gap: 10px; max-width: 860px; }
#sched-list[hidden], #sched-cal[hidden], #sched-sorthead[hidden] { display: none; }

/* content requests: asks addressed to me, and pending asks on slots */
#sched-requests { display: flex; flex-direction: column; gap: 8px; max-width: 720px; }
#sched-requests:empty { display: none; }
.sched-request {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #edeefd;
  border: 1px solid #cacdfa;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}
.sched-request span:nth-child(2) { flex: 1; }
.req-pending { font-size: 12px; color: var(--blue-dark); white-space: nowrap; }

/* format groups: same collapsible-card motif */
.sched-group-body {
  border-top: 1px solid var(--border-soft);
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sched-group-body[hidden] { display: none; }

#sched-viewtabs { display: flex; gap: 6px; }

/* sortable column headers over the list */
#sched-sorthead { display: flex; gap: 6px; max-width: 720px; }
#sched-sorthead button {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
}
#sched-sorthead button:hover { color: var(--blue); background: none; }
#sched-sorthead button.on { color: var(--blue-dark); }

/* calendar view */
#sched-cal { max-width: 980px; display: flex; flex-direction: column; gap: 10px; }
.cal-head { display: flex; align-items: center; gap: 12px; }
.cal-head b { font-size: 16px; min-width: 150px; text-align: center; }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-dow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 2px 0;
}
.cal-cell {
  min-height: 86px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-cell.blank { background: none; border: none; }
.cal-cell.today { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.cal-day { color: var(--muted); font-size: 11px; font-weight: 700; align-self: flex-end; }
.cal-chip {
  border: none;
  border-radius: 5px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}
.cal-chip.st-open { background: var(--orange); }
.cal-chip.st-done { background: #40bf6a; }
.cal-chip.st-skipped { background: var(--border); color: var(--muted); }
.cal-chip:hover { filter: brightness(1.08); color: #fff; }
.cal-chip.st-skipped:hover { color: var(--muted); }
.sched-none { color: var(--muted); padding: 18px 4px; }
.sched-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 13px 16px;
  cursor: pointer;
}
.sched-card:hover { border-color: var(--blue); background: var(--card-hover); }
.sched-card.skipped { opacity: 0.6; }
.sched-date { flex: 1; display: flex; flex-direction: column; }
.sched-date b { font-size: 14.5px; }
.sched-date span { color: var(--muted); font-size: 12.5px; }
.sched-status { font-size: 12px; font-weight: 700; white-space: nowrap; }
.sched-status.ok { color: #40bf6a; }
.sched-status.warn { color: #d0652c; }
.sched-status.grey { color: var(--muted); }
.sched-back { color: var(--muted); text-decoration: none; font-weight: 700; font-size: 13px; }
.sched-back:hover { color: var(--blue); }
#sched-inst .panel-title { font-size: 15px; font-weight: 700; }
.spacer { flex: 1; }

.sched-slots { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.sched-slot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(46, 53, 59, 0.04);
  padding: 11px 16px;
}
.sched-slot .info { flex: 1; min-width: 220px; }
.sched-slot h4 { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sched-slot .desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.sched-slot .actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.sched-slot .actions select { max-width: 260px; }
.sched-slot.st-filled { border-left-color: #40bf6a; }
.sched-slot.st-usual { border-left-color: #40bf6a; }
.sched-slot.st-needs { border-left-color: var(--orange); background: linear-gradient(90deg, #fdf3e9, var(--card) 55%); }
.sched-slot.st-soon { border-left-color: #b9c3cc; }
.sched-slot .state { font-size: 10px; font-weight: 900; letter-spacing: 0.04em; border-radius: 4px; padding: 2px 7px; }
.sched-slot .state.st-filled, .sched-slot .state.st-usual { background: #ecf9f0; color: #40bf6a; }
.sched-slot .state.st-needs { background: #fdf3e9; color: #d0652c; }
.sched-slot .state.st-soon { background: #f1f4f7; color: var(--muted); }

.sched-export { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 6px 2px; }
.sched-export-note { color: var(--muted); font-size: 12.5px; }
#sched-export-result { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; width: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
#sched-export-result a { color: var(--blue); font-weight: 700; }
#sched-export-result audio { height: 34px; flex: 1; min-width: 220px; max-width: 420px; }

button.sm { padding: 4px 10px; font-size: 12px; }

/* --- audience: splits, listeners, and the per-variant slot rows ----------- */

#aud-body { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(340px, 1.2fr);
  gap: 16px; align-items: start; }
@media (max-width: 900px) { #aud-body { grid-template-columns: 1fr; } }

.aud-dim { border: 1px solid var(--border-soft); border-radius: 9px; padding: 11px 13px;
  margin-bottom: 11px; background: var(--card); }
.aud-dim-head { display: flex; gap: 8px; align-items: center; }
.aud-dim-name { flex: 1; font-weight: 700; font-size: 14px; padding: 7px 9px; }
.aud-vals { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.aud-val { display: inline-flex; align-items: center; gap: 3px; background: var(--wave-bg);
  border: 1px solid var(--border-soft); border-radius: 999px; padding: 2px 4px 2px 10px; }
.aud-val input { border: 0; background: transparent; font-size: 12.5px; width: 118px; padding: 3px 0; }
.aud-val input:focus { outline: none; border-bottom: 1px solid var(--blue); }
.aud-addval { border-style: dashed; }

.aud-count { background: var(--wave-bg); border-radius: 999px; padding: 1px 9px;
  font-size: 11.5px; color: var(--muted); font-weight: 700; margin-left: 6px; }
.aud-list { display: flex; flex-direction: column; gap: 8px; }
.aud-listener { border: 1px solid var(--border-soft); border-radius: 9px; background: var(--card);
  padding: 9px 12px; }
.aud-listener.open { border-color: var(--blue); }
.aud-l-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.aud-l-head input[type="text"] { width: 150px; font-size: 13.5px; font-weight: 700; padding: 5px 8px; }
.aud-l-groups { flex: 1; display: flex; gap: 5px; flex-wrap: wrap; min-width: 120px; }
.aud-chip { background: #eef0ff; color: var(--blue); border-radius: 999px; padding: 2px 9px;
  font-size: 11.5px; font-weight: 700; }
.aud-none { color: var(--muted); font-size: 12px; font-style: italic; }
.aud-l-edit { margin-top: 10px; border-top: 1px dashed var(--border-soft); padding-top: 9px; }
.aud-l-dim { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.aud-l-dimname { font-size: 11.5px; font-weight: 900; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); min-width: 88px; }
.aud-pick { font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px; }

/* one part, several audiences: rows after the first tuck under their part */
.sched-slot.sched-samepart { margin-top: -8px; border-top-left-radius: 0; border-top-right-radius: 0; }
.sched-slot.sched-variant { margin-left: 18px; }
.sched-slot.sched-fallback { border-left-style: dashed; opacity: 0.92; }
.sched-slot .slot-cont { color: var(--muted); font-weight: 400; }
.sched-slot .slot-aud { background: #eef0ff; color: var(--blue); border-radius: 999px;
  padding: 1px 9px; font-size: 11px; font-weight: 800; }
.sched-slot.sched-fallback .slot-aud { background: var(--wave-bg); color: var(--muted); }

/* who hears what, and listening as one of them */
.sched-aud { background: var(--card); border: 1px solid var(--border-soft); border-radius: 9px;
  padding: 11px 14px; margin-bottom: 12px; max-width: 760px; }
.sched-aud-empty { color: var(--muted); font-size: 12.5px; }
.sched-aud-empty a { color: var(--blue); font-weight: 700; }
.sched-aud-head { font-size: 13px; margin-bottom: 8px; }
.sched-cohorts { display: flex; flex-direction: column; gap: 5px; }
.sched-cohort { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  border-left: 3px solid var(--blue); padding-left: 9px; }
.coh-who { font-size: 12.5px; font-weight: 700; }
.coh-meta { font-size: 12px; color: var(--muted); }
.coh-missing { color: var(--orange); font-weight: 700; }

.sched-listen { display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  max-width: 760px; margin-bottom: 12px; }
.sched-listen label { font-size: 12.5px; font-weight: 700; }
.sched-listen-meta { font-size: 12px; color: var(--muted); }
.sched-listen-lineup { display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  width: 100%; }
.listen-seg { background: var(--wave-bg); border: 1px solid var(--border-soft);
  border-radius: 6px; padding: 3px 9px; font-size: 11.5px; }
.listen-arrow { color: var(--muted); font-size: 11px; }

/* a template part that plays differently per listener */
.tpl-vary { font-size: 11px; color: var(--blue); font-weight: 800; }
.tpl-vary-dot { color: var(--blue); }

.coh-aud { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.coh-aud .aud-chip { font-size: 10.5px; }
