/* ChemWarden Learn: lab-notebook paper, ink, and a periodic-table motif. */
:root {
  --paper: #f2f6f7; --paper-2: #e3ecee; --card: #fbfdfd; --ink: #10262b; --ink-2: #3e5458; --muted: #66787b;
  --rule: #cfdcdf; --green: #0c434e; --green-2: #082d35; --copper: #a85a06; --copper-soft: #fde8c8;
  --ma: #6b4fa0; --ph: #1f6f9c; --in: #c26a0b; --or: #2f7d4a; --ca: #a8323e;
  --serif: "Newsreader", Georgia, serif; --display: "Young Serif", Georgia, serif; --mono: "Martian Mono", ui-monospace, monospace;
  --radius: 10px; --shadow: 0 1px 0 #00000008, 0 10px 30px -18px #0c434e55;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #0b1a1e; --paper-2: #10242a; --card: #12282e; --ink: #e6eff0; --ink-2: #b4c5c8; --muted: #829598; --rule: #22404a;
  --green: #5fc0cf; --green-2: #8bd5e0; --copper: #f49b1f; --copper-soft: #3b2a12; --shadow: 0 10px 30px -18px #000;
  --ma: #b29be0; --ph: #7fc0e6; --in: #f4a63a; --or: #7fcf96; --ca: #ec8a95; color-scheme: dark; } }
:root[data-theme="dark"] {
  --paper: #0b1a1e; --paper-2: #10242a; --card: #12282e; --ink: #e6eff0; --ink-2: #b4c5c8; --muted: #829598; --rule: #22404a;
  --green: #5fc0cf; --green-2: #8bd5e0; --copper: #f49b1f; --copper-soft: #3b2a12; --shadow: 0 10px 30px -18px #000;
  --ma: #b29be0; --ph: #7fc0e6; --in: #f4a63a; --or: #7fcf96; --ca: #ec8a95; color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font: 18px/1.6 var(--serif); font-optical-sizing: auto;
  background-image: linear-gradient(var(--rule) 1px, transparent 1px); background-size: 100% 2.2rem; background-attachment: fixed;
  background-blend-mode: normal;
}
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 20% -10%, #ffffff55, transparent 60%), linear-gradient(90deg, transparent 54px, #c9603a22 54px, #c9603a22 56px, transparent 56px); z-index: -1; }
a { color: var(--green); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--copper); }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.15; letter-spacing: -.01em; }
code, .mono { font-family: var(--mono); font-size: .78em; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 12px; top: 12px; background: var(--card); padding: 8px 12px; z-index: 99; }
.muted { color: var(--muted); } .fine { font-size: 14px; color: var(--muted); }
.eyebrow { font: 500 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--copper); margin: 0 0 12px; }

/* Masthead */
.masthead { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 24px; padding: 12px clamp(16px, 4vw, 48px); background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); }
.wordmark { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 400 20px var(--display); white-space: nowrap; }
.wordmark em { font-style: italic; color: var(--copper); font-family: var(--serif); }
.cell { position: relative; width: 38px; height: 38px; border: 1.5px solid var(--ink); border-radius: 4px; display: grid; place-items: center; font: 400 17px var(--display); background: var(--card); }
.cell small { position: absolute; top: 2px; left: 4px; font: 500 7px var(--mono); }
.primary { display: flex; gap: 22px; } .primary a { color: var(--ink-2); text-decoration: none; font-size: 16px; } .primary a:hover, .primary a[aria-current] { color: var(--ink); box-shadow: inset 0 -2px var(--copper); }
.mast-tools { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.search input { font: 15px var(--serif); padding: 8px 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--card); color: var(--ink); width: 210px; }
.search input:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.account-slot a, .account-slot button { font: 15px var(--serif); }
main { max-width: 1160px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px) 80px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; background: var(--green); color: #fff; text-decoration: none; border: 0; font: 500 16px var(--serif); cursor: pointer; }
.btn:hover { background: var(--green-2); color: #fff; } .btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); } .btn.ghost:hover { background: var(--ink); color: var(--paper); }
.btn.small { padding: 6px 12px; font-size: 14px; } .btn.danger { background: #a8323e; } .btn[disabled] { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Hero */
.hero { padding: clamp(40px, 8vw, 96px) 0 40px; max-width: 860px; }
.hero h1 { font-size: clamp(44px, 7.5vw, 92px); margin: 0 0 24px; }
.hero h1 span { color: var(--copper); font-style: italic; font-family: var(--serif); font-weight: 500; }
.lede { font-size: clamp(19px, 2vw, 22px); color: var(--ink-2); max-width: 680px; }
.stats { display: flex; flex-wrap: wrap; gap: 0; margin: 36px 0 0; border-top: 1.5px solid var(--ink); }
.stats div { padding: 14px 28px 0 0; margin-right: 28px; } .stats dt { font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); } .stats dd { margin: 4px 0 0; font: 400 34px var(--display); }

/* Tier switch */
.tier-switch { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 18px; padding: 6px; background: var(--card); border: 1px solid var(--rule); border-radius: 999px; }
.tier-switch span { font: 500 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 0 8px; }
.tier-switch button { border: 0; background: transparent; font: 15px var(--serif); padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--ink-2); }
.tier-switch button[aria-checked="true"] { background: var(--ink); color: var(--paper); }

/* Element tiles */
.section-title { font-size: 30px; margin: 56px 0 18px; }
.elements { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.element { --c: var(--green); position: relative; aspect-ratio: 1; display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; border-radius: 6px; text-decoration: none; color: var(--ink); background: var(--card); border: 1.5px solid var(--ink); box-shadow: 6px 6px 0 var(--c); transition: transform .2s, box-shadow .2s; animation: rise .6s both; animation-delay: calc(var(--i) * 70ms); }
.element:hover { transform: translate(-3px, -3px); box-shadow: 9px 9px 0 var(--c); color: var(--ink); }
.element .z { position: absolute; top: 12px; left: 14px; font: 500 13px var(--mono); }
.element .count { position: absolute; top: 12px; right: 14px; font: 400 11px var(--mono); color: var(--muted); }
.element .sym { font: 400 64px/1 var(--display); color: var(--c); }
.element .name { font-size: 17px; margin-top: 8px; line-height: 1.25; }
.el-maths { --c: var(--ma); } .el-physical { --c: var(--ph); } .el-inorganic { --c: var(--in); } .el-organic { --c: var(--or); } .el-catalysis { --c: var(--ca); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) { .element { animation: none; } }

/* Cards */
.split { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; margin-top: 56px; }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font-size: 28px; }
.community-card { background: #0c434e; color: #f2f6f7; border-color: #0c434e; } .community-card .eyebrow { color: var(--copper-soft); }
.community-card .btn { background: var(--copper); } .community-card .btn.ghost { color: #f2f6f7; box-shadow: inset 0 0 0 1px #f2f6f7; background: transparent; }
.paper-list { list-style: none; padding: 0; margin: 0; } .paper-list li { padding: 10px 0; border-bottom: 1px dashed var(--rule); font-size: 16px; line-height: 1.4; }
.paper-list a { color: var(--ink); text-decoration: none; } .paper-list a:hover { color: var(--green); } .paper-list small { display: block; font: 400 11px var(--mono); color: var(--muted); margin-top: 4px; }

/* Branch page */
.branch-head { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: end; padding: 48px 0 28px; border-bottom: 1.5px solid var(--ink); }
.branch-head .crumb { grid-column: 1 / -1; }
.big-cell { position: relative; width: 140px; height: 140px; border: 2px solid var(--ink); border-radius: 6px; display: grid; place-items: center; background: var(--card); box-shadow: 8px 8px 0 var(--c); }
.big-cell .sym { font: 400 72px var(--display); color: var(--c); } .big-cell .z { position: absolute; top: 8px; left: 10px; font: 500 14px var(--mono); }
.branch-head h1 { font-size: clamp(36px, 5vw, 60px); margin: 0 0 6px; }
.crumb { font: 400 13px var(--mono); color: var(--muted); margin: 0 0 8px; } .crumb a { color: var(--muted); }
.chapter { margin-top: 40px; } .chapter h2 { font-size: 26px; margin: 0 0 8px; } .ch-no { font: 500 14px var(--mono); color: var(--copper); vertical-align: middle; margin-right: 6px; }
.topic-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.topic-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.topic-row > a { font-size: 20px; color: var(--ink); text-decoration: none; } .topic-row > a:hover { color: var(--green); }
.topic-row .scope { grid-column: 1 / -1; color: var(--ink-2); font-size: 16px; }
.topic-row.dim { opacity: .35; } .topic-row.dim:hover { opacity: .8; }
.tiers { display: inline-flex; flex-wrap: wrap; gap: 4px; align-self: center; }
.t { font: 500 10px/1 var(--mono); text-decoration: none; padding: 5px 7px; border-radius: 3px; border: 1px solid currentColor; letter-spacing: .04em; }
.t-G { color: #2f7d4a; } .t-A { color: #1f6f9c; } .t-U { color: #6b4fa0; } .t-P { color: #a8323e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .t-G { color: #7fcf96; } :root:not([data-theme="light"]) .t-A { color: #7fc0e6; } :root:not([data-theme="light"]) .t-U { color: #b29be0; } :root:not([data-theme="light"]) .t-P { color: #ec8a95; } }

/* Topic page */
.topic-head { padding: 44px 0 20px; } .topic-head h1 { font-size: clamp(34px, 5vw, 58px); margin: 0 0 10px; }
.topic-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 28px; align-items: start; margin-top: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1.5px solid var(--ink); }
.tabs button { border: 0; background: transparent; font: 16px var(--serif); padding: 10px 16px; cursor: pointer; color: var(--ink-2); border-radius: 6px 6px 0 0; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.note { background: var(--card); border: 1px solid var(--rule); border-top: 0; padding: 22px 26px; border-radius: 0 0 var(--radius) var(--radius); }
.note[hidden] { display: none; } .note p { margin: 0 0 14px; } .note h3 { font-size: 22px; margin: 20px 0 8px; }
.unwritten { color: var(--ink-2); } .draft-flag { font: 500 12px var(--mono); color: var(--copper); text-transform: uppercase; letter-spacing: .1em; }
.equations { background: var(--card); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 20px 22px; position: sticky; top: 84px; box-shadow: 6px 6px 0 var(--c, var(--green)); }
.equations h2 { margin: 0; font-size: 24px; } .equations dl { margin: 12px 0 0; } .equations div { padding: 12px 0; border-top: 1px dashed var(--rule); }
.equations dt { font: 500 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); } .equations dd { margin: 6px 0 0; overflow-x: auto; overflow-y: hidden; }
.math.display { display: block; } .katex { font-size: 1.08em; }
.preprints { margin-top: 28px; }
.prevnext { display: flex; justify-content: space-between; gap: 16px; margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 16px; }

/* Plain/prose pages */
.plain { max-width: 760px; padding-top: 48px; } .plain h1 { font-size: clamp(36px, 5vw, 56px); margin: 0 0 12px; }
.prose h2 { font-size: 26px; margin: 34px 0 10px; } .prose li { margin-bottom: 8px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 28px 0; }
.plan { display: flex; flex-direction: column; gap: 6px; padding: 22px; border: 1.5px solid var(--ink); border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none; box-shadow: 6px 6px 0 var(--copper); transition: transform .2s, box-shadow .2s; }
.plan:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--copper); color: var(--ink); }
.price { font: 400 40px var(--display); } .price small { font: 16px var(--serif); color: var(--muted); }
.results { list-style: none; padding: 0; } .results li { padding: 14px 0; border-bottom: 1px solid var(--rule); } .results small { display: block; color: var(--muted); font-size: 14px; }
.search.big input { width: 100%; font-size: 20px; padding: 14px 18px; }

/* Community */
.community { padding-top: 36px; }
.c-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; } .c-head h1 { margin: 0; font-size: clamp(32px, 4.5vw, 48px); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 30px; }
.cat { display: block; padding: 16px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none; }
.cat:hover, .cat.active { border-color: var(--ink); box-shadow: 4px 4px 0 var(--green); color: var(--ink); } .cat strong { display: block; font-size: 18px; } .cat span { font-size: 14px; color: var(--muted); }
.thread-list { list-style: none; padding: 0; margin: 0; border-top: 1.5px solid var(--ink); }
.thread-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.thread-list a { font-size: 19px; color: var(--ink); text-decoration: none; } .thread-list a:hover { color: var(--green); } .thread-list .meta { font: 400 12px var(--mono); color: var(--muted); }
.post { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 14px; }
.post header { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; font: 400 12px var(--mono); color: var(--muted); margin-bottom: 8px; } .post header strong { font: 600 15px var(--serif); color: var(--ink); }
.post .body { white-space: pre-wrap; overflow-wrap: anywhere; } .post footer { margin-top: 10px; display: flex; gap: 12px; }
.linkish { border: 0; background: none; padding: 0; font: 14px var(--serif); color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; } .linkish:hover { color: var(--copper); }
.composer { background: var(--card); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 18px; margin-top: 18px; }
.composer label { display: block; font: 500 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 10px 0 6px; }
.composer input, .composer textarea, .composer select, .form input, .form select { width: 100%; font: 17px var(--serif); padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); color: var(--ink); }
.composer textarea { min-height: 130px; resize: vertical; } .composer .actions { margin-top: 12px; align-items: center; }
.notice { padding: 12px 16px; border-radius: 8px; background: var(--copper-soft); color: var(--ink); margin: 12px 0; font-size: 16px; } .notice.ok { background: color-mix(in srgb, var(--green) 18%, var(--card)); }
.form { max-width: 440px; } .form .row { margin-bottom: 14px; } .form label { display: block; font-size: 15px; margin-bottom: 4px; } .form .check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; } .form .check input { width: auto; margin-top: 5px; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; } .auth-grid > section { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 24px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.chat { display: grid; grid-template-rows: 1fr auto; height: min(70vh, 640px); background: var(--card); border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden; }
.chat-log { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; } .msg .who { font: 400 11px var(--mono); color: var(--muted); } .msg .text { background: var(--paper-2); padding: 8px 12px; border-radius: 4px 12px 12px 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; }
.msg.mine { align-self: flex-end; } .msg.mine .text { background: var(--green); color: #fff; border-radius: 12px 4px 12px 12px; } .msg.mine .who { text-align: right; }
.chat form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--rule); background: var(--paper); } .chat input { flex: 1; font: 17px var(--serif); padding: 10px 12px; border: 1px solid var(--rule); border-radius: 999px; background: var(--card); color: var(--ink); }
.pill { font: 500 10px var(--mono); padding: 3px 6px; border-radius: 3px; background: var(--copper-soft); color: var(--copper); text-transform: uppercase; letter-spacing: .06em; }
.mod-item { border-left: 4px solid var(--copper); }

/* Footer */
.colophon { border-top: 1.5px solid var(--ink); padding: 28px clamp(16px, 4vw, 48px) 48px; max-width: 1160px; margin: 0 auto; display: grid; gap: 14px; font-size: 16px; color: var(--ink-2); }
.colophon nav { display: flex; flex-wrap: wrap; gap: 18px; } .colophon a { color: var(--ink-2); }

@media (max-width: 860px) {
  .masthead { flex-wrap: wrap; gap: 10px 16px; } .primary { order: 3; width: 100%; overflow-x: auto; gap: 18px; padding-bottom: 2px; }
  .search input { width: 150px; } .split, .topic-body, .auth-grid { grid-template-columns: 1fr; } .equations { position: static; }
  .branch-head { grid-template-columns: 1fr; } .big-cell { width: 100px; height: 100px; } .big-cell .sym { font-size: 52px; }
  .msg { max-width: 92%; }
}
@media (max-width: 480px) { body { font-size: 17px; } .search input { width: 120px; } .elements { grid-template-columns: 1fr 1fr; gap: 10px; } .element .sym { font-size: 44px; } .element { padding: 12px; } .stats dd { font-size: 26px; } }

/* ChemWarden shield; pale version in dark mode. */
.wordmark .logo { height: 32px; width: auto; display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wordmark .logo { content: url("/static/brand/logo-mark-light.png"); } }
:root[data-theme="dark"] .wordmark .logo { content: url("/static/brand/logo-mark-light.png"); }
