:root {
  color-scheme: light;
  --paper: #fbfaf6;
  --surface: #fff;
  --ink: #182527;
  --muted: #607073;
  --line: #dce3de;
  --teal: #087f73;
  --red: #aa3c4c;
  --red-bg: #fbeaec;
  --green: #08745b;
  --green-bg: #e4f4ee;
  --blue: #2463a9;
  --blue-bg: #eaf2fb;
  --amber: #956000;
  --amber-bg: #fff3d8;
  --violet: #7353a6;
  --violet-bg: #f0ebf8;
  --gray-bg: #eff2f0;
  --shadow: 0 1px 2px rgb(22 38 38 / 5%), 0 12px 30px rgb(31 53 52 / 6%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.55; }
button, input, select, textarea { font: inherit; }
a { color: var(--teal); text-underline-offset: .2em; }

.skip-link { position: fixed; top: .7rem; left: .7rem; z-index: 30; padding: .5rem .75rem; background: var(--ink); color: white; transform: translateY(-180%); }
.skip-link:focus { transform: none; }
.site-bar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; gap: 1rem; padding: .75rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--line); background: rgb(251 250 246 / 92%); backdrop-filter: blur(14px); }
.site-bar strong { font-size: .78rem; }
.site-bar nav { display: flex; gap: 1rem; font-size: .75rem; }

main { width: min(100% - 2rem, 82rem); margin: 0 auto; padding: clamp(3rem, 7vw, 6rem) 0 5rem; }
.hero { max-width: 70rem; }
.kicker, .eyebrow { margin: 0 0 .7rem; color: var(--teal); font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2 { margin: 0; line-height: 1.02; letter-spacing: -.045em; text-wrap: balance; }
h1 { font-size: clamp(3.5rem, 9vw, 7rem); }
h2 { font-size: clamp(2rem, 4vw, 3.5rem); }
.dek { max-width: 70ch; margin: 1rem 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.25rem); }
.summary { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.4rem; }
.summary span { padding: .4rem .65rem; border: 1px solid var(--line); border-radius: 999px; background: white; font-size: .75rem; font-weight: 700; }

.toolbar { display: grid; grid-template-columns: minmax(16rem, 1fr) 2fr; gap: 1rem; align-items: end; margin-top: 2.5rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: white; box-shadow: var(--shadow); }
label span { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .7rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
input, select, textarea { width: 100%; padding: .7rem .75rem; border: 1px solid #cdd7d1; border-radius: .55rem; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgb(8 127 115 / 18%); border-color: var(--teal); }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; }
.filters button, .share-actions button, form > button, .verify-box button { padding: .58rem .78rem; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--ink); cursor: pointer; font-size: .78rem; font-weight: 700; }
.filters button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: white; }

.legend { display: flex; flex-wrap: wrap; gap: .45rem; margin: 1rem 0 1.4rem; }
.legend span, .state-pill { padding: .28rem .55rem; border-radius: 999px; font-size: .68rem; font-weight: 800; }
.state-worse { background: var(--red-bg); color: var(--red); }
.state-okay { background: var(--green-bg); color: var(--green); }
.state-helped { background: var(--blue-bg); color: var(--blue); }
.state-uncertain { background: var(--amber-bg); color: var(--amber); }
.state-no-help { background: var(--violet-bg); color: var(--violet); }
.state-preference { background: var(--gray-bg); color: var(--muted); }

.cluster-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.cluster { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: white; box-shadow: var(--shadow); }
.cluster-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; padding-bottom: .85rem; border-bottom: 1px solid var(--line); }
.cluster-head span { color: var(--teal); font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.cluster-head h2 { margin-top: .18rem; font-size: clamp(1.45rem, 3vw, 2.2rem); }
.cluster-head p { max-width: 28rem; margin: .4rem 0 0; color: var(--muted); font-size: .8rem; }
.cluster-count { flex: 0 0 auto; padding: .3rem .5rem; border-radius: 999px; background: var(--gray-bg); color: var(--muted); font-size: .68rem; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; margin-top: .8rem; }
.exposure-card { position: relative; min-height: 7.3rem; padding: .75rem; border: 1px solid var(--line); border-left-width: 4px; border-radius: .7rem; background: #fff; cursor: pointer; text-align: left; }
.exposure-card:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgb(31 53 52 / 8%); }
.exposure-card[data-state="worse"] { border-left-color: var(--red); }
.exposure-card[data-state="okay"] { border-left-color: var(--green); }
.exposure-card[data-state="helped"] { border-left-color: var(--blue); }
.exposure-card[data-state="uncertain"] { border-left-color: var(--amber); }
.exposure-card[data-state="no-help"] { border-left-color: var(--violet); }
.exposure-card[data-state="preference"] { border-left-color: #9aa5a3; }
.card-top { display: flex; justify-content: space-between; gap: .4rem; align-items: start; }
.exposure-card strong { display: block; line-height: 1.25; }
.compound { display: inline-block; margin-top: .55rem; padding: .2rem .42rem; border-radius: .35rem; background: var(--gray-bg); color: var(--muted); font-size: .67rem; font-weight: 750; }
.exposure-card p { margin: .45rem 0 0; color: var(--muted); font-size: .74rem; line-height: 1.4; }
.review-badge { position: absolute; right: .55rem; bottom: .5rem; font-size: .64rem; font-weight: 800; }
.review-correct { color: var(--green); }
.review-wrong { color: var(--red); }
.review-unsure { color: var(--amber); }
.empty { grid-column: 1 / -1; color: var(--muted); font-size: .82rem; }

.add-memory, .share-panel { display: grid; grid-template-columns: 1fr 1.7fr; gap: 2rem; margin-top: clamp(5rem, 10vw, 8rem); padding: clamp(1.2rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: 1rem; background: white; }
.add-memory > div > p:last-child, .share-panel > div > p:last-child { color: var(--muted); }
#memory-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
#memory-form .wide { grid-column: 1 / -1; }
#memory-form > button { justify-self: start; border-color: var(--teal); background: var(--teal); color: white; }
.memory-list { grid-column: 1 / -1; }
.memory-item { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-top: 1px solid var(--line); font-size: .82rem; }
.memory-item button { border: 0; background: none; color: var(--red); cursor: pointer; }
.share-panel { align-items: end; margin-top: 1rem; }
.share-actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.share-actions button { border-color: var(--teal); background: var(--teal); color: white; }
.share-actions .quiet { border-color: var(--line); background: white; color: var(--muted); }
#copy-status { color: var(--muted); font-size: .75rem; }

dialog { width: min(100% - 1.2rem, 40rem); max-height: calc(100vh - 2rem); overflow: auto; padding: 0; border: 1px solid var(--line); border-radius: 1rem; background: white; color: var(--ink); box-shadow: 0 30px 80px rgb(14 30 29 / 24%); }
dialog::backdrop { background: rgb(16 30 30 / 42%); backdrop-filter: blur(3px); }
.dialog-bar { position: sticky; top: 0; z-index: 1; display: flex; justify-content: end; padding: .65rem; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 94%); }
.dialog-bar button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
#detail-content { padding: 1.2rem; }
#detail-content h2 { margin: .5rem 0 0; font-size: clamp(2rem, 6vw, 3.2rem); }
#detail-content h3 { margin: 1.3rem 0 .35rem; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
#detail-content p { margin: .35rem 0 0; color: var(--muted); }
#detail-content a { display: inline-block; margin-top: 1rem; }
.verify-box { padding: 1.2rem; border-top: 1px solid var(--line); background: #f7f9f7; }
.verify-box > p { margin: 0 0 .6rem; font-weight: 750; }
.verify-box > div { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.verify-box button[data-selected="true"] { border-color: var(--ink); background: var(--ink); color: white; }
footer { max-width: 75ch; margin-top: 5rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.noscript { padding: 1rem; background: var(--amber-bg); }

@media (max-width: 900px) {
  .cluster-grid, .add-memory, .share-panel { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  main { width: min(100% - 1rem, 82rem); padding-top: 3rem; }
  .site-bar nav a:first-child { display: none; }
  .toolbar, #memory-form, .cards { grid-template-columns: 1fr; }
  .cluster-head { display: block; }
  .cluster-count { display: inline-block; margin-top: .6rem; }
  .exposure-card { min-height: 0; }
  h1 { font-size: clamp(3.6rem, 20vw, 5.5rem); }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
