:root {
  --bg: #111210;
  --surface: #191a18;
  --elevated: #22231f;
  --text: #f2efe7;
  --muted: #a6a198;
  --forest: #355b4a;
  --forest-bright: #4a7d66;
  --amber: #c28b37;
  --amber-soft: rgba(194, 139, 55, 0.22);
  --line: rgba(242, 239, 231, 0.08);
  --line-strong: rgba(242, 239, 231, 0.14);
  --danger: #c45c4a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-serif: var(--font-display);
  --font-ui: "Sora", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-ui);
  font-weight: 400;
  line-height: 1.5;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.ambient {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 15% -10%, rgba(53, 91, 74, 0.28), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(194, 139, 55, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 35% at 50% 100%, rgba(53, 91, 74, 0.15), transparent 55%);
  animation: ambient-drift 28s ease-in-out infinite alternate;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 4vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  background: rgba(17, 18, 16, 0.72);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 4px;
  background: linear-gradient(145deg, var(--forest-bright), var(--forest));
  box-shadow: 0 0 0 1px rgba(242, 239, 231, 0.08), inset 0 0 12px rgba(194, 139, 55, 0.25);
  animation: mark-pulse 4.5s ease-in-out infinite;
}
.brand-name {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: -0.03em;
}

.topbar-actions { display: flex; align-items: center; gap: 14px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font: 500 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.status-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6b655c;
}
.status-pill.connected i {
  background: var(--forest-bright);
  box-shadow: 0 0 10px rgba(74, 125, 102, 0.7);
}
.status-pill.connected { color: var(--text); }

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  flex: 1;
}
.hidden { display: none !important; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--amber);
  font: 500 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
.muted { color: var(--muted); }
h1, h2, p { margin-top: 0; }

.login-view {
  max-width: 560px;
  padding: clamp(64px, 12vh, 140px) 0 90px;
}
.brand-hero {
  margin: 0 0 18px;
  font: 400 clamp(64px, 12vw, 104px) / 0.9 var(--font-display);
  letter-spacing: -0.04em;
  background: linear-gradient(120deg, var(--text) 40%, var(--amber) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.intro {
  max-width: 420px;
  margin-bottom: 36px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
  font-weight: 300;
}

.login-card,
.panel,
.kpi,
.hero-pulse,
.current-book {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card { width: min(100%, 400px); padding: 28px; }
label, .field span {
  display: block;
  margin: 0 0 8px;
  font: 500 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
input {
  width: 100%;
  padding: 12px 0;
  margin: 0 0 20px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  outline: 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus {
  border-color: var(--amber);
  box-shadow: 0 1px 0 var(--amber);
}
textarea:focus,
select:focus,
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: 500 12px var(--font-mono);
  letter-spacing: 0.02em;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.button:hover { transform: translateY(-1px); }
.button:active,
.view-toggle:active,
.segment:active,
.lib-filter:active { transform: scale(0.97); }
.button-primary {
  width: 100%;
  color: var(--bg);
  background: linear-gradient(120deg, var(--amber), #d4a45a);
}
.button-primary:hover { filter: brightness(1.05); }
.button-outline {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-strong);
}
.button-outline:hover { border-color: var(--amber); color: var(--amber); }
.button-ghost {
  padding: 6px 0;
  color: var(--muted);
  background: transparent;
}
.button-ghost:hover { color: var(--text); }

#passkey-login-btn { margin-top: 8px; }
#passkey-login-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.form-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.form-error {
  min-height: 18px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 13px;
}
.form-status {
  min-height: 18px;
  margin: 14px 0 0;
  color: var(--forest-bright);
  font-size: 13px;
}
.auth-switch {
  display: block;
  margin: 18px auto 0;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  font: 11px var(--font-mono);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-switch:hover { color: var(--amber); }

.dashboard { padding: 48px 0 80px; }
.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 36px;
}
.dashboard-heading h1 {
  margin: 0;
  font: 400 clamp(36px, 5.5vw, 58px) / 1.05 var(--font-display);
  letter-spacing: -0.03em;
}
.heading-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sync-meta {
  color: var(--muted);
  font: 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.live-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.live-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--forest-bright);
  box-shadow: 0 0 10px rgba(74, 125, 102, 0.7);
  animation: mark-pulse 2.4s ease-in-out infinite;
}
.live-status.paused::before {
  background: #6b655c;
  box-shadow: none;
  animation: none;
}

.orbit-hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.hero-pulse {
  position: relative;
  overflow: hidden;
  min-height: 320px;
  padding: 28px;
  background:
    linear-gradient(160deg, rgba(53, 91, 74, 0.35), transparent 55%),
    var(--elevated);
}
.hero-pulse-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font: 500 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.streak-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid rgba(194, 139, 55, 0.35);
}
.hero-value {
  margin-top: 42px;
  font: 400 clamp(72px, 11vw, 120px) / 0.85 var(--font-display);
  letter-spacing: -0.05em;
}
.hero-caption { margin: 14px 0 28px; color: var(--muted); font-size: 15px; }
.hero-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font: 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.orbit-ring {
  position: absolute;
  right: -40px;
  top: 50%;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 1px solid rgba(194, 139, 55, 0.25);
  transform: translateY(-50%);
  animation: orbit-spin 18s linear infinite;
}
.orbit-ring::before,
.orbit-ring::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(74, 125, 102, 0.35);
}
.orbit-ring::before { inset: 18px; }
.orbit-ring::after {
  inset: 42px;
  border-color: rgba(194, 139, 55, 0.2);
}

.current-book { padding: 24px 26px; min-height: 320px; }
.current-book-body {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 18px;
  align-items: start;
}
.current-cover {
  width: 96px;
  height: 136px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--elevated);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.current-cover.fallback {
  display: grid;
  place-items: center;
  font: 42px var(--font-display);
  color: var(--amber);
  background: linear-gradient(160deg, var(--elevated), #2a2c27);
}
.current-book-info h2 {
  margin: 0 0 6px;
  font: 400 28px / 1.15 var(--font-display);
  letter-spacing: -0.02em;
}
.progress-block { margin-top: 22px; }
.progress-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(242, 239, 231, 0.06);
  border: 1px solid rgba(242, 239, 231, 0.08);
}
.progress-track span {
  display: block;
  height: 100%;
  width: 0%;
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--forest) 0%, var(--forest-bright) 55%, var(--amber) 100%);
  box-shadow: none;
  transition: width 0.85s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.progress-track span[data-progress="0"],
.progress-track span:not([style*="width"]),
.progress-track span[style="width: 0%;"],
.progress-track span[style="width:0%"] {
  box-shadow: none;
}
.progress-track span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(242, 239, 231, 0.22), transparent);
  transform: translateX(-100%);
  animation: none;
  opacity: 0;
}
.progress-track span.is-filled::after {
  opacity: 1;
  animation: progress-sheen 2.4s ease-in-out infinite;
}
.progress-track.is-finished span {
  background: linear-gradient(90deg, #8a6a2a, var(--amber), #e2c078);
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  color: var(--muted);
  font: 11px var(--font-mono);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.kpi {
  padding: 20px 22px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.kpi:hover {
  border-color: rgba(194, 139, 55, 0.35);
  transform: translateY(-2px);
}
.kpi-trophy {
  border-color: rgba(194, 139, 55, 0.28);
  background:
    linear-gradient(160deg, rgba(194, 139, 55, 0.12), transparent 60%),
    var(--surface);
}
.kpi-label {
  color: var(--muted);
  font: 500 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.kpi strong {
  font: 400 36px var(--font-display);
  letter-spacing: -0.03em;
}

.panel { padding: 22px 24px; margin-bottom: 18px; }
.panel-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.panel-heading h2 {
  margin: 0;
  font: 400 24px var(--font-display);
  letter-spacing: -0.02em;
}
.panel-rule { height: 1px; flex: 1; background: var(--line); }
.panel-help {
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 13px;
}
.count-pill {
  margin-left: auto;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font: 11px var(--font-mono);
}

.segmented {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}
.segment {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font: 11px var(--font-mono);
}
.segment.active,
.segment:hover {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.chart-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 12px;
  color: var(--muted);
  font: 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.advanced-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font: 10px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.advanced-metrics span { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.025); }
.advanced-metrics b { display: block; margin-bottom: 3px; color: var(--amber); font-size: 12px; }
.sync-rejections { margin-top: 16px; }
.sync-rejections h3 { margin: 0 0 8px; font-size: 14px; font-weight: 500; }
.sync-rejection-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sync-rejection-list li { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.025); }
.sync-rejection-list strong { color: var(--amber); font-size: 12px; }
.sync-rejection-list small { grid-column: 1 / -1; color: var(--muted); }
.timeline-filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 14px; }
.timeline-filters label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.timeline-filters input { min-width: 150px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--surface); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(12px, 1fr)); gap: 5px; }
.calendar-cell { aspect-ratio: 1; border-radius: 4px; background: var(--line); }
.calendar-cell[data-level="1"] { background: #355b4a; }
.calendar-cell[data-level="2"] { background: #5f8066; }
.calendar-cell[data-level="3"] { background: #9d8b52; }
.calendar-cell[data-level="4"] { background: #c28b37; }
.compare-metrics small { color: var(--forest); }

.metrics-chart {
  min-height: 220px;
  position: relative;
}
.metrics-chart svg { width: 100%; height: 220px; display: block; }
.metrics-chart .bar-row {
  display: flex;
  align-items: flex-end;
  gap: clamp(4px, 1vw, 12px);
  height: 180px;
  padding-top: 8px;
  border-bottom: 1px solid var(--line);
}
.metric-bar-wrap {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.metric-bar {
  width: min(28px, 70%);
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(to top, var(--forest), var(--amber));
  transform-origin: bottom;
  animation: bar-grow 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.metric-bar-wrap small {
  color: var(--muted);
  font: 9px var(--font-mono);
  white-space: nowrap;
}

.dual-grid,
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.dual-grid > .panel,
.content-grid > .panel { margin-bottom: 0; }

.heatmap {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 4px;
}
.heat-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: rgba(242, 239, 231, 0.05);
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.2s ease;
}
.heat-cell:hover { transform: scale(1.15); border-color: var(--amber); }
.heat-cell[data-level="1"] { background: rgba(53, 91, 74, 0.35); }
.heat-cell[data-level="2"] { background: rgba(53, 91, 74, 0.55); }
.heat-cell[data-level="3"] { background: rgba(74, 125, 102, 0.75); }
.heat-cell[data-level="4"] { background: linear-gradient(135deg, var(--forest-bright), var(--amber)); }

.habits-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 160px;
  padding-top: 8px;
}
.habit-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  height: 100%;
}
.habit-bar i {
  display: block;
  width: 46%;
  max-width: 14px;
  border-radius: 4px 4px 1px 1px;
  background: linear-gradient(to top, var(--elevated), var(--forest-bright));
  transform-origin: bottom;
  animation: bar-grow 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.habit-columns { display: flex; align-items: flex-end; justify-content: center; gap: 2px; height: 100%; width: 100%; }
.habit-bar .habit-page { background: linear-gradient(to top, var(--forest), var(--forest-bright)); }
.habit-bar .habit-session { background: linear-gradient(to top, #735d2e, var(--amber)); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: -4px 0 8px; color: var(--muted); font: 10px var(--font-mono); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 8px; height: 8px; border-radius: 2px; background: var(--forest-bright); }
.legend-session { background: var(--amber); }
.habit-bar small {
  color: var(--muted);
  font: 8px var(--font-mono);
  opacity: 0.7;
}

.library-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}
.library-toolbar input {
  margin: 0;
  font-size: 13px;
}
.library-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.library-filters,
.view-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lib-filter,
.view-toggle {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font: 11px var(--font-mono);
}
.view-toggle {
  min-width: 36px;
  padding: 7px 10px;
}
.lib-filter.active,
.lib-filter:hover,
.view-toggle.active,
.view-toggle:hover {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.book-shelf,
.finished-shelf {
  display: grid;
  gap: 18px;
}
.book-shelf.view-grid-lg,
.finished-shelf.view-grid-lg {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.book-shelf.view-grid-md,
.finished-shelf.view-grid-md {
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
}
.book-shelf.view-grid-sm,
.finished-shelf.view-grid-sm {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.book-shelf.view-list,
.finished-shelf.view-list {
  grid-template-columns: 1fr;
  gap: 10px;
}

.book-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: var(--elevated);
  border: 1px solid var(--line);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  animation: rise-in 0.55s ease both;
}
.book-card:hover {
  transform: translateY(-4px);
  border-color: rgba(194, 139, 55, 0.4);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}
.book-card.is-finished {
  border-color: rgba(194, 139, 55, 0.35);
  background:
    linear-gradient(165deg, rgba(194, 139, 55, 0.14), transparent 50%),
    var(--elevated);
}
.view-list .book-card {
  flex-direction: row;
  align-items: stretch;
  gap: 16px;
  padding: 12px 14px;
}
.view-list .book-card:hover { transform: translateY(-2px); }
.view-list .book-card-cover-wrap {
  width: 72px;
  flex: 0 0 72px;
  aspect-ratio: 2 / 3;
}
.view-list .book-card-body {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  align-content: center;
}
.view-list .book-card-progress { grid-column: 1 / -1; }
.view-grid-sm .book-card { padding: 10px; gap: 8px; }
.view-grid-sm .book-card-title { font-size: 14px; }
.view-grid-sm .book-card-stats { display: none; }
.view-grid-sm .status-chip { font-size: 9px; padding: 3px 6px; }

.book-card-cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #1c1d1a;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.book-card-cover-wrap img,
.book-card-cover-wrap .fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: grid;
  place-items: center;
  font: 48px var(--font-display);
  color: var(--amber);
}
.trophy-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #1a1408;
  background: linear-gradient(145deg, #e2c078, var(--amber));
  box-shadow: 0 8px 18px rgba(194, 139, 55, 0.45);
}
.trophy-badge svg { display: block; }
.status-chip {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(17, 18, 16, 0.78);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font: 500 10px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  backdrop-filter: blur(8px);
}
.book-card-body { display: grid; gap: 8px; }
.book-card-title {
  margin: 0;
  font: 400 17px / 1.25 var(--font-display);
  letter-spacing: -0.02em;
}
.book-card-author,
.book-card-stats {
  margin: 0;
  color: var(--muted);
  font: 11px var(--font-mono);
}
.book-card-progress { display: grid; gap: 8px; }
.book-card-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--amber);
  font: 500 12px var(--font-mono);
}
.book-card-progress-top .pages-label { color: var(--muted); }

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.pagination[hidden] { display: none !important; }
.pagination-info {
  color: var(--muted);
  font: 11px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pagination-actions { display: flex; gap: 8px; }
.pagination-actions .button {
  min-width: 96px;
}
.pagination-actions .button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.trophy-heading {
  color: var(--amber);
  display: inline-flex;
  align-items: center;
}
.finished-panel {
  background:
    linear-gradient(180deg, rgba(194, 139, 55, 0.08), transparent 40%),
    var(--surface);
}
.finished-card .book-card-cover-wrap {
  box-shadow: 0 12px 28px rgba(194, 139, 55, 0.18);
}

.book-list,
.session-list { border-top: 1px solid var(--line); }
.session-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  animation: rise-in 0.5s ease both;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
}
.session-time {
  color: var(--amber);
  font: 11px var(--font-mono);
}
.session-name { margin: 0 0 4px; font-size: 14px; font-weight: 500; }
.session-meta {
  color: var(--muted);
  font: 11px var(--font-mono);
}

.top-books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.top-card {
  padding: 14px;
  border-radius: 14px;
  background: var(--elevated);
  border: 1px solid var(--line);
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.top-card:hover {
  transform: translateY(-3px);
  border-color: rgba(194, 139, 55, 0.4);
}
.top-card .rank {
  color: var(--amber);
  font: 11px var(--font-mono);
  margin-bottom: 10px;
}
.top-card .rank-star { margin-right: 3px; }
.top-card .cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--surface);
}
.top-card .cover.fallback {
  display: grid;
  place-items: center;
  font: 36px var(--font-display);
  color: var(--amber);
}
.top-card h3 {
  margin: 0 0 4px;
  font: 400 16px / 1.25 var(--font-display);
}
.top-card p {
  margin: 0;
  color: var(--muted);
  font: 11px var(--font-mono);
}

.pairing-panel { margin-top: 8px; }
.pairing-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: end;
}
.pairing-form .field { margin: 0; }
.pairing-form input { margin: 0; }
.pairing-form .button { min-height: 44px; }

.empty-state {
  padding: 24px 0;
  color: var(--muted);
  font-size: 14px;
}

.book-detail-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(860px, calc(100vh - 32px));
  border: 1px solid rgba(194, 139, 55, .45);
  border-radius: 20px;
  padding: 0;
  color: var(--text);
  background: #171916;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}
.book-detail-dialog::backdrop { background: rgba(4, 6, 5, .78); backdrop-filter: blur(4px); }
.book-detail-shell { position: relative; display: grid; gap: 24px; padding: 32px; }
.dialog-close { position: absolute; top: 14px; right: 16px; border: 0; background: transparent; color: inherit; font-size: 28px; cursor: pointer; }
.book-detail-header { display: flex; align-items: center; gap: 20px; padding-right: 32px; }
.detail-cover { width: 92px; height: 128px; flex: 0 0 auto; border-radius: 10px; display: grid; place-items: center; overflow: hidden; object-fit: cover; background: var(--elevated); font-size: 36px; }
.book-detail-header h2 { margin: 0; font-family: var(--font-display); font-size: clamp(28px, 5vw, 44px); }
.book-detail-grid { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 12px; }
.detail-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.detail-stat-grid > div { display: grid; gap: 5px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); }
.detail-stat-grid span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.metadata-history { display: grid; gap: 8px; max-height: 180px; overflow: auto; }
.metadata-history-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 12px; border-left: 2px solid var(--amber); background: rgba(255,255,255,.035); }
.metadata-history-row span { color: var(--muted); text-align: right; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.book-card[role="button"] { cursor: pointer; }
.book-card[role="button"]:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
@media (max-width: 640px) {
  .book-detail-shell { padding: 24px 18px; }
  .book-detail-grid, .detail-stat-grid { grid-template-columns: 1fr 1fr; }
  .book-detail-grid label:first-child { grid-column: 1 / -1; }
  .metadata-history-row { display: grid; gap: 4px; }
  .metadata-history-row span { text-align: left; }
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 20px clamp(20px, 4vw, 72px);
  color: var(--muted);
  border-top: 1px solid var(--line);
  font: 10px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.reveal {
  animation: rise-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--d, 0) * 70ms);
}

.chart-line {
  fill: none;
  stroke: var(--amber);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: draw-line 1.4s ease forwards;
}
.chart-area {
  fill: url(#inkoraArea);
  opacity: 0;
  animation: fade-in 1s ease 0.3s forwards;
}
.chart-grid line {
  stroke: rgba(242, 239, 231, 0.06);
  stroke-width: 1;
}
.chart-grid text {
  fill: var(--muted);
  font: 10px var(--font-mono);
  text-anchor: start;
}
.chart-axis-label {
  fill: var(--muted);
  font: 10px var(--font-mono);
  text-anchor: middle;
}
.chart-dot {
  fill: var(--bg);
  stroke: var(--amber);
  stroke-width: 2;
  opacity: 0;
  animation: fade-in 0.4s ease 1s forwards;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes bar-grow {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
@keyframes draw-line {
  to { stroke-dashoffset: 0; }
}
@keyframes fade-in {
  to { opacity: 1; }
}
@keyframes ambient-drift {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.05) translate(-1%, 1%); }
}
@keyframes orbit-spin {
  to { transform: translateY(-50%) rotate(360deg); }
}
@keyframes mark-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(242, 239, 231, 0.08), inset 0 0 12px rgba(194, 139, 55, 0.25); }
  50% { box-shadow: 0 0 0 1px rgba(194, 139, 55, 0.35), inset 0 0 16px rgba(74, 125, 102, 0.4); }
}
@keyframes progress-sheen {
  0% { transform: translateX(-120%); }
  55%, 100% { transform: translateX(120%); }
}

@media (max-width: 960px) {
  .orbit-hero,
  .dual-grid,
  .content-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .top-books { grid-template-columns: repeat(2, 1fr); }
  .pairing-form { grid-template-columns: 1fr; }
  .panel-heading { flex-wrap: wrap; }
  .segmented { margin-left: 0; width: 100%; }
}

@media (max-width: 640px) {
  main { width: min(100% - 28px, 580px); }
  .topbar { padding: 0 14px; }
  .dashboard-heading { flex-direction: column; align-items: flex-start; }
  .current-book-body { grid-template-columns: 72px 1fr; }
  .current-cover { width: 72px; height: 102px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .heatmap { gap: 3px; }
  footer { flex-direction: column; padding: 18px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .ambient { animation: none; }
  .chart-line { stroke-dasharray: none; stroke-dashoffset: 0; }
  .chart-area,
  .chart-dot { opacity: 1; }
}


/* Refinos de interação para operações e acessibilidade. */
.heading-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.button:disabled {
  cursor: progress;
  opacity: 0.58;
  transform: none;
}

.button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .heading-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .heading-actions .button {
    flex: 1 1 auto;
  }
}

.device-health { display: grid; gap: 0.55rem; margin-top: 1rem; }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem 0.95rem; border: 1px solid rgba(215, 191, 137, 0.18); border-radius: 0.65rem; background: rgba(255, 255, 255, 0.025); }
.device-row div { display: grid; gap: 0.2rem; }
.device-row span, .device-row em { color: var(--muted, #9d9f96); font-size: 0.76rem; font-style: normal; }
.kindle-delivery-panel { margin-top: 1.35rem; padding-top: 1.2rem; border-top: 1px solid rgba(215, 191, 137, 0.18); }
.kindle-delivery-panel h3 { margin: 0; font: 500 1.15rem var(--font-display); }
.kindle-delivery-form { display: grid; grid-template-columns: minmax(180px, 0.8fr) minmax(220px, 1.2fr) auto; gap: 14px; align-items: end; }
.kindle-delivery-form .field { margin: 0; }
.kindle-delivery-form input, .kindle-delivery-form select { margin: 0; }
.kindle-delivery-list { display: grid; gap: 0.55rem; margin-top: 0.8rem; }
.kindle-delivery-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem 0.9rem; border: 1px solid rgba(215, 191, 137, 0.18); border-radius: 0.65rem; background: rgba(255, 255, 255, 0.025); }
.kindle-delivery-info { display: grid; gap: 0.2rem; min-width: 0; }
.kindle-delivery-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kindle-delivery-info span { color: var(--muted, #9d9f96); font-size: 0.76rem; }
@media (max-width: 760px) { .kindle-delivery-form { grid-template-columns: 1fr; } }

/* Hero pulse — leitura viva e reativa */
.hero-pulse {
  --hero-progress: 0%;
  --hero-intensity: 0;
  isolation: isolate;
  animation: hero-breathe 7s ease-in-out infinite;
}
.hero-pulse::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(242, 239, 231, .08);
  border-radius: 14px;
  opacity: .65;
  animation: hero-frame-pulse 5s ease-in-out infinite;
  pointer-events: none;
}
.hero-pulse::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  right: -72px;
  top: 50%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 72%, rgba(194,139,55,.45), transparent 83% 100%);
  mask: radial-gradient(circle, transparent 58%, #000 60% 61%, transparent 63%);
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 60% 61%, transparent 63%);
  animation: orbit-spin 12s linear infinite reverse;
  pointer-events: none;
}
.hero-glow {
  position: absolute;
  width: 190px;
  height: 190px;
  right: 4px;
  top: 50%;
  border-radius: 50%;
  transform: translateY(-50%);
  background: radial-gradient(circle, rgba(194,139,55,.18), transparent 68%);
  filter: blur(8px);
  opacity: calc(.35 + var(--hero-intensity) * .65);
  animation: glow-breathe 4s ease-in-out infinite;
  pointer-events: none;
}
.hero-progress-ring {
  position: absolute;
  right: 34px;
  top: 50%;
  width: 128px;
  height: 128px;
  transform: translateY(-50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--amber);
  font: 500 11px var(--font-mono);
  background: conic-gradient(var(--amber) var(--hero-progress), rgba(242,239,231,.08) 0);
  mask: radial-gradient(circle, transparent 61%, #000 62%);
  -webkit-mask: radial-gradient(circle, transparent 61%, #000 62%);
  animation: progress-ring-glow 3.4s ease-in-out infinite;
  pointer-events: none;
}
.hero-progress-ring span { position: absolute; }
.orbit-ring::before { animation: orbit-pulse 4s ease-in-out infinite; }
.orbit-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 16px rgba(194,139,55,.9);
}
.orbit-dot-one { left: 18px; top: 52px; animation: orbit-dot-one 9s linear infinite; }
.orbit-dot-two { right: 26px; bottom: 34px; background: var(--forest-bright); box-shadow: 0 0 16px rgba(74,125,102,.9); animation: orbit-dot-two 13s linear infinite reverse; }
@keyframes hero-breathe { 0%, 100% { transform: translateZ(0) scale(1); } 50% { transform: translateZ(0) scale(1.008); } }
@keyframes hero-frame-pulse { 0%, 100% { opacity: .35; transform: scale(1); } 50% { opacity: .75; transform: scale(1.012); } }
@keyframes glow-breathe { 0%, 100% { transform: translateY(-50%) scale(.92); } 50% { transform: translateY(-50%) scale(1.08); } }
@keyframes progress-ring-glow { 0%, 100% { filter: drop-shadow(0 0 3px rgba(194,139,55,.2)); } 50% { filter: drop-shadow(0 0 12px rgba(194,139,55,.75)); } }
@keyframes orbit-pulse { 0%, 100% { opacity: .35; } 50% { opacity: .8; } }
@keyframes orbit-dot-one { to { transform: rotate(360deg) translateX(92px) rotate(-360deg); } }
@keyframes orbit-dot-two { to { transform: rotate(360deg) translateX(70px) rotate(-360deg); } }
@media (max-width: 640px) {
  .hero-progress-ring { right: 18px; width: 96px; height: 96px; }
  .hero-glow { right: -10px; width: 150px; height: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-pulse, .hero-pulse::before, .hero-pulse::after, .hero-glow, .hero-progress-ring, .orbit-ring, .orbit-ring::before, .orbit-dot { animation: none !important; }
}

/* Navegação contextual: transforma uma página longa em uma biblioteca explorável. */
.section-nav {
  position: sticky;
  top: 78px;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 18px;
  width: max-content;
  max-width: 100%;
  min-height: 48px;
  padding: 5px 7px 5px 14px;
  margin: 0 0 22px auto;
  border: 1px solid rgba(242, 239, 231, 0.1);
  border-radius: 999px;
  background: rgba(17, 18, 16, 0.78);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(242, 239, 231, 0.04);
  backdrop-filter: blur(16px);
}

.section-nav-kicker {
  color: var(--amber);
  font: 500 10px var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.section-nav-links {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.section-nav-links::-webkit-scrollbar { display: none; }

.section-nav-link {
  position: relative;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  font: 500 11px var(--font-mono);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--inkora-fast) ease, background var(--inkora-fast) ease, transform 160ms var(--inkora-ease);
}

.section-nav-link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 1px;
  background: var(--amber);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--inkora-fast) var(--inkora-ease);
}

.section-nav-link:hover,
.section-nav-link.active {
  color: var(--text);
  background: rgba(242, 239, 231, 0.07);
}

.section-nav-link.active::after { transform: scaleX(1); }
.section-nav-link:active { transform: scale(0.97); }

#current-book-card,
#rhythm-section,
#patterns-section,
#library-section,
#timeline-section,
#pairing-panel,
[id$="-section"] { scroll-margin-top: 144px; }

@media (max-width: 720px) {
  .section-nav {
    top: 68px;
    width: 100%;
    margin: 0 0 16px;
    padding-left: 10px;
  }

  .section-nav-kicker { display: none; }
  .section-nav-links { width: 100%; }
  #current-book-card,
  #rhythm-section,
  #patterns-section,
  #library-section,
  #timeline-section,
  #pairing-panel,
  [id$="-section"] { scroll-margin-top: 124px; }
}

@media (max-width: 480px) {
  .topbar { height: auto; min-height: 68px; flex-wrap: wrap; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .command-palette-trigger { order: 3; width: 100%; }
  .command-palette-trigger .trigger-label { display: inline; }
  .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .dialog-actions .button { min-width: 0; padding-inline: 10px; }
}

/* Direção visual: observatório editorial — a leitura como sinal, não como planilha. */
:root {
  --inkora-paper: #f2efe7;
  --inkora-night: #0d0f0d;
  --inkora-surface-strong: #1d201c;
  --inkora-forest-deep: #203d32;
  --inkora-gold-light: #e0b873;
  --inkora-line-soft: rgba(242, 239, 231, 0.11);
  --inkora-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --inkora-fast: 180ms;
  --inkora-normal: 360ms;
}

body {
  background:
    linear-gradient(180deg, rgba(13, 15, 13, 0.2), transparent 30%),
    var(--bg);
}

.ambient::before,
.ambient::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.ambient::before {
  inset: 0;
  opacity: 0.18;
  background-image: linear-gradient(rgba(242, 239, 231, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(242, 239, 231, 0.035) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

.ambient::after {
  width: 420px;
  height: 420px;
  right: -180px;
  top: 38vh;
  border: 1px solid rgba(194, 139, 55, 0.09);
  border-radius: 50%;
  box-shadow: 0 0 0 28px rgba(194, 139, 55, 0.018), 0 0 0 56px rgba(194, 139, 55, 0.012);
}

.topbar {
  height: 78px;
  border-bottom-color: rgba(242, 239, 231, 0.12);
  background: rgba(13, 15, 13, 0.78);
}

.brand-mark {
  position: relative;
  width: 30px;
  height: 30px;
  transform: rotate(-8deg);
  transition: transform var(--inkora-normal) var(--inkora-ease), box-shadow var(--inkora-normal) var(--inkora-ease);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(242, 239, 231, 0.62);
  border-radius: 50%;
}

.brand:hover .brand-mark {
  transform: rotate(16deg) scale(1.08);
}

.brand-name { font-size: 28px; }

main { width: min(1240px, calc(100% - 48px)); }

.dashboard-heading {
  position: relative;
  padding: clamp(44px, 7vw, 84px) 0 30px;
}

.dashboard-heading::after {
  content: "";
  display: block;
  width: min(340px, 42vw);
  height: 1px;
  margin-top: 28px;
  background: linear-gradient(90deg, var(--amber), transparent);
  opacity: 0.65;
}

.dashboard-heading h1 {
  max-width: 620px;
  margin-bottom: 8px;
  font-size: clamp(42px, 6vw, 78px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.dashboard-heading .eyebrow { margin-bottom: 16px; }
.heading-actions { align-self: flex-end; }

.orbit-hero {
  gap: 18px;
  margin-bottom: 18px;
}

.hero-pulse,
.current-book {
  border-color: var(--inkora-line-soft);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(242, 239, 231, 0.035);
}

.hero-pulse {
  min-height: 332px;
  background:
    radial-gradient(circle at 75% 38%, rgba(194, 139, 55, 0.1), transparent 28%),
    linear-gradient(135deg, rgba(53, 91, 74, 0.32), transparent 56%),
    var(--surface);
}

.hero-value {
  font-size: clamp(78px, 10vw, 132px);
  letter-spacing: -0.08em;
  text-shadow: 0 12px 42px rgba(194, 139, 55, 0.12);
}

.hero-caption {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: -0.02em;
}

.current-book {
  position: relative;
  min-height: 332px;
  background:
    linear-gradient(145deg, rgba(242, 239, 231, 0.045), transparent 45%),
    var(--surface);
}

.current-book::before {
  content: "agora";
  position: absolute;
  top: 24px;
  right: 26px;
  color: var(--forest-bright);
  font: 500 10px var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.current-book-info h2 {
  max-width: 390px;
  font-size: clamp(28px, 3.4vw, 48px);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.current-cover {
  box-shadow: 12px 16px 28px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(242, 239, 231, 0.12);
}

.kpi-grid { gap: 12px; margin-bottom: 18px; }

.kpi {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  padding: 22px 22px 20px;
  border-color: var(--inkora-line-soft);
  transition: transform var(--inkora-normal) var(--inkora-ease), border-color var(--inkora-fast) ease, background var(--inkora-fast) ease;
}

.kpi::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -36px;
  width: 100px;
  height: 100px;
  border: 1px solid rgba(194, 139, 55, 0.18);
  border-radius: 50%;
}

.kpi:hover { transform: translateY(-4px); border-color: rgba(194, 139, 55, 0.38); background: var(--inkora-surface-strong); }
.kpi strong { font-size: clamp(30px, 3vw, 42px); letter-spacing: -0.06em; }

.panel {
  border-color: var(--inkora-line-soft);
  background: linear-gradient(145deg, rgba(242, 239, 231, 0.025), transparent 42%), var(--surface);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(242, 239, 231, 0.025);
}

.panel-heading h2 { letter-spacing: -0.035em; }
.panel-heading h2::first-letter { color: var(--inkora-gold-light); }
.panel-help { max-width: 54ch; }

.segmented,
.library-filters,
.view-toggles {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.14);
}

.segment,
.lib-filter,
.view-toggle {
  border-radius: 999px;
  transition: background var(--inkora-fast) ease, color var(--inkora-fast) ease, transform var(--inkora-fast) ease;
}

.segment:hover,
.lib-filter:hover,
.view-toggle:hover { transform: translateY(-1px); color: var(--inkora-paper); }

.segment.active,
.lib-filter.active,
.view-toggle.active {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.library-toolbar {
  gap: 12px;
  padding: 16px;
  margin: 0 -2px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.12);
}

.library-toolbar input,
.library-toolbar select,
.library-toolbar > button {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(242, 239, 231, 0.035);
}

.library-toolbar input { padding: 12px 14px; }
.library-toolbar select, .library-toolbar > button { padding: 10px 12px; }
.library-toolbar > button:hover { border-color: var(--amber); color: var(--amber); }

.book-card,
.top-card {
  border-color: var(--line);
  transition: transform var(--inkora-normal) var(--inkora-ease), border-color var(--inkora-fast) ease, box-shadow var(--inkora-normal) var(--inkora-ease);
}

.book-card:hover,
.top-card:hover {
  transform: translateY(-5px);
  border-color: rgba(194, 139, 55, 0.42);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
}

.book-card-cover-wrap { border-radius: 12px; overflow: hidden; }
.book-card-title, .top-card h3 { letter-spacing: -0.025em; }
.status-chip, .streak-chip, .count-pill { border-color: rgba(194, 139, 55, 0.28); }

.button { min-height: 42px; }
.button-primary { box-shadow: 0 8px 24px rgba(194, 139, 55, 0.16); }
.button-outline:hover { box-shadow: 0 8px 24px rgba(194, 139, 55, 0.08); }

footer {
  max-width: 1240px;
  width: min(100% - 48px, 1240px);
  margin: 28px auto 0;
  border-top-color: var(--line-soft);
}

/* ==========================================================================
   Intelligence & Cognitive Focus
   ========================================================================== */
.intelligence-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.intel-card {
  padding: 20px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.intel-card-wide {
  grid-column: 1 / -1;
}

.intel-label {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--amber);
}

.intel-value-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.intel-hero-num {
  font-family: var(--font-serif, serif);
  font-size: 38px;
  font-weight: normal;
  color: var(--text);
}

.intel-hero-text {
  font-family: var(--font-serif, serif);
  font-size: 32px;
  font-style: italic;
  color: var(--text);
}

.intel-meta-pills {
  display: flex;
  gap: 12px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.intel-meta-pills b {
  color: var(--text);
}

.chip-deep {
  background: rgba(53, 91, 74, 0.25);
  color: #72a88f;
  border: 1px solid rgba(53, 91, 74, 0.4);
}

.chip-stalled {
  background: rgba(194, 70, 55, 0.2);
  color: #e57373;
  border: 1px solid rgba(194, 70, 55, 0.4);
}

.abandonment-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.abandonment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  gap: 14px;
}

.abandonment-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.abandonment-item-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.abandonment-item-rec {
  font-size: 13px;
  color: var(--muted);
}

/* ==========================================================================
   Series & Sagas
   ========================================================================== */
.series-creator {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.series-creator input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(242, 239, 231, 0.035);
  color: var(--text);
}

.series-list {
  display: grid;
  gap: 14px;
}

.series-card {
  padding: 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.series-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.series-card-title {
  font-family: var(--font-serif, serif);
  font-size: 22px;
  color: var(--text);
}

/* ==========================================================================
   Retrospective & Reading Wrapped
   ========================================================================== */
.retro-actions, .vault-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.retro-actions select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--elevated);
  color: var(--text);
}

.retro-preview-container {
  display: flex;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  border: 1px solid var(--line);
  margin-top: 14px;
  min-height: 400px;
}

.retro-preview-container svg {
  max-width: 100%;
  height: auto;
  max-height: 600px;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.retro-preview-container .retrospective-card-image {
  max-width: 100%;
  height: auto;
  max-height: 600px;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Vault & Notes
   ========================================================================== */
.vault-notes-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.vault-note-card {
  padding: 16px;
  border-radius: 12px;
  background: var(--elevated);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vault-note-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--amber);
  font-family: var(--font-mono, monospace);
}

.vault-note-text {
  font-style: italic;
  color: var(--text);
  line-height: 1.5;
}

/* Fica fora do bloco 640px abaixo: como ele vem depois da regra de 480px, a
   altura fixa vencia e a terceira linha do topbar transbordava no celular. */
@media (min-width: 481px) and (max-width: 640px) {
  .topbar { height: 68px; }
}

@media (max-width: 640px) {
  main { width: min(100% - 28px, 580px); }
  .dashboard-heading { padding-top: 38px; }
  .dashboard-heading h1 { font-size: clamp(42px, 14vw, 64px); }
  .dashboard-heading::after { width: 68%; }
  .hero-pulse, .current-book { min-height: 296px; }
  .current-book::before { top: 20px; right: 20px; }
  .library-toolbar { padding: 12px; }
  .library-toolbar input { min-width: 100%; }
  .series-creator { flex-direction: column; }
  footer { width: calc(100% - 28px); }
}

/* Knowledge Graph Styles */
.graph-viewport-container {
  width: 100%;
  height: 450px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  margin-top: 14px;
}

.knowledge-graph-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.graph-node {
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.graph-node:hover {
  filter: drop-shadow(0 0 8px var(--amber));
}

.graph-edge {
  stroke: var(--line);
  stroke-width: 1.5;
  stroke-dasharray: 4 2;
}

/* Author Benchmark Styles */
.author-benchmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.author-benchmark-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.author-name {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--text);
  font-weight: bold;
}

.author-stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}
.author-stats-row strong {
  color: var(--amber);
}

/* Zen Companion Styles */
.zen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.zen-timer-card, .zen-audio-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.zen-display {
  font-family: var(--font-serif);
  font-size: 72px;
  font-weight: bold;
  color: var(--text);
  letter-spacing: 4px;
  line-height: 1;
}

.zen-controls {
  display: flex;
  gap: 10px;
}

.zen-audio-card {
  align-items: stretch;
}
.zen-audio-card h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--amber);
  margin-bottom: 4px;
}

.zen-sound-toggles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.zen-sound-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  padding: 8px 12px;
  background: var(--elevated, #22231F);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.zen-duration-presets {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.zen-duration-btn {
  background: var(--elevated, #22231F);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.zen-duration-btn:hover {
  color: var(--text);
  border-color: var(--amber);
}
.zen-duration-btn.active {
  background: var(--amber);
  color: #111210;
  border-color: var(--amber);
  font-weight: 600;
}

/* Command Palette Trigger in Topbar */
.command-palette-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 14px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.command-palette-trigger:hover {
  border-color: var(--amber);
  color: var(--text);
  background: var(--elevated, #22231F);
}
.search-icon {
  font-size: 14px;
  color: var(--amber);
}
.kbd-shortcut, .kbd-esc {
  background: var(--elevated, #22231F);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  color: var(--muted);
}

/* Command Palette Dialog */
.command-palette-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 640px;
  width: 90vw;
  margin: auto;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}
.command-palette-dialog::backdrop {
  background: rgba(17, 18, 16, 0.75);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.2s ease forwards;
}

.cmd-palette-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cmd-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.cmd-icon {
  font-size: 18px;
  color: var(--amber);
}
.cmd-input-wrapper input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  outline: none;
  font-family: inherit;
}
.cmd-input-wrapper input::placeholder {
  color: var(--muted);
}

.cmd-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px 0;
}

.cmd-group-title {
  padding: 8px 20px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--amber);
}

.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-left: 3px solid transparent;
}
.cmd-item:hover, .cmd-item.selected {
  background: rgba(194, 139, 55, 0.12);
  border-left-color: var(--amber);
}
.cmd-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cmd-item-title {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.cmd-item-sub {
  font-size: 12px;
  color: var(--muted);
}
.cmd-item-badge {
  font-size: 11px;
  background: var(--elevated, #22231F);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--muted);
  border: 1px solid var(--line);
}

.cmd-footer {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  background: var(--elevated, #22231F);
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.cmd-footer kbd {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
}

/* Floating Toast Notifications Stack */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100vw - 48px);
}

.toast-item {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  color: var(--text);
  font-size: 13px;
}
.toast-item.toast-success {
  border-left: 4px solid var(--forest, #355B4A);
}
.toast-item.toast-info {
  border-left: 4px solid var(--amber, #C28B37);
}
.toast-item.toast-error {
  border-left: 4px solid #D9534F;
}
.toast-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}
.toast-close:hover {
  color: var(--text);
}

@keyframes toastSlideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes toastSlideOut {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(20px);
    opacity: 0;
  }
}

/* Skeleton Loaders */
.skeleton-shimmer {
  background: linear-gradient(90deg, var(--surface) 25%, var(--elevated, #22231F) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.6s infinite ease-in-out;
  border-radius: 6px;
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  height: 180px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.skeleton-line {
  height: 14px;
  margin: 6px 0;
}

/* Library List View Density */
.book-shelf.view-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.book-list-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.book-list-row:hover {
  border-color: var(--amber);
  transform: translateX(4px);
}
.book-list-cover {
  width: 38px;
  height: 52px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--elevated, #22231F);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--amber);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.book-list-info {
  flex: 1;
  min-width: 0;
}
.book-list-title {
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-list-author {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-list-progress-wrap {
  width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.book-list-progress-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.book-list-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--forest), var(--amber));
}
.book-list-meta {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono, monospace);
  display: flex;
  justify-content: space-between;
}

/* Visually hidden, still announced by assistive technology. Referenced by
   #chart-data-summary in index.html, which was rendering as visible body text. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Kindle delivery status chips. Previously every state rendered as the same
   neutral chip, so "entregue" and "falhou" were visually identical. */
.status-chip.delivery-queued,
.status-chip.delivery-downloading {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 45%, transparent);
}

.status-chip.delivery-delivered {
  color: var(--forest-bright, var(--forest));
  border-color: color-mix(in srgb, var(--forest-bright, var(--forest)) 45%, transparent);
}

.status-chip.delivery-failed,
.status-chip.delivery-cancelled {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
