:root {
  color-scheme: dark;
  --ink: #0f141a;
  --ink-2: #171e26;
  --ink-3: #202832;
  --cream: #f0eadf;
  --muted: rgba(240, 234, 223, 0.66);
  --faint: rgba(240, 234, 223, 0.33);
  --hairline: rgba(240, 234, 223, 0.14);
  --strong-line: rgba(240, 234, 223, 0.24);
  --accent: #d28a59;
  --leaf: #8eb78f;
  --blue: #7aa4c7;
  --danger: #e07a6b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(122, 164, 199, 0.16), transparent 34%),
    linear-gradient(180deg, #151c23 0%, var(--ink) 58%, #0b0f13 100%);
  color: var(--cream);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--hairline);
  background: rgba(15, 20, 26, 0.78);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand-lockup {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: var(--cream);
  color: var(--ink);
  font-family: ui-serif, Georgia, serif;
  font-size: 24px;
}

.brand-name,
.account-email {
  font-weight: 800;
}

.brand-subtitle,
.credit-balance,
.auth-note,
.panel-message,
.player-meta p {
  color: var(--muted);
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost-button,
.secondary-button,
.google-button,
.icon-button,
.speed-select {
  border: 1px solid var(--hairline);
  color: var(--cream);
  background: rgba(240, 234, 223, 0.045);
  border-radius: 8px;
}

.nav-item {
  height: 42px;
  text-align: left;
  padding: 0 12px;
  font-weight: 750;
}

.nav-item.active {
  border-color: rgba(210, 138, 89, 0.55);
  background: rgba(210, 138, 89, 0.14);
}

.account-panel {
  margin-top: auto;
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--hairline);
  padding-top: 18px;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  overflow: auto;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.auth-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2 {
  font-family: ui-serif, Georgia, serif;
  font-weight: 500;
  letter-spacing: 0;
}

.auth-panel h1 {
  font-size: 58px;
}

.auth-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.auth-options {
  display: grid;
  gap: 14px;
}

.qr-login-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: rgba(240, 234, 223, 0.055);
  text-align: center;
}

.qr-login-panel canvas {
  width: 220px;
  height: 220px;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
}

.qr-login-title {
  color: var(--cream);
  font-weight: 850;
}

.qr-login-status {
  margin-top: 4px;
  font-size: 13px;
}

.auth-form,
.generate-view,
.library-view {
  display: grid;
  gap: 14px;
}

input:not([type="range"]),
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(240, 234, 223, 0.08);
  color: var(--cream);
}

select option {
  color: #111;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.primary-button,
.secondary-button,
.google-button,
.ghost-button {
  min-height: 44px;
  padding: 0 16px;
  font-weight: 850;
}

.primary-button {
  border: 0;
  border-radius: 8px;
  background: var(--cream);
  color: var(--ink);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.secondary-button.compact,
.primary-button.compact {
  min-height: 38px;
}

.wide {
  width: 100%;
}

.main-view {
  min-height: 100vh;
  padding: 28px 28px 124px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: clamp(34px, 4vw, 52px);
}

.status-strip {
  border: 1px solid rgba(210, 138, 89, 0.28);
  background: rgba(210, 138, 89, 0.09);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--cream);
  font-weight: 700;
}

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

.book-card {
  min-height: 168px;
  display: grid;
  align-content: space-between;
  gap: 18px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 16px;
  background: rgba(240, 234, 223, 0.045);
  text-align: left;
  color: var(--cream);
}

.book-card:hover,
.book-card:focus-visible {
  border-color: rgba(240, 234, 223, 0.38);
  background: rgba(240, 234, 223, 0.075);
}

.book-title {
  font-family: ui-serif, Georgia, serif;
  font-size: 23px;
  line-height: 1.08;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.book-author,
.book-progress,
.book-detail {
  color: var(--muted);
  font-size: 13px;
}

.book-progress-bar {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(240, 234, 223, 0.13);
}

.book-progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--leaf));
}

.empty-state {
  border: 1px dashed var(--strong-line);
  border-radius: 8px;
  padding: 42px;
  text-align: center;
}

.upload-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.drop-zone,
.quote-panel {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: rgba(240, 234, 223, 0.045);
}

.drop-zone {
  min-height: 520px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  text-align: center;
  padding: 28px;
  border-style: dashed;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: rgba(210, 138, 89, 0.10);
}

.drop-icon {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink);
  font-size: 42px;
  line-height: 1;
}

.drop-zone p,
.quote-panel p {
  max-width: 560px;
  color: var(--muted);
  line-height: 1.45;
}

.quote-panel {
  padding: 20px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.quote-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quote-metrics div {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 12px;
  background: rgba(15, 20, 26, 0.44);
}

.quote-metrics span {
  display: block;
  font-size: 25px;
  font-weight: 850;
}

.quote-metrics small {
  color: var(--muted);
}

.enhanced-audio-panel,
.quote-payment-panel,
.credits-balance-card,
.credits-pack-panel {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: rgba(240, 234, 223, 0.045);
}

.enhanced-audio-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
}

.enhanced-audio-panel h3,
.panel-heading h2,
.credits-balance-card h2 {
  margin: 4px 0 6px;
}

.enhanced-audio-panel p,
.credits-balance-card p {
  color: var(--muted);
  line-height: 1.45;
}

.enhanced-extra {
  margin-top: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--cream);
  font-weight: 850;
  white-space: nowrap;
}

.switch-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.quote-payment-panel {
  padding: 12px;
}

.quote-balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 750;
}

.quote-balance-row strong {
  color: var(--cream);
}

.credits-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(320px, 1.25fr);
  gap: 18px;
}

.credits-balance-card,
.credits-pack-panel {
  padding: 18px;
}

.credit-pack-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.credit-pack-row {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 12px;
  background: rgba(54, 94, 84, 0.42);
  color: var(--cream);
  text-align: left;
}

.credit-pack-row strong,
.credit-pack-row span {
  display: block;
}

.credit-pack-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.credit-pack-row em {
  border-radius: 999px;
  padding: 7px 9px;
  background: var(--accent);
  color: var(--ink);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

progress {
  width: 100%;
  accent-color: var(--accent);
}

.player {
  position: fixed;
  inset: 0 0 0 264px;
  z-index: 20;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: 18px;
  padding: 24px clamp(28px, 5vw, 76px);
  background:
    linear-gradient(135deg, rgba(142, 183, 143, 0.13), transparent 38%),
    linear-gradient(180deg, #151c23, #0b0f13);
}

.player-header,
.player-meta,
.player-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.player-header h2 {
  font-size: clamp(24px, 3vw, 42px);
}

.readalong-stage {
  min-height: 0;
  display: grid;
  align-items: center;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  padding: 28px 0;
}

.readalong-words {
  max-width: 1120px;
  font-size: clamp(46px, 6.2vw, 92px);
  font-weight: 850;
  line-height: 1.08;
  letter-spacing: 0;
}

.readalong-word {
  color: var(--faint);
  padding: 0 0.08em;
  border-radius: 6px;
}

.readalong-word.past {
  color: var(--cream);
}

.readalong-word.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.readalong-placeholder {
  color: var(--muted);
  font-size: 24px;
}

.time-pair {
  display: flex;
  gap: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 800;
}

.timeline {
  width: 100%;
  accent-color: var(--accent);
}

.player-controls {
  justify-content: center;
}

.icon-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  font-weight: 900;
}

.play-button {
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink);
  font-size: 28px;
  font-weight: 900;
}

.speed-select {
  width: auto;
  min-width: 94px;
}

.chapter-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  border-left: 1px solid var(--hairline);
  background: rgba(15, 20, 26, 0.96);
  padding: 20px;
  overflow: auto;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.chapter-list {
  display: grid;
  gap: 8px;
}

.chapter-row {
  min-height: 48px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--cream);
  background: rgba(240, 234, 223, 0.045);
  text-align: left;
}

.chapter-row.active {
  border-color: rgba(210, 138, 89, 0.62);
  background: rgba(210, 138, 89, 0.13);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
  }

  .nav-stack {
    grid-auto-flow: column;
    margin-left: auto;
  }

  .account-panel {
    display: none;
  }

  .upload-layout {
    grid-template-columns: 1fr;
  }

  .credits-layout {
    grid-template-columns: 1fr;
  }

  .player {
    inset: 0;
    padding: 18px;
  }

  .readalong-words {
    font-size: clamp(36px, 11vw, 64px);
  }
}

@media (max-width: 620px) {
  .sidebar {
    flex-wrap: wrap;
  }

  .topbar,
  .player-header,
  .player-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .book-grid {
    grid-template-columns: 1fr;
  }

  .player-controls {
    flex-wrap: wrap;
  }
}
