:root {
  --bg: #efe6d8;
  --panel: rgba(255, 252, 247, 0.9);
  --panel-strong: rgba(255, 251, 244, 0.96);
  --ink: #1d1712;
  --muted: #62584d;
  --accent: #8a4426;
  --accent-soft: #cf8d67;
  --accent-deep: #4a2414;
  --gold: #b88a3b;
  --line: rgba(33, 22, 15, 0.11);
  --line-strong: rgba(72, 36, 20, 0.18);
  --shadow: 0 28px 90px rgba(41, 24, 10, 0.11);
  --shadow-tight: 0 14px 36px rgba(41, 24, 10, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  background:
    radial-gradient(circle at top left, rgba(218, 155, 104, 0.33), transparent 24%),
    radial-gradient(circle at top right, rgba(111, 56, 34, 0.18), transparent 22%),
    linear-gradient(180deg, #fbf6ee 0%, var(--bg) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent 20%, rgba(255, 255, 255, 0.03) 80%, transparent),
    radial-gradient(circle at 20% 15%, rgba(184, 138, 59, 0.05), transparent 12%),
    radial-gradient(circle at 78% 18%, rgba(138, 68, 38, 0.05), transparent 16%);
  mix-blend-mode: soft-light;
}

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px 22px 72px;
}

.global-notice {
  position: sticky;
  top: 14px;
  z-index: 20;
  margin-bottom: 18px;
  padding: 14px 18px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  border-radius: 18px;
  border: 1px solid rgba(160, 33, 33, 0.18);
  background: rgba(255, 246, 242, 0.96);
  color: #7b1d1d;
  box-shadow: var(--shadow-tight);
  backdrop-filter: blur(10px);
}

.global-notice-message {
  flex: 1 1 auto;
  line-height: 1.45;
}

.global-notice-close {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.hero {
  margin-bottom: 30px;
  padding: 34px 36px 30px;
  border-radius: 34px;
  border: 1px solid rgba(74, 36, 20, 0.09);
  background:
    radial-gradient(circle at top right, rgba(184, 138, 59, 0.12), transparent 24%),
    linear-gradient(180deg, rgba(255, 250, 242, 0.96), rgba(248, 240, 229, 0.9));
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(125deg, transparent 0%, rgba(255,255,255,0.32) 38%, transparent 60%),
    linear-gradient(180deg, transparent 0%, rgba(138, 68, 38, 0.03) 100%);
  pointer-events: none;
}

.mode-banner {
  margin-top: 18px;
  padding: 13px 16px;
  border-radius: 18px;
  background: rgba(138, 68, 38, 0.08);
  border: 1px solid rgba(138, 68, 38, 0.16);
  color: var(--accent);
  max-width: 56ch;
}

h2 {
  margin: 0;
  font-size: clamp(1.56rem, 2vw, 2.36rem);
  line-height: 1;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.8rem, 4.8vw, 5.4rem);
  line-height: 0.92;
  letter-spacing: -0.045em;
  max-width: 11ch;
}

.lede {
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.5;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.75fr);
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent);
  pointer-events: none;
}

.controls {
  padding: 26px;
}

.slider-preset-panel {
  margin: 12px 0 18px;
  padding: 20px 22px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(27, 23, 18, 0.08);
  box-shadow: var(--shadow-tight);
}

.slider-preset-panel h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

.slider-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.preset-chip {
  display: grid;
  gap: 8px;
  text-align: left;
  align-items: start;
  min-height: 116px;
  padding: 22px 24px;
  border-radius: 28px;
  line-height: 1.25;
}

.preset-chip strong {
  display: block;
  font-size: 1rem;
  line-height: 1.2;
}

.preset-chip span {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.4;
  max-width: 28ch;
}

.project-head {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.featured {
  margin-top: 22px;
  padding: 26px;
}

.formatter {
  margin-top: 22px;
  padding: 26px;
  background:
    linear-gradient(180deg, rgba(255, 250, 244, 0.92), rgba(247, 239, 228, 0.88));
}

.my-library {
  margin-top: 22px;
  padding: 26px;
  background:
    radial-gradient(circle at top left, rgba(138, 68, 38, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(255, 251, 245, 0.96), rgba(245, 237, 225, 0.92));
}

.video-export {
  margin-top: 22px;
  padding: 26px;
}

.translator {
  margin-top: 22px;
  padding: 26px;
}

.sampler {
  margin-top: 22px;
  padding: 26px;
  background:
    radial-gradient(circle at top right, rgba(184, 138, 59, 0.1), transparent 28%),
    linear-gradient(180deg, rgba(255, 251, 245, 0.96), rgba(246, 238, 226, 0.9));
  border-color: rgba(138, 68, 38, 0.14);
}

.featured-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 24px;
  align-items: end;
  margin-bottom: 20px;
}

.featured-copy {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.48;
}

.field-help {
  margin-top: 8px;
  line-height: 1.45;
}

.slider-help {
  margin-top: 10px;
  display: grid;
  gap: 4px;
}

.slider-summary,
.slider-range-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.94rem;
}

.slider-range-copy strong {
  color: var(--ink);
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.sampler-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 22px;
}

.formatter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 22px;
}

.library-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
  gap: 22px;
}

.formatter-note {
  max-width: 44rem;
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
}

.library-player-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.sampler-panel {
  padding: 24px 26px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(27, 23, 18, 0.08);
  box-shadow: var(--shadow-tight);
}

.narration-cleanup-panel {
  margin-top: 12px;
  margin-bottom: 24px;
  padding: 30px 38px;
}

.narration-cleanup-panel h3 {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.sampler-copy {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.5;
}

.voice-button-grid,
.compare-voice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.voice-chip,
.compare-chip {
  padding-inline: 16px;
}

.compare-chip.is-selected {
  background: rgba(138, 68, 38, 0.11);
  border-color: rgba(138, 68, 38, 0.34);
  color: var(--accent);
}

.compare-panel h3 {
  margin: 0;
  font-size: 1.15rem;
}

.compare-panel .muted {
  line-height: 1.45;
}

@media (max-width: 780px) {
  .slider-preset-grid {
    grid-template-columns: 1fr;
  }
}

#compareVoicesBtn {
  width: 100%;
  margin-top: 18px;
}

#compareStatus {
  margin-top: 12px;
}

.book-card {
  overflow: hidden;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(245, 236, 224, 0.88)),
    linear-gradient(135deg, rgba(201, 128, 95, 0.18), rgba(122, 59, 34, 0.06));
  border: 1px solid rgba(27, 23, 18, 0.08);
  box-shadow: var(--shadow-tight);
}

.book-cover {
  min-height: 220px;
  padding: 20px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  color: #fff9f3;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.28), transparent 28%),
    linear-gradient(145deg, var(--cover-a, #8b4d33), var(--cover-b, #402116));
}

.book-monogram {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: rgba(255, 250, 243, 0.16);
  border: 1px solid rgba(255, 250, 243, 0.22);
  font-size: 1.25rem;
  letter-spacing: 0.08em;
}

.book-runtime {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.16);
  border: 1px solid rgba(255, 250, 243, 0.18);
  font-size: 0.8rem;
}

.book-body {
  padding: 16px 18px 18px;
}

.book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(138, 68, 38, 0.08);
  color: var(--accent);
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.book-title {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.book-author {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.96rem;
}

.book-description {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.book-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.audio-dock {
  margin-top: 16px;
  padding: 15px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(27, 23, 18, 0.09);
}

.audio-dock audio {
  width: 100%;
  margin-top: 10px;
}

.featured-dock {
  margin-bottom: 18px;
}

.translation-library {
  margin-top: 8px;
}

.sidecar {
  padding: 18px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.card {
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(27, 23, 18, 0.08);
  box-shadow: var(--shadow-tight);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field-toggle {
  align-content: start;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-stack {
  display: grid;
  gap: 10px;
}

.wallet-bar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(74, 36, 20, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
}

.wallet-label {
  margin: 0 0 4px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  font-size: 0.94rem;
  color: #2d241c;
}

input[type="text"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1px solid rgba(43, 28, 18, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.4);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(138, 68, 38, 0.42);
  box-shadow: 0 0 0 4px rgba(138, 68, 38, 0.08);
  background: rgba(255, 255, 255, 0.94);
}

input[readonly] {
  color: var(--muted);
}

textarea {
  resize: vertical;
}

.slider-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin-bottom: 8px;
}

.slider input[type="range"] {
  width: 100%;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 10px 0 18px;
  color: var(--muted);
}

.cleanup-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 28px;
  margin-top: 20px;
}

.cleanup-toggles label {
  display: flex;
  align-items: start;
  gap: 10px;
  line-height: 1.45;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(57, 31, 17, 0.12);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.primary {
  background: linear-gradient(180deg, #9d5331, var(--accent));
  color: #fff9f4;
}

.secondary {
  background: linear-gradient(180deg, #d79a78, var(--accent-soft));
  color: #2d160d;
}

.ghost {
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid rgba(27, 23, 18, 0.14);
  color: var(--ink);
}

.muted {
  color: var(--muted);
}

.outputs {
  padding-left: 18px;
  margin: 10px 0 0;
}

.library-list {
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 14px;
  max-height: 560px;
  overflow-y: auto;
  padding-right: 8px;
}

.library-list-compact {
  max-height: 720px;
}

.library-list::-webkit-scrollbar {
  width: 10px;
}

.library-list::-webkit-scrollbar-track {
  background: rgba(27, 23, 18, 0.05);
  border-radius: 999px;
}

.library-list::-webkit-scrollbar-thumb {
  background: rgba(138, 68, 38, 0.28);
  border-radius: 999px;
}

.outputs a {
  color: var(--accent);
  font-weight: 600;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
}

.library-item {
  list-style: none;
  padding: 15px 16px;
  border-radius: 20px;
  border: 1px solid rgba(27, 23, 18, 0.08);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-tight);
}

.library-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.library-title {
  display: block;
  font-size: 1.03rem;
}

.library-author {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.library-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

.library-tagline {
  margin-top: 10px;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.4;
}

.library-actions {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.library-actions a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.library-play-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  background: rgba(138, 68, 38, 0.12);
  border: 1px solid rgba(138, 68, 38, 0.18);
  color: var(--accent);
  font-weight: 600;
}

.library-play-button:hover {
  background: rgba(138, 68, 38, 0.16);
}

.library-sublist {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

#jobPlayer {
  margin-top: 14px;
}

#jobPlayer audio {
  width: 100%;
}

.error {
  color: #a02121;
}

code {
  word-break: break-all;
  background: rgba(138, 68, 38, 0.08);
  padding: 2px 5px;
  border-radius: 7px;
}

@media (max-width: 920px) {
  .grid,
  .row,
  .slider-group,
  .formatter-grid,
  .library-grid,
  .sampler-grid,
  .featured-head,
  .featured-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 28px 24px 24px;
  }

  h1 {
    max-width: 12ch;
  }

  .cleanup-toggles {
    grid-template-columns: 1fr;
  }

  .narration-cleanup-panel {
    padding: 24px 22px;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 22px 14px 56px;
  }

  .global-notice {
    top: 8px;
    padding: 12px 14px;
    gap: 10px;
    align-items: flex-start;
  }

  .global-notice-close {
    min-height: 40px;
  }

  .wallet-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .wallet-bar .ghost,
  .actions > * {
    width: 100%;
  }

  .actions {
    flex-direction: column;
  }

  .library-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .library-actions a,
  .library-actions button,
  .library-play-button {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  .library-head {
    flex-direction: column;
  }
}
