/* ============================================================
   GRACEFULLY — App theme v2
   Matches landing design language: ink/paper neutrals, Fraunces
   serif display type, Inter UI, single terracotta accent reserved
   for interactive elements. Layered soft shadows, generous radii.
   Class names unchanged from v1 — drop-in replacement.
   ============================================================ */

/* Fraunces+Inter loaded via <link> in HTML head (CSP style-src 'self' blocks @import) */

:root {
  --ink: #1a1a18;
  --paper: #f6f5f2;
  --card: #ffffff;
  --muted: #5c5a56;
  --faint: #8f8d88;
  --line: #e7e5e0;
  --dark-bg: #0b0b0a;
  --accent: #c2571f;
  --accent-hover: #a84812;
  --accent-soft: rgba(194, 87, 31, 0.09);
  --danger: #8f2d16;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow-card: 0 20px 40px -24px rgba(26,26,24,.22), 0 4px 12px -6px rgba(26,26,24,.10);
  --shadow-lift: 0 28px 52px -28px rgba(26,26,24,.30), 0 6px 16px -8px rgba(26,26,24,.13);
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-text-size-adjust: 100%; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 500px at 85% -100px, rgba(194,87,31,.06), transparent 60%),
    var(--paper);
  color: var(--ink);
  line-height: 1.6;
  font-size: clamp(15px, 0.5rem + 0.8vw, 17px);
  min-height: 100vh; min-height: 100dvh;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2 { font-family: var(--serif); font-weight: 450; letter-spacing: -0.015em; }

/* ---------- top bar ---------- */
.topbar {
  background: rgba(11,11,10,.92);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) clamp(12px, 2.5vw, 24px) 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
}
.brand a { text-decoration: none; }
.brand strong { font-family: var(--serif); font-size: clamp(15px, 3.5vw, 19px); font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.brand strong i { color: var(--accent); font-style: normal; }
.brand span {
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: rgba(255,255,255,.45); font-weight: 600;
}
.topnav { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; max-width: 100%; align-items: center; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  color: rgba(255,255,255,.68); text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 9px 13px; border-radius: 999px; white-space: nowrap; flex-shrink: 0;
  transition: color .15s, background .15s;
}
.topnav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.topnav a.active { color: #fff; background: rgba(194,87,31,.22); box-shadow: inset 0 0 0 1px rgba(194,87,31,.45); }
.topnav button {
  background: none; border: 1px solid rgba(255,255,255,.22); color: rgba(255,255,255,.68);
  font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: border-color .15s, color .15s;
}
.topnav button:hover { color: #fff; border-color: rgba(255,255,255,.55); }

/* ---------- layout ---------- */
.view {
  max-width: 960px; margin: 0 auto;
  padding: clamp(28px, 5vh, 56px) clamp(16px, 4vw, 40px) 90px;
}
.view.narrow { max-width: 740px; }
.hidden { display: none !important; }

.part-num {
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: 8px;
}
h1 { font-size: clamp(27px, 4.6vw, 42px); line-height: 1.1; }
.view h1 { margin-bottom: 4px; }
h2 { font-size: clamp(21px, 3.4vw, 28px); margin: clamp(30px, 5vw, 44px) 0 14px; }
h3 { font-size: clamp(16px, 3vw, 18px); font-weight: 700; margin: 22px 0 10px; }
p.lead { font-size: clamp(15.5px, 2.2vw, 18px); color: var(--muted); max-width: 58ch; margin-top: 12px; }
p.body { max-width: 66ch; margin-top: 10px; }
p.small { font-size: 13px; color: var(--faint); margin-top: 8px; }

/* ---------- hero ---------- */
.hero { padding-bottom: clamp(28px, 5vw, 44px); border-bottom: 1px solid var(--line); margin-bottom: clamp(24px, 4vw, 36px); }
.hero .stat-row { display: flex; flex-wrap: wrap; gap: clamp(18px, 4vw, 40px); margin-top: 26px; }
.hero .stat-row strong { display: block; font-family: var(--serif); font-weight: 550; font-size: clamp(19px, 3.4vw, 25px); letter-spacing: -0.01em; }
.hero .stat-row span { font-size: 11px; letter-spacing: .13em; text-transform: uppercase; color: var(--faint); }

/* ---------- buttons: pill, terracotta ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: clamp(14px, 1rem, 15px); font-weight: 600;
  padding: 13px 26px; min-height: 50px; border-radius: 999px; cursor: pointer;
  border: none; background: var(--accent); color: #fff; text-decoration: none;
  box-shadow: 0 10px 26px -10px rgba(194,87,31,.55);
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 14px 30px -10px rgba(194,87,31,.62); }
.btn:active { transform: translateY(0); }
.btn.ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--ink); box-shadow: none;
}
.btn.ghost:hover { background: var(--ink); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

button, input, select, summary, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 16px; margin-top: 20px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: clamp(16px, 3vw, 22px);
  box-shadow: var(--shadow-card); border: 1px solid rgba(26,26,24,.05);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.card h4 { font-size: clamp(14px, 3.6vw, 16px); font-weight: 700; margin-bottom: 7px; }
.card p { font-size: clamp(13px, 3.3vw, 14.5px); color: var(--muted); }

/* ---------- assessment ---------- */
.progress-wrap {
  position: sticky; top: 58px; z-index: 5;
  background: rgba(246,245,242,.94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  padding: 12px 0; border-bottom: 1px solid var(--line); margin-bottom: 22px;
}
.progress-bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-hover), var(--accent));
  border-radius: 999px; transition: width .3s cubic-bezier(.22,1,.36,1);
}
.progress-label { font-size: 11.5px; color: var(--muted); margin-top: 7px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }

.q-block {
  background: var(--card); border: 1px solid rgba(26,26,24,.06); border-radius: var(--radius);
  padding: clamp(15px, 3vw, 22px); margin-bottom: 12px;
  box-shadow: 0 8px 20px -14px rgba(26,26,24,.18);
}
.q-block .q-text { font-weight: 600; font-size: clamp(14px, 3.7vw, 15.5px); margin-bottom: 12px; line-height: 1.45; }
.q-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px,100%), 1fr)); gap: 8px; }
.q-opts label {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; cursor: pointer; font-size: clamp(13px, 3.4vw, 14.5px); background: var(--paper);
  min-height: 48px; transition: border-color .15s, background .15s;
}
.q-opts label:hover { border-color: var(--accent); }
.q-opts label:active { background: var(--accent-soft); }
.q-opts input { accent-color: var(--accent); width: 17px; height: 17px; flex-shrink: 0; }
.q-opts input:checked ~ span { font-weight: 700; }
.q-opts label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- results ---------- */
.score-hero {
  background: linear-gradient(135deg, #141310 0%, var(--dark-bg) 70%);
  color: #fff; border-radius: 20px; padding: clamp(24px, 5vw, 40px); margin-top: 20px;
  position: relative; overflow: hidden;
  box-shadow: 0 32px 64px -36px rgba(11,11,10,.6);
}
.score-hero::after {
  content: ""; position: absolute; right: -80px; top: -80px;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(194,87,31,.5), rgba(194,87,31,.08) 65%, transparent);
  pointer-events: none;
}
.score-hero .big { font-family: var(--serif); font-size: clamp(44px, 11vw, 72px); font-weight: 500; letter-spacing: -0.03em; line-height: 1; }
.score-hero .big + span { font-size: clamp(15px, 3vw, 19px); color: rgba(255,255,255,.55); }
.score-hero .stage {
  display: inline-block; margin-top: 14px;
  font-size: clamp(11px, 3vw, 13px); letter-spacing: .16em; text-transform: uppercase; font-weight: 700;
  color: var(--accent); border: 1px solid rgba(194,87,31,.5); border-radius: 999px; padding: 6px 16px;
  background: rgba(194,87,31,.1);
}
.score-hero p { color: rgba(255,255,255,.75); max-width: 56ch; margin-top: 16px; font-size: clamp(13.5px, 3.4vw, 15px); }

.domain {
  background: var(--card); border-radius: 12px; padding: clamp(13px, 3vw, 17px); margin-bottom: 10px;
  border: 1px solid rgba(26,26,24,.05); box-shadow: 0 6px 16px -12px rgba(26,26,24,.15);
}
.domain .d-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.domain .d-name { font-weight: 600; font-size: clamp(13.5px, 3.4vw, 15px); }
.domain .d-score { font-family: var(--serif); font-weight: 550; font-size: clamp(14px, 3.6vw, 16px); white-space: nowrap; }
.domain .d-bar { height: 5px; background: var(--line); border-radius: 999px; margin-top: 10px; overflow: hidden; }
.domain .d-bar i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent-hover), var(--accent));
  border-radius: 999px;
}

/* ---------- plan tiers ---------- */
.tier {
  background: var(--card); border: 1px solid rgba(26,26,24,.05); border-left: 4px solid var(--accent);
  border-radius: 6px var(--radius) var(--radius) 6px;
  padding: clamp(16px, 3.5vw, 24px); margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.tier h4 {
  font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-weight: 800; margin-bottom: 12px;
  color: var(--accent);
}
.tier.no { border-left: 4px dashed var(--danger); }
.tier.no h4 { color: var(--danger); }
.tier ul { margin-left: 18px; }
.tier li { margin-bottom: 13px; font-size: clamp(13.5px, 3.5vw, 15px); line-height: 1.6; }
.tier li .grade {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 2.5px 10px; margin-right: 8px;
  vertical-align: 1px; white-space: nowrap;
}
.tier.no li .grade { color: var(--danger); background: rgba(143,45,22,.08); }
.tier li .cite { display: block; color: var(--faint); font-size: 12px; margin-top: 4px; }

/* ---------- library ---------- */
.article { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: clamp(16px, 3vw, 24px); margin-bottom: 14px; border: 1px solid rgba(26,26,24,.05); }
.article h4 { font-size: clamp(15.5px, 3.8vw, 17.5px); font-weight: 700; font-family: var(--serif); font-weight: 550; }
.article .a-meta { font-size: 11.5px; color: var(--faint); margin-top: 5px; letter-spacing: .04em; }
.article p { font-size: clamp(13.5px, 3.5vw, 15px); color: var(--muted); margin-top: 8px; max-width: 68ch; }
.article details > summary {
  cursor: pointer; font-weight: 700; color: var(--accent); margin-top: 12px;
  min-height: 44px; display: flex; align-items: center; list-style: none; gap: 8px;
}
.article details > summary::-webkit-details-marker { display: none; }
.article details[open] > summary { margin-bottom: 8px; }
.article .a-src { font-size: 12px; color: var(--faint); margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }

/* ---------- tools ---------- */
.tool {
  background: var(--card); border-radius: var(--radius); padding: clamp(18px, 3.5vw, 26px); margin-top: 16px;
  border: 1px solid rgba(26,26,24,.05); box-shadow: var(--shadow-card);
}
.tool h4 { font-size: clamp(15.5px, 3.9vw, 18px); font-weight: 700; font-family: var(--serif); font-weight: 550; line-height: 1.35; }
.tool .t-meta { font-size: 12px; color: var(--faint); margin-top: 4px; }
.tool .t-body { margin-top: 14px; font-size: clamp(13.5px, 3.5vw, 15px); max-width: 66ch; }
.tool ol { margin: 12px 0 0 20px; font-size: clamp(13.5px, 3.5vw, 15px); }
.tool li { margin-bottom: 10px; }
.tool li::marker { color: var(--accent); font-weight: 700; }
.tool h4 + .t-body h4, .tool .t-body h4 { font-size: 15px; margin: 14px 0 6px; }
.tool .t-grade {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft); border-radius: 999px;
  padding: 3px 11px; margin-left: 8px; vertical-align: 2px;
}

/* ---------- tracker ---------- */
.track-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 14px; margin-top: 18px; }
.track-item {
  background: var(--card); border: 1px solid rgba(26,26,24,.05); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-card);
}
.track-item label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; display: block; margin-bottom: 12px; }
.track-item input[type="number"], .track-item select {
  width: 100%; font: inherit; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); min-height: 46px;
}
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; font: inherit; font-size: clamp(11.5px, 3vw, 13.5px); font-weight: 700;
  padding: 11px 4px; min-height: 46px; min-width: 42px;
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px; cursor: pointer;
  transition: all .15s ease; white-space: nowrap;
}
.seg button:hover { border-color: var(--accent); }
.seg button.on {
  background: var(--ink); color: #fff; border-color: var(--ink);
  box-shadow: 0 6px 14px -6px rgba(26,26,24,.4);
}
.log-list { margin-top: 22px; }
.log-row {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
  font-size: clamp(12.5px, 3.3vw, 14px); background: var(--card);
}
.log-row:first-child { border-top: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.log-row:last-child { border-radius: 0 0 12px 12px; border-bottom: none; box-shadow: var(--shadow-card); }
.log-row .lr-date { color: var(--faint); white-space: nowrap; font-weight: 600; }

/* ---------- report ---------- */
.report-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.report-sheet {
  background: var(--card); border-radius: 18px; padding: clamp(22px, 4.5vw, 40px); margin-top: 24px;
  box-shadow: 0 30px 60px -34px rgba(26,26,24,.35);
}
.report-sheet h2 { margin-top: 0; }
.report-sheet .rs-line {
  display: flex; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--line); padding: 10px 0; font-size: clamp(13px, 3.4vw, 14.5px);
}
.report-sheet .rs-line span:last-child { font-weight: 700; text-align: right; }
.report-sheet ul { margin: 8px 0 0 18px; font-size: clamp(13px, 3.4vw, 14px); }
.report-sheet li { margin-bottom: 7px; }
.report-sheet .rs-foot { margin-top: 24px; font-size: 11px; color: var(--faint); border-top: 1px solid var(--line); padding-top: 12px; }

/* ---------- paywall ---------- */
.paywall {
  border: none; outline: 2px solid var(--ink); outline-offset: -2px;
  border-radius: 20px; background: var(--card);
  padding: clamp(24px, 5vw, 38px); margin-top: 28px; text-align: center;
  box-shadow: 0 34px 64px -34px rgba(26,26,24,.4);
}
.paywall h3 { font-family: var(--serif); font-weight: 500; font-size: clamp(20px, 4vw, 26px); margin-top: 0; }
.paywall .price { font-family: var(--serif); font-size: clamp(32px, 8vw, 46px); font-weight: 550; letter-spacing: -0.02em; margin: 12px 0 2px; }
.paywall .price small { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--faint); }
.paywall ul { list-style: none; margin: 20px auto 0; max-width: 430px; text-align: left; }
.paywall li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: clamp(13.5px, 3.5vw, 15px); }
.paywall li:last-child { border-bottom: none; }
.paywall li b::before { content: "— "; color: var(--accent); }

.locked { position: relative; }
.locked::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(rgba(255,255,255,0) 0%, var(--paper) 92%);
  pointer-events: all;
}

/* ---------- footer ---------- */
footer.foot {
  background: var(--dark-bg); color: rgba(255,255,255,.5);
  margin-top: 48px;
  padding: 30px calc(20px + env(safe-area-inset-left)) calc(36px + env(safe-area-inset-bottom));
  text-align: center; font-size: 12px; line-height: 1.7;
}
footer.foot b { color: rgba(255,255,255,.8); font-family: var(--serif); font-weight: 500; font-size: 13px; letter-spacing: -0.01em; }
footer.foot b i { color: var(--accent); font-style: normal; }

.disclaimer-band {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 6px var(--radius) var(--radius) 6px;
  padding: 15px 19px; font-size: 12.5px; color: var(--muted); margin-top: 34px;
}

#install-btn { display: none; }

/* ============================================================
   COMPACT MODE (<380px)
   ============================================================ */
@media (max-width: 380px) {
  body { line-height: 1.5; }
  .topbar { padding: 8px 10px; gap: 6px; }
  .brand span { display: none; }
  .view { padding-left: 12px; padding-right: 12px; }
  .btn-row .btn { width: 100%; }
  .score-hero .big { font-size: 46px; }
  .q-opts { grid-template-columns: 1fr; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .view { padding-top: 14px; padding-bottom: 40px; }
  .progress-wrap { position: static; }
}

@media (pointer: coarse) {
  .q-opts label { min-height: 50px; }
  .seg button { min-height: 48px; }
  .topnav a, .topnav button { min-height: 44px; display: inline-flex; align-items: center; }
  ::-webkit-scrollbar { width: 0; height: 0; }
}

@media (max-width: 259px) {
  :root { font-size: 13px; }
  .topbar { position: static; }
  .topnav { flex-wrap: wrap; }
  .cards, .track-grid { grid-template-columns: 1fr !important; }
}

@media print {
  .topbar, .btn-row, .report-actions, footer.foot, .disclaimer-band, #install-btn { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .view { padding: 0; max-width: none; }
  .q-block, .domain, .tier, .article, .tool, .track-item { box-shadow: none; border: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
@media (prefers-contrast: more) {
  :root { --muted: #333330; --faint: #555550; --line: #b0aea8; --accent: #9c3f0d; }
}
