/* Qualitative analysis practice: a bench sheet. Warm white tile, iron(III) rust for the controls, condensed headings,
   problem numbers in the round wells of a spotting tile. */
:root {
  --bg: #f6f1ea; --paper: #fffdf9; --ink: #251a14; --muted: #574639; --line: #e0d3c5; --line2: #9a8574; --rule: #a4471a;
  --accent: #8c3510; --accent-ink: #fff; --hi: #f8e7da; --soft: #fbf4ec; --given: #faf3eb; --well: #efe4d8;
  --right: #1e6b3a; --wrong: #b02318; --close: #7a5300; --info: #2a4f7a;
  --mk-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%231e6b3a' stroke-width='2.4'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7.5-8'/%3E%3C/svg%3E");
  --mk-wrong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23b02318' stroke-width='2.4'%3E%3Cpath d='M3.5 3.5l9 9M12.5 3.5l-9 9'/%3E%3C/svg%3E");
  --mk-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237a5300' stroke-width='2.4'%3E%3Cpath d='M8 2.5v7M8 13v.5'/%3E%3C/svg%3E");
  --mk-empty: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23b02318' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='5.5'/%3E%3C/svg%3E");
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --cond: "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "Liberation Sans Narrow", "DejaVu Sans Condensed", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r: 4px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1411; --paper: #241c17; --ink: #f2e8df; --muted: #cdbcad; --line: #3d3029; --line2: #7d6a5c; --rule: #e58a5a;
    --accent: #f2a77e; --accent-ink: #261309; --hi: #3b2619; --soft: #2c221c; --given: #2a201a; --well: #33281f;
    --right: #74d39a; --wrong: #ff9488; --close: #f0c060; --info: #9cc2f0;
    --mk-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2374d39a' stroke-width='2.4'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7.5-8'/%3E%3C/svg%3E");
    --mk-wrong: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ff9488' stroke-width='2.4'%3E%3Cpath d='M3.5 3.5l9 9M12.5 3.5l-9 9'/%3E%3C/svg%3E");
    --mk-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23f0c060' stroke-width='2.4'%3E%3Cpath d='M8 2.5v7M8 13v.5'/%3E%3C/svg%3E");
    --mk-empty: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ff9488' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='5.5'/%3E%3C/svg%3E");
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
a { color: var(--accent); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; background: var(--paper); padding: 8px 12px; z-index: 9; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--cond); font-stretch: condensed; line-height: 1.2; font-weight: 700; letter-spacing: .005em; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.hero { padding: 22px 0 4px; }
.hero h1 { font-size: clamp(1.6rem, 4.6vw, 2.4rem); margin: 0 0 6px; }
.lede { margin: 0 0 4px; max-width: 64ch; }

/* setup */
.setup { margin: 10px 0 12px; }
fieldset { border: 0; margin: 0 0 8px; padding: 0; min-width: 0; }
legend { font-weight: 650; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; border: 1px solid var(--line2); border-radius: 22px; background: var(--paper); }
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chip input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.setrow { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
select, input, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line2); border-radius: var(--r); min-height: 44px; padding: 6px 8px; max-width: 100%; }
.btn { font: inherit; font-weight: 600; min-height: 44px; padding: 8px 16px; border-radius: var(--r); border: 1.5px solid var(--accent); background: var(--paper); color: var(--accent); cursor: pointer; display: inline-flex; align-items: center; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.small { padding: 6px 14px; }
.link { font: inherit; background: none; border: 0; padding: 8px 2px; color: var(--accent); text-decoration: underline; cursor: pointer; min-height: 44px; }
.note { padding: 10px 12px; background: var(--paper); border: 1px solid var(--wrong); border-radius: var(--r); margin: 8px 0; }
#store-note { overflow-wrap: anywhere; }
.note.info { border-color: var(--info); }

/* the sheet */
.sheet { background: var(--paper); border: 1px solid var(--line2); border-radius: 6px; padding: 14px 18px; margin: 8px 0 18px; }
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 16px; border-bottom: 2px solid var(--rule); padding-bottom: 6px; }
.sheet-head h2 { margin: 0; font-size: 1.3rem; }
.code { font-family: var(--mono); letter-spacing: .06em; color: var(--accent); }
.kname { font-family: var(--sans); font-weight: 400; font-size: 1rem; color: var(--muted); }
.score { margin: 0; color: var(--muted); }
.rules { margin: 6px 0; }
.rules summary, details.work summary, .recent summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--accent); }
.rules ul { margin: 2px 0 8px; padding-left: 20px; max-width: 72ch; }
.notes-d { border-bottom: 1px solid var(--line); }
.qs { list-style: none; margin: 0; padding: 0; }
.q { padding: 14px 0 18px; border-bottom: 1px solid var(--line2); }
.q h3 { font-size: 1.2rem; margin: 4px 0 6px; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }
.q h3 .see { margin-left: auto; font: 600 1rem var(--sans); white-space: nowrap; padding: 10px 0; }
/* a spotting-tile well */
.qn { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--well); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .18); font: 700 1rem var(--mono); color: var(--rule); }
.scen { margin: 0 0 8px; max-width: 72ch; }

/* results table */
.twrap { max-width: 100%; margin: 4px 0 8px; }
table.rt { border-collapse: collapse; width: 100%; max-width: 52rem; }
.rt th, .rt td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-weight: 400; }
.rt thead th { font-weight: 650; border-bottom: 2px solid var(--rule); }
.rt th[scope="row"] { width: 50%; }
.rt td { background: var(--given); }
.rt tr.todo td { background: none; }
.tn { font: 700 1rem var(--mono); color: var(--rule); margin-right: 4px; }
.rt .cell { width: 100%; }

/* flowchart */
.flow { display: grid; justify-items: center; gap: 0; margin: 6px 0 10px; max-width: 52rem; }
.fbox { border: 1.5px solid var(--line2); border-radius: var(--r); background: var(--given); padding: 6px 10px; text-align: center; max-width: 100%; }
.fbox.root { background: var(--paper); border-color: var(--rule); font-weight: 600; }
.fl { font-family: var(--mono); color: var(--rule); }
.fedge { display: grid; justify-items: center; padding: 0 0 0; }
.fedge::before { content: ""; width: 2px; height: 14px; background: var(--line2); }
.fedge span { font-style: italic; padding: 2px 8px; text-align: center; max-width: 30rem; }
.fedge::after { content: ""; width: 0; height: 0; border: 7px solid transparent; border-top-color: var(--line2); border-bottom: 0; }
.fouts, .fbranches { display: grid; gap: 10px; width: 100%; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); align-items: start; }
.fbr { display: grid; justify-items: center; align-content: start; }
.ffrom { margin-top: 8px; color: var(--muted); }
.fbfrom { display: none; color: var(--muted); }

/* answers */
.answers { display: grid; gap: 8px; margin: 10px 0 4px; max-width: 52rem; }
.arow { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.arow .al { grid-column: 2; }
.arow .cell { grid-column: 2; }
.arow:not(:has(.pl)) { grid-template-columns: minmax(0, 1fr); }
.arow:not(:has(.pl)) .al, .arow:not(:has(.pl)) .cell { grid-column: 1; }
.pl { font: 700 1rem var(--mono); color: var(--rule); grid-row: 1; padding-top: 1px; }
/* one width for each kind of box: a long observation fills the row, a name fits "chromium(III) sulfate, Cr₂(SO₄)₃" */
.cell { display: block; }
.cell.u-long { width: 100%; min-height: 3.4em; resize: vertical; line-height: 1.4; field-sizing: content; }
.cell.u-name { width: 22rem; }
.cell.is-right { border-color: var(--right); box-shadow: inset 0 0 0 1px var(--right); }
.cell.is-wrong, .cell.is-unread, .cell.is-empty { border-color: var(--wrong); box-shadow: inset 0 0 0 1px var(--wrong); }
.cell.is-empty { border-style: dashed; }
.cell.is-close, .cell.is-own { border-color: var(--close); box-shadow: inset 0 0 0 1px var(--close); border-style: dashed; }
.cell:is(.is-right, .is-wrong, .is-unread, .is-close, .is-own, .is-empty) { background-repeat: no-repeat; background-position: 6px 13px; background-size: 15px; padding-left: 26px; }
.cell.is-right { background-image: var(--mk-right); }
.cell.is-wrong, .cell.is-unread { background-image: var(--mk-wrong); }
.cell.is-close, .cell.is-own { background-image: var(--mk-close); }
.cell.is-empty { background-image: var(--mk-empty); }

/* the notes */
.notes { display: grid; gap: 12px; padding: 4px 0 10px; }
table.nt { border-collapse: collapse; width: 100%; }
.nt caption { text-align: left; font: 700 1.08rem var(--cond); font-stretch: condensed; padding: 4px 0; }
.nt th, .nt td { text-align: left; vertical-align: top; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); font-weight: 400; }
.nt thead th { font-weight: 650; border-bottom: 1.5px solid var(--rule); }
.nt th[scope="row"] { font-weight: 600; white-space: nowrap; }
.fm { font-weight: 400; color: var(--muted); }
.nsrc { margin: 0; color: var(--muted); }

/* feedback */
.fbwrap { margin: 8px 0 0; max-width: 72ch; }
/* one level only inside a problem: the summary is a tinted band, each reason a ruled row (no boxes inside boxes) */
.fb { margin: 4px 0; padding: 6px 10px; border-radius: var(--r); background: var(--hi); }
.fblist { margin: 4px 0 0; padding-left: 1.8em; }
.fblist li.fb { margin: 0; padding: 6px 0 6px 2px; border-radius: 0; background: none; border-bottom: 1px solid var(--line); }
.fblist li.fb:last-child { border-bottom: 0; }
.qfoot { margin-top: 8px; }

/* the key */
details.work { margin-top: 8px; }
.keyfig { margin: 4px 0; }
.keylist { margin: 4px 0; display: grid; gap: 4px; max-width: 72ch; }
.keylist div { display: grid; grid-template-columns: minmax(7rem, auto) minmax(0, 1fr); gap: 0 12px; border-bottom: 1px solid var(--line); padding: 2px 0; }
.keylist dt { color: var(--muted); }
.keylist dd { margin: 0; font-weight: 600; }
.steps { margin: 6px 0 8px; padding-left: 20px; max-width: 72ch; }
.steps li { margin: 2px 0; }

.sheet-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-top: 12px; }
.confirm { flex-basis: 100%; margin: 0; padding: 8px 10px; background: var(--soft); border: 1px solid var(--close); border-radius: var(--r); }
.save-hint { flex-basis: 100%; margin: 0; color: var(--muted); }
.share { margin: 0 0 22px; }
.print-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; }
.print-row label, .share-out label { display: grid; gap: 2px; }
.share-out input { width: 100%; font-family: var(--mono); }
.recent ul { list-style: none; padding: 0; margin: 4px 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 4px 0; }
.recent small { display: block; color: var(--muted); font-size: 1rem; }
.hint { color: var(--muted); margin: 6px 0; }

/* content below the tool */
.content { max-width: 72ch; padding-bottom: 20px; }
.content h2 { font-size: 1.4rem; margin: 26px 0 8px; }
.content ul { padding-left: 20px; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 10px 0; font-weight: 600; min-height: 44px; }
.faq p { margin: 0 0 12px; }
.sources { color: var(--muted); overflow-wrap: anywhere; }

footer { border-top: 1px solid var(--line2); padding: 16px 0 28px; color: var(--muted); font-size: 1rem; }
.indep { margin: 0 0 10px; }
.sb-footer p { margin: 6px 0; }
.sb-more { line-height: 1.8; }
.sb-footer a { color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 16px; transform: translate(-50%, 140%); max-width: min(92vw, 520px); background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r); transition: transform .2s; z-index: 10; pointer-events: none; }
.toast.on { transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
.print-root { display: none; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .sheet { padding: 10px 10px; }
  .hero { padding-top: 14px; }
  .hero h1 { font-size: 1.5rem; }
  .lede { display: none; }
  .chip span { padding: 6px 11px; }
  .cell.u-name { width: 100%; }
  /* the results table: each test above its observation */
  .rt, .rt tbody, .rt tr, .rt th, .rt td { display: block; width: 100%; }
  .rt thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rt tr { border-bottom: 1px solid var(--line2); padding: 4px 0 6px; }
  .rt th[scope="row"], .rt td { border: 0; padding: 2px 0; width: 100%; }
  .rt td { padding: 4px 8px; border-radius: var(--r); }
  .rt tr.todo td { padding: 4px 0; }
  .nt th[scope="row"] { white-space: normal; }
  .keylist div { grid-template-columns: minmax(0, 1fr); }
  .fouts, .fbranches { grid-template-columns: minmax(0, 1fr); }
  .fbfrom { display: block; margin-top: 10px; }
  .fbr + .fbr { border-top: 1px solid var(--line); }
}

/* the narrowest phones: the longest name with its formula and mark still fits its box */
@media (max-width: 400px) {
  .sheet { padding: 10px 7px; }
  .cell { padding-right: 4px; }
  .cell:is(.is-right, .is-wrong, .is-unread, .is-close, .is-own, .is-empty) { padding-left: 24px; background-position: 5px 13px; }
}

@media print {
  :root { --ink: #000; --muted: #222; --line: #888; --line2: #444; --rule: #000; --paper: #fff; --bg: #fff; --accent: #000; --hi: #fff; --given: #fff; --soft: #fff; --well: #fff; }
  @page { margin: 10mm 12mm; }
  body { background: #fff; color: #000; font: 10.5pt/1.3 var(--sans); }
  main, footer, .skip, .toast { display: none !important; }
  .print-root { display: block; }
  .psheet, .pkey, .pnotes { break-after: page; }
  .pkey:last-child, .psheet:last-child, .pnotes:last-child { break-after: auto; }
  table.pt { width: 100%; border-collapse: collapse; }
  .pt > thead .prun { color: #222; font-size: 10pt; padding-bottom: 4px; border-bottom: 0.5pt solid #888; }
  .ph h2 { margin: 4px 0 4px; font-size: 16pt; }
  .ph p { margin: 0 0 4px; }
  .pmeta { display: flex; justify-content: space-between; gap: 10px; margin: 8px 0; }
  .phrow { display: flex; align-items: baseline; gap: 6mm; margin: 0 0 6pt; }
  .phrow .pmeta { flex: 1; margin: 0; }
  .pmeta span { white-space: nowrap; }
  .prules { margin: 0 0 6pt; padding-left: 14pt; }
  .prules li { break-inside: avoid; }
  .pq, .pk { list-style: none; margin: 0; padding: 0; }
  .pq > li { break-inside: avoid; padding: 4pt 0 8pt; border-top: 0.5pt solid #888; }
  /* app.js marks the problem that starts each page, the same in every copy, so every copy prints the same length */
  .pq > li.pb { break-before: page; }
  /* a key problem may run on to the next page between its steps, so a long key does not leave half a page blank */
  .pk > li { padding: 3pt 0 6pt; border-top: 0.5pt solid #888; }
  .pk .keylist, .pk .keyfig { break-inside: avoid; }
  .pk .steps { orphans: 2; widows: 2; }
  .pqh h3, .pk h3 { font-size: 12.5pt; margin: 2pt 0 3pt; break-after: avoid; }
  .scen { margin: 0 0 4pt; max-width: none; }
  .rt { max-width: none; break-inside: avoid; font-size: 10pt; line-height: 1.2; }
  .rt th[scope="row"] { width: 57%; }
  .rt th, .rt td { padding: 2pt 6pt 2pt 0; border-bottom: 0.5pt solid #999; background: none; }
  .rt thead th { border-bottom: 1pt solid #000; }
  .rt tr.todo td { vertical-align: bottom; }
  .flow { max-width: none; break-inside: avoid; }
  .fbox { border: 0.75pt solid #000; padding: 3pt 6pt; }
  .fedge::before { background: #000; height: 8pt; }
  .fedge::after { border-top-color: #000; }
  .fedge span { padding: 1pt 6pt; }
  .fbfrom { display: none; }
  .fouts, .fbranches { grid-template-columns: repeat(auto-fit, minmax(40mm, 1fr)); gap: 6pt; }
  .answers { max-width: none; gap: 2pt; margin: 4pt 0; }
  .arow { border-bottom: 0; padding: 0; break-inside: avoid; }
  /* ruled lines to write on: 21pt apart, two for an observation, one for a name */
  .pblank { display: block; height: 21pt; border-bottom: 0.75pt solid #000; }
  .pblank.two { height: 42pt; background: linear-gradient(transparent 20.6pt, #000 20.6pt, #000 21.4pt, transparent 21.4pt); }
  .arow.long .pblank { grid-column: 2; }
  .arow.long:not(:has(.pl)) .pblank { grid-column: 1; }
  .arow.name { grid-template-columns: auto minmax(0, 1fr) 70mm; align-items: end; }
  .arow.name:not(:has(.pl)) { grid-template-columns: minmax(0, 1fr) 70mm; }
  .arow.name .al, .arow.name .pblank { grid-column: auto; }
  .arow.name .pl, .arow.name .al { grid-row: auto; align-self: start; }
  /* name rows two to a line on paper, so two problems fit a page */
  .answers:not(:has(.arow.long)) { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 8mm; }
  .answers:not(:has(.arow.long)) .arow.name { grid-template-columns: auto minmax(0, 1fr) 34mm; }
  .answers:not(:has(.arow.long)) .arow.name:not(:has(.pl)) { grid-template-columns: minmax(0, 1fr) 34mm; }
  /* "Name the ion or gas": each prompt is a sentence or two, so one to a line */
  .pq > li.pq-id .answers:not(:has(.arow.long)) { grid-template-columns: minmax(0, 1fr); row-gap: 4pt; }
  .pq > li.pq-id .answers .arow.name { grid-template-columns: auto minmax(0, 1fr) 60mm; }
  .keylist { max-width: none; }
  .keylist div { border-bottom: 0.5pt solid #bbb; grid-template-columns: 40mm minmax(0, 1fr); padding: 1.5pt 0; }
  .steps li { margin: 0; }
  .steps { margin: 4pt 0; max-width: none; }
  .steps li { break-inside: avoid; }
  .keyfig { margin: 2pt 0 4pt; }
  .pnotes .notes { gap: 8pt; }
  .nt { break-inside: avoid; }
  .nt caption { font-size: 12pt; }
  .nt th, .nt td { padding: 2pt 6pt 2pt 0; border-bottom: 0.5pt solid #999; }
  .fm { color: #000; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
