/* Book — open-spread script editor for Movie 10s beats (pages 1–360) */

#panel-book.panel[hidden] {
  display: none !important;
}

#panel-book.panel.active {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 5rem);
  max-height: calc(100dvh - 5rem);
  overflow: hidden;
  padding: 0;
  margin: 0;
}

body.bk-tab-active #panel-book.panel.active {
  min-height: 100dvh;
  max-height: 100dvh;
}

body.bk-tab-active .site-footer,
body.bk-tab-active .site-header .subtitle {
  display: none;
}

body.bk-tab-active .site-header {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.bk-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse 100% 70% at 50% 0%, #2a2010 0%, #120e08 45%, #080604 100%);
  color: #f0e8d8;
}

.bk-top {
  flex: 0 0 auto;
  padding: 0.45rem 0.9rem 0.35rem;
  border-bottom: 1px solid rgba(200, 160, 80, 0.25);
}

.bk-top h2 {
  margin: 0 0 0.12rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  background: linear-gradient(90deg, #ffe0a0, #c9a24a, #fff5d8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.bk-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 56rem;
}

.bk-hint strong {
  color: #e8d5a8;
}

.bk-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid rgba(180, 140, 60, 0.2);
}

.bk-spread-label {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: #e8d5a8;
  min-width: 8rem;
  text-align: center;
}

.bk-btn {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  border: 1px solid rgba(200, 160, 80, 0.35);
  background: rgba(40, 30, 16, 0.9);
  color: #f0e8d8;
  cursor: pointer;
}

.bk-btn:hover:not(:disabled) {
  border-color: rgba(255, 210, 120, 0.55);
}

.bk-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bk-btn.accent {
  background: linear-gradient(165deg, #8a6420, #4a3410);
  border-color: rgba(220, 170, 70, 0.5);
  font-weight: 600;
}

.bk-field {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: rgba(230, 210, 170, 0.85);
}

.bk-field input,
.bk-select {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.28rem 0.4rem;
  border-radius: 6px;
  border: 1px solid rgba(200, 160, 80, 0.3);
  background: #1a140c;
  color: #f0e8d8;
  width: 4.5rem;
}

.bk-select {
  width: auto;
}

.bk-spread {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem 0.4rem;
  overflow: auto;
}

.bk-page {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(180, 140, 70, 0.28);
  background: linear-gradient(180deg, #f7f0e0 0%, #ebe0c8 100%);
  color: #1a140c;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.bk-page[data-side="left"] {
  border-radius: 8px 2px 2px 8px;
}

.bk-page[data-side="right"] {
  border-radius: 2px 8px 8px 2px;
}

.bk-page-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(40, 30, 10, 0.12);
  padding-bottom: 0.25rem;
}

.bk-page-num {
  font-weight: 700;
  font-size: 0.85rem;
}

.bk-page-act {
  font-size: 0.72rem;
  color: rgba(40, 30, 10, 0.55);
  font-style: italic;
}

.bk-page-preview {
  position: relative;
  width: 100%;
  aspect-ratio: var(--bk-ar, 16 / 9);
  max-height: 180px;
  background: #0c0a08;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex: 0 0 auto;
}

.bk-page-preview-compact {
  max-height: 110px;
  min-height: 72px;
}

.bk-page-img,
.bk-page-vid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.bk-page-img[hidden],
.bk-page-vid[hidden],
.bk-page-empty[hidden] {
  display: none !important;
}

.bk-page-empty {
  margin: 0;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(240, 230, 200, 0.45);
  font-size: 0.78rem;
}

.bk-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(40, 30, 10, 0.55);
  margin-top: 0.15rem;
}

.bk-script {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 0.45rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(40, 30, 10, 0.18);
  background: rgba(255, 252, 245, 0.95);
  color: #1a140c;
  resize: vertical;
  min-height: 4.5rem;
}

.bk-script-sm {
  min-height: 2.6rem;
}

.bk-dialogue {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  min-height: 8rem;
}

/* —— Live chat is the hard focus of each page —— */
.bk-live-chat {
  flex: 1 1 auto;
  min-height: 14rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0.55rem 0.6rem 0.65rem;
  border-radius: 10px;
  background: linear-gradient(165deg, rgba(28, 20, 12, 0.94), rgba(12, 10, 8, 0.97));
  border: 1px solid rgba(201, 162, 74, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 230, 160, 0.08), 0 8px 24px rgba(0, 0, 0, 0.25);
  color: #f2ebe0;
}

.bk-live-chat-head {
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(201, 162, 74, 0.22);
  padding-bottom: 0.35rem;
}

.bk-live-chat-title {
  margin: 0;
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: #f0d48a;
}

.bk-live-chat-sub {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  color: rgba(230, 210, 170, 0.7);
  line-height: 1.3;
}

.bk-live-chat-dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(201, 162, 74, 0.18);
}

.bk-mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.65rem 1.15rem;
  border-radius: 999px;
  border: 1px solid rgba(220, 80, 80, 0.45);
  background: linear-gradient(165deg, #8a3030, #3a1414);
  color: #fff5f0;
  cursor: pointer;
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
  letter-spacing: 0.02em;
}

.bk-mic-btn:hover {
  border-color: rgba(220, 100, 100, 0.55);
}

.bk-mic-btn.recording {
  background: linear-gradient(165deg, #c03030, #601818);
  border-color: #ff6a6a;
  box-shadow: 0 0 0 3px rgba(220, 60, 60, 0.25), 0 0 18px rgba(200, 40, 40, 0.45);
  animation: bk-mic-pulse 1.1s ease-in-out infinite;
}

.bk-mic-btn.thinking {
  opacity: 0.85;
  cursor: wait;
}

@keyframes bk-mic-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(220, 60, 60, 0.2), 0 0 10px rgba(200, 40, 40, 0.3);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(220, 60, 60, 0.35), 0 0 22px rgba(255, 80, 80, 0.5);
  }
}

.bk-talk-hint {
  margin: 0;
  font-size: 0.7rem;
  color: rgba(230, 210, 170, 0.65);
  line-height: 1.35;
  text-align: center;
}

.bk-conversation {
  flex: 1 1 auto;
  min-height: 10rem;
  max-height: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.88rem;
  line-height: 1.4;
  padding: 0.35rem 0.15rem;
  scrollbar-width: thin;
}

.bk-conversation:empty::before {
  content: "Live chat is empty — press Talk to page and speak. Your words and the art’s reply land here.";
  color: rgba(230, 210, 170, 0.45);
  font-style: italic;
  font-size: 0.85rem;
  line-height: 1.45;
  padding: 1.25rem 0.75rem;
  text-align: center;
  margin: auto 0;
}

.bk-chat-line {
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  white-space: pre-wrap;
  animation: bk-chat-in 0.25s ease;
}

@keyframes bk-chat-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bk-chat-line.you {
  background: rgba(70, 110, 170, 0.28);
  border-left: 3px solid #7aabf0;
  align-self: flex-end;
  max-width: 92%;
  color: #e8f0ff;
}

.bk-chat-line.art {
  background: rgba(160, 110, 40, 0.28);
  border-left: 3px solid #e0b050;
  align-self: flex-start;
  max-width: 92%;
  color: #fff4d8;
}

.bk-chat-line.intercom {
  background: rgba(40, 55, 50, 0.55);
  border-left: 3px solid #6ecf9a;
  align-self: center;
  max-width: 96%;
  color: #d8ffe8;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.84rem;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(110, 200, 150, 0.15);
}

.bk-chat-who {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
  opacity: 0.75;
}

.bk-voice-player {
  width: 100%;
  height: 2.1rem;
  margin-top: 0.1rem;
  filter: invert(0.05);
}

.bk-clarity-btn {
  font-size: 0.75rem !important;
  padding: 0.4rem 0.65rem !important;
  flex: 0 0 auto;
  color: #f0e8d8 !important;
  background: rgba(40, 30, 16, 0.85) !important;
}

.bk-talk-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: stretch;
}

.bk-talk-row .bk-mic-btn {
  flex: 1 1 12rem;
}

.bk-clear-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.bk-clear-btn {
  font-size: 0.72rem !important;
  padding: 0.32rem 0.55rem !important;
  color: #f0e8d8 !important;
  background: rgba(40, 30, 16, 0.75) !important;
  border-color: rgba(180, 140, 80, 0.35) !important;
}

.bk-clear-btn:hover {
  border-color: rgba(240, 180, 100, 0.55) !important;
}

.bk-clear-all {
  border-color: rgba(200, 100, 80, 0.45) !important;
}

.bk-live-status {
  min-height: 1.3em;
  color: rgba(230, 210, 170, 0.85) !important;
  font-size: 0.78rem !important;
}

.bk-live-status.ok {
  color: #8fd9a8 !important;
}

.bk-live-status.error {
  color: #f0a0a0 !important;
}

.bk-live-status.pending {
  color: #e0c878 !important;
}

/* Script desk folds away — chat stays primary */
.bk-script-desk {
  flex: 0 0 auto;
  border-radius: 6px;
  border: 1px solid rgba(40, 30, 10, 0.14);
  background: rgba(255, 252, 245, 0.55);
  font-size: 0.78rem;
}

.bk-script-desk > summary {
  cursor: pointer;
  padding: 0.4rem 0.55rem;
  font-weight: 600;
  color: rgba(40, 30, 10, 0.7);
  list-style: none;
  user-select: none;
}

.bk-script-desk > summary::-webkit-details-marker {
  display: none;
}

.bk-script-desk > summary::before {
  content: "▸ ";
  color: rgba(140, 100, 40, 0.8);
}

.bk-script-desk[open] > summary::before {
  content: "▾ ";
}

.bk-script-desk-hint {
  font-weight: 400;
  font-size: 0.68rem;
  color: rgba(40, 30, 10, 0.45);
  margin-left: 0.25rem;
}

.bk-script-desk-body {
  padding: 0.15rem 0.55rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 40vh;
  overflow-y: auto;
}

.bk-script-desk .bk-script,
.bk-script-desk .bk-dialogue {
  min-height: 2.8rem;
}

.bk-script:focus {
  outline: 2px solid rgba(180, 130, 40, 0.45);
  outline-offset: 1px;
}

.bk-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.bk-page-actions .bk-btn {
  color: #f0e8d8;
}

.bk-page-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.72rem;
  color: rgba(40, 30, 10, 0.65);
}

.bk-page-status.ok {
  color: #1a6b3a;
}

.bk-page-status.error {
  color: #8b2020;
}

.bk-page-status.pending {
  color: #6a4a10;
}

.bk-status {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.35rem 0.85rem 0.55rem;
  font-size: 0.78rem;
  color: rgba(230, 210, 170, 0.85);
}

@media (max-width: 900px) {
  .bk-spread {
    grid-template-columns: 1fr;
  }

  .bk-page[data-side="left"],
  .bk-page[data-side="right"] {
    border-radius: 8px;
  }
}
