:root {
  --paper: #f6f0e2;
  --paper-deep: #efe6d0;
  --card: #fffdf6;
  --ink: #2b2118;
  --ink-soft: #5c4f3d;
  --accent: #8c2f1b;
  --accent-soft: #b4552d;
  --gold: #c19a3d;
  --line: #ddd0b4;
  --good: #3f7a3a;
  --hard: #b8860b;
  --again: #a33327;
  --easy: #2f6690;
  --shadow: 0 2px 10px rgba(60, 42, 20, .12);
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.55;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; margin: 0; }

/* ---------- top bar ---------- */
.topbar {
  background: linear-gradient(180deg, #3a2a1a, #2b2118);
  color: #f3e9d2;
  border-bottom: 4px solid var(--gold);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 30px; color: var(--gold); border: 2px solid var(--gold);
  border-radius: 50%; width: 46px; height: 46px; display: grid; place-items: center; flex: none;
}
.brand h1 { font-size: 22px; letter-spacing: .4px; }
.tagline { margin: 0; font-size: 12.5px; color: #cdbd97; font-style: italic; }

.mainnav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  background: transparent; color: #e9dcbc; border: 1px solid #6d5a3a;
  padding: 7px 13px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px;
}
.nav-btn:hover { background: #4a3823; }
.nav-btn.active { background: var(--gold); color: #2b2118; border-color: var(--gold); font-weight: 700; }

/* ---------- layout ---------- */
main { max-width: 960px; margin: 0 auto; padding: 22px 16px 40px; }
.view { display: none; }
.view.active { display: block; }
.hidden { display: none !important; }
.section-title { font-size: 21px; margin: 26px 0 12px; border-bottom: 2px solid var(--line); padding-bottom: 6px; }

/* ---------- dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 10px; text-align: center; box-shadow: var(--shadow);
}
.stat-num { font-size: 32px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--ink-soft); }

.cta-row { margin: 22px 0 4px; text-align: center; }
.cta-note { color: var(--ink-soft); font-size: 14px; max-width: 560px; margin: 10px auto 0; }

.btn {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); padding: 9px 18px; font-size: 15px;
}
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fdf6e3; font-weight: 700; }
.btn-primary:hover { background: var(--accent-soft); }
.btn-big { font-size: 18px; padding: 14px 30px; border-radius: 999px; }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 12px; font-size: 13px; }
.btn-danger { background: #fff; border-color: var(--again); color: var(--again); }

.period-bar-row { margin-bottom: 10px; }
.period-bar-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 3px; }
.period-bar-head .pname { font-weight: 700; }
.period-bar-head .ppct { color: var(--ink-soft); }
.progress-track { background: var(--paper-deep); border: 1px solid var(--line); border-radius: 999px; height: 12px; overflow: hidden; flex: 1; }
.progress-fill { background: linear-gradient(90deg, var(--gold), var(--accent-soft)); height: 100%; width: 0; transition: width .4s ease; }

.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.mode-card {
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; font: inherit; box-shadow: var(--shadow);
}
.mode-card:hover { border-color: var(--gold); }
.mode-card h3 { font-size: 17px; color: var(--accent); margin-bottom: 4px; }
.mode-card p { margin: 0; font-size: 14px; color: var(--ink-soft); }

/* ---------- study ---------- */
.period-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.period-pick {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; cursor: pointer; font: inherit; text-align: left; box-shadow: var(--shadow);
}
.period-pick:hover { border-color: var(--gold); }
.period-pick .pp-title { font-weight: 700; display: block; }
.period-pick .pp-sub { font-size: 13px; color: var(--ink-soft); display: block; }
.period-pick .pp-due { font-size: 12.5px; color: var(--accent); display: block; margin-top: 4px; }

.session-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; font-size: 14px; }
.session-head .progress-track { height: 10px; }

.study-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 26px 24px; min-height: 300px;
  display: flex; flex-direction: column;
}
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  font-size: 12px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink-soft); letter-spacing: .3px;
}
.chip.type { background: var(--accent); border-color: var(--accent); color: #fdf6e3; font-weight: 700; }
.chip.due { background: #f3e2c7; }
.card-q { font-size: 21px; line-height: 1.45; margin: 4px 0 10px; }
.card-hint { color: var(--ink-soft); font-size: 14px; font-style: italic; margin-top: auto; }
.card-a {
  border-top: 2px dashed var(--line); margin-top: 16px; padding-top: 16px;
  font-size: 17.5px;
}
.card-a .context { display: block; margin-top: 8px; font-size: 14.5px; color: var(--ink-soft); font-style: italic; }

.reveal-row { text-align: center; margin-top: 20px; }

.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.grade-btn {
  font: inherit; cursor: pointer; border-radius: 10px; padding: 12px 6px; font-weight: 700; font-size: 16px;
  border: 2px solid; background: var(--card);
}
.grade-btn small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.grade-again { border-color: var(--again); color: var(--again); }
.grade-hard { border-color: var(--hard); color: var(--hard); }
.grade-good { border-color: var(--good); color: var(--good); }
.grade-easy { border-color: var(--easy); color: var(--easy); }
.grade-btn:hover { filter: brightness(.95); }

.options-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.option-btn {
  font: inherit; text-align: left; cursor: pointer; background: var(--paper);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px;
}
.option-btn:hover:not(:disabled) { border-color: var(--gold); }
.option-btn:disabled { cursor: default; opacity: .92; }
.option-btn.correct { border-color: var(--good); background: #e9f3e4; }
.option-btn.wrong { border-color: var(--again); background: #f9e7e2; }
.option-btn .opt-letter { font-weight: 700; color: var(--accent); margin-right: 8px; }
.feedback {
  margin-top: 14px; border-radius: 10px; padding: 12px 14px; font-size: 15.5px;
  border: 1px solid var(--line); background: var(--paper);
}
.feedback.good { border-color: var(--good); }
.feedback.bad { border-color: var(--again); }
.feedback .verdict { font-weight: 700; display: block; margin-bottom: 4px; }
.feedback.good .verdict { color: var(--good); }
.feedback.bad .verdict { color: var(--again); }

.summary-body {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); font-size: 16.5px;
}
.summary-body ul { margin: 8px 0; padding-left: 20px; }

/* ---------- browse ---------- */
.search-input {
  width: 100%; font: inherit; font-size: 16px; padding: 11px 14px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card); margin-bottom: 18px;
}
.browse-period { margin-bottom: 26px; }
.browse-period > h3 { font-size: 19px; color: var(--accent); }
.browse-period .overview {
  background: var(--paper-deep); border-left: 4px solid var(--gold);
  padding: 12px 16px; border-radius: 0 10px 10px 0; font-size: 15px; margin: 8px 0 12px;
}
.browse-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 8px; font-size: 15px;
}
.browse-item .bq { font-weight: 700; }
.browse-item .ba { color: var(--ink-soft); margin-top: 3px; }
.browse-item .bstatus { font-size: 12px; color: var(--accent); float: right; }

/* ---------- settings ---------- */
.settings-box {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.file-label { display: inline-block; }
.settings-msg { color: var(--good); font-size: 14.5px; min-height: 1.2em; }

.footer {
  max-width: 960px; margin: 0 auto; padding: 0 16px 30px;
  color: var(--ink-soft); font-size: 13px; text-align: center;
}

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .mode-grid { grid-template-columns: 1fr; }
  .period-picker { grid-template-columns: 1fr; }
  .grade-row { grid-template-columns: repeat(2, 1fr); }
  .brand h1 { font-size: 19px; }
  .card-q { font-size: 19px; }
  .topbar-inner { justify-content: center; }
}

/* ============================================================
   v2 — subscription product: landing, auth, paywall, account
   ============================================================ */

/* ---------- dashboard hero (image pass) ---------- */
.hero {
  height: 190px; border-radius: var(--radius); margin-bottom: 18px;
  background-size: cover; background-position: center 30%;
  background-color: var(--paper-deep); border: 1px solid var(--line);
  position: relative; box-shadow: var(--shadow);
}
.hero-credit {
  position: absolute; right: 10px; bottom: 8px; font-size: 11.5px;
  color: #f3e9d2; background: rgba(43, 33, 24, .72);
  padding: 3px 9px; border-radius: 999px; max-width: 92%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.browse-img { width: 100%; border-radius: 10px; margin: 4px 0 10px; border: 1px solid var(--line); }
.credits-list { font-size: 13.5px; color: var(--ink-soft); padding-left: 20px; }
.credits-list li { margin-bottom: 6px; }
.credits-list a { color: var(--accent); }

/* ---------- account area ---------- */
.account-area { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.account-email { font-size: 13.5px; color: #cdbd97; margin-right: 2px; }

/* ---------- landing ---------- */
.landing-hero { text-align: center; padding: 26px 8px 6px; }
.landing-title { font-size: 40px; line-height: 1.15; color: var(--accent); }
.landing-sub { max-width: 680px; margin: 16px auto 0; font-size: 17px; color: var(--ink-soft); }

.landing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 28px; align-items: start; }
.price-card, .science-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.price-card { border-top: 5px solid var(--gold); }
.price-amount { font-size: 46px; font-weight: 700; color: var(--accent); line-height: 1; }
.price-per { font-size: 19px; color: var(--ink-soft); font-weight: 400; }
.price-note { color: var(--ink-soft); font-size: 15px; margin: 10px 0; }
.price-list { margin: 12px 0 4px; padding-left: 20px; font-size: 15px; }
.price-list li { margin-bottom: 5px; }

.science-card h3 { color: var(--accent); font-size: 20px; margin-bottom: 8px; }
.science-item { margin-top: 14px; }
.science-item h4 { margin: 0 0 3px; font-size: 16.5px; }
.science-item p { margin: 0; font-size: 14.5px; color: var(--ink-soft); }

.auth-form { margin-top: 20px; border-top: 2px dashed var(--line); padding-top: 18px; }
.auth-form h3 { font-size: 18px; margin-bottom: 10px; }
.auth-form label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.auth-form input {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; font-weight: 400;
  padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff;
}
.auth-form input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.auth-form .btn-big { width: 100%; margin-top: 4px; }
.auth-switch { font-size: 14px; color: var(--ink-soft); text-align: center; margin: 12px 0 0; }
.auth-switch a { color: var(--accent); font-weight: 700; }
.auth-error { color: var(--again); font-size: 14.5px; min-height: 1.2em; margin: 10px 0 0; }
.auth-fineprint { font-size: 12.5px; color: var(--ink-soft); margin-top: 12px; }

.landing-periods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.landing-period {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.landing-period img { width: 100%; height: 120px; object-fit: cover; display: block; }
.landing-period .lp-body { padding: 12px 14px; }
.landing-period .lp-title { font-weight: 700; font-size: 15px; }
.landing-period .lp-range { color: var(--accent); font-size: 13px; font-weight: 700; }
.landing-period .lp-text { font-size: 13.5px; color: var(--ink-soft); margin: 6px 0 0; }

/* ---------- subscribe wall ---------- */
.wall-card {
  background: var(--card); border: 1px solid var(--line); border-top: 5px solid var(--gold);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
  max-width: 620px; margin: 20px auto; text-align: center;
}
.wall-card .section-title { border-bottom: none; text-align: center; }
.wall-card p { font-size: 16px; color: var(--ink-soft); }
.wall-activating { color: var(--good); font-weight: 700; }
.wall-error { color: var(--again); font-size: 14.5px; min-height: 1.2em; }
.wall-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .landing-grid { grid-template-columns: 1fr; }
  .landing-periods { grid-template-columns: 1fr; }
  .landing-title { font-size: 31px; }
  .hero { height: 140px; }
  .account-area { justify-content: center; }
}
