:root {
  --paper: #f2eee5;
  --paper-deep: #e5ded0;
  --ink: #171816;
  --muted: #6d6a62;
  --line: rgba(23, 24, 22, .13);
  --card: #fbf9f3;
  --sage: #52624e;
  --sage-soft: #dfe4d8;
  --gold: #a48650;
  --ruby: #8d342e;
  --night: #20231f;
  --shadow: 0 24px 65px rgba(27, 27, 23, .1);
  --radius-lg: 28px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }

html { background: var(--paper); color-scheme: light; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(255,255,255,.92), transparent 34%),
    radial-gradient(circle at 96% 30%, rgba(141, 52, 46, .08), transparent 31%),
    radial-gradient(circle at 12% 78%, rgba(164, 134, 80, .08), transparent 28%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(141, 52, 46, .24);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 960px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 22px 112px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: flex;
  align-items: baseline;
  justify-content: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid rgba(196, 162, 97, .82);
  background: var(--night);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  line-height: 42px;
}
.brand-one { color: var(--gold); font-size: 17px; }
.brand-w { margin-left: -1px; color: #f5efe4; font-size: 16px; letter-spacing: -.06em; }

.brand strong { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 18px; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255,255,255,.44);
  cursor: pointer;
}

.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.view { display: none; animation: fade-in .26s ease; }
.view.active { display: block; }

@keyframes fade-in { from { opacity: 0; transform: translateY(5px); } }

.intro-row, .section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 34px 0 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--ruby);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -.025em;
}

h1 { font-size: clamp(31px, 6vw, 48px); line-height: 1.03; }
h2 { font-size: clamp(27px, 4vw, 36px); line-height: 1.08; }
h3 { font-size: 23px; line-height: 1.16; }

.streak-pill, .count-label {
  flex: none;
  border: 1px solid rgba(167, 130, 72, .3);
  border-radius: 999px;
  background: rgba(251, 249, 243, .78);
  color: #75572f;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(27, 27, 23, .05);
}

.streak-pill::before { margin-right: 2px; color: var(--gold); content: "◆"; font-size: 8px; }

.daily-progress {
  display: grid;
  grid-template-columns: 1fr minmax(120px, 230px);
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
  border: 1px solid rgba(23, 24, 22, .09);
  border-radius: 22px;
  background: rgba(251, 249, 243, .82);
  padding: 17px 19px;
  box-shadow: 0 14px 34px rgba(27,27,23,.055);
}

.daily-progress div:first-child { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 1px 12px; }
.daily-progress span { color: var(--muted); font-size: 12px; font-weight: 700; }
.daily-progress .score-label { grid-column: 1; color: var(--ruby); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.daily-progress #daily-progress-label { grid-column: 1; color: var(--ink); font: 500 27px/1.05 Georgia, "Times New Roman", serif; }
.daily-progress #daily-progress-message { grid-column: 2; grid-row: 1 / 3; max-width: 270px; color: var(--muted); font: italic 13px/1.4 Georgia, "Times New Roman", serif; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--paper-deep); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ruby), var(--gold)); transition: width .45s ease; }
.daily-progress.complete { border-color: rgba(164,134,80,.3); background: #f8f2e6; }
.daily-progress.complete .progress-track span { background: linear-gradient(90deg, var(--gold), #d2b575); }

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

.daily-topic-card {
  position: relative;
  display: flex;
  min-height: 370px;
  overflow: hidden;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid rgba(23,24,22,.09);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(255,254,250,.97), rgba(244,240,232,.94));
  padding: 23px;
  box-shadow: 0 18px 44px rgba(27,27,23,.075);
  cursor: pointer;
  text-align: left;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.daily-topic-card::after {
  position: absolute;
  right: -28px;
  bottom: -34px;
  width: 105px;
  height: 105px;
  border: 1px solid rgba(164,134,80,.42);
  border-radius: 50%;
  opacity: .12;
  content: "";
}

.daily-topic-card:hover { transform: translateY(-4px) rotate(-.25deg); border-color: rgba(164,134,80,.52); box-shadow: 0 24px 52px rgba(27,27,23,.12); }
.daily-topic-card:nth-child(2):hover { transform: translateY(-4px) rotate(.25deg); }
.daily-topic-card.complete { border-color: rgba(164,134,80,.58); background: linear-gradient(145deg, #fffdf8, #f1ece2); }
.daily-card-number { position: absolute; top: 19px; right: 21px; color: #827b70 !important; font: 500 13px/1 Georgia, serif; letter-spacing: .1em; }
.daily-symbol { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 28px; border: 1px solid rgba(23,24,22,.1); border-radius: 13px; background: #eee9df; color: var(--ink); font-size: 19px; }
.daily-topic-card .topic-tag { margin-bottom: 16px; }
.daily-topic-card > strong { max-width: 270px; font: 500 27px/1.1 Georgia, "Times New Roman", serif; letter-spacing: -.025em; }
.daily-card-hook { margin: 13px 0 24px; color: var(--muted) !important; font-size: 14px !important; font-weight: 450 !important; line-height: 1.52; }
.daily-card-action { margin-top: auto; color: var(--ruby) !important; font-size: 12px !important; font-weight: 800 !important; letter-spacing: .04em; }

.daily-skeleton { cursor: default; }
.daily-skeleton:hover { transform: none; box-shadow: 0 16px 38px rgba(43,46,40,.07); }
.skeleton-line { display: block; width: 78%; height: 13px; margin-top: 11px; border-radius: 999px; background: linear-gradient(90deg, #ece8df 25%, #f7f4ed 50%, #ece8df 75%); background-size: 200% 100%; animation: shimmer 1.25s infinite linear; }
.skeleton-line.wide { width: 92%; height: 22px; margin-top: 19px; }
.skeleton-line.short { width: 55%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.learning-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow);
}

.learning-card::before {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7px;
  background: linear-gradient(90deg, var(--night), var(--gold));
  content: "";
}

.card-inner { padding: clamp(26px, 6vw, 54px); }

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

.topic-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid rgba(23,24,22,.08);
  background: #eee9df;
  color: #5e5a52;
  padding: 8px 11px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.topic-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.read-time { color: var(--muted); font-size: 12px; }

.card-title { max-width: 690px; font-size: clamp(31px, 6vw, 52px); line-height: 1.04; }
.card-hook { max-width: 710px; margin: 17px 0 28px; color: #555c53; font-size: clamp(16px, 2vw, 19px); line-height: 1.55; }

.concept-box {
  border-left: 3px solid var(--gold);
  background: #f1ede5;
  padding: 17px 18px;
  border-radius: 0 14px 14px 0;
  line-height: 1.58;
}

.concept-box strong { display: block; margin-bottom: 5px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.concept-box p { margin: 0; }

.why-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin: 26px 0 0;
}

.why-row div { padding-top: 17px; border-top: 1px solid var(--line); }
.why-row span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.why-row p { margin: 0; line-height: 1.5; }

.quiz-box {
  position: relative;
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #faf8f3;
  padding: 20px;
}

.quiz-box::after {
  position: absolute;
  top: -28px;
  right: -25px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #e7e0d3;
  opacity: .72;
  content: "";
}

.quiz-heading { position: relative; z-index: 1; display: flex; align-items: baseline; gap: 10px; }
.quiz-heading span { color: var(--ruby); font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.quiz-heading strong { color: var(--muted); font-size: 12px; font-weight: 600; }
.quiz-question { position: relative; z-index: 1; margin: 15px 0; font: 500 19px/1.35 Georgia, "Times New Roman", serif; }
.quiz-options { display: grid; gap: 8px; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 11px 13px;
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}
.quiz-option:hover:not(:disabled) { transform: translateX(3px); border-color: var(--gold); }
.quiz-option span { display: grid; place-items: center; flex: none; width: 25px; height: 25px; border-radius: 8px; background: #eee9df; color: var(--ink); font-size: 11px; font-weight: 800; }
.quiz-option:disabled { cursor: default; opacity: .65; }
.quiz-option.correct { border-color: #7d9b78; background: #edf4eb; opacity: 1; }
.quiz-option.incorrect { border-color: #c18479; background: #f8edeb; opacity: 1; }
.quiz-feedback { margin-top: 12px; border-radius: 12px; padding: 12px 14px; }
.quiz-feedback.correct { background: #e9f1e7; color: #40523e; }
.quiz-feedback.incorrect { background: #f7ece8; color: #744a43; }
.quiz-feedback strong { font-size: 13px; }
.quiz-feedback p { margin: 4px 0 0; font-size: 13px; line-height: 1.45; }
.quiz-feedback button { margin-top: 9px; border: 0; border-bottom: 1px solid currentColor; background: transparent; padding: 0 0 2px; color: inherit; cursor: pointer; font-size: 12px; font-weight: 800; }
.recall-button { width: 100%; border: 1px solid rgba(141,52,46,.5); border-radius: 12px; background: #fff; padding: 12px 14px; color: var(--ruby); cursor: pointer; font-weight: 750; }
.source-link { display: inline-flex; margin-top: 17px; border-bottom: 1px solid currentColor; color: var(--ruby); text-decoration: none; font-size: 12px; font-weight: 750; }

.card-actions { display: flex; gap: 10px; margin-top: 30px; }

.primary-button, .secondary-button {
  min-height: 48px;
  border-radius: 14px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 750;
  transition: transform .16s ease, background .16s ease;
}

.primary-button { border: 1px solid var(--night); background: var(--night); color: white; }
.secondary-button { border: 1px solid var(--line); background: transparent; }
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); }
.primary-button.completed { border-color: var(--gold); background: var(--night); }
.secondary-button.saved { border-color: var(--gold); background: #f7f0e4; color: #74582f; }
.full-width { width: 100%; }

.daily-note { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.privacy-note { margin: 36px auto 4px; text-align: center; color: var(--muted); font-size: 11px; }

.filter-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 17px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-button {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.42);
  padding: 9px 14px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.filter-button.active { border-color: var(--ink); background: var(--ink); color: #fff; }

.discovery-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -5px 0 18px;
  border: 1px solid rgba(23,24,22,.1);
  border-radius: 20px;
  background: linear-gradient(120deg, rgba(251,249,243,.92), rgba(229,222,208,.68));
  padding: 15px 16px;
}
.discovery-bar > div { display: flex; align-items: center; gap: 12px; }
.discovery-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 13px; background: var(--ruby); color: #fff; }
.discovery-bar strong, .discovery-bar small { display: block; }
.discovery-bar strong { font-size: 14px; }
.discovery-bar small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.discovery-bar .primary-button { flex: none; min-height: 43px; font-size: 12px; }
.discovery-bar .primary-button:disabled { cursor: wait; opacity: .7; }

.library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.mini-card {
  display: flex;
  min-height: 210px;
  flex-direction: column;
  border: 1px solid rgba(23,24,22,.09);
  border-radius: 22px;
  background: rgba(251,249,243,.9);
  padding: 21px;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(27,27,23,.055);
  text-align: left;
  transition: transform .18s ease, box-shadow .18s ease;
}

.mini-card:hover { transform: translateY(-3px); box-shadow: 0 20px 42px rgba(27,27,23,.1); }
.mini-card .topic-tag { align-self: flex-start; }
.mini-card h3 { margin: 18px 0 9px; }
.mini-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.mini-meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 18px; color: var(--muted); font-size: 12px; }
.mini-state { color: var(--ruby); font-weight: 750; }

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed rgba(36,41,35,.2);
  border-radius: var(--radius-md);
  padding: 48px 25px;
  text-align: center;
  color: var(--muted);
}
.empty-state h3 { color: var(--ink); margin-bottom: 8px; }
.empty-state p { margin: 0 auto; max-width: 400px; line-height: 1.5; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(calc(100% - 28px), 470px);
  transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 21px;
  background: rgba(32,35,31,.95);
  padding: 8px;
  box-shadow: 0 16px 45px rgba(33,38,31,.23);
  backdrop-filter: blur(16px);
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: rgba(255,255,255,.55);
  padding: 10px 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-item svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

dialog { border: 0; padding: 0; }
dialog::backdrop { background: rgba(27,31,26,.4); backdrop-filter: blur(4px); }
.sheet-dialog {
  width: min(calc(100% - 24px), 760px);
  border-radius: 26px;
  background: var(--card);
  color: var(--ink);
  padding: 26px;
  box-shadow: var(--shadow);
}
.sheet-handle { display: none; width: 40px; height: 4px; margin: -10px auto 23px; border-radius: 99px; background: #d5d3cd; }
.sheet-dialog .muted { margin: 11px 0 22px; color: var(--muted); line-height: 1.5; }
.topic-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.topic-option { display: block; }
.topic-option input { position: absolute; opacity: 0; pointer-events: none; }
.topic-choice {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  transition: border .16s ease, background .16s ease;
}
.topic-option input:checked + .topic-choice { border-color: rgba(164,134,80,.62); background: #eee9df; }
.topic-symbol { display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid rgba(23,24,22,.08); border-radius: 12px; background: #eee9df; color: var(--ink); font-family: Georgia,serif; font-size: 19px; }
.topic-copy strong, .topic-copy small { display: block; }
.topic-copy small { margin-top: 3px; color: var(--muted); }
.topic-check { width: 20px; height: 20px; margin-left: auto; border: 1px solid #b7bcb3; border-radius: 50%; }
.topic-option input:checked + .topic-choice .topic-check { border: 6px solid var(--ruby); }
.form-error { min-height: 18px; margin: -8px 0 10px; color: #a84b3e; font-size: 12px; }

.card-dialog {
  width: min(calc(100% - 24px), 760px);
  max-height: calc(100vh - 40px);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.dialog-content { position: relative; max-height: calc(100vh - 40px); overflow-y: auto; }
.dialog-close { position: absolute; z-index: 2; top: 18px; right: 18px; background: rgba(255,255,255,.8); font-size: 25px; font-weight: 300; }
.card-dialog .card-inner { padding-top: 62px; }
.card-dialog .learning-card { border: 0; border-radius: 0; box-shadow: none; }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 95px;
  max-width: calc(100% - 32px);
  transform: translate(-50%, 15px);
  border-radius: 12px;
  background: var(--night);
  color: #fff;
  padding: 11px 15px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .app-shell { padding-inline: 16px; }
  .topbar { padding-top: 16px; }
  .intro-row, .section-heading { align-items: flex-start; margin-top: 22px; }
  .streak-pill, .count-label { margin-top: 3px; }
  .daily-progress { grid-template-columns: 1fr; gap: 12px; padding: 14px 15px; }
  .daily-progress div:first-child { display: grid; grid-template-columns: auto 1fr; gap: 1px 12px; }
  .daily-progress #daily-progress-message { max-width: none; }
  .daily-deck { grid-template-columns: 1fr; }
  .daily-topic-card { min-height: 255px; padding: 21px; }
  .daily-symbol { margin-bottom: 20px; }
  .daily-topic-card > strong { font-size: 25px; }
  .card-inner { padding: 28px 22px 24px; }
  .card-topline { margin-bottom: 22px; }
  .why-row { grid-template-columns: 1fr; gap: 17px; }
  .card-actions { flex-direction: column; }
  .primary-button, .secondary-button { width: 100%; }
  .library-grid { grid-template-columns: 1fr; }
  .mini-card { min-height: 188px; }
  .discovery-bar { align-items: stretch; flex-direction: column; }
  .discovery-bar .primary-button { width: 100%; }
  .sheet-dialog { position: fixed; inset: auto 12px 12px; width: auto; margin: 0; border-radius: 26px; }
  .sheet-handle { display: block; }
  .topic-options { grid-template-columns: 1fr; max-height: 52vh; overflow-y: auto; padding-right: 3px; }
  .nav-item { flex-direction: column; gap: 3px; padding: 8px 4px; }
}

@media (min-width: 641px) and (max-width: 840px) {
  .daily-deck { grid-template-columns: 1fr; }
  .daily-topic-card { min-height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
