@font-face { font-family: Nunito; src: url('/assets/fonts/nunito.woff2') format('woff2'); font-weight: 200 1000; font-display: swap; }
@font-face { font-family: Fredoka; src: url('/assets/fonts/fredoka.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }

:root {
  --ink: #1d1f33; --ink-2: #545a78; --paper: #fffaee; --card: #ffffff; --line: #1d1f33; --soft: #f2efe6;
  --violet: #5b4cf5; --violet-ink: #ffffff; --pink: #ff5c8a; --yellow: #ffd23f; --mint: #2ee6a6; --sky: #e2f0ff;
  --bw: 2.5px; --r: 16px; --pop: 4px 4px 0 var(--line); --pop-sm: 2px 2px 0 var(--line); --pop-lg: 6px 6px 0 var(--line);
  --head: 52px; --tabs: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f3f1ff; --ink-2: #b7b5d6; --paper: #14132a; --card: #1f1d3d; --line: #0a0918; --soft: #2a2850;
    --violet: #8b80ff; --violet-ink: #14132a; --sky: #1b2145;
    --pop: 4px 4px 0 #05040f; --pop-sm: 2px 2px 0 #05040f; --pop-lg: 6px 6px 0 #05040f;
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .card, :root:not([data-theme="light"]) .panel, :root:not([data-theme="light"]) .controls { border-color: #3d3a70; }
}
/* Picked in the menu: overrides the system setting. */
:root[data-theme="dark"] {
  --ink: #f3f1ff; --ink-2: #b7b5d6; --paper: #14132a; --card: #1f1d3d; --line: #0a0918; --soft: #2a2850;
  --violet: #8b80ff; --violet-ink: #14132a; --sky: #1b2145;
  --pop: 4px 4px 0 #05040f; --pop-sm: 2px 2px 0 #05040f; --pop-lg: 6px 6px 0 #05040f;
  color-scheme: dark;
}
:root[data-theme="dark"] .card, :root[data-theme="dark"] .panel, :root[data-theme="dark"] .controls { border-color: #3d3a70; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 500 16px/1.6 Nunito, system-ui, -apple-system, Segoe UI, sans-serif; }
a { color: var(--violet); font-weight: 700; text-underline-offset: 3px; text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: Fredoka, Nunito, system-ui, sans-serif; line-height: 1.12; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(30px, 6vw, 46px); margin: 6px 0 12px; }
h2 { font-size: clamp(21px, 3.2vw, 27px); margin: 0 0 10px; }
h3 { font-size: 18px; margin: 20px 0 8px; }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; height: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--yellow); color: #1d1f33; padding: 8px 14px; border: var(--bw) solid var(--line); border-radius: 12px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn, .controls button, .seg button, .chips button, .dl-menu button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 14px;
  border: var(--bw) solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
  font-weight: 800; font-size: 15px; cursor: pointer; box-shadow: var(--pop-sm); transition: transform .08s, box-shadow .08s, background .15s; text-decoration: none; user-select: none;
}
.btn:hover, .controls button:hover, .chips button:hover { background: var(--soft); }
.btn:active, .controls button:active, .seg button:active, .chips button:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.btn.primary { background: var(--violet); color: var(--violet-ink); }
.btn.danger { background: #ffe1e8; color: #b0123f; }
.btn.wide { width: 100%; }
.upload { cursor: pointer; }
.upform { display: grid; gap: 10px; }
.upprev { display: grid; place-items: center; background: var(--soft); border-radius: 12px; padding: 10px; }
.upprev img { max-height: 160px; max-width: 100%; width: auto; object-fit: contain; }
.uprow { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }

/* ---------- header ---------- */
.site-head { position: relative; z-index: 30; height: var(--head); display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--paper); border-bottom: var(--bw) solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font: 700 20px Fredoka, sans-serif; flex: none; }
.logo-t { font-weight: inherit; white-space: nowrap; }
.logo span { color: var(--pink); }
.mark { display: inline-flex; align-items: flex-end; gap: 2px; width: 26px; height: 26px; padding: 4px; border: 2px solid var(--line); border-radius: 8px; background: var(--violet); }
.mark i { flex: 1; border-radius: 2px; background: var(--yellow); height: 45%; }
.mark i:nth-child(2) { background: var(--pink); height: 70%; }
.mark i:nth-child(3) { background: var(--mint); height: 100%; }
.site-head nav { display: flex; align-items: center; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.site-head nav::-webkit-scrollbar { display: none; }
.site-head nav > a, .menu summary { color: var(--ink); text-decoration: none; font-weight: 800; font-size: 14px; padding: 6px 10px; border-radius: 10px; white-space: nowrap; cursor: pointer; border: 2px solid transparent; }
.site-head nav > a:hover, .menu summary:hover { background: var(--soft); }
.site-head nav > a[aria-current] { background: var(--yellow); border-color: var(--line); color: #1d1f33; }
.menu { position: static; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: ' ▾'; font-size: 11px; }
.menu-l, .m-only { display: none; }
@media (max-width: 760px) {
  .site-head nav > a { display: none; }
  .menu-l { display: inline; } .more-l { display: none; }
  .menu-list .m-only { display: block; }
  .menu summary { border-color: var(--line); background: var(--yellow); color: #1d1f33; box-shadow: var(--pop-sm); padding: 6px 12px; }
}
.menu-list { position: absolute; right: 8px; top: calc(var(--head) - 4px); width: min(320px, calc(100vw - 16px)); max-height: 70vh; overflow: auto; background: var(--card); border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 8px; display: flex; flex-direction: column; z-index: 40; }
.menu-list a { padding: 8px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 15px; }
.menu-list a:hover { background: var(--soft); }
.theme-row { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 4px 4px 8px; font-weight: 800; font-size: 14px; color: var(--ink-2); }
.theme-row .seg { display: flex; flex: 1; gap: 4px; background: var(--soft); border-radius: 12px; padding: 3px; }
.theme-row span { padding: 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.theme-row button { flex: 1; min-width: 0; margin: 0; box-shadow: none; transform: none; border: 2px solid transparent; background: none; border-radius: 9px; padding: 5px 6px; font-weight: 800; font-size: 13.5px; color: var(--ink); cursor: pointer; white-space: nowrap; }
.theme-row button[aria-pressed="true"] { background: var(--yellow); color: #1d1f33; border-color: var(--line); box-shadow: var(--pop-sm); }
.menu-list hr { border: 0; border-top: 2px dashed var(--soft); margin: 6px 4px; }

/* ---------- app shell: the canvas is the page ---------- */
body.app { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; overscroll-behavior: none; }
body.app main { flex: 1; position: relative; min-height: 0; }
.tool { position: absolute; inset: 0; overflow: hidden; background: var(--sky); }
.tool canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; outline: none; }
.tool canvas:active { cursor: grabbing; }
.loading, .noscript { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--ink-2); font-weight: 800; }
.tool.is-live .loading { display: none; }
.tool:not(.is-live) .controls, .tool:not(.is-live) .hint, .tool:not(.is-live) .card-toggle, .tool:not(.is-live) .pclose, .tool:not(.is-live) [role=tab], .tool:not(.is-live) [data-tabpanel=add], .tool:not(.is-live) [data-tabpanel=compare] { display: none; }
.tool:not(.is-live) [data-tabpanel] { display: block !important; }

/* title card */
.card { position: absolute; z-index: 5; top: 10px; left: 10px; right: 10px; background: var(--card); border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--pop); padding: 10px 46px 10px 14px; }
.card h1 { font-size: 21px; margin: 0; }
.card .lede { font-size: 15px; line-height: 1.5; margin: 6px 0 0; }
.card .lede strong { background: linear-gradient(transparent 55%, rgba(255,210,63,.75) 0); }
.card .hint { margin: 8px 0 0; font-size: 12.5px; font-weight: 800; color: var(--ink-2); }
.card-min .card-body, .card-min .crumbs { display: none; }
.crumbs { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 2px; }
.crumbs a { color: var(--ink-2); font-weight: 700; }
.card-toggle { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 10px; border: 2px solid var(--line); background: var(--yellow); color: #1d1f33; font-size: 20px; font-weight: 800; line-height: 1; cursor: pointer; box-shadow: var(--pop-sm); }

/* controls */
.controls { position: absolute; z-index: 6; left: 10px; right: 10px; bottom: calc(var(--tabs) + 14px + env(safe-area-inset-bottom)); display: flex; gap: 6px; overflow-x: auto; padding: 2px 4px 6px 2px; scrollbar-width: none; }
.controls::-webkit-scrollbar { display: none; }
.controls button { flex: none; min-height: 40px; padding: 6px 12px; font-size: 14px; }
.controls .ic { width: 42px; padding: 0; font-size: 22px; }
@media (max-width: 560px) { .controls .ic { display: none; } .controls { justify-content: center; } }
.controls .tour { background: var(--pink); color: #fff; }
.dl { position: relative; flex: none; }
.dl-menu { position: fixed; z-index: 20; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--card); border: var(--bw) solid var(--line); border-radius: 14px; box-shadow: var(--pop); left: 50%; bottom: calc(var(--tabs) + 70px); transform: translateX(-50%); }
.dl-menu[hidden] { display: none; }
.toast { position: absolute; z-index: 25; left: 50%; top: 14px; transform: translateX(-50%); background: var(--ink); color: var(--paper); font-weight: 800; padding: 10px 16px; border-radius: 12px; box-shadow: var(--pop-sm); max-width: calc(100% - 24px); text-align: center; }
.toast[hidden] { display: none; }

/* panel / bottom sheet */
.panel { position: absolute; z-index: 10; left: 0; right: 0; bottom: 0; height: min(68%, 620px); background: var(--card); border: var(--bw) solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -4px 0 rgba(0,0,0,.06); display: flex; flex-direction: column; transition: transform .28s cubic-bezier(.2,.8,.2,1); padding-bottom: env(safe-area-inset-bottom); }
.tool:not(.is-ready) .panel { transition: none; }
.panel-closed .panel { transform: translateY(calc(100% - var(--tabs) - env(safe-area-inset-bottom))); }
.phead { flex: none; display: flex; gap: 4px; align-items: center; height: var(--tabs); padding: 6px 8px; border-bottom: 2px solid var(--soft); }
.phead [role=tab] { flex: 1 1 0; min-width: 0; padding: 4px 2px 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px; border: 2px solid transparent; border-radius: 14px; background: none; font-weight: 800; font-size: 13px; cursor: pointer; color: var(--ink-2); line-height: 1.1; }
.phead .ti { position: relative; display: inline-flex; align-items: center; justify-content: center; height: 20px; min-width: 20px; font-size: 18px; line-height: 1; }
.phead .tl { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phead .ti small { position: absolute; left: 70%; top: -8px; min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; font: 800 11px/1 Nunito, sans-serif; background: var(--pink); color: #fff; border: 2px solid var(--line); border-radius: 99px; }
.phead [role=tab][aria-selected="true"] { background: var(--yellow); border-color: var(--line); color: #1d1f33; box-shadow: var(--pop-sm); }
.pclose { flex: none; width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 22px; font-weight: 800; cursor: pointer; line-height: 1; }
.panel-closed .pclose { display: none; }
.pbody { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.psec { padding: 14px; border-bottom: 2px dashed var(--soft); }
.psec:last-child { border-bottom: 0; }
.ptitle { display: block; margin: 0 0 10px; font: 700 17px Fredoka, sans-serif; color: var(--ink); cursor: default; }
details.psec > summary { list-style: none; cursor: pointer; }
.create { background: color-mix(in srgb, var(--mint) 14%, var(--card)); }
.create:not([open]) > summary { margin: 0; }
details.psec > summary::-webkit-details-marker { display: none; }
details.psec > summary::after { content: '▾'; float: right; font-size: 14px; }
details.psec:not([open]) > summary { margin: 0; }
details.psec:not([open]) > summary::after { content: '▸'; }
.muted { color: var(--ink-2); font-size: 13.5px; margin: 8px 0 0; }
.meta { margin: -4px 0 10px; color: var(--ink-2); font-size: 14px; }

input[type=search], input:not([type]), input[type=number], select { width: 100%; min-height: 44px; padding: 8px 12px; border: var(--bw) solid var(--line); border-radius: 12px; background: var(--card); font-weight: 700; font-size: 16px; }
input[type=range] { width: 100%; accent-color: var(--violet); }
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 13px; font-weight: 800; color: var(--ink-2); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 800; min-height: 40px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--violet); }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btnrow .btn { flex: 1 1 auto; }

/* chips & segmented */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; min-height: 36px; padding: 4px 12px; font-size: 14px; border-radius: 99px; }
.chips button.on, .seg button.on { background: var(--violet); color: var(--violet-ink); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.seg button { min-height: 36px; padding: 4px 12px; font-size: 14px; flex: 1 1 auto; border-radius: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: var(--bw) solid var(--line); cursor: pointer; box-shadow: var(--pop-sm); padding: 0; }
.swatches button.on { outline: 3px solid var(--violet); outline-offset: 2px; }
.height .hrow { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 6px; }
.height .unit { display: flex; align-items: center; gap: 4px; }
.height .unit b { font-size: 14px; color: var(--ink-2); }
.height .unit input { min-width: 0; padding: 8px; }

/* lists */
.list, .results { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.list li, .results li { display: flex; align-items: center; gap: 6px; }
.row, .results button { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 12px; background: var(--card); border: 2px solid var(--soft); border-radius: 12px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 15px; text-align: left; cursor: pointer; min-width: 0; }
.row:hover, .results button:hover { border-color: var(--line); }
.list li.is-sel .row { background: var(--yellow); border-color: var(--line); color: #1d1f33; box-shadow: var(--pop-sm); }
.list li.is-sel .sz { color: #3b3f5c; }
.list .empty { color: var(--ink-2); font-weight: 700; padding: 8px 2px; }
.nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sz, .results small { color: var(--ink-2); font-weight: 700; font-size: 13px; white-space: nowrap; }
.results b { width: 30px; height: 30px; display: grid; place-items: center; flex: none; border-radius: 9px; background: var(--mint); border: 2px solid var(--line); color: #1d1f33; font-size: 18px; }
.results button.added b { background: var(--soft); }
.results .none { color: var(--ink-2); font-weight: 700; padding: 6px 2px; }
.sw { width: 14px; height: 14px; border-radius: 5px; flex: none; display: inline-block; border: 2px solid var(--line); }
.x { flex: none; width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--soft); background: var(--card); font-size: 22px; font-weight: 800; color: var(--ink-2); cursor: pointer; }
.x:hover { border-color: var(--line); color: #b0123f; }
.editor { background: color-mix(in srgb, var(--yellow) 18%, var(--card)); }

/* compare */
.pick { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; font-weight: 800; color: var(--ink-2); }
.pick select { font-size: 15px; padding: 8px; }
.out { margin-top: 12px; }
.out p { margin: 0 0 10px; }
.out .big { font: 700 44px/1 Fredoka, sans-serif; color: var(--pink); overflow-wrap: anywhere; }
.out .lead { font-weight: 800; font-size: 17px; }

/* ---------- article content (Facts tab and plain pages) ---------- */
.facts { padding: 18px 16px 6px; }
.prose { font-size: 16px; line-height: 1.6; }
.prose section { margin: 0 0 26px; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 4px 0; }
.facts h2 { font-size: 21px; }
.tablewrap { overflow-x: auto; border: var(--bw) solid var(--line); border-radius: 14px; background: var(--card); box-shadow: var(--pop-sm); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 2px solid var(--soft); white-space: nowrap; }
thead th { white-space: normal; min-width: 90px; background: var(--yellow); color: #1d1f33; font-weight: 800; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 800; }
.chart { margin: 0; }
.chart img { width: 100%; height: auto; border-radius: 14px; border: var(--bw) solid var(--line); box-shadow: var(--pop-sm); display: block; }
.chart figcaption { font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.related { background: var(--soft); border-radius: 16px; padding: 16px 16px 6px; }
.sources { font-size: 14px; color: var(--ink-2); }
.sources h2 { color: var(--ink); font-size: 19px; }
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.cards a { display: flex; flex-direction: column; gap: 2px; background: var(--card); border: var(--bw) solid var(--line); border-radius: 14px; padding: 8px; color: var(--ink); text-decoration: none; box-shadow: var(--pop-sm); font-size: 14.5px; }
.cards a:hover { transform: translate(-1px, -1px); box-shadow: var(--pop); }
.cards img { display: block; width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 8px; border: 2px solid var(--soft); margin-bottom: 4px; }
.cards span { color: var(--ink-2); font-size: 13px; font-weight: 700; }
.chiplinks { list-style: none; padding: 0 !important; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chiplinks li { margin: 0; }
.chiplinks a { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; background: var(--card); border: 2px solid var(--line); border-radius: 99px; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 800; }
.chiplinks a:hover { background: var(--yellow); color: #1d1f33; }
.site-foot { border-top: 2px dashed var(--soft); padding: 14px 0 6px; font-size: 13.5px; color: var(--ink-2); }
.site-foot p { margin: 0 0 6px; }
body:not(.app) .site-foot { max-width: 760px; margin: 40px auto 0; padding: 18px 16px 30px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 24px; }
.page .lede { font-size: 19px; }

/* ---------- desktop: floating panel on the right ---------- */
@media (min-width: 861px) {
  :root { --tabs: 0px; }
  .site-head { padding: 0 18px; }
  .card { right: auto; max-width: 440px; top: 16px; left: 16px; padding: 14px 50px 14px 18px; }
  .card h1 { font-size: 27px; }
  .controls { left: 50%; right: auto; transform: translateX(-50%); bottom: 18px; padding: 6px; background: var(--card); border: var(--bw) solid var(--line); border-radius: 18px; box-shadow: var(--pop); overflow: visible; }
  .tool:not(.panel-closed) .controls { left: calc((100% - 400px) / 2); }
  .dl-menu { position: absolute; left: 0; bottom: calc(100% + 12px); transform: none; }
  .panel { top: 16px; right: 16px; bottom: 16px; left: auto; height: auto; width: 380px; border: var(--bw) solid var(--line); border-radius: 22px; box-shadow: var(--pop-lg); }
  .panel-closed .panel { transform: translateX(calc(100% + 24px)); }
  .phead { height: auto; padding: 9px; }
  .phead [role=tab] { min-height: 52px; font-size: 13.5px; }
  .panel-closed::after { content: none; }
  .tool.panel-closed [data-sheet-tabs] { display: flex; }
}
/* desktop: a floating "open" control when the panel is closed */
@media (min-width: 861px) {
  .tool.panel-closed .panel { transform: none; top: 16px; bottom: auto; height: auto; width: auto; }
  .tool.panel-closed .pbody { display: none !important; }
  .tool.panel-closed .phead { border-bottom: 0; }
  .tool.panel-closed .phead [role=tab] { flex: none; }
  .tool.panel-closed .phead [role=tab][aria-selected="true"] { background: none; border-color: transparent; box-shadow: none; color: var(--ink-2); }
}
@media (max-width: 380px) {
  .phead [role=tab] { font-size: 12px; }
  .site-head nav > a { padding: 6px 7px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
