:root {
  --page-bg: #f2eadf;
  --panel-bg: rgba(255, 249, 241, 0.92);
  --panel-border: rgba(77, 54, 37, 0.12);
  --ink: #2d2119;
  --ink-soft: #715d4f;
  --accent: #ab5f2c;
  --accent-soft: #d6a06a;
  --success: #2f7d4a;
  --success-soft: rgba(47, 125, 74, 0.12);
  --error: #a53c2f;
  --shadow: 0 20px 60px rgba(59, 41, 29, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(214, 160, 106, 0.35), transparent 30%),
    radial-gradient(circle at bottom right, rgba(171, 95, 44, 0.18), transparent 30%),
    linear-gradient(180deg, #f8f0e7 0%, var(--page-bg) 100%);
}

.background-glow {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
}

.background-glow-left {
  top: -10rem;
  left: -8rem;
  background: rgba(214, 160, 106, 0.32);
}

.background-glow-right {
  right: -8rem;
  bottom: -10rem;
  background: rgba(171, 95, 44, 0.18);
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.hero {
  max-width: 58rem;
  margin-bottom: 2rem;
}

.hero-logo {
  display: block;
  width: min(280px, 60vw);
  height: auto;
  margin-bottom: 1rem;
  filter: drop-shadow(0 12px 32px rgba(59, 41, 29, 0.18));
}

.eyebrow {
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  line-height: 0.95;
}

.lede {
  max-width: 42rem;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink-soft);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 1.25rem;
}

.panel-control {
  grid-column: 1 / -1;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 1.5rem;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  backdrop-filter: blur(10px);
}

.panel-dashboard-shell {
  margin-top: 1.25rem;
}

.dashboard-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.dashboard-toggle::-webkit-details-marker {
  display: none;
}

.dashboard-toggle-hint {
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.dashboard-content {
  padding-top: 1rem;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.panel h2,
.panel h3 {
  margin: 0;
}

.workflow-hint {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.8rem;
  background: rgba(171, 95, 44, 0.08);
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.import-progress {
  margin: 0 0 1rem;
  padding: 0.8rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(77, 54, 37, 0.1);
  background: rgba(255, 255, 255, 0.68);
}

.import-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.import-progress-header p {
  margin: 0;
  font-weight: 600;
}

.import-progress-track {
  width: 100%;
  height: 0.65rem;
  border-radius: 999px;
  background: rgba(77, 54, 37, 0.1);
  overflow: hidden;
}

.import-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  transition: width 200ms ease;
}

.field,
.field-group {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.field span {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

select,
button,
audio {
  font: inherit;
}

select {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(77, 54, 37, 0.14);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.button-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.1rem;
  background: linear-gradient(135deg, var(--accent) 0%, #bf7641 100%);
  color: white;
  cursor: pointer;
  transition: transform 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled,
.button:disabled:hover {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button-secondary {
  background: rgba(77, 54, 37, 0.08);
  color: var(--ink);
}

.button-compact {
  padding: 0.7rem 0.9rem;
}

.summary-card,
.status-card,
.log-panel {
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(77, 54, 37, 0.1);
  padding: 1rem;
}

.status-card + .status-card,
.summary-card + .status-card,
.status-card + .summary-card {
  margin-top: 1rem;
}

.summary-card {
  margin-bottom: 1rem;
}

.summary-card h3,
.status-card h3 {
  margin-bottom: 0.35rem;
}

.book-timeline-shell {
  margin: 0.9rem 0 0.75rem;
}

.book-timeline-track {
  position: relative;
  width: 100%;
  height: 1rem;
  border-radius: 999px;
  background: rgba(77, 54, 37, 0.08);
  overflow: hidden;
}

.book-timeline-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #78b88f, var(--success));
  border-radius: 999px;
}

.book-timeline-marker {
  position: absolute;
  top: 50%;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  border: 2px solid rgba(77, 54, 37, 0.18);
  background: rgba(255, 255, 255, 0.95);
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.book-timeline-marker-selected {
  border-color: rgba(255, 255, 255, 0.95);
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(171, 95, 44, 0.18);
}

.book-timeline-bookmark {
  position: absolute;
  top: -0.3rem;
  bottom: -0.3rem;
  width: 2px;
  background: var(--ink);
  transform: translateX(-50%);
}

.chapter-jump-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 0.75rem;
}

.chapter-jump {
  width: 100%;
  border: 1px solid rgba(77, 54, 37, 0.12);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  padding: 0.8rem 0.9rem;
  text-align: left;
  display: grid;
  gap: 0.25rem;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.chapter-jump:hover {
  transform: translateY(-1px);
}

.chapter-jump-current {
  border-color: rgba(171, 95, 44, 0.45);
  box-shadow: 0 0 0 3px rgba(171, 95, 44, 0.12);
}

.chapter-jump-ready {
  background: rgba(47, 125, 74, 0.08);
}

.chapter-jump-partial {
  background: rgba(171, 95, 44, 0.08);
}

.chapter-jump-bookmark {
  border-style: dashed;
}

.chapter-jump-title {
  font-weight: 600;
}

.chapter-jump-status {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.status-chip-cache {
  color: var(--success);
  background: var(--success-soft);
}

.status-chip-api {
  color: var(--accent);
  background: rgba(171, 95, 44, 0.12);
}

.audio-player {
  width: 100%;
  margin: 0.5rem 0 1rem;
}

.details-shell {
  margin-bottom: 1rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(77, 54, 37, 0.08);
  padding: 0.9rem 1rem;
}

.details-shell summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-weight: 600;
}

.details-body {
  padding-top: 0.9rem;
}

.status-card-inline {
  margin-top: 0;
}

.message {
  min-height: 1.5rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.8rem;
  background: rgba(77, 54, 37, 0.06);
  color: var(--ink-soft);
}

.message[data-tone='success'] {
  color: var(--success);
  background: rgba(47, 125, 74, 0.08);
}

.message[data-tone='error'] {
  color: var(--error);
  background: rgba(165, 60, 47, 0.08);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.kpi-card {
  padding: 1rem;
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(252, 243, 233, 0.88));
  border: 1px solid rgba(77, 54, 37, 0.08);
}

.kpi-label {
  margin: 0 0 0.35rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.kpi-value {
  margin: 0;
  font-size: 1.45rem;
}

.usage-mix-card h3 {
  margin-top: 0;
}

.mix-bar {
  display: flex;
  width: 100%;
  height: 1rem;
  margin: 1rem 0 0.8rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(77, 54, 37, 0.08);
}

.mix-segment {
  height: 100%;
}

.mix-segment-api {
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
}

.mix-segment-cache {
  background: linear-gradient(90deg, #78b88f, var(--success));
}

.mix-legend {
  display: grid;
  gap: 0.45rem;
}

.mix-legend p {
  margin: 0;
}

.legend-dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  margin-right: 0.45rem;
  vertical-align: middle;
}

.legend-dot-api {
  background: var(--accent);
}

.legend-dot-cache {
  background: var(--success);
}

.table-shell {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid rgba(77, 54, 37, 0.08);
}

th {
  color: var(--ink-soft);
  font-weight: 400;
}

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

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
}


.auth-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.8rem 0 1rem;
}

.auth-user-email {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(520px, 100%);
}

.login-form {
  display: grid;
  gap: 0.75rem;
}

.login-divider {
  margin: 1rem 0 0.6rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

input[type='email'],
input[type='password'] {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(77, 54, 37, 0.14);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}


[hidden] {
  display: none !important;
}

.app-busy {
  overflow: hidden;
}

.app-busy .page {
  pointer-events: none;
  user-select: none;
  opacity: 0.72;
}

.operation-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(45, 33, 25, 0.38);
  backdrop-filter: blur(3px);
}

.operation-dialog {
  width: min(520px, 100%);
  border-radius: 1.25rem;
  border: 1px solid rgba(77, 54, 37, 0.18);
  background: rgba(255, 249, 241, 0.98);
  box-shadow: 0 20px 60px rgba(20, 13, 8, 0.28);
  padding: 1rem;
}

.operation-title {
  margin: 0 0 0.45rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.operation-description {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

.operation-progress {
  margin-top: 0.9rem;
  width: 100%;
  height: 0.7rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(77, 54, 37, 0.14);
}

.operation-progress-bar {
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  animation: operation-pulse 1200ms ease-in-out infinite;
}

.operation-result-shell {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}

#operation-overlay[data-tone='success'] .operation-dialog {
  border-color: rgba(47, 125, 74, 0.35);
}

#operation-overlay[data-tone='error'] .operation-dialog {
  border-color: rgba(165, 60, 47, 0.35);
}

#operation-overlay[data-tone='success'] .operation-title {
  color: var(--success);
}

#operation-overlay[data-tone='error'] .operation-title {
  color: var(--error);
}

@keyframes operation-pulse {
  0% {
    transform: translateX(-120%);
    opacity: 0.65;
  }

  50% {
    opacity: 1;
  }

  100% {
    transform: translateX(280%);
    opacity: 0.65;
  }
}

