/* ====================================================================
   STORY MODE (story.html) -- laid out in the Storybook mood's palette
   and type (moods/storybook.css is loaded first for the header, the
   fonts, the wave and the focus ring). There is no design board for
   this page: it is a plain reading column, a vellum panel for playback
   and the chapter's script, and the voice table on the night desk.
   ==================================================================== */

.st-page { min-height: 100vh; display: flex; flex-direction: column; background: #0B1620; }
.st-main { flex: 1 0 auto; width: 100%; max-width: 1100px; box-sizing: border-box; margin: 0 auto; padding: 0 24px 60px; display: flex; flex-direction: column; gap: 26px; }
.st-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- title ---------- */
.st-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 0 0; text-align: center; }
.st-title { margin: 0; font-family: 'Cinzel', serif; font-weight: 700; font-size: 44px; line-height: 1.15; letter-spacing: 2px; color: #EDE6D6; text-shadow: 0 0 40px rgba(217,164,65,0.25); }
.st-meta { margin: 0; font-style: italic; font-size: 17px; color: #A9C9C4; }

/* ---------- loading a story ---------- */
.st-load { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px; border: 1px dashed #2A4A4A; border-radius: 14px; text-align: center; }
.st-page.is-dragging .st-load { border-color: #D9A441; background: #0F1E28; }
.st-file { display: inline-flex; align-items: center; }
.st-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.st-file:focus-within { outline: 3px solid #5AA8A0; outline-offset: 4px; }
.st-load-note { margin: 4px 0 0; font-size: 17px; color: #EDE6D6; }
.st-load-note.is-error { color: #E9BE62; }
.st-load-hint { margin: 0; font-style: italic; font-size: 14px; color: #7E9593; }

/* ---------- buttons ---------- */
.st-btn {
  height: 46px; padding: 0 20px; box-sizing: border-box; border: 1px solid #0F1E28; border-radius: 6px; background: transparent; color: #0F1E28;
  font-family: 'Cinzel', serif; font-weight: 600; font-size: 13px; letter-spacing: 2px; cursor: pointer;
}
.st-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.st-btn--gold { background: #D9A441; border-color: #8A6420; }
.st-btn--dark { background: #0F1E28; border-color: #D9A441; color: #D9A441; }
.st-btn--ghost { border-color: #2A4A4A; color: #A9C9C4; }
.st-btn--small { height: 38px; padding: 0 14px; font-size: 12px; letter-spacing: 1px; }

/* ---------- rendered audio ---------- */
.st-render { display: flex; flex-direction: column; gap: 14px; padding: 20px; border: 1px solid #1E3A3A; border-radius: 14px; background: #0F1E28; }
.st-render-head { display: flex; flex-direction: column; gap: 6px; }
.st-render-title { margin: 0; font-family: 'Cinzel', serif; font-weight: 600; font-size: 13px; letter-spacing: 5px; text-transform: uppercase; color: #5AA8A0; }
.st-render-note { margin: 0; font-size: 16px; line-height: 1.45; color: #EDE6D6; }
.st-render-note.is-error { color: #E9BE62; }
.st-render-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.st-render-actions .st-btn[hidden] { display: none; }
.st-file.is-disabled { opacity: 0.45; cursor: not-allowed; }
.st-render-progress { display: flex; flex-direction: column; gap: 8px; }
.st-render-progress[hidden] { display: none; }
.st-render-progress .sb-progress { background: rgba(90,168,160,0.2); }
.st-render-progress .sb-progress-fill { background: #D9A441; }
.st-render-text { font-family: 'Cinzel', serif; font-size: 13px; letter-spacing: 1px; color: #A9C9C4; font-variant-numeric: tabular-nums; }

/* ---------- vellum panels ---------- */
.st-panel {
  background: #EDE6D6; color: #1B2A36; border-radius: 8px; padding: 28px 32px; box-sizing: border-box;
  box-shadow: 0 0 0 6px #132A2A, 0 0 0 7px #B8923E, 0 30px 60px rgba(0,0,0,0.55), inset 0 0 80px rgba(160,120,60,0.18);
  display: flex; flex-direction: column; gap: 20px;
}
.st-player-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.st-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.st-field--chapter { flex: 1 1 280px; max-width: 460px; }

.st-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; font-style: italic; color: #3B4B57; cursor: pointer; }
.st-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.st-switch-track { position: relative; flex-shrink: 0; width: 44px; height: 24px; border-radius: 999px; background: #C9BFA8; border: 1px solid #B8923E; transition: background .15s ease; }
.st-switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #F6F1E6; border: 1px solid #8A6420; transition: transform .15s ease; }
.st-switch input:checked + .st-switch-track { background: #2E6E69; }
.st-switch input:checked + .st-switch-track::after { transform: translateX(20px); }
.st-switch input:focus-visible + .st-switch-track { outline: 3px solid #5AA8A0; outline-offset: 3px; }

/* ---------- now playing ---------- */
.st-now { display: flex; flex-direction: column; gap: 10px; min-height: 150px; padding: 18px 20px; border: 1px solid #B8923E; border-radius: 6px; background: #F6F1E6; }
.st-now-speaker { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.st-now-name { font-family: 'Cinzel', serif; font-weight: 700; font-size: 20px; letter-spacing: 1px; color: #8A6420; }
.st-now-role { font-style: italic; font-size: 15px; color: #2E6E69; }
.st-now-text { margin: 0; font-size: 22px; line-height: 1.5; color: #1B2A36; }
.st-now.is-cue { background: #0F1E28; border-color: #D9A441; }
.st-now.is-cue .st-now-name { font-family: 'Silkscreen', monospace; font-weight: 400; font-size: 13px; color: #5AA8A0; }
.st-now.is-cue .st-now-text { font-style: italic; color: #EDE6D6; }
.st-now.is-pause .st-now-text { font-style: italic; color: #8A6420; }
.st-direction { margin: 0; font-style: italic; font-size: 14px; line-height: 1.35; color: #8A6420; }
.st-direction[hidden] { display: none; }
/* The Kokoro voice id the current line is spoken in. */
.st-voice-used { margin: auto 0 0; font-family: 'Silkscreen', monospace; font-size: 10px; letter-spacing: 0.5px; color: #2E6E69; }
.st-voice-used[hidden] { display: none; }
.st-voice-used.is-wrong { color: #A33B2B; }

.st-transport { display: flex; flex-wrap: wrap; gap: 10px; }
.st-status { display: flex; flex-direction: column; gap: 8px; }
.st-status-row { display: flex; align-items: center; gap: 18px; min-height: 26px; }
.st-state { font-family: 'Cinzel', serif; font-weight: 700; font-size: 16px; letter-spacing: 3px; color: #0F1E28; }
.st-wave { display: flex; align-items: center; gap: 4px; height: 24px; }
.st-wave span { height: 24px; width: 4px; }

/* ---------- the chapter's script ---------- */
.st-lines { position: relative; list-style: none; margin: 0; padding: 0 6px 0 0; max-height: 520px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.st-seg {
  display: block; width: 100%; box-sizing: border-box; margin: 0; padding: 10px 14px; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-left: 4px solid transparent; border-radius: 4px;
  font-family: 'Cardo', Georgia, serif; font-size: 18px; line-height: 1.5; color: #1B2A36;
}
.st-seg:hover { background: rgba(184,146,62,0.12); }
.st-seg:focus-visible { outline: 3px solid #5AA8A0; outline-offset: 2px; }
.st-seg-speaker { display: block; font-family: 'Cinzel', serif; font-weight: 600; font-size: 12px; letter-spacing: 2px; color: #8A6420; }
.st-seg-tag { font-family: 'Silkscreen', monospace; font-weight: 400; font-size: 9px; letter-spacing: 0.5px; color: #2E6E69; border: 1px solid #2E6E69; border-radius: 999px; padding: 2px 7px; margin-left: 8px; }
.st-seg-text { display: block; }
.st-seg .st-direction { display: block; margin-top: 2px; }
.st-line--dialogue .st-seg { padding-left: 30px; }
.st-line--lore .st-seg { font-style: italic; }
/* Cue cards: shown, never spoken. */
.st-line--cue .st-seg { background: #0F1E28; border-color: #2A4A4A; border-left-color: #2A4A4A; color: #EDE6D6; font-size: 16px; font-style: italic; }
.st-line--cue .st-seg-speaker { font-family: 'Silkscreen', monospace; font-weight: 400; font-size: 10px; letter-spacing: 1px; color: #5AA8A0; }
.st-line--pause .st-seg { padding: 4px 14px; text-align: center; font-family: 'Cinzel', serif; font-size: 12px; letter-spacing: 3px; color: #8A6420; }
.st-line.is-skipped .st-seg { opacity: 0.4; }
.st-line.is-current .st-seg { background: #F6F1E6; border-color: #B8923E; border-left-color: #D9A441; box-shadow: 0 6px 16px rgba(60,40,10,0.18); }
.st-line--cue.is-current .st-seg { background: #0F1E28; border-color: #D9A441; border-left-color: #D9A441; box-shadow: 0 0 0 2px rgba(217,164,65,0.35); }
.st-line.is-current .st-seg-speaker { color: #2E6E69; }
.st-line--cue.is-current .st-seg-speaker { color: #D9A441; }

/* ---------- the voice table ---------- */
.st-voices { display: flex; flex-direction: column; gap: 12px; padding-top: 20px; }
.st-voices-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.st-voices-title { margin: 0; font-family: 'Cinzel', serif; font-weight: 700; font-size: 34px; letter-spacing: 2px; color: #D9A441; }
.st-voices-note { margin: 0; font-style: italic; font-size: 15px; color: #A9C9C4; }
.st-table { width: 100%; border-collapse: collapse; }
.st-table th { padding: 10px 12px; text-align: left; font-family: 'Cinzel', serif; font-weight: 500; font-size: 12px; letter-spacing: 3px; color: #5AA8A0; border-bottom: 1px solid #2A4A4A; }
.st-table td { padding: 14px 12px; vertical-align: top; border-bottom: 1px solid #1E3A3A; }
.st-table tr.is-speaking td { background: #0F1E28; }
.st-table tr.is-speaking td:first-child { box-shadow: inset 4px 0 0 #D9A441; }
.st-voice-name { font-family: 'Cinzel', serif; font-weight: 700; font-size: 16px; line-height: 1.25; color: #EDE6D6; }
.st-table tr.is-speaking .st-voice-name { color: #D9A441; }
.st-voice-id { margin-top: 4px; font-family: 'Silkscreen', monospace; font-size: 9px; letter-spacing: 0.5px; color: #5AA8A0; }
.st-voice-style { font-style: italic; font-size: 15px; color: #A9C9C4; }
.st-voice-desc { margin: 4px 0 0; font-size: 15px; line-height: 1.45; color: #C9D6D2; }
.st-voice-warn { margin: 6px 0 0; font-style: italic; font-size: 13px; color: #E9BE62; }
.st-table .sb-select { width: 100%; min-width: 190px; }
.st-speed { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.st-speed input { flex: 1 1 auto; min-width: 0; height: 44px; margin: 0; accent-color: #D9A441; }
.st-speed-value { flex-shrink: 0; width: 46px; text-align: right; font-family: 'Cinzel', serif; font-size: 14px; color: #D9A441; font-variant-numeric: tabular-nums; }
.st-table .st-btn { border-color: #D9A441; color: #D9A441; white-space: nowrap; }
.st-table .st-btn.is-previewing { background: #D9A441; color: #0F1E28; }

.st-footer { display: flex; justify-content: center; padding: 26px 0 30px; border-top: 1px solid #1E3A3A; }

/* ---------- narrow screens: the table's rows become stacked cards ---------- */
@media (max-width: 820px) {
  .st-main { padding: 0 16px 40px; gap: 20px; }
  .st-hero { padding-top: 24px; }
  .st-title { font-size: 28px; letter-spacing: normal; text-shadow: none; }
  .st-meta { font-size: 15px; }
  .st-panel { padding: 20px 18px; box-shadow: 0 0 0 4px #132A2A, 0 0 0 5px #B8923E, inset 0 0 60px rgba(160,120,60,0.2); }
  .st-now-text { font-size: 19px; }
  .st-transport { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .st-transport .st-btn { padding: 0; }
  .st-transport .st-btn--gold { grid-column: 1 / -1; grid-row: 1; }
  .st-render-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .st-render-actions .st-file { justify-content: center; }
  .st-seg { font-size: 17px; }
  .st-line--dialogue .st-seg { padding-left: 20px; }
  .st-voices-title { font-size: 26px; }
  .st-table, .st-table tbody, .st-table tr, .st-table td { display: block; }
  .st-table thead { display: none; }
  .st-table tr { padding: 14px 0; border-bottom: 1px solid #1E3A3A; }
  .st-table td { padding: 6px 10px; border-bottom: 0; }
}
