/* Components. Spacing on a 4px grid: cards 20, lists 16, sections 32 apart, titles 24 above / 12 below. */
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon.lg { width: 24px; height: 24px; }
.icon.sm { width: 16px; height: 16px; }

/* page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 20px; }
.page-head h1 { font-size: 32px; line-height: 36px; letter-spacing: -.01em; }
.page-head .sub { color: var(--text-3); font-size: 13px; line-height: 18px; margin-bottom: 2px; }
.page-head .side { text-align: right; color: var(--text-2); font-size: 13px; line-height: 18px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 32px 0 12px; }
.section-title h2 { font-size: 20px; line-height: 24px; }
.section-title .mono, .section-title a, .section-title .link { color: var(--text-3); font-size: 13px; }
.section-title .link { background: none; border: 0; padding: 0; color: var(--accent-ink); font-weight: 500; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; box-shadow: var(--shadow-s); }
.card + .card { margin-top: 12px; }
.card.flat { box-shadow: none; background: var(--raised); border-color: transparent; }
.card.tight { padding: 16px; }
.card h3 { font-size: 17px; line-height: 22px; }
.stack > * + * { margin-top: 16px; }
.stack-s > * + * { margin-top: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* list rows: one height, one gap */
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; width: 100%; text-align: left; background: none; border: 0; color: inherit; transition: background-color var(--t-fast) var(--ease); }
.li + .li { border-top: 1px solid var(--line); }
button.li:active, a.li:active { background: var(--raised); }
.li .t { font-size: 15px; line-height: 20px; font-weight: 500; }
.li .s { font-size: 13px; line-height: 18px; color: var(--text-3); margin-top: 1px; }
.li .end { margin-left: auto; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.li .lead { width: 36px; height: 36px; border-radius: 12px; background: var(--raised); display: grid; place-items: center; color: var(--text-2); flex: none; }
.li .lead.c { background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.li.done .t { color: var(--text-3); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--raised); color: var(--text); font-weight: 600; font-size: 15px; white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary-bg); color: var(--primary-fg); border-color: transparent; }
.btn.accent { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.danger { color: var(--neg); }
.btn.block { width: 100%; }
.btn.big { height: 56px; font-size: 17px; border-radius: 18px; font-family: var(--round); }
.btn.sm { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: transparent; color: var(--text-2); display: inline-grid; place-items: center; flex: none; transition: background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.icon-btn:active { background: var(--raised); transform: scale(.94); }
.icon-btn.filled { background: var(--raised); }

/* segmented, chips, tags */
.seg { display: flex; background: var(--raised); border-radius: 14px; padding: 4px; gap: 2px; }
.seg button { flex: 1; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-size: 14px; font-weight: 600; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 0 1px var(--line); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line-strong); background: transparent; color: var(--text-2); font-size: 14px; font-weight: 500; white-space: nowrap; flex: none; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.chip.on { background: var(--text); color: var(--bg); border-color: transparent; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: 12px; background: var(--raised); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag.c { background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.xp-chip { margin-left: auto; font: 600 13px/16px var(--round); color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 15%, transparent); padding: 4px 10px; border-radius: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--c, var(--text-3)); display: inline-block; flex: none; }

/* bars */
.bar { height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; position: relative; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--c, var(--text)); transition: width 700ms var(--ease); }
.bar.accent > i { background: var(--accent); }
.bar.thin { height: 4px; }
.bar.thick { height: 12px; border-radius: 6px; }
.bar .mark { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text-3); }
.metric { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; align-items: baseline; }
.metric .label { font-size: 13px; color: var(--text-2); }
.metric .val { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.metric .bar { grid-column: 1 / -1; }

/* rings */
.rings { display: block; transform: rotate(-90deg); overflow: visible; }
.rings circle { fill: none; stroke-linecap: round; }
.rings .bg { opacity: .16; }
.rings .fg { transition: stroke-dashoffset var(--t-ring) var(--ease); }
.rings .done-cap { opacity: 0; }

/* the trail of 12 camps (signature on Base) */
.route { display: flex; align-items: center; height: 20px; }
.route .stop { width: 8px; height: 8px; border-radius: 4px; background: var(--raised-2); flex: none; }
.route .stop.done { background: var(--text-2); }
.route .stop.now { width: 14px; height: 14px; border-radius: 7px; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.route .seg-line { flex: 1; height: 0; border-top: 2px dashed var(--line-strong); }
.route .seg-line.done { border-top-style: solid; border-color: var(--text-3); }

/* inputs */
.field { display: block; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.input, select.input, textarea.input { width: 100%; height: 48px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--raised); padding: 0 14px; font-size: 16px; }
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; line-height: 22px; resize: vertical; }
.input:focus { outline: none; border-color: var(--text-2); }
.stepper { display: inline-flex; align-items: center; border-radius: 14px; overflow: hidden; height: 48px; background: var(--raised); }
.stepper button { width: 44px; height: 100%; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; }
.stepper button:active { background: var(--raised-2); }
.stepper input { width: 60px; border: 0; text-align: center; font: 600 18px var(--round); font-variant-numeric: tabular-nums; background: transparent; height: 100%; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.check { width: 30px; height: 30px; border-radius: 10px; border: 2px solid var(--c, var(--line-strong)); display: grid; place-items: center; flex: none; background: transparent; color: transparent;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.check .icon { stroke-width: 3; }
.check.on { background: var(--c, var(--text)); border-color: var(--c, var(--text)); color: var(--bg); }
.check.round { border-radius: 15px; }
.check.on.pop { animation: pop 360ms var(--ease); }
.scale5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale5 button { height: 52px; border-radius: 14px; border: 0; background: var(--raised); font: 600 18px var(--round); font-variant-numeric: tabular-nums; transition: background-color var(--t-fast) var(--ease); }
.scale5 button.on { background: var(--text); color: var(--bg); }

/* tabbar */
.tabbar[hidden] { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: saturate(1.5) blur(20px); backdrop-filter: saturate(1.5) blur(20px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar .in { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; max-width: 560px; height: var(--tabbar-h); }
.tabbar button { border: 0; background: none; color: var(--text-3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; line-height: 14px; font-weight: 500; transition: color var(--t-fast) var(--ease); }
.tabbar button .icon { width: 24px; height: 24px; transition: transform var(--t-fast) var(--ease); }
.tabbar button:active .icon { transform: scale(.9); }
.tabbar button.on { color: var(--text); }
.tabbar button.on .icon { stroke-width: 2; }
.tabbar .kdock { position: absolute; bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px); left: 50%; transform: translateX(-50%); }

/* sheet */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; opacity: 0; transition: opacity var(--t-menu) var(--ease); }
.scrim.in { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow: auto; background: var(--card);
  border-radius: var(--r-panel) var(--r-panel) 0 0; padding: 8px 20px calc(24px + var(--safe-b)); transform: translateY(24px); opacity: 0;
  transition: transform var(--t-enter) var(--ease), opacity var(--t-menu) var(--ease); max-width: 560px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; }
.sheet.in { transform: none; opacity: 1; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 4px auto 16px; }
.sheet h2 { font-size: 22px; line-height: 28px; margin-bottom: 4px; }
.sheet .sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.sheet.full { top: 0; max-height: none; border-radius: 0; border: 0; padding: calc(var(--safe-t) + 12px) 16px 0; background: var(--bg); }

/* toast and XP burst */
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; max-width: 520px; width: 100%; background: var(--primary-bg); color: var(--primary-fg); border-radius: 16px; padding: 14px 16px; font-size: 14px; line-height: 20px; font-weight: 500;
  box-shadow: var(--shadow-f); display: flex; align-items: center; gap: 12px; opacity: 0; transform: translateY(10px); transition: opacity var(--t-menu) var(--ease), transform var(--t-menu) var(--ease); }
.toast.in { opacity: 1; transform: none; }
.toast .xp { font: 600 13px var(--round); opacity: .7; margin-left: auto; white-space: nowrap; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; padding: 0 4px; }
.xp-burst { position: fixed; top: calc(var(--safe-t) + 12px); left: 50%; z-index: 65; transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 20px; background: var(--card); border: 1px solid var(--line-strong); box-shadow: var(--shadow-f);
  font: 700 17px var(--round); color: var(--c, var(--accent)); animation: burst 1600ms var(--ease) forwards; }
.xp-burst .dot { width: 10px; height: 10px; border-radius: 5px; }
@keyframes burst { 0% { opacity: 0; transform: translate(-50%, -8px) scale(.9); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -12px); } }

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 80; }

/* level up */
.levelup { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; background: var(--scrim); opacity: 0; transition: opacity 300ms var(--ease); padding: 24px; }
.levelup.in { opacity: 1; }
.levelup .lu-card { width: 100%; max-width: 360px; background: var(--card); border-radius: var(--r-panel); border: 1px solid var(--line); padding: 24px; text-align: center; transform: translateY(24px) scale(.96); transition: transform 500ms var(--ease); }
.levelup.in .lu-card { transform: none; }
.lu-avatar { height: 220px; border-radius: 20px; background: var(--paper); overflow: hidden; margin-bottom: 20px; position: relative; }
.lu-kicker { color: var(--accent-ink); font-weight: 600; font-size: 14px; }
.lu-level { font: 700 72px/76px var(--round); letter-spacing: -.02em; }
.lu-rank { color: var(--text-2); margin-bottom: 20px; }

/* illustration plate */
.plate { background: var(--paper); border-radius: var(--r-m); overflow: hidden; position: relative; display: grid; place-items: center; color: #8C877D; }
.plate img { width: 100%; height: 100%; object-fit: cover; }
.plate .icon { width: 28px; height: 28px; opacity: .55; }

/* banner */
.banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); font-size: 14px; line-height: 20px; margin-bottom: 12px; width: 100%; text-align: left; }
.banner.accent { background: var(--accent-soft); border-color: transparent; }
.banner > .icon { color: var(--text-2); }

/* markdown */
.md { font-size: 15px; line-height: 24px; }
.md h3, .md h4, .md h5 { font: 600 17px/24px var(--round); margin: 24px 0 8px; }
.md ul, .md ol { padding-left: 20px; margin: 0 0 12px; }
.md li + li { margin-top: 6px; }
.md code { font-family: var(--mono); font-size: 12px; background: var(--raised); padding: 1px 5px; border-radius: 6px; }
.md blockquote { margin: 12px 0; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--raised); border-radius: 0 12px 12px 0; color: var(--text-2); }
.md .tbl { overflow-x: auto; margin: 0 -20px 12px; padding: 0 20px; }
.md table { border-collapse: collapse; font-size: 13px; line-height: 18px; min-width: 100%; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.md th { color: var(--text-2); font-weight: 600; }

.empty { text-align: center; color: var(--text-3); padding: 32px 16px; font-size: 14px; }
