:root {
  color-scheme: dark;
  --bg: #070707;
  --panel: #141416;
  --panel-2: #1c1d20;
  --panel-3: #25262a;
  --text: #f7f3ea;
  --muted: rgba(247, 243, 234, 0.68);
  --faint: rgba(247, 243, 234, 0.42);
  --line: rgba(255, 255, 255, 0.09);
  --accent: #d8ae62;
  --accent-2: #f0d19a;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(216, 174, 98, 0.12), transparent 28rem),
    linear-gradient(180deg, #0c0c0d 0%, var(--bg) 42%);
  color: var(--text);
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 28px 16px;
}

.app {
  position: relative;
  width: min(100%, 480px);
  min-height: min(860px, calc(100vh - 56px));
  max-height: calc(100vh - 56px);
  overflow: hidden;
  background: rgba(10, 10, 11, 0.92);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 20px 14px;
  background: rgba(10, 10, 11, 0.94);
  border-bottom: 1px solid var(--line);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.refresh-button {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.refresh-button:active {
  transform: scale(0.96);
}

.refresh-button.is-loading {
  color: #0b0b0b;
  background: var(--accent);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-family: ui-serif, Georgia, serif;
  font-size: clamp(2.25rem, 9vw, 3.1rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-family: ui-serif, Georgia, serif;
  font-size: 2rem;
  line-height: 1.05;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.06rem;
}

.score-pill {
  min-width: 84px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-align: center;
}

.score-pill span {
  display: block;
  color: var(--accent-2);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.score-pill small {
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 700;
}

.view {
  display: none;
  height: calc(100% - 100px);
  overflow: auto;
  padding: 16px 18px 94px;
}

.view.is-active {
  display: block;
}

.category-strip {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 0 0 16px;
  scrollbar-width: none;
  scroll-behavior: smooth;
  flex: 1;
}

.rail-control {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.rail-arrow {
  flex: 0 0 auto;
  width: 34px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel-2);
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.rail-arrow:active {
  transform: scale(0.96);
}

.feed-status {
  min-height: 28px;
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 0 0 10px;
}

.category-strip::-webkit-scrollbar,
.view::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.chip.is-active {
  color: #090909;
  background: var(--accent);
}

.feed,
.books-list,
.profile-learned-list {
  display: grid;
  gap: 14px;
}

.card,
.book-card,
.profile-card,
.stats-grid article {
  background: linear-gradient(180deg, var(--panel) 0%, #101113 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 18px;
  touch-action: pan-y;
  transition: transform 180ms ease, opacity 180ms ease, border-color 180ms ease;
  will-change: transform;
}

.card.is-swiping {
  cursor: grabbing;
  transition: border-color 120ms ease;
}

.card.swipe-learned {
  border-color: rgba(216, 174, 98, 0.72);
}

.card.swipe-later {
  border-color: rgba(255, 255, 255, 0.28);
}

.card.swipe-out-right {
  opacity: 0;
  transform: translateX(120%) rotate(10deg) !important;
}

.card.swipe-out-left {
  opacity: 0;
  transform: translateX(-120%) rotate(-10deg) !important;
}

.swipe-badge {
  position: absolute;
  top: 16px;
  z-index: 1;
  padding: 7px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.swipe-badge-left {
  left: 16px;
  color: rgba(247, 243, 234, 0.72);
}

.swipe-badge-right {
  right: 16px;
  color: var(--accent-2);
}

.card.swipe-later .swipe-badge-left,
.card.swipe-learned .swipe-badge-right {
  opacity: 1;
}

.card-header,
.card-actions,
.book-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.category-label {
  color: #0b0b0b;
  background: var(--accent);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.72rem;
  font-weight: 900;
}

.source-label {
  color: var(--faint);
  font-size: 0.74rem;
  font-weight: 700;
  text-align: right;
}

.card h3 {
  font-family: ui-serif, Georgia, serif;
  font-size: 1.48rem;
  line-height: 1.08;
}

.card p,
.book-card p,
.profile-card p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0;
}

.book-origin,
.book-line {
  margin: 10px 0 0;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.book-origin {
  display: grid;
  gap: 2px;
}

.book-origin span {
  color: var(--faint);
  font-size: 0.74rem;
  font-weight: 800;
}

.book-origin strong {
  color: var(--text);
  font-family: ui-serif, Georgia, serif;
  font-size: 1rem;
  line-height: 1.2;
}

.book-line strong {
  display: block;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.book-line p {
  color: var(--text);
  font-family: ui-serif, Georgia, serif;
  font-size: 1.04rem;
}

.why {
  padding-top: 2px;
}

.why strong {
  display: block;
  color: var(--accent);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.action-button {
  flex: 1;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel-3);
  font-weight: 900;
  cursor: pointer;
}

.card-actions .action-button {
  width: 100%;
}

.action-button.is-active {
  color: #0b0b0b;
  background: var(--accent);
}

.section-heading {
  padding: 2px 0 18px;
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.book-card,
.profile-card {
  padding: 18px;
}

.book-card h3 {
  font-family: ui-serif, Georgia, serif;
  font-size: 1.45rem;
}

.book-meta {
  margin-bottom: 12px;
}

.author {
  color: var(--accent);
  font-weight: 800;
}

.lessons {
  display: grid;
  gap: 7px;
  margin: 15px 0;
  padding: 0;
  list-style: none;
}

.lessons li {
  color: var(--muted);
  font-weight: 650;
}

.lessons li::before {
  content: "›";
  color: var(--accent);
  margin-right: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}

.stats-grid article {
  padding: 18px;
}

.stats-grid strong {
  display: block;
  color: var(--accent);
  font-size: 2.15rem;
  line-height: 1;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-top: 8px;
}

.profile-card.compact {
  margin-top: 14px;
}

.learned-profile-strip {
  margin-top: 14px;
  padding-bottom: 12px;
}

.mini-learned-card {
  appearance: none;
  text-align: left;
  font: inherit;
  padding: 12px;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.mini-learned-card strong {
  display: block;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.25;
}

.mini-learned-card span {
  display: block;
  color: var(--faint);
  font-size: 0.74rem;
  font-weight: 800;
  margin-top: 5px;
}

.install-steps {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
  font-weight: 700;
}

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 12px 12px 18px;
  background: rgba(10, 10, 11, 0.96);
  border-top: 1px solid var(--line);
}

.nav-button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--faint);
  background: transparent;
  font-size: 0.84rem;
  font-weight: 900;
  cursor: pointer;
}

.nav-button.is-active {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line);
}

dialog {
  width: min(92vw, 470px);
  max-height: 86vh;
  overflow: auto;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
}

.dialog-card {
  padding: 22px;
  background: #101113;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.dialog-card .close-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.close-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 0;
  }

  .app {
    width: 100%;
    min-height: 100vh;
    max-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    padding-top: max(20px, env(safe-area-inset-top));
  }
}
