/* Retold — warm paper for the quiet screens, dark stage for the live one. */

:root {
  --paper:      #FAF7F2;
  --card:       #FFFFFF;
  --ink:        #1C1A17;
  --muted:      #7A736A;
  --faint:      #A79E92;
  --line:       #E4DCD1;
  --line-soft:  #EFE8DE;

  --ember:      #C2571E;
  --ember-dim:  #A4471480;
  --ember-soft: #FBEDE3;
  --teal:       #1F6F6B;
  --teal-soft:  #E6F0EE;
  --live:       #C8322A;

  --stage:      #131110;
  --stage-2:    #1D1A17;
  --stage-line: #332E29;
  --stage-ink:  #F4EFE8;
  --stage-mute: #9B9188;

  --r-sm: 8px;
  --r:    13px;
  --r-lg: 20px;

  --shadow:    0 1px 2px rgba(40,26,14,.05), 0 8px 24px rgba(40,26,14,.06);
  --shadow-lg: 0 2px 6px rgba(40,26,14,.06), 0 24px 60px rgba(40,26,14,.12);

  --display: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--ui);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.08rem; }

a { color: var(--ember); }

/* ---------- shell ---------- */

.boot { display: grid; place-items: center; min-height: 100vh; }

.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--ember);
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 13px 22px;
  background: rgba(250,247,242,.88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--display); font-size: 1.22rem; font-weight: 600;
  letter-spacing: -.02em; color: var(--ink); text-decoration: none;
  display: flex; align-items: center; gap: 9px;
}
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ember); }

.topbar .spacer { flex: 1; }
.topbar .who { font-size: .85rem; color: var(--muted); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 30px 22px 80px; }
.wrap.narrow { max-width: 620px; }

/* ---------- type helpers ---------- */

.lede { color: var(--muted); font-size: 1.02rem; max-width: 60ch; }
.small { font-size: .84rem; color: var(--muted); }
.tiny { font-size: .76rem; color: var(--faint); }
.mono { font-family: var(--mono); font-size: .8rem; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.mt { margin-top: 22px; }
.mt-sm { margin-top: 12px; }
.mb { margin-bottom: 18px; }
.center { text-align: center; }

/* ---------- controls ---------- */

.btn {
  font: inherit; font-weight: 600; font-size: .9rem;
  padding: 10px 17px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 8px; justify-content: center;
  transition: background .15s, border-color .15s, transform .06s, opacity .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--faint); background: #FFFDFA; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .48; cursor: not-allowed; }

.btn.primary { background: var(--ember); border-color: var(--ember); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #AC4B18; border-color: #AC4B18; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--line-soft); color: var(--ink); }
.btn.danger { color: var(--live); border-color: #EFD3D0; background: #FDF4F3; }
.btn.danger:hover:not(:disabled) { background: #FBE9E7; }
.btn.sm { padding: 6px 11px; font-size: .81rem; }
.btn.block { width: 100%; }

input[type=text], input[type=email], input[type=datetime-local], textarea, select {
  font: inherit; font-size: .93rem; width: 100%;
  padding: 10px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px var(--ember-soft);
}
textarea { resize: vertical; min-height: 78px; line-height: 1.5; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }

/* ---------- cards ---------- */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.panel > header {
  padding: 13px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel > header h3 { font-size: .95rem; font-family: var(--ui); font-weight: 700; }
.panel .body { padding: 18px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .71rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 9px; border-radius: 100px; background: var(--line-soft); color: var(--muted);
}
.pill.host { background: var(--ember-soft); color: #9C4514; }
.pill.cohost { background: #EDE7F6; color: #5B3E8E; }
.pill.contributor { background: var(--teal-soft); color: #17544F; }
.pill.viewer { background: #EDEFF2; color: #55606B; }
.pill.onair { background: #FCE9E7; color: var(--live); }
.pill.onair::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--live); animation: pulse 1.4s infinite; }
.pill.done { background: var(--teal-soft); color: #17544F; }
@keyframes pulse { 50% { opacity: .25; } }

.empty { text-align: center; padding: 46px 20px; color: var(--faint); }
.empty h3 { color: var(--muted); margin-bottom: 6px; }

/* ---------- show list ---------- */

.show-row {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--card); text-decoration: none; color: inherit; margin-bottom: 12px;
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.show-row:hover { border-color: var(--faint); box-shadow: var(--shadow); transform: translateY(-1px); }
.show-row .thumb {
  width: 86px; height: 62px; border-radius: var(--r-sm); flex: none;
  background: var(--line-soft); object-fit: cover; border: 1px solid var(--line);
}
.show-row .title { font-family: var(--display); font-size: 1.12rem; font-weight: 600; }

.recording-list { border-top: 1px solid var(--line-soft); }
.recording-row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 15px 0; border-bottom: 1px solid var(--line-soft);
}
.recording-row:last-child { border-bottom: 0; padding-bottom: 0; }
.recording-empty { padding: 24px 12px 8px; }

.danger-zone { border-color: #E4B8B4; }
.danger-zone > header { background: #FDF4F3; border-bottom-color: #EFD3D0; }
.danger-zone > header h3 { color: var(--live); }
.danger-confirm { margin-top: 18px; padding-top: 18px; border-top: 1px solid #EFD3D0; }
.danger-confirm[hidden] { display: none; }
.danger-title { display: block; margin: 3px 0 10px; font-family: var(--mono); font-size: .84rem; }

/* ---------- builder ---------- */

.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--r);
  padding: 30px; text-align: center; color: var(--muted);
  background: #FDFBF8; transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone.hot { border-color: var(--ember); background: var(--ember-soft); color: #9C4514; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }

.photo-tile {
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  background: var(--card); position: relative; cursor: grab;
}
.photo-tile.dragging { opacity: .4; }
.photo-tile.over { border-color: var(--ember); box-shadow: 0 0 0 3px var(--ember-soft); }
.photo-tile img { width: 100%; aspect-ratio: 3/2; object-fit: cover; display: block; background: var(--line-soft); }
.photo-tile .n {
  position: absolute; top: 8px; left: 8px; background: rgba(28,26,23,.78); color: #fff;
  font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 100px;
}
.photo-tile .x {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(28,26,23,.7); color: #fff; cursor: pointer; font-size: .9rem;
  opacity: 0; transition: opacity .15s;
}
.photo-tile:hover .x { opacity: 1; }
.photo-tile .cap { border: none; border-top: 1px solid var(--line-soft); border-radius: 0; font-size: .8rem; padding: 8px 10px; }
.photo-tile .cap:focus { box-shadow: none; border-color: var(--line-soft); background: var(--ember-soft); }

.invite-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.invite-row:last-child { border-bottom: none; }
.invite-row input { font-family: var(--mono); font-size: .76rem; background: #FCFAF7; }

/* ---------- slideshow / annotation ---------- */

.stagebox { position: relative; background: #100E0D; border-radius: var(--r); overflow: hidden; }
.stagebox img { width: 100%; display: block; max-height: 68vh; object-fit: contain; }
.stagebox .layer { position: absolute; inset: 0; }
.stagebox canvas.layer { pointer-events: none; }
.stagebox .layer.grab { cursor: crosshair; }

.slide-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.slide-dots { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; max-width: 460px; }
.slide-dots button {
  width: 9px; height: 9px; border-radius: 50%; border: none; padding: 0;
  background: var(--line); cursor: pointer;
}
.slide-dots button.on { background: var(--ember); transform: scale(1.3); }
.slide-dots button.has { background: var(--teal); }

.pin {
  position: absolute; width: 25px; height: 25px; border-radius: 50%;
  background: var(--ember); color: #fff; border: 2px solid #fff;
  font-size: .75rem; font-weight: 700; display: grid; place-items: center;
  transform: translate(-50%, -50%); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.pin.answered { background: var(--teal); }

.qcard { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; background: var(--card); }
.qcard + .qcard { margin-top: 10px; }
.qcard.answered { opacity: .55; }
.qcard .q { font-family: var(--display); font-size: 1rem; }

/* ---------- live stage ---------- */

.live { background: var(--stage); color: var(--stage-ink); min-height: 100vh; display: flex; flex-direction: column; }
.live a { color: #F0A87B; }

.live-top {
  display: flex; align-items: center; gap: 14px; padding: 11px 18px;
  border-bottom: 1px solid var(--stage-line); background: var(--stage-2);
}
.live-top .title { font-family: var(--display); font-size: 1.02rem; }
.live-top .spacer { flex: 1; }
.live-top .clock { font-family: var(--mono); font-size: .84rem; color: var(--stage-mute); }

.live-main { flex: 1; display: grid; grid-template-columns: 1fr 336px; min-height: 0; }
.live-stagecol { display: flex; flex-direction: column; min-width: 0; padding: 18px; gap: 14px; }
.live-side { border-left: 1px solid var(--stage-line); background: var(--stage-2); display: flex; flex-direction: column; min-height: 0; }

.tabs { display: flex; border-bottom: 1px solid var(--stage-line); }
.tabs button {
  flex: 1; padding: 11px 6px; background: none; border: none; cursor: pointer;
  color: var(--stage-mute); font: inherit; font-size: .83rem; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tabs button.on { color: var(--stage-ink); border-bottom-color: var(--ember); }
.tabs .badge {
  display: inline-block; min-width: 17px; padding: 0 5px; margin-left: 5px;
  background: var(--ember); color: #fff; border-radius: 100px; font-size: .68rem;
}

.tabpane { flex: 1; overflow-y: auto; padding: 14px; display: none; min-height: 0; }
.tabpane.on { display: block; }

.msg { margin-bottom: 13px; font-size: .87rem; }
.msg .from { font-weight: 700; font-size: .78rem; color: var(--stage-mute); display: flex; align-items: center; gap: 6px; }
.msg .text { margin-top: 2px; }
.msg.snap { border: 1px solid var(--stage-line); border-radius: var(--r-sm); padding: 10px; background: #221E1A; }
.msg.snap .crop { width: 100%; border-radius: 6px; margin-bottom: 8px; display: block; background: #100E0D; }
.msg.system { color: var(--stage-mute); font-size: .8rem; font-style: italic; }

.composer { border-top: 1px solid var(--stage-line); padding: 11px; display: flex; gap: 8px; }
.composer input {
  background: var(--stage); border-color: var(--stage-line); color: var(--stage-ink); font-size: .87rem;
}
.composer input:focus { border-color: var(--ember); box-shadow: none; }

.person { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: .87rem; }
.person .meter { width: 42px; height: 4px; border-radius: 2px; background: var(--stage-line); overflow: hidden; }
.person .meter i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .1s; }
.person.talking .name { color: #7FD0C8; }

.live-bar {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-top: 1px solid var(--stage-line); background: var(--stage-2); flex-wrap: wrap;
}
.live-bar .spacer { flex: 1; }

.mic {
  display: flex; align-items: center; gap: 10px; padding: 7px 14px 7px 10px;
  border-radius: 100px; border: 1px solid var(--stage-line); background: var(--stage);
  color: var(--stage-ink); font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.mic.live-on { border-color: var(--teal); background: #16302D; color: #86DCD3; }
.mic .ring { width: 12px; height: 12px; border-radius: 50%; background: var(--stage-line); flex: none; }
.mic.live-on .ring { background: #3ECBBB; box-shadow: 0 0 0 4px rgba(62,203,187,.18); }

.seg { display: inline-flex; border: 1px solid var(--stage-line); border-radius: 100px; overflow: hidden; }
.seg button {
  padding: 7px 14px; background: none; border: none; cursor: pointer;
  color: var(--stage-mute); font: inherit; font-size: .81rem; font-weight: 600;
}
.seg button.on { background: var(--ember); color: #fff; }

.live .stagebox { background: #000; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.live .stagebox img { max-height: calc(100vh - 250px); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--ink); color: #FBF8F4; padding: 11px 16px; border-radius: var(--r-sm);
  font-size: .87rem; box-shadow: var(--shadow-lg); max-width: 340px;
  animation: rise .2s ease-out;
}
.toast.err { background: #8E2B23; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- replay ---------- */

.scrub { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.scrub input[type=range] { flex: 1; accent-color: var(--ember); }
.scrub .t { font-family: var(--mono); font-size: .82rem; color: var(--muted); min-width: 92px; }

.logline {
  display: grid; grid-template-columns: 62px 128px 1fr; gap: 10px;
  font-family: var(--mono); font-size: .74rem; padding: 3px 0;
  border-bottom: 1px solid var(--line-soft); color: var(--muted);
}
.logline.on { background: var(--ember-soft); color: var(--ink); }
.logline .ty { color: var(--ember); font-weight: 600; }

.pipeline { display: grid; gap: 10px; }
.stepline { display: flex; gap: 12px; align-items: flex-start; }
.stepline .bullet {
  width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--line-soft); color: var(--muted); font-size: .74rem; font-weight: 700;
}
.stepline.done .bullet { background: var(--teal); color: #fff; }
.stepline.active .bullet { background: var(--ember); color: #fff; }

.filetree { font-family: var(--mono); font-size: .78rem; line-height: 1.85; color: var(--muted); }
.filetree .k { color: var(--ink); }

.processing-state {
  min-height: 320px; display: grid; place-items: center; align-content: center;
  gap: 12px; text-align: center; padding: 34px 18px;
}
.processing-state .small { max-width: 520px; }
.activity-details {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.activity-details > summary {
  cursor: pointer; padding: 16px 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.activity-details > summary:hover { background: #FDFBF8; }
.activity-details[open] > summary { border-bottom: 1px solid var(--line-soft); }
.activity-body { padding: 0 18px; }
.activity-section { padding: 22px 0; border-bottom: 1px solid var(--line-soft); }
.activity-section:last-child { border-bottom: 0; }

@media (max-width: 860px) {
  .live-main { grid-template-columns: 1fr; }
  .live-side { border-left: none; border-top: 1px solid var(--stage-line); max-height: 44vh; }
  .live .stagebox img { max-height: 40vh; }
  h1 { font-size: 1.6rem; }
  .recording-row { align-items: stretch; flex-direction: column; }
  .recording-row .btn { align-self: flex-start; }
  .activity-details > summary { align-items: flex-start; flex-direction: column; gap: 3px; }
}
