/* Jar of Life: a quiet, Notion-like page. The jar is the one loud thing. */
:root {
  --paper: #ffffff;
  --ink: #37352f;
  --ink-2: #787774;
  --ink-3: #9b9a97;
  --line: #e9e9e7;
  --hover: #f1f1ef;
  --blue: #2383e2;
  --blue-hover: #0077d4;
  --red: #d44c47;
  --red-bg: #fdebec;
  --c-rock: #8e8b85;
  --c-pebble: #b89b7e;
  --c-sand: #e6d5ae;
  --c-beer: #e5a84b;
  --float: 0 0 0 1px rgba(15, 15, 15, .05), 0 3px 6px rgba(15, 15, 15, .1), 0 9px 24px rgba(15, 15, 15, .2);
  --font: "Geist", ui-sans-serif, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- page head ---------- */
.page-head { max-width: 1120px; margin: 0 auto; padding: 56px 48px 8px; }
.page-icon { width: 64px; height: 64px; margin-bottom: 14px; }
.page-head h1 { font-size: 40px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; }
.page-sub { margin: 6px 0 0; color: var(--ink-2); font-size: 16px; }

/* ---------- layout ---------- */
.layout {
  max-width: 1120px; margin: 0 auto; padding: 28px 48px 24px;
  display: grid; grid-template-columns: minmax(0, 500px) minmax(0, 1fr); gap: 56px; align-items: start;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .jar-col { max-width: 500px; width: 100%; margin: 0 auto; }
}
@media (max-width: 640px) {
  .page-head { padding: 32px 16px 4px; }
  .page-head h1 { font-size: 32px; }
  .page-icon { width: 48px; height: 48px; }
  .layout { padding: 20px 16px 20px; }
}

.jar-stage { position: relative; width: 100%; aspect-ratio: 560 / 480; }
#jar { width: 100%; height: 100%; display: block; touch-action: none; }
.tooltip {
  position: absolute; pointer-events: none; transform: translate(-50%, -135%);
  background: #2f2f2f; color: #fff; font-size: 12.5px; padding: 4px 8px; border-radius: 4px;
  white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.tooltip span { color: rgba(255,255,255,.6); margin-left: 6px; }
.size-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; max-width: 420px; font-size: 14px; color: var(--ink-2); }
.size-end { font-size: 12.5px; color: var(--ink-3); }
.size-row output { font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; color: var(--ink); }
.size-row input[type=range] { flex: 1; min-width: 80px; accent-color: var(--ink); height: 20px; cursor: pointer; }
@media (max-width: 420px) { .size-end { display: none; } }
.jar-actions { display: flex; flex-wrap: wrap; gap: 2px; margin: 8px 0 0 -8px; }

/* legend: a simple table, not cards */
.legend { list-style: none; padding: 0; margin: 88px 0 0; /* about one row of space */ border-top: 1px solid var(--line); }
.legend li {
  display: grid; grid-template-columns: 26px 92px 28px 1fr; align-items: start; gap: 10px;
  padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.legend .sw { align-self: start; margin-top: 2px; }
.legend b { font-weight: 500; }
.legend .count { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.legend p { margin: 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.45; }
@media (max-width: 480px) {
  .legend li { grid-template-columns: 26px 1fr auto; }
  .legend p { grid-column: 2 / -1; }
}

.sw { width: 18px; height: 16px; border-radius: 50%; display: inline-block; flex: none; }
.sw.rock { border-radius: 46% 54% 50% 50% / 55% 45% 55% 45%; width: 20px; height: 17px; }
.sw.pebble { width: 13px; height: 11px; border-radius: 50% 45% 55% 50%; }
.sw.sand { width: 13px; height: 13px; background-image: radial-gradient(rgba(0,0,0,.25) 1px, transparent 1.3px); background-size: 4px 4px; }
.sw.beer { border-radius: 2px 2px 5px 5px; width: 12px; height: 16px; }

/* ---------- panel ---------- */
.panel { min-width: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tab {
  background: none; border: 0; padding: 6px 8px 9px; cursor: pointer; color: var(--ink-2);
  font-size: 14px; font-weight: 500; white-space: nowrap; position: relative; border-radius: 4px 4px 0 0;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--ink); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 8px; }
.section-head h2 { font-size: 16px; }
.lead { margin: 0 0 16px; color: var(--ink-2); max-width: 60ch; }

.btn {
  border: 0; background: none; padding: 5px 9px; border-radius: 4px; cursor: pointer;
  font-size: 14px; color: var(--ink-2); line-height: 1.4;
}
.btn:hover { background: var(--hover); color: var(--ink); }
.btn:active { background: #e8e7e4; }
.btn-primary { background: var(--blue); color: #fff; font-weight: 500; padding: 6px 12px; }
.btn-primary:hover { background: var(--blue-hover); color: #fff; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-quiet { color: var(--ink-3); }
.panel .btn:not(.btn-primary), .row-btns .btn:not(.btn-primary) { box-shadow: inset 0 0 0 1px var(--line); }
.jar-actions .btn { box-shadow: none; }
.link { background: none; border: 0; color: var(--ink-2); cursor: pointer; padding: 2px 6px; border-radius: 4px; font-size: 14px; }
.link:hover { background: var(--hover); color: var(--ink); }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }

.text-in {
  width: 100%; font: inherit; padding: 7px 10px; border-radius: 6px; border: 0;
  box-shadow: inset 0 0 0 1px var(--line); background: #fff; color: var(--ink); outline: none;
}
.text-in::placeholder { color: var(--ink-3); }
.text-in:focus { box-shadow: inset 0 0 0 1px var(--blue), 0 0 0 3px rgba(35, 131, 226, .18); }
.add-form { display: grid; gap: 10px; }
.add-form .btn-primary { justify-self: start; }

.type-picker { display: flex; flex-wrap: wrap; gap: 4px; }
.type-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px 4px 7px; border-radius: 4px;
  border: 0; background: none; cursor: pointer; font-size: 14px; color: var(--ink-2);
}
.type-btn:hover { background: var(--hover); color: var(--ink); }
.type-btn[aria-checked="true"] { background: var(--hover); color: var(--ink); box-shadow: inset 0 0 0 1px #d9d8d4; }
.type-btn .q { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; background: #e3e2e0; font-size: 11px; font-weight: 600; color: var(--ink-2); }

/* groups + tags */
.group { margin-bottom: 14px; }
.group-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; }
.group-title .count { color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; max-width: 100%;
  border-radius: 4px; padding: 2px 8px; font-size: 14px; cursor: pointer; color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line);
}
.chip:hover { background: var(--hover); color: var(--ink); }
.chip .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .plus { color: var(--ink-3); }
.chip.tag { background: var(--tag-bg); color: var(--tag-ink); box-shadow: none; }
.chip.tag:hover { filter: brightness(.96); }
.chip-edit { display: inline-flex; align-items: center; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--blue); padding: 0 2px 0 8px; }
.chip-edit input { border: 0; outline: 0; font: inherit; font-size: 14px; width: 13ch; background: transparent; color: var(--ink); padding: 2px 0; }
.chip-edit button { border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 0 6px; border-radius: 3px; font-size: 16px; line-height: 1.4; }
.chip-edit button:hover { color: var(--red); background: var(--red-bg); }
.chip-add { color: var(--ink-3); box-shadow: none; }
.empty-note { color: var(--ink-3); font-size: 14px; margin: 0; }

.sort-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.sort-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sort-row .btn { font-size: 13px; padding: 3px 9px; }

.wording-toggle, .seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 6px; background: var(--hover); flex-wrap: wrap; margin-bottom: 16px; }
.wording-toggle button, .seg button { border: 0; background: none; padding: 4px 11px; border-radius: 4px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.wording-toggle button[aria-pressed="true"], .seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 0 0 1px rgba(15,15,15,.06), 0 1px 2px rgba(15,15,15,.08); }

/* customize */
.drink-own { display: block; max-width: 280px; margin-top: 4px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.preset { display: inline-flex; align-items: center; gap: 8px; }
.preset .dots { display: inline-flex; }
.preset .dots i { width: 11px; height: 11px; border-radius: 50%; margin-left: -3px; border: 1.5px solid #fff; display: block; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.color-item { display: flex; align-items: center; gap: 10px; border-radius: 4px; padding: 5px 6px; cursor: pointer; font-size: 14px; }
.color-item:hover { background: var(--hover); }
.color-item input[type=color] { width: 22px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer; }
.color-item input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.color-item input[type=color]::-webkit-color-swatch { border-radius: 4px; border: 1px solid rgba(0,0,0,.08); }

/* brain dump */
.steps { display: flex; gap: 4px; margin-bottom: 18px; }
.steps i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--ink); }
.dump-h { font-size: 20px; margin-bottom: 2px; }
.dump-area {
  width: 100%; min-height: 200px; resize: vertical; font: inherit; padding: 10px 12px; border-radius: 6px; border: 0;
  box-shadow: inset 0 0 0 1px var(--line); background: #fff; line-height: 1.75; outline: none; color: var(--ink);
}
.dump-area:focus { box-shadow: inset 0 0 0 1px var(--blue), 0 0 0 3px rgba(35, 131, 226, .18); }
.dump-list { list-style: none; padding: 0; margin: 14px 0; border-top: 1px solid var(--line); }
.dump-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none; font-size: 14.5px;
}
.dump-item:hover { background: var(--hover); }
.dump-item .name { flex: 1; min-width: 0; }
.dump-item .sw:empty:not(.rock):not(.pebble):not(.sand):not(.beer) { width: 14px; height: 14px; box-shadow: inset 0 0 0 1.5px #d3d1cb; border-radius: 50%; }
.dump-item.circled .name { font-weight: 600; }
.dump-item.crossed .name { text-decoration: line-through; color: var(--ink-3); }
.dump-item.fixed { color: var(--ink-3); cursor: default; }
.dump-item.fixed:hover { background: none; }
.dump-item .mini-seg { display: inline-flex; gap: 2px; }
.dump-item .mini-seg button { border: 0; background: none; padding: 3px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.dump-item .mini-seg button:hover { background: var(--hover); }
.dump-item .mini-seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px #d9d8d4; }
.dump-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); cursor: pointer; }

/* popover menu */
.popover {
  position: fixed; z-index: 30; width: 264px; background: #fff; border-radius: 8px;
  box-shadow: var(--float); padding: 8px; display: grid; gap: 8px;
}
.popover[hidden] { display: none; }
.ed-actions { display: flex; justify-content: space-between; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }

/* wizard modal */
.wizard {
  border: 0; border-radius: 10px; padding: 0; width: min(500px, calc(100vw - 32px));
  background: #fff; color: var(--ink); box-shadow: var(--float);
}
.wizard::backdrop { background: rgba(15, 15, 15, .4); }
#wiz-body { padding: 20px 24px 18px; }
.wiz-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.wiz-kicker { font-size: 13.5px; color: var(--ink-2); }
.wiz-close { border: 0; background: none; cursor: pointer; font-size: 20px; color: var(--ink-3); line-height: 1; padding: 2px 7px; border-radius: 4px; }
.wiz-close:hover { background: var(--hover); color: var(--ink); }
.wiz-q { font-size: 21px; line-height: 1.35; margin: 8px 0 18px; font-weight: 600; letter-spacing: -.015em; }
.wiz-ans { display: grid; gap: 6px; }
.ans {
  text-align: left; border: 0; background: none; border-radius: 6px; padding: 10px 12px;
  cursor: pointer; display: grid; gap: 2px; box-shadow: inset 0 0 0 1px var(--line);
}
.ans:hover { background: var(--hover); }
.ans b { font-weight: 500; }
.ans span { font-size: 13px; color: var(--ink-2); }
.wiz-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; min-height: 26px; }
.result { text-align: left; }
.result canvas { display: block; margin: 4px 0 8px -8px; }
.result h3 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
.result p { color: var(--ink-2); margin: 0 0 16px; }
.result .muted.small { margin: 18px 0 6px; }

/* lesson */
.page-sub a { color: inherit; text-decoration: underline; text-decoration-color: #c7c6c3; text-underline-offset: 3px; }
.page-sub a:hover { text-decoration-color: var(--ink); }
.lesson { max-width: 1120px; margin: 0 auto; padding: 40px 48px 8px; }
.lesson > * { max-width: 760px; }
.lesson h2 { font-size: 28px; letter-spacing: -.02em; padding-top: 32px; border-top: 1px solid var(--line); max-width: none; }
.lesson h3 { font-size: 18px; margin: 40px 0 10px; }
.lesson-lead { font-size: 17px; margin: 8px 0 24px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.compare figure { margin: 0; }
.mini { width: 100%; max-width: 200px; display: block; margin-bottom: 8px; }
.mini .glass { fill: rgba(236,240,241,.35); stroke: #9aa4a6; stroke-width: 1.5; }
.mini .rim { fill: none; stroke: #9aa4a6; stroke-width: 1.5; }
.mini .f-rock { fill: var(--c-rock); }
.mini .f-pebble { fill: var(--c-pebble); }
.mini .f-sand { fill: var(--c-sand); }
.mini .f-beer { fill: var(--c-beer); }
.compare figcaption { font-size: 14.5px; color: var(--ink-2); }
.compare figcaption b { color: var(--ink); font-weight: 600; }
.btn-outline { box-shadow: inset 0 0 0 1px var(--line); margin-top: 16px; }
.legend .sw.jar { width: 14px; height: 17px; border-radius: 2px 2px 5px 5px; background: #eef1f1; box-shadow: inset 0 0 0 1.5px #9aa4a6; }
.rules { margin: 0; border-top: 1px solid var(--line); }
.rules div { display: grid; grid-template-columns: 160px 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rules dt { font-weight: 500; font-size: 14.5px; }
.rules dd { margin: 0; color: var(--ink-2); font-size: 14.5px; }
@media (max-width: 640px) {
  .lesson { padding: 24px 16px 8px; }
  .compare { gap: 16px; }
  .rules div { grid-template-columns: 1fr; gap: 2px; }
}

/* toast + footer */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40;
  background: #2f2f2f; color: #fff; padding: 8px 8px 8px 14px; border-radius: 6px;
  display: flex; gap: 12px; align-items: center; box-shadow: var(--float); font-size: 14px;
  max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }
.toast button { background: rgba(255,255,255,.1); border: 0; color: #fff; font-weight: 500; cursor: pointer; padding: 3px 9px; border-radius: 4px; }
.toast button:hover { background: rgba(255,255,255,.2); }
.foot { max-width: 1120px; margin: 0 auto; padding: 48px 48px 72px; }
.quote-row { display: flex; align-items: flex-start; gap: 16px; max-width: 760px; }
.quote { flex: 1; border-left: 3px solid var(--ink); padding: 2px 0 2px 14px; margin: 0; font-size: 16px; min-height: 3.2em; transition: opacity .4s; }
.quote-zh { display: block; font-family: "Ma Shan Zheng", "Kaiti SC", "STKaiti", serif; font-size: 26px; line-height: 1.2; margin-bottom: 4px; }
.quote-nav { display: flex; gap: 2px; flex: none; }
.icon-btn { width: 28px; height: 28px; display: grid; place-items: center; border: 0; background: none; border-radius: 4px; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.quote small { display: block; font-size: 13.5px; color: var(--ink-2); margin-top: 2px; }
@media (max-width: 640px) { .foot { padding: 32px 16px 48px; } }
