/**
 * EchoLab shared theme — visual source of truth matches Recorder (/generate).
 * Variables + .card / .btn-* / .title / .subtitle used across Jobs, Recorder, Player.
 * Layout shell: .main-content + .container (served from this file at /css/theme.css).
 */

:root {
  --bg-main: #f4ecd8;
  --bg-card: rgba(255, 255, 255, 0.35);
  --border: rgba(46, 46, 46, 0.12);
  --text-main: #2e2e2e;
  --text-muted: #5a5548;
  --accent: #28506e;
  --radius-card: 16px;
  --shadow-card: 0 8px 24px rgba(46, 46, 46, 0.08);
  --font-serif: Georgia, "Times New Roman", serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Layout: dynamic viewport avoids iOS URL bar jump with 100vh */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-main: #1e1e1e;
    --bg-card: rgba(0, 0, 0, 0.25);
    --border: rgba(255, 255, 255, 0.1);
    --text-main: #ddd;
    --text-muted: #b8b3a8;
    --accent: #9ec5e8;
    --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

html,
body {
  height: 100%;
}

body.reading-theme {
  margin: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  background: var(--bg-main);
  color: var(--text-main);
}

/* Page frame: nav offset lives on .container; avoid nested scroll + main-content pad gap */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: var(--header-height, 52px);
  overflow: hidden;
}

.main-content > .container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.main-content > .container:not(.player-layout),
.main-content > .container.player-layout {
  padding-top: 0;
}

.container {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  background: transparent;
}

.reading-shell .app {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.reading-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: none;
  margin: 0;
  padding: 16px;
  padding-bottom: 32px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.8;
  color: var(--text-main);
}

/* Inside .container: width + padding come from container; keep vertical rhythm */
.reading-shell--framed {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  padding-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.reading-shell--player {
  padding-bottom: max(20px, 40dvh);
}

.reading-shell--framed.reading-shell--player {
  padding-bottom: max(20px, 40dvh);
}

.title {
  margin: 0 0 6px;
  font-size: 1.35em;
  font-weight: normal;
  letter-spacing: normal;
  color: var(--text-main);
}

.subtitle {
  margin: 0 0 22px;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Jobs page keeps subtitle but with tighter spacing */
#recentSubtitle.subtitle {
  margin: 0 0 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}

/* ----- Cards ----- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}

.app > .card {
  display: flex;
  flex: 1;
  flex-direction: column;
}

@media (min-width: 480px) {
  .card {
    padding: 22px 20px 24px;
  }
}

/* ----- Buttons ----- */

.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  text-decoration: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-primary {
  background: #e0d6b8;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 16px;
}

.btn-primary:hover:not(:disabled) {
  background: #d8ccb0;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary--block {
  width: 100%;
  margin-top: 18px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 650;
}

.btn-secondary {
  background: #ebe3cc;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 14px;
  font-size: 0.88rem;
}

.btn-secondary:hover:not(:disabled) {
  background: #e0d6b8;
}

.btn-secondary:disabled,
.btn-secondary.disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

.btn-danger {
  background: #8b2e2e;
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: #fff;
  padding: 8px 14px;
  font-size: 0.88rem;
}

.btn-danger:hover:not(:disabled) {
  background: #a23838;
}

.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (prefers-color-scheme: dark) {
  .btn-danger {
    background: #b84d4d;
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .btn-danger:hover:not(:disabled) {
    background: #c55a5a;
  }

  .btn-primary {
    background: #3a3528;
    border-color: rgba(255, 255, 255, 0.12);
    color: #ddd;
  }

  .btn-primary:hover:not(:disabled) {
    background: #454032;
  }

  .btn-secondary {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.12);
    color: #ddd;
  }

  .btn-secondary:hover:not(:disabled) {
    background: #333;
  }
}

/* ----- Form controls (Recorder + Player toolbars) ----- */

.field-row {
  margin-top: 14px;
  font-family: var(--font-ui);
}

.field-row--tight {
  margin-top: 10px;
}

.field-row label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.select-input,
.input-compact {
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(46, 46, 46, 0.15);
  background: #ebe3cc;
  color: var(--text-main);
  font-size: 14px;
  font-family: var(--font-ui);
}

.input-compact {
  width: auto;
  max-width: 5.5rem;
  padding: 6px 8px;
}

@media (prefers-color-scheme: dark) {
  .select-input,
  .input-compact {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.15);
    color: #ddd;
  }
}

.form-status {
  margin: 12px 0 0;
  min-height: 1.35em;
  font-size: 14px;
  font-family: var(--font-ui);
  line-height: 1.5;
  color: #6b4a38;
}

.form-status:empty {
  display: none;
}

.form-status--progress {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-status--warn {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-status a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.form-status a:hover {
  text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
  .form-status {
    color: #d4a574;
  }
}

.mode-note {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: #7a4c1f;
}

@media (prefers-color-scheme: dark) {
  .mode-note {
    color: #e0b07a;
  }
}

.optional-hint {
  font-weight: 400;
  color: #7a7568;
}

@media (prefers-color-scheme: dark) {
  .optional-hint {
    color: #9a9588;
  }
}

/* Recorder: textarea */
.textarea-field {
  flex: 1;
  min-height: 0;
  height: 100%;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text-main);
  padding: 16px;
  font-size: 17px;
  font-family: var(--font-serif);
  line-height: 1.75;
  resize: none;
}

.textarea-field:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(46, 46, 46, 0.12);
}

@media (prefers-color-scheme: dark) {
  .textarea-field {
    color: #ddd;
  }

  .textarea-field:focus {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  }
}

/* Input page: same content-first surface as reader, but editable */
body.input-page .container {
  max-width: 700px;
}

body.input-page .main-content {
  min-height: 100dvh;
  padding-top: calc(var(--header-height, 52px) + env(safe-area-inset-top, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(132px + env(safe-area-inset-bottom, 0px));
}

body.input-page .main-content > .container {
  overflow: visible;
}

body.input-page .reading-shell.reading-shell--framed {
  gap: 12px;
  padding-bottom: 20px;
  overflow: visible;
  overscroll-behavior: auto;
}

body.input-page .reading-shell .app {
  flex: 1;
  min-height: 0;
  position: relative;
}

body.input-page .input-content {
  overflow: visible;
  padding: 0;
}

body.input-page .app > .card {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  margin: 0;
  padding: 0;
  gap: 10px;
  padding-bottom: 0;
}

.text-editor {
  position: relative;
  z-index: 1;
}

body.input-page .text-editor {
  flex: 1;
  min-height: clamp(320px, 60dvh, 1400px);
  height: auto;
  margin: 0;
  padding: 0 0 6px;
  border-radius: 0;
  box-shadow: none;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 19px;
  font-family: var(--font-serif);
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: visible;
  outline: none;
}

body.input-page .text-editor:empty::before {
  content: attr(data-placeholder);
  color: color-mix(in srgb, var(--text-muted) 85%, transparent);
  pointer-events: none;
}

body.input-page #generateBtn {
  margin-top: 0;
  width: auto;
  min-width: 148px;
  padding: 8px 14px;
  font-size: 0.9rem;
}

body.input-page .input-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  will-change: transform;
  background: var(--bg-main);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
}

body.input-page .input-bottom-inner {
  max-width: 700px;
  margin: 0 auto;
  padding: 8px 16px 10px;
}

body.input-page .input-bottom-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

body.input-page .input-bottom-toggles {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  flex: 0 0 auto;
}

body.input-page .input-toggle-btn {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1.1;
}

body.input-page .input-toggle-btn.is-active {
  background: color-mix(in srgb, var(--accent) 20%, #0000);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--text-main);
}

body.input-page .input-bottom-inner .form-status {
  margin-top: 8px;
}

body.input-page .input-bottom-inner .form-status:empty {
  display: none;
}

body.input-page .input-flyout-layer {
  position: fixed;
  inset: 0;
  z-index: 34;
}

body.input-page .input-flyout {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(132px + env(safe-area-inset-bottom, 0px));
  max-width: 700px;
  margin: 0 auto;
  z-index: 35;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-card) 92%, #0000);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: transform 140ms ease, opacity 140ms ease;
}

body.input-page .input-flyout.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

body.input-page .input-flyout-inner {
  max-height: 50vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 14px;
}

@media (prefers-color-scheme: dark) {
  body.input-page .input-bottom-bar {
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
  }
}

@media (min-width: 900px) {
  body.echolab-nav-ready.input-page .input-dock {
    left: var(--echolab-sidebar-w, 260px);
  }

  body.echolab-nav-ready.input-page .input-bottom-bar {
    left: var(--echolab-sidebar-w, 260px);
  }
}

.voice-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-family: var(--font-ui);
}

.voice-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: #ebe3cc;
  color: #3d3828;
  cursor: pointer;
  font-size: 14px;
  border: 1px solid var(--border);
  transition: 0.15s;
  font-family: var(--font-ui);
}

.voice-pill:hover {
  background: #e0d6b8;
}

.voice-pill.active {
  background: #e6d8a8;
  color: var(--text-main);
  border-color: rgba(46, 46, 46, 0.18);
}

@media (prefers-color-scheme: dark) {
  .voice-pill {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.12);
    color: #b8b3a8;
  }

  .voice-pill:hover {
    background: #333;
  }

  .voice-pill.active {
    background: #4a4330;
    color: #ddd;
    border-color: rgba(255, 255, 255, 0.12);
  }
}

.advanced-details {
  margin-top: 20px;
  font-family: var(--font-ui);
  border-radius: 12px;
  border: 1px solid rgba(46, 46, 46, 0.1);
  background: rgba(255, 255, 255, 0.2);
}

.advanced-details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.advanced-details > summary::-webkit-details-marker {
  display: none;
}

.advanced-details > summary::after {
  content: "";
  flex: 0 0 auto;
  width: 0.45em;
  height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.55;
  margin-bottom: 0.15em;
}

.advanced-details[open] > summary::after {
  transform: rotate(-135deg);
  margin-bottom: -0.2em;
}

.advanced-details .advanced-inner {
  padding: 0 14px 16px;
  border-top: 1px solid rgba(46, 46, 46, 0.08);
}

.advanced-details .field-row:first-child {
  margin-top: 14px;
}

@media (prefers-color-scheme: dark) {
  .advanced-details {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
  }

  .advanced-details > summary {
    color: #b8b3a8;
  }

  .advanced-details .advanced-inner {
    border-top-color: rgba(255, 255, 255, 0.08);
  }
}

/* ----- Player: title above text; fixed bottom bar for controls ----- */

.player-layout {
  --player-scroll-pad-bottom: 168px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding-bottom: 0;
}

/*
 * Title strip above the transcript scrollport.
 * Must paint ABOVE .content (later sibling defaults to higher paint order when layers overlap).
 * Do not use sticky here: only .content scrolls — sticky ties to the viewport and can overlap
 * the scroller on iOS; relative + z-index keeps a solid header band.
 */
.player-dock {
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  margin: 0 -16px;
  padding: 8px 16px 10px;
  background-color: var(--bg-main);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui);
  isolation: isolate;
}

/* Fixed bottom: status + speed row + transport + scrub */
.player-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--bg-main) 94%, #000);
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.player-bottom-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 16px 8px;
}

@media (prefers-color-scheme: dark) {
  .player-bottom {
    background: color-mix(in srgb, var(--bg-main) 96%, #fff 2%);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
  }
}

@media (min-width: 900px) {
  body.echolab-nav-ready .player-bottom {
    left: var(--echolab-sidebar-w, 260px);
  }
}

.player-bottom .player-loading-line {
  margin: 0 0 4px;
  text-align: center;
}

.player-bottom-message:empty {
  display: none;
}

.player-bottom .text-error {
  margin: 0 0 6px;
  text-align: center;
  font-size: 0.82rem;
}

.player-hero {
  position: relative;
  text-align: center;
  margin-bottom: 0;
  padding: 0;
  min-height: 0;
  background-color: var(--bg-main);
}

.player-title {
  margin: 0 0 2px;
  padding: 4px 0 2px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: normal;
  color: #9aa4b2;
  font-family: var(--font-ui);
  line-height: 1.35;
  background-color: var(--bg-main);
}

.player-loading-line {
  margin: 0 0 2px;
  min-height: 1.15em;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Single row: transport + counter + repeat + time + scrub + total + extras */
.player-controls {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 2px 0;
  margin: 0;
  border-bottom: none;
  font-family: var(--font-ui);
}

.player-controls .player-time {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 2.1rem;
  text-align: center;
}

.player-controls .player-scrub {
  flex: 1 1 auto;
  min-width: 32px;
  width: auto;
  height: 6px;
  margin: 0 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

.player-controls .player-scrub:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.player-controls .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  background: transparent;
  border: 1px solid #1f2937;
  color: #9aa4b2;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}

.player-controls .icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: #c5cdd8;
}

.player-controls .icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.player-controls .icon-btn.repeat {
  opacity: 0.45;
}

.player-controls .icon-btn.repeat.is-on {
  opacity: 1;
  border-color: #4f8cff;
  color: #9ec5fe;
  background: rgba(79, 140, 255, 0.12);
}

.player-controls .icon-btn.speed-toggle.is-open {
  border-color: #4f8cff;
  color: #9ec5fe;
  background: rgba(79, 140, 255, 0.1);
}

.player-controls .play-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 16px;
  border: none;
  background: #4f8cff;
  color: #fff;
  font-weight: 600;
  font-size: 0.8125rem;
  font-family: var(--font-ui);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.12s ease, transform 0.08s ease;
}

.player-controls .play-btn:hover:not(:disabled) {
  opacity: 0.92;
}

.player-controls .play-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.player-controls .download-btn {
  height: 28px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-ui);
  border-radius: 8px;
  border: 1px solid #1f2937;
  background: transparent;
  color: #9aa4b2;
  cursor: pointer;
  opacity: 0.7;
  flex-shrink: 0;
  transition: opacity 0.12s ease, background 0.12s ease;
}

.player-controls .download-btn:hover:not(:disabled) {
  opacity: 1;
  background: rgba(255, 255, 255, 0.05);
}

.player-controls .sentence-count {
  font-size: 11px;
  color: #9aa4b2;
  margin: 0 1px;
  font-variant-numeric: tabular-nums;
  min-width: 2.75rem;
  text-align: center;
  flex-shrink: 0;
}

.player-controls .download-btn[hidden] {
  display: none !important;
}

.speed-row {
  margin: 0 0 6px;
  padding: 4px 0 2px;
  border-bottom: 1px solid var(--border);
}

.speed-row .wait-time {
  display: block;
  font-size: 11px;
  color: #9aa4b2;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin-bottom: 4px;
}

.speed-row.hidden {
  display: none !important;
}

.speed-row .delay-range {
  display: block;
  width: 100%;
  margin: 0;
  accent-color: #4f8cff;
}

.speed-row .player-speed-value {
  display: block;
  margin-top: 4px;
  text-align: center;
  font-size: 0.75rem;
  color: #9aa4b2;
  font-family: var(--font-ui);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Scrollable transcript — below title; z-index lower than .player-dock so title wins if overlap */
.player-layout .content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding-top: 16px;
  padding-left: 16px;
  padding-right: 16px;
  padding-bottom: calc(var(--player-scroll-pad-bottom) + env(safe-area-inset-bottom, 0px));
  scroll-padding-top: 12px;
  scroll-padding-bottom: calc(var(--player-scroll-pad-bottom) + env(safe-area-inset-bottom, 0px));
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--bg-main);
}

.player-layout .content .reading-content {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.8;
  color: var(--text-main);
}

.player-layout .reading-content p:first-child {
  margin-top: 0;
}

.player-layout .reading-content p {
  margin: 0 0 14px;
}

.reading-content p {
  margin: 0 0 20px;
}

.reading-content p:last-child {
  margin-bottom: 0;
}

.sentence {
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.12s ease;
  scroll-margin-top: 12px;
  scroll-margin-bottom: calc(var(--player-scroll-pad-bottom) + env(safe-area-inset-bottom, 0px));
}

.sentence.active {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

@media (prefers-color-scheme: dark) {
  .sentence.active {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
  }
}

/* Legacy class names still used by script for loading text */
.job-progress {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  min-height: 1.2em;
  line-height: 1.5;
  font-family: var(--font-ui);
}

.job-gen-timer {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
  font-family: var(--font-ui);
}

.text-error {
  color: #8a2f2f;
  font-weight: 600;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  .text-error {
    color: #e8a0a0;
  }
}

/* ----- Jobs list ----- */

.jobs-message {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
  font-family: var(--font-ui);
}

.date-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 22px 0 10px;
  font-family: var(--font-ui);
}

.date-heading:first-child {
  margin-top: 0;
}

/* ----- Jobs / Library: featured card + compact rows ----- */

.library-section-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 18px 0 8px;
  font-family: var(--font-ui);
}

.library-section-heading:first-child {
  margin-top: 0;
}

.library-featured-wrap {
  margin-bottom: 2px;
}

.library-featured-wrap .job-card {
  margin-bottom: 0;
}

.job-card--featured .job-actions {
  flex: 0 0 auto;
}

.job-row-list {
  display: flex;
  flex-direction: column;
  margin: 0 0 8px;
}

.job-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  min-height: 52px;
  padding: 8px 6px 8px 8px;
  margin: 0;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui);
  transition: background 0.12s ease;
  box-sizing: border-box;
}

.job-row:last-child {
  border-bottom: none;
}

.job-row:hover {
  background: rgba(46, 46, 46, 0.05);
}

@media (prefers-color-scheme: dark) {
  .job-row:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

.job-row-play {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--accent);
  background: transparent;
  pointer-events: none;
}

.job-row:hover .job-row-play {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.job-row-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}

.job-row-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.25;
}

.job-tags {
  margin-top: 4px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
}

.tag-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(46, 46, 46, 0.08);
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .tag-pill {
    background: rgba(255, 255, 255, 0.08);
    color: #bbb;
  }
}

.job-row-meta {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  align-self: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.job-row-duration {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text-main);
}

.job-row-voice {
  text-transform: capitalize;
  opacity: 0.9;
  max-width: 5.5rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.job-row-wrap {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}

.job-row-wrap:last-child {
  border-bottom: none;
}

.job-row-wrap .job-row {
  flex: 1 1 auto;
  min-width: 0;
  border-bottom: none;
}

.job-row-wrap .job-row:last-child {
  border-bottom: none;
}

/* Persistent "last interacted" track (localStorage echolab_last_active_job_id) */
.job-row.is-last-active {
  position: relative;
  background: linear-gradient(
    to right,
    rgba(255, 204, 64, 0.08),
    rgba(255, 204, 64, 0.02)
  );
}

.job-row.is-last-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 3px;
  border-radius: 2px;
  background: rgba(255, 204, 64, 0.6);
  box-shadow: 0 0 8px rgba(255, 204, 64, 0.4);
  z-index: 0;
  pointer-events: none;
}

.job-row.is-last-active > * {
  position: relative;
  z-index: 1;
}

.job-row.is-last-active:hover {
  background: linear-gradient(
      to right,
      rgba(255, 204, 64, 0.1),
      rgba(255, 204, 64, 0.025)
    ),
    rgba(46, 46, 46, 0.05);
}

@media (prefers-color-scheme: dark) {
  .job-row.is-last-active:hover {
    background: linear-gradient(
        to right,
        rgba(255, 204, 64, 0.12),
        rgba(255, 204, 64, 0.03)
      ),
      rgba(255, 255, 255, 0.06);
  }
}

.job-row-side-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 6px 8px 6px 4px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.job-row-side-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 0;
  max-width: 11rem;
  text-align: right;
}

.job-row-note-count {
  color: var(--text-muted);
  font-weight: 500;
}

.job-row-inline-link {
  color: var(--text-muted);
  text-decoration: none;
}

.job-row-inline-link:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.job-row-inline-action {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: inherit;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.job-row-inline-action:hover {
  color: var(--text-main);
}

.job-row-wrap--processing .job-row {
  pointer-events: none;
  cursor: default;
  opacity: 0.88;
}

.job-row-wrap--processing .job-row-side-actions,
.job-row-wrap--processing .job-row-kebab {
  pointer-events: auto;
}

.job-row-progress {
  margin-top: 4px;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
}

.job-row-kebab {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  margin: 0;
  padding: 0;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  font-family: var(--font-ui);
  cursor: pointer;
  border-radius: 0;
  transition: background 0.12s ease, color 0.12s ease;
}

.job-row-kebab:hover {
  background: rgba(46, 46, 46, 0.06);
  color: var(--text-main);
}

@media (prefers-color-scheme: dark) {
  .job-row-kebab:hover {
    background: rgba(255, 255, 255, 0.08);
  }
}

.row-action-menu__sep {
  height: 1px;
  margin: 0.35rem 0.45rem;
  padding: 0;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: light) {
  .row-action-menu__sep {
    background: rgba(46, 46, 46, 0.12);
  }
}

.row-action-menu {
  position: fixed;
  z-index: 300;
  min-width: 11rem;
  padding: 6px 0;
  margin: 0;
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}

.row-action-menu[hidden] {
  display: none !important;
}

.row-action-menu-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 14px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 0.9rem;
  font-family: var(--font-ui);
  color: var(--text-main);
  cursor: pointer;
}

.row-action-menu-item:hover {
  background: rgba(46, 46, 46, 0.06);
}

.row-action-menu-item--danger {
  color: #9a2c2c;
}

.row-action-menu-item--danger:hover {
  background: rgba(154, 44, 44, 0.1);
}

@media (prefers-color-scheme: dark) {
  .row-action-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  .row-action-menu-item--danger {
    color: #f0a0a0;
  }

  .row-action-menu-item--danger:hover {
    background: rgba(240, 160, 160, 0.12);
  }
}

.row-action-menu-item:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.row-action-menu-item.row-action-menu-item--danger:disabled {
  color: var(--text-muted);
}

.row-action-menu-item:disabled:hover {
  background: transparent;
}

@media (prefers-color-scheme: dark) {
  .row-action-menu-item:disabled:hover {
    background: transparent;
  }
}

.job-row-dates {
  margin-top: 3px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
  font-family: var(--font-ui);
}

.job-row-date-sep {
  margin: 0 0.35rem;
  opacity: 0.65;
}

.library-delete-confirm {
  position: fixed;
  inset: 0;
  z-index: 410;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.library-delete-confirm[hidden] {
  display: none !important;
}

.library-delete-backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.library-delete-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 300px;
  padding: 14px 14px 12px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  font-family: var(--font-ui);
}

.library-delete-title {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
}

.library-delete-actions {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.library-move-layer {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.library-move-layer[hidden] {
  display: none !important;
}

.library-move-backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.42);
  cursor: pointer;
}

.library-move-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 18px 16px 16px;
  border-radius: var(--radius-card);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  font-family: var(--font-ui);
}

.library-move-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-main);
}

.library-move-subtitle {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.album-picker--dialog .album-pill-row {
  margin-bottom: 14px;
}

.library-move-cancel {
  width: 100%;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.job-card {
  transition: background 0.15s, border-color 0.15s;
}

.job-card:hover {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(46, 46, 46, 0.18);
}

@media (prefers-color-scheme: dark) {
  .job-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
  }
}

.job-card-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.35;
  margin: 0 0 6px;
  color: var(--text-main);
}

.job-card-preview {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0 0 14px;
  min-height: 1.35em;
  font-family: var(--font-ui);
}

.job-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}

.job-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.job-meta-row {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
}

.job-duration {
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  font-weight: 500;
}

.job-voice {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.85;
  text-transform: capitalize;
}

.flash {
  padding: 12px 14px;
  border-radius: var(--radius-card);
  margin-bottom: 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  font-family: var(--font-ui);
}

.flash--ok {
  background: rgba(40, 80, 110, 0.08);
  border: 1px solid rgba(40, 80, 110, 0.22);
  color: var(--text-main);
}

@media (prefers-color-scheme: dark) {
  .flash--ok {
    background: rgba(158, 197, 232, 0.1);
    border-color: rgba(158, 197, 232, 0.28);
  }
}

#libraryEmpty {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0 0 18px;
  font-family: var(--font-ui);
}

@media (max-width: 420px) {
  .job-card-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .job-meta-row {
    margin-left: 0;
    justify-content: space-between;
  }
}

/* ----- Album picker (dark pills on recorder) ----- */

.album-picker {
  margin-top: 2px;
}

.album-selected-label {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 10px;
  min-height: 1.2em;
}

.album-selected-label:empty {
  display: none;
}

.album-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.album-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  background: #252830;
  color: #e8eaed;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.album-pill .album-icon {
  display: flex;
  align-items: center;
  line-height: 0;
  color: #b8c0d4;
}

.album-pill .album-icon svg {
  display: block;
}

.album-pill:hover {
  background: #2e3340;
}

.album-pill.active {
  border-color: rgba(110, 168, 254, 0.55);
  background: #303848;
  color: #fff;
}

.album-pill.active .album-icon {
  color: #9ec5e8;
}

@media (prefers-color-scheme: dark) {
  .album-pill {
    background: #1a1c22;
    border-color: rgba(255, 255, 255, 0.12);
  }

  .album-pill:hover {
    background: #22252e;
  }

  .album-pill.active {
    background: #252a36;
    border-color: rgba(158, 197, 232, 0.45);
  }
}
