:root {
  --ink: #10272b;
  --muted: #5d706f;
  --paper: #f4f0e5;
  --paper-deep: #e7e0d0;
  --night: #071b21;
  --night-2: #0d2a31;
  --acid: #d8ff4f;
  --cyan: #57d9db;
  --orange: #ff8b4b;
  --red: #ef5d5d;
  --line: rgba(16, 39, 43, 0.16);
  --shadow: 0 18px 55px rgba(0, 15, 18, 0.23);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; color-scheme: dark; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(87, 217, 219, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87, 217, 219, 0.055) 1px, transparent 1px),
    var(--night);
  background-size: 28px 28px;
  font-family: Aptos, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
button { color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: rgba(216,255,79,.25); }

button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  left: 12px;
  top: 10px;
  padding: 10px 14px;
  color: var(--night);
  background: var(--acid);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  height: 72px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 28px;
  padding: 0 30px;
  color: #eef7ee;
  border-bottom: 1px solid rgba(255,255,255,.13);
  background: rgba(7,27,33,.95);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  letter-spacing: .14em;
  font-weight: 800;
}

.brand-mark { display: flex; align-items: end; gap: 2px; height: 24px; }
.brand-mark i { width: 5px; background: var(--acid); display: block; }
.brand-mark i:nth-child(1) { height: 11px; }
.brand-mark i:nth-child(2) { height: 23px; }
.brand-mark i:nth-child(3) { height: 16px; background: var(--cyan); }

.tagline { margin: 0; color: #94aaa8; font-size: .9rem; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.calculator-menu { position: relative; }
.calculator-toggle[aria-expanded="true"] { color: var(--night); border-color: var(--acid); background: var(--acid); }
.saved-work-toggle[aria-expanded="true"] { color: var(--night); border-color: var(--cyan); background: var(--cyan); }

.quiet-button, .export-all-button, .clear-button, .close-button {
  border: 0;
  cursor: pointer;
}

.quiet-button, .export-all-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.15);
  color: #e9f1ed;
  background: transparent;
}
.export-all-button { color: var(--night); background: var(--acid); border-color: var(--acid); font-weight: 750; }
.quiet-button:hover { border-color: var(--cyan); color: var(--cyan); }
.export-all-button:hover { background: #ecff9d; }

kbd {
  padding: .13em .38em;
  border: 1px solid currentColor;
  border-radius: 3px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .72em;
  opacity: .78;
  box-shadow: 0 1px 0 currentColor;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.52fr) minmax(400px, .82fr);
  max-width: 1680px;
  margin: 0 auto;
  min-height: calc(100vh - 72px);
}
.app-shell.reference-collapsed { grid-template-columns: minmax(0, 1fr) 52px; }

.workspace {
  min-width: 0;
  padding: clamp(32px, 5vw, 74px);
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent 43px, rgba(239,93,93,.18) 44px, transparent 45px),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(16,39,43,.055) 32px);
}

.workspace-heading, .dialog-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: #667573;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { text-wrap: balance; scroll-margin-top: 92px; }
h1, h2, h3 { margin: 0; }
h1 {
  max-width: 720px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: clamp(2.25rem, 4.5vw, 4.9rem);
  line-height: .99;
  letter-spacing: -.05em;
}

.clear-button {
  padding: 8px 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--muted);
  font-size: .82rem;
}
.clear-button:hover { color: var(--ink); }

.composer-wrap {
  position: relative;
  margin-top: 38px;
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  background: #fffdf5;
}

.mode-badge {
  position: absolute;
  left: 18px;
  top: -13px;
  padding: 5px 10px;
  color: var(--night);
  background: var(--acid);
  border: 2px solid var(--ink);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .12em;
}

#command-input {
  display: block;
  width: 100%;
  min-height: 220px;
  border: 0;
  padding: 18px 24px 24px;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(16,39,43,.1) 32px),
    #fffdf5;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: clamp(1.05rem, 2vw, 1.38rem);
  line-height: 32px;
  caret-color: #157f82;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#command-input:focus { outline: 0; }
#command-input:focus-visible { outline: 3px solid var(--acid); outline-offset: 4px; }
.composer-wrap:focus-within { box-shadow: 8px 8px 0 #087478; }
#command-input:empty::before { content: attr(data-placeholder); color: #8c9892; pointer-events: none; }

.notepad-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 7px 8px 7px 92px;
  border-bottom: 1px solid var(--line);
  background: #eee8d8;
}
.notation-tools, .notepad-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.notepad-toolbar > * { min-width: 0; }
.notation-button, .next-step-button, .save-note-button {
  min-height: 36px;
  border: 1px solid rgba(16,39,43,.28);
  background: #fffdf5;
  cursor: pointer;
  font-weight: 750;
}
.notation-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 39px;
  padding: 0 8px;
  color: #087478;
  font-family: Georgia, serif;
  font-size: 1.05rem;
}
.notation-button:hover, .notation-button[aria-pressed="true"] { color: var(--night); background: var(--cyan); }
.notation-label { font-family: "Cascadia Code", Consolas, monospace; font-size: .61rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.notation-example { min-width: 20px; font-family: Georgia, serif; font-size: 1.05rem; }
.highlight-swatch { padding: 0 2px; color: var(--ink); background: #fff27a; }
.highlight-button[data-color="green"] .highlight-swatch { background: #9df5c0; }
.highlight-button[data-color="pink"] .highlight-swatch { background: #ffb3d4; }
.highlight-button[data-color="blue"] .highlight-swatch { background: #a7dcff; }
.paste-question-button { min-height: 36px; min-width: 144px; padding: 0 11px; border: 1px solid var(--ink); color: var(--night); background: var(--acid); cursor: pointer; font-family: "Cascadia Code", Consolas, monospace; font-size: .66rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.paste-question-button:hover { background: #ecff9d; }
.paste-question-button kbd { margin-left: 5px; padding: 1px 3px; border: 1px solid currentColor; border-radius: 2px; font-size: .58rem; }
.notation-button.notation-feedback { animation: notation-confirm .24s cubic-bezier(.2,.8,.2,1); }
@keyframes notation-confirm {
  50% { color: var(--night); border-color: var(--acid); background: var(--acid); transform: translateY(-2px) scale(1.035); box-shadow: 0 3px 0 rgba(16,39,43,.32); }
}
.draft-status {
  justify-self: end;
  color: var(--muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.draft-status.is-saving { color: #087478; }
.draft-status.is-fraction-help { color: #087478; font-weight: 800; }
.next-step-button, .save-note-button { padding: 0 11px; font-size: .72rem; }
.next-step-button { color: var(--night); background: var(--acid); }
.next-step-button:hover { background: #ecff9d; }
.save-note-button:hover { background: var(--acid); }
.live-fraction {
  display: inline-grid;
  grid-template-rows: minmax(25px, auto) 2px minmax(25px, auto);
  min-width: 72px;
  margin: 0 5px;
  vertical-align: middle;
  text-align: center;
  line-height: 25px;
}
.live-fraction > span { min-width: 20px; padding-inline: 4px; }
.live-fraction-line { position: relative; z-index: 1; height: 2px; padding: 0 !important; background: currentColor; pointer-events: none; }
.live-numerator, .live-denominator { outline: none; }
.saved-note { white-space: pre-wrap; font-family: "Cascadia Code", Consolas, monospace; line-height: 1.7; }
.saved-note sub, .saved-note sup, .notepad-editor sub, .notepad-editor sup { color: #087478; font-weight: 800; }
.saved-note mark, .notepad-editor mark { padding: .05em .08em; color: inherit; background: #fff27a; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.saved-note mark.mark-green, .notepad-editor mark.mark-green { background: #9df5c0; }
.saved-note mark.mark-pink, .notepad-editor mark.mark-pink { background: #ffb3d4; }
.saved-note mark.mark-blue, .notepad-editor mark.mark-blue { background: #a7dcff; }

.saved-note s, .notepad-editor s { text-decoration: line-through; text-decoration-thickness: 2px; opacity: .5; }
.strike-example { text-decoration: line-through; text-decoration-thickness: 2px; }
.undo-button[disabled] { opacity: .38; cursor: not-allowed; }
.undo-button[disabled]:hover { color: #087478; background: #fffdf5; }
.highlight-group { position: relative; display: flex; }
.highlight-group .highlight-button { border-right-width: 0; }
.highlight-more { display: grid; place-items: center; min-width: 26px; min-height: 36px; padding: 0; border: 1px solid rgba(16,39,43,.28); color: #087478; background: #fffdf5; cursor: pointer; font-size: .72rem; line-height: 1; }
.highlight-more:hover, .highlight-more[aria-expanded="true"] { color: var(--night); background: var(--cyan); }
.highlight-menu { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; padding: 9px; border: 1px solid var(--ink); box-shadow: 5px 5px 0 rgba(0,0,0,.22); background: #fffdf5; }
.highlight-menu[hidden] { display: none; }
.highlight-swatches { display: flex; gap: 6px; }
.highlight-swatches button { width: 30px; height: 30px; padding: 3px; border: 1px solid var(--ink); background: transparent; cursor: pointer; }
.highlight-swatches button span { display: block; width: 100%; height: 100%; }
[data-highlight="yellow"] span { background: #fff27a; }
[data-highlight="green"] span { background: #9df5c0; }
[data-highlight="pink"] span { background: #ffb3d4; }
[data-highlight="blue"] span { background: #a7dcff; }
.highlight-swatches button:hover, .highlight-swatches button[aria-pressed="true"] { outline: 2px solid var(--night); outline-offset: 1px; }
.highlight-clear { width: 100%; min-height: 30px; margin-top: 7px; padding: 0 8px; border: 1px solid var(--ink); color: var(--night); background: transparent; cursor: pointer; font-family: "Cascadia Code", Consolas, monospace; font-size: .6rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.highlight-clear:hover { color: var(--night); background: var(--cyan); }

.work-steps:empty { display: none; }
.work-step {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  min-height: 86px;
  border-bottom: 1px solid var(--line);
  background:
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(16,39,43,.08) 32px),
    #f4f0e5;
}
.work-step-number {
  padding: 18px 10px;
  border-right: 1px solid var(--line);
  color: #087478;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}
.work-step-main { position: relative; min-width: 0; }
.work-step-content { min-height: 82px; padding: 14px 142px 18px 22px; color: var(--ink); font-size: 1rem; outline: none; }
.work-step-actions { position: absolute; z-index: 1; top: 10px; right: 10px; display: flex; gap: 5px; }
.work-step-edit, .work-step-delete { min-height: 26px; padding: 0 8px; border: 1px solid rgba(16,39,43,.35); color: #087478; background: #fffdf5; cursor: pointer; font-family: "Cascadia Code", Consolas, monospace; font-size: .62rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.work-step-edit:hover { color: var(--night); border-color: var(--cyan); background: var(--cyan); }
.work-step-delete { color: #9e4a30; }
.work-step-delete:hover { color: #fffdf5; border-color: #9e4a30; background: #9e4a30; }
.active-work-step { position: relative; }
.active-step-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 30px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--line);
  color: #60716f;
  background: #fffdf5;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.active-step-heading strong { color: #087478; }
.saved-work { display: grid; gap: 14px; }
.saved-work-step { padding: 14px 16px; border-left: 4px solid #087478; background: #f4f0e5; }
.saved-work-step > span { display: block; margin-bottom: 7px; color: #087478; font-family: "Cascadia Code", Consolas, monospace; font-size: .66rem; font-weight: 800; text-transform: uppercase; }

.examples {
  display: grid;
  grid-template-columns: .72fr 1.28fr;
  gap: clamp(24px, 4vw, 64px);
  margin-top: 72px;
  padding-top: 24px;
  border-top: 2px solid var(--ink);
}
.examples h2 { font-family: Georgia, serif; font-weight: 500; font-size: 1.7rem; }
.examples-copy > p:last-child { color: var(--muted); line-height: 1.5; }
.command-list { display: grid; }
.command-list > div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .84rem;
}
.command-list code { color: #087478; font-weight: 800; }
.command-list span { color: var(--muted); }

.results { display: grid; gap: 20px; margin-top: 42px; }
.result-card {
  position: relative;
  border: 1px solid var(--ink);
  background: #fffcf1;
  box-shadow: 5px 5px 0 var(--paper-deep);
  animation: card-in .32s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(12px); } }

.result-meta {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .67rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.result-number { color: #087478; font-weight: 800; }
.result-meta time { justify-self: end; color: var(--muted); }
.result-content { min-height: 116px; padding: 28px 24px; }
.result-content h3 { margin-bottom: 17px; font-family: Georgia, serif; font-size: 1.1rem; font-weight: 500; color: var(--muted); }
.result-actions {
  display: flex;
  justify-content: end;
  border-top: 1px solid var(--line);
}
.result-actions button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-size: .73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.result-actions button:hover { background: var(--acid); }
.result-actions button[data-action="edit"] { color: #087478; }

.chemical-equation {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .3em;
  font-family: Georgia, serif;
  font-size: clamp(1.55rem, 4vw, 2.8rem);
  line-height: 1.25;
}
.chemical-equation .coefficient { color: #087478; font-weight: 800; margin-right: .05em; }
.chemical-equation .arrow { color: var(--orange); padding: 0 .16em; }
.chemical-equation sub, .ion-formula sub, .element-detail sub { font-size: .58em; }
.chemical-equation sup, .ion-formula sup { font-size: .55em; }
.equation-input { margin-top: 16px; color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .77rem; }

.factor-chain { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.factor { display: inline-grid; grid-template-rows: 1fr 2px 1fr; min-width: 100px; text-align: center; font-family: Georgia, serif; font-size: 1.1rem; }
.factor-line { display: block; height: 2px; margin: 5px 0; background: var(--ink); }
.factor-operator { color: var(--orange); font-size: 1.4rem; }
.factor-result { padding: 9px 12px; background: var(--acid); font-weight: 800; }
.cancelled { text-decoration: line-through 2px var(--orange); text-decoration-skip-ink: none; color: var(--muted); }

.conversion-answer { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.conversion-answer strong { font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3.6rem); font-weight: 500; }
.conversion-answer .equals { color: var(--orange); font-size: 1.7rem; }
.conversion-note { color: var(--muted); margin: 12px 0 0; }
.error-box { border-left: 5px solid var(--red); padding-left: 16px; }
.error-box h3 { color: var(--ink); margin-bottom: 8px; }
.error-box p { color: var(--muted); margin: 0; line-height: 1.5; }

.reference-panel {
  position: relative;
  min-width: 0;
  padding: 20px clamp(18px, 2.3vw, 34px) 46px;
  color: #eaf2ee;
  border-left: 1px solid rgba(255,255,255,.12);
  background: rgba(7,27,33,.72);
}
.reference-panel.is-collapsed { padding-inline: 0; }
.reference-toggle {
  position: sticky;
  top: 87px;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: calc(clamp(18px, 2.3vw, 34px) * -1 - 18px);
  margin-bottom: -36px;
  border: 2px solid var(--night);
  border-radius: 50%;
  color: var(--night);
  background: var(--acid);
  box-shadow: 0 0 0 3px rgba(7,27,33,.8);
  transform: translateX(-50%);
  cursor: pointer;
}
.reference-toggle:hover { background: #efffa8; }
.reference-toggle svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; transform-box: fill-box; transform-origin: center; transition: transform .18s ease; }
.reference-panel.is-collapsed .reference-toggle { margin-left: 0; }
.reference-panel.is-collapsed .reference-toggle svg { transform: rotate(180deg); }
.reference-sticky { position: sticky; top: 88px; }

.calculator-popover { position: absolute; z-index: 30; top: calc(100% + 10px); right: 0; width: min(320px, calc(100vw - 32px)); padding: 12px; border: 1px solid var(--cyan); box-shadow: 7px 7px 0 rgba(0,0,0,.28); color: #dce8e4; background: #10272b; }
.calculator-popover[hidden] { display: none; }
.calculator-popover-heading { display: flex; align-items: center; justify-content: space-between; color: #a6b8b5; font-family: "Cascadia Code", Consolas, monospace; font-size: .7rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.calculator-popover-heading button { width: 28px; height: 28px; border: 1px solid rgba(255,255,255,.25); color: #c6d3d0; background: transparent; cursor: pointer; font-size: 1.15rem; line-height: 1; }
.calculator-popover-heading button:hover { color: var(--night); border-color: var(--acid); background: var(--acid); }
.calculator-popover input { width: 100%; min-width: 0; height: 52px; margin-top: 11px; padding: 0 12px; border: 1px solid rgba(87,217,219,.55); color: #f7fbf8; background: #071b21; font-family: "Cascadia Code", Consolas, monospace; font-size: 1.05rem; text-align: right; }
.calculator-popover input:focus-visible { outline-color: var(--acid); }
.calculator-result { display: block; width: 100%; min-height: 22px; border: 0; background: transparent; cursor: default; padding: 7px 2px 2px; color: var(--acid); font-family: "Cascadia Code", Consolas, monospace; font-size: .83rem; font-variant-numeric: tabular-nums; text-align: right; }
.calculator-result.is-error { color: #ff9e75; }
.calculator-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 5px; }
.calculator-pad button { min-height: 39px; border: 1px solid rgba(255,255,255,.2); color: #e5efec; background: #17343a; cursor: pointer; font-family: "Cascadia Code", Consolas, monospace; font-size: .9rem; font-weight: 700; }
.calculator-pad button:hover { border-color: var(--cyan); background: #255057; }
.calculator-pad button:nth-child(4n), .calculator-pad button:nth-child(-n+2) { color: var(--cyan); background: #0b2126; }
.calculator-pad .calculator-equals { color: var(--night); border-color: var(--cyan); background: var(--cyan); }
.calculator-pad .calculator-equals:hover { border-color: var(--acid); background: var(--acid); }

.saved-work-drawer { position: fixed; z-index: 40; top: 0; left: 0; width: min(400px, calc(100vw - 28px)); height: 100dvh; padding: 22px; overflow-y: auto; border-right: 1px solid rgba(87,217,219,.7); box-shadow: 12px 0 0 rgba(0,0,0,.18); color: #dce8e4; background: #0b2126; }
.saved-work-drawer[hidden] { display: none; }
.saved-work-drawer-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.14); }
.saved-work-drawer-heading .eyebrow { color: var(--cyan); }
.saved-work-drawer-heading h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 1.7rem; }
.saved-work-drawer-heading button { width: 32px; height: 32px; border: 1px solid rgba(255,255,255,.25); color: #dce8e4; background: transparent; cursor: pointer; font-size: 1.3rem; }
.saved-work-drawer-heading button:hover { color: var(--night); border-color: var(--acid); background: var(--acid); }
.saved-work-intro { margin: 15px 0 11px; color: #a7bbb7; font-size: .82rem; line-height: 1.5; }
.saved-work-search { position: relative; display: block; }
.saved-work-search svg { position: absolute; top: 50%; left: 13px; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--cyan); stroke-width: 1.8; pointer-events: none; }
.saved-work-search input { width: 100%; height: 46px; padding: 0 38px; border: 1px solid rgba(87,217,219,.48); border-radius: 0; outline: 0; color: #f3f8f5; background: #071b21; font-family: "Cascadia Code", Consolas, monospace; font-size: .78rem; }
.saved-work-search input::placeholder { color: #76918d; }
.saved-work-search input:focus { border-color: var(--acid); box-shadow: inset 4px 0 0 var(--acid); }
.saved-work-count { min-height: 16px; margin: 9px 0 12px; color: var(--cyan); font-family: "Cascadia Code", Consolas, monospace; font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.saved-work-list { display: grid; gap: 9px; }
.saved-work-item { width: 100%; padding: 13px; border: 1px solid rgba(255,255,255,.17); color: inherit; background: #102d33; cursor: pointer; text-align: left; }
.saved-work-item:hover { border-color: var(--cyan); background: #163b42; }
.saved-work-item strong, .saved-work-item small, .saved-work-item .saved-work-preview { display: block; }
.saved-work-item strong { display: -webkit-box; overflow: hidden; color: #f3f8f5; font-family: "Cascadia Code", Consolas, monospace; font-size: .78rem; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.saved-work-item .saved-work-preview { margin-top: 8px; padding-top: 8px; overflow: hidden; border-top: 1px solid rgba(255,255,255,.1); color: var(--acid); font-family: "Cascadia Code", Consolas, monospace; font-size: .72rem; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.saved-work-item .saved-work-preview::before { content: "LAST  "; color: #78918d; font-size: .58rem; font-weight: 800; letter-spacing: .08em; }
.saved-work-item small { margin-top: 7px; color: var(--cyan); font-family: "Cascadia Code", Consolas, monospace; font-size: .64rem; letter-spacing: .07em; text-transform: uppercase; }
.saved-work-empty { padding: 18px 0; color: #93aaa5; font-family: "Cascadia Code", Consolas, monospace; font-size: .78rem; }

.reference-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid rgba(255,255,255,.2); }
.reference-tabs button {
  min-height: 44px;
  border: 0;
  color: #b9c8c4;
  background: transparent;
  cursor: pointer;
  font-weight: 700;
}
.reference-tabs button + button { border-left: 1px solid rgba(255,255,255,.2); }
.reference-tabs button[aria-selected="true"] { color: var(--night); background: var(--cyan); }
.reference-tabs kbd { margin-left: 4px; }

.course-guide { display: grid; gap: 8px; padding-top: 2px; }
.course-guide details { border: 1px solid rgba(125,218,219,.35); background: rgba(255,255,255,.035); }
.course-guide summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; color: #f3f8f5; cursor: pointer; font-family: "Cascadia Code", Consolas, monospace; font-size: .76rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.course-guide summary::after { content: "+"; color: var(--acid); font-size: 1rem; }
.course-guide details[open] summary { color: var(--cyan); border-bottom: 1px solid rgba(125,218,219,.25); }
.course-guide details[open] summary::after { content: "−"; }
.course-guide summary::-webkit-details-marker { display: none; }
.guide-content { display: grid; gap: 10px; padding: 12px; color: #c8d8d4; font-size: .8rem; line-height: 1.45; }
.guide-content p { margin: 0; }
.guide-content strong { color: #fffdf5; }
.guide-content code { padding: 2px 4px; color: var(--acid); background: rgba(0,0,0,.24); font-family: "Cascadia Code", Consolas, monospace; font-size: .76rem; }
.guide-formula { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.guide-formula > div { padding: 8px; border-left: 2px solid var(--cyan); background: rgba(0,0,0,.16); }
.guide-formula span { display: block; color: #8ca5a0; font-family: "Cascadia Code", Consolas, monospace; font-size: .62rem; letter-spacing: .05em; text-transform: uppercase; }
.guide-formula strong { display: block; margin-top: 3px; color: #fffdf5; font-family: "Cascadia Code", Consolas, monospace; font-size: .78rem; }
.guide-list { display: grid; gap: 5px; margin: 0; padding-left: 18px; }
.guide-list li::marker { color: var(--acid); }
.guide-prefixes { display: flex; flex-wrap: wrap; gap: 5px; }
.guide-prefixes span { padding: 4px 6px; border: 1px solid rgba(125,218,219,.28); color: #dce8e4; font-family: "Cascadia Code", Consolas, monospace; font-size: .67rem; }

.search-field {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 8px 0 12px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255,255,255,.3);
}
.search-field svg { width: 18px; fill: none; stroke: #86a09e; stroke-width: 1.8; }
.search-field input { width: 100%; min-height: 40px; border: 0; outline: 0; color: #fff; background: transparent; }
.search-field input::placeholder { color: #718a89; }
.search-field kbd { color: #8fa3a0; }

.element-detail {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}
.element-tile-preview {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr auto;
  width: 64px;
  height: 64px;
  padding: 6px;
  border: 0;
  color: var(--night);
  background: var(--acid);
  font: inherit;
  text-align: left;
  cursor: copy;
}
.element-tile-preview strong { grid-column: 1 / 3; align-self: center; font-family: Georgia, serif; font-size: 1.65rem; line-height: 1; }
.element-tile-preview small { grid-column: 1 / 3; font-size: .58rem; }
.detail-kicker { margin: 0 0 4px; color: #7f9896; font-family: "Cascadia Code", Consolas, monospace; font-size: .63rem; text-transform: uppercase; letter-spacing: .12em; }
.element-detail h3 { font-family: Georgia, serif; font-size: 1.4rem; font-weight: 500; }
.element-detail p:last-child { margin: 5px 0 0; color: #94aaa8; font-size: .8rem; }

.periodic-wrap { width: 100%; overflow: visible; padding-bottom: 5px; }
.periodic-table {
  position: relative;
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  grid-template-rows: 12px repeat(7, 31px) 5px repeat(2, 31px);
  gap: 2px;
  width: 100%;
  min-width: 0;
}
.group-label {
  align-self: end;
  color: #698481;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: clamp(.32rem, .45vw, .45rem);
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.metalloid-staircase {
  position: absolute;
  z-index: 4;
  inset: 14px 0 auto;
  width: 100%;
  height: 229px;
  overflow: visible;
  pointer-events: none;
}
.metalloid-staircase path {
  fill: none;
  stroke: var(--orange);
  stroke-width: 2.5;
  stroke-linecap: square;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
}
.element-cell {
  position: relative;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.15);
  color: #ebf5f0;
  background: rgba(255,255,255,.05);
  cursor: pointer;
  font-family: "Cascadia Code", Consolas, monospace;
  min-width: 0;
  padding: 0;
  font-size: clamp(.46rem, .72vw, .62rem);
  transition: transform .15s ease, color .15s ease, background .15s ease;
}
.element-cell:hover, .element-cell:focus { z-index: 2; transform: scale(1.55); color: var(--night); background: var(--acid); }
.element-cell.is-match { color: var(--night); background: var(--cyan); }
.element-cell.is-dimmed { opacity: .15; }
.element-cell::before { content: attr(data-number); position: absolute; left: 2px; top: 1px; font-size: .38rem; opacity: .7; font-variant-numeric: tabular-nums; }
.element-cell.cat-noble { border-color: rgba(216,255,79,.65); }
.element-cell.cat-alkali { border-color: rgba(255,139,75,.75); }
.element-cell.cat-transition { border-color: rgba(87,217,219,.55); }
.element-cell.cat-nonmetal { background: rgba(216,255,79,.09); }
.element-cell.cat-metalloid { color: #fff3e9; background: rgba(255,139,75,.18); border-color: var(--orange); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 13px; margin-top: 10px; color: #819997; font-size: .63rem; }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border: 1px solid rgba(255,255,255,.4); }
.legend .cat-nonmetal { background: rgba(216,255,79,.4); }
.legend .cat-noble { border-color: var(--acid); }
.legend .cat-alkali { border-color: var(--orange); }
.legend .cat-transition { border-color: var(--cyan); }
.legend .cat-metalloid { border-color: var(--orange); background: rgba(255,139,75,.25); }
.legend .stair-key { width: 12px; height: 7px; border: 0; border-left: 2px solid var(--orange); border-bottom: 2px solid var(--orange); }

.element-search-results { display: none; gap: 6px; }
.element-search-results.is-visible { display: grid; }
.element-search-results button, .ion-row {
  width: 100%;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.12);
  color: #ecf5f0;
  background: rgba(255,255,255,.035);
  text-align: left;
}
.element-search-results button { cursor: pointer; }
.element-search-results strong { color: var(--acid); font-family: Georgia, serif; font-size: 1.1rem; }
.element-search-results small, .ion-row small { color: #809895; }

.ions-list { display: grid; gap: 6px; }
.ion-row { grid-template-columns: minmax(70px, .65fr) 1fr auto; }
.ion-formula { color: var(--acid); font-family: Georgia, serif; font-size: 1.12rem; }
.ion-name { font-size: .82rem; }
.ion-charge { color: var(--cyan); font-family: "Cascadia Code", Consolas, monospace; font-size: .73rem; }

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 25px;
  padding: 11px 16px;
  color: var(--night);
  background: var(--acid);
  border: 2px solid var(--night);
  box-shadow: 4px 4px 0 #fff;
  font-weight: 750;
  transform: translate(-50%, 160%);
  transition: transform .24s ease;
}
.toast.is-visible { transform: translate(-50%, 0); }

dialog {
  width: min(560px, calc(100% - 30px));
  max-width: calc(100vw - 30px);
  box-sizing: border-box;
  padding: 0;
  border: 2px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
  box-shadow: 12px 12px 0 var(--acid);
  overscroll-behavior: contain;
}
dialog::backdrop { background: rgba(3,15,18,.82); }
dialog form { padding: 28px; }
.paste-question-form { display: grid; gap: 15px; }
.cloud-sync-form { display: grid; gap: 13px; }
.cloud-sync-form > p { margin: 0; color: var(--muted); line-height: 1.45; }
.cloud-sync-form label { display: grid; gap: 4px; color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .76rem; }
.cloud-sync-form label span { color: #8a5f32; font-size: .65rem; }
.cloud-sync-form textarea { width: 100%; min-height: 64px; resize: vertical; padding: 10px; border: 1px solid var(--ink); color: var(--ink); background: #fffdf5; font-family: "Cascadia Code", Consolas, monospace; font-size: .73rem; line-height: 1.4; }
.cloud-sync-form textarea:focus-visible { outline: 3px solid var(--acid); outline-offset: 2px; }
.cloud-sync-form #cloud-sync-code { color: #087478; background: #f5f1e4; }
.paste-question-form .dialog-heading { margin-bottom: 4px; }
.paste-question-form label { color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .78rem; }
.paste-question-form textarea { width: 100%; min-height: 82px; resize: vertical; padding: 12px; border: 1px solid var(--ink); color: var(--ink); background: #fffdf5; font-family: "Cascadia Code", Consolas, monospace; font-size: .95rem; line-height: 1.45; }
.paste-question-form textarea:focus-visible { outline: 3px solid var(--acid); outline-offset: 2px; }
.paste-question-form .dialog-note { margin: 0; }
.build-question-button { min-height: 44px; border: 1px solid var(--ink); color: var(--night); background: var(--cyan); cursor: pointer; font-weight: 800; }
.build-question-button:hover { background: var(--acid); }
.dialog-heading h2 { font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.close-button { width: 40px; height: 40px; background: transparent; font-size: 1.8rem; }
.shortcut-list { margin: 25px 0 0; }
.shortcut-list > div { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.shortcut-list dt, .shortcut-list dd { margin: 0; }
.shortcut-list dd { color: var(--muted); }
.dialog-note { margin: 22px 0 0; padding: 14px; background: var(--paper-deep); }
.confirm-dialog { width: min(470px, calc(100% - 30px)); box-shadow: 10px 10px 0 var(--cyan); }
.confirm-dialog form { padding: 26px; }
.confirm-dialog .eyebrow { margin: 0 0 8px; color: #087478; }
.confirm-dialog h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(1.65rem, 5vw, 2rem); font-weight: 500; line-height: 1.05; }
.confirm-dialog #confirm-dialog-copy { margin: 12px 0 0; color: var(--muted); line-height: 1.5; }
.confirm-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.confirm-dialog-actions button { min-height: 44px; padding: 10px 16px; border: 1px solid var(--ink); cursor: pointer; font-weight: 800; }
.confirm-cancel-button { color: var(--ink); background: transparent; }
.confirm-action-button { color: #fff; background: #9b2f2f; }
.confirm-action-button:hover { background: #7e2020; }

@media (max-width: 420px) {
  .confirm-dialog { width: calc(100% - 48px); max-width: calc(100% - 48px) !important; box-shadow: 6px 6px 0 var(--cyan); }
  .confirm-dialog form { padding: 22px 20px; }
  .confirm-dialog-actions { display: grid; grid-template-columns: 1fr; }
  .confirm-dialog-actions button { width: 100%; }
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: minmax(0, 1.25fr) minmax(350px, .75fr); }
  .workspace { padding: 44px 34px; }
  .reference-panel { padding-inline: 20px; }
  .reference-toggle { margin-left: -38px; }
  .tagline { display: none; }
}

@media (min-width: 821px) {
  html, body { height: 100%; overflow: hidden; }
  .topbar { position: relative; }
  .app-shell { height: calc(100dvh - 72px); min-height: 0; }
  .workspace, .reference-panel {
    height: 100%;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
  }
  .reference-sticky { position: static; }
  .reference-toggle { top: 16px; margin-left: 0; transform: none; }
  .reference-sticky > .reference-tabs { margin-left: 44px; }
  .reference-panel.is-collapsed .reference-toggle { margin-left: 7px; }
}

@media (max-width: 820px) {
  .topbar { padding: 0 16px; grid-template-columns: 1fr auto; }
  .quiet-button { display: none; }
  .calculator-toggle, .saved-work-toggle, .cloud-sync-toggle { display: block; }
  .header-actions { gap: 5px; }
  .export-all-button kbd { display: none; }
  .app-shell { display: block; }
  .app-shell.reference-collapsed { display: block; }
  .workspace { min-height: auto; padding: 38px 20px 52px 28px; }
  .reference-panel { border-left: 0; border-top: 1px solid rgba(255,255,255,.15); padding: 20px 20px 50px; }
  .reference-panel.is-collapsed { min-height: 58px; padding: 11px 20px; }
  .reference-toggle,
  .reference-panel.is-collapsed .reference-toggle { top: 75px; margin: 0 0 -36px auto; transform: none; }
  .reference-sticky { position: static; }
  .calculator-popover { position: fixed; top: 76px; right: 16px; }
  .saved-work-drawer { width: min(340px, calc(100vw - 20px)); padding: 18px; }
  .ions-list { max-height: none; }
}

@media (max-width: 560px) {
  .topbar { height: 62px; }
  .app-shell { min-height: calc(100vh - 62px); }
  .brand { font-size: .88rem; }
  .export-all-button { min-height: 36px; padding: 0 10px; font-size: .75rem; }
  .calculator-toggle { min-width: 38px; padding-inline: 9px; font-size: 0; }
  .calculator-toggle::before { content: "CALC"; font-family: "Cascadia Code", Consolas, monospace; font-size: .65rem; font-weight: 800; }
  .calculator-toggle kbd { display: none; }
  .saved-work-toggle { min-width: 38px; padding-inline: 9px; font-size: 0; }
  .saved-work-toggle::before { content: "NOTES"; font-family: "Cascadia Code", Consolas, monospace; font-size: .65rem; font-weight: 800; }
  .cloud-sync-toggle { min-width: 38px; padding-inline: 9px; font-size: 0; }
  .cloud-sync-toggle::before { content: "SYNC"; font-family: "Cascadia Code", Consolas, monospace; font-size: .65rem; font-weight: 800; }
  .workspace { padding: 30px 15px 48px 23px; background-image: linear-gradient(90deg, transparent 16px, rgba(239,93,93,.2) 17px, transparent 18px), repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(16,39,43,.055) 32px); }
  .workspace-heading { display: block; }
  .clear-button { margin-top: 10px; }
  h1 { font-size: 2.5rem; }
  .composer-wrap { margin-top: 30px; box-shadow: 5px 5px 0 var(--ink); }
  #command-input { min-height: 210px; padding: 14px 14px 20px; font-size: 1rem; }
  .notepad-toolbar { grid-template-columns: auto 1fr; gap: 7px; padding: 24px 7px 7px; }
  .notepad-toolbar { grid-template-columns: 1fr; }
  .draft-status { grid-column: 1; justify-self: end; }
  .notepad-actions { grid-column: 1; }
  .notepad-actions { grid-column: 1 / 3; display: grid; grid-template-columns: repeat(2, 1fr); }
  .notation-tools { flex-wrap: wrap; }
  .paste-question-button { flex: 1 0 auto; }
  .paste-question-button kbd { display: none; }
  .next-step-button, .save-note-button { padding-inline: 6px; }
  .work-step { grid-template-columns: 54px minmax(0, 1fr); }
  .work-step-content { padding-left: 14px; padding-right: 14px; padding-top: 48px; }
  .work-step-actions { top: 8px; right: 8px; }
  .examples { display: block; margin-top: 54px; }
  .command-list { margin-top: 20px; }
  .command-list > div { grid-template-columns: 76px 1fr; gap: 8px; font-size: .7rem; }
  .result-content { padding: 22px 16px; }
  .result-meta { grid-template-columns: auto 1fr; }
  .result-meta time { display: none; }
  .factor-chain { gap: 9px; }
  .factor { min-width: 82px; font-size: .94rem; }
  .periodic-table { grid-template-rows: 10px repeat(7, 25px) 4px repeat(2, 25px); gap: 1px; }
  .metalloid-staircase { top: 11px; height: 181px; }
  .element-cell { font-size: .43rem; }
  .element-cell::before { display: none; }
  .element-search-results.is-visible { display: grid; }
  .legend { gap: 7px 10px; }
  .element-detail { grid-template-columns: 66px 1fr; }
  .element-tile-preview { width: 66px; height: 66px; }
  .reference-tabs kbd { display: none; }
  .reference-tabs button { padding-inline: 4px; font-size: .74rem; }
  .guide-formula { grid-template-columns: 1fr; }
  .shortcut-list > div { grid-template-columns: 1fr; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Below ~380px the header buttons no longer fit beside the wordmark, so the
   export action collapses to a chip like the others and the brand steps down. */
@media (max-width: 380px) {
  .topbar { padding: 0 10px; gap: 10px; }
  .brand { font-size: .72rem; letter-spacing: .02em; }
  .brand-mark { height: 18px; }
  .header-actions { gap: 4px; }
  .export-all-button { min-width: 42px; padding-inline: 8px; font-size: 0; }
  .export-all-button::before { content: "PNG"; font-family: "Cascadia Code", Consolas, monospace; font-size: .65rem; font-weight: 800; letter-spacing: .03em; }
}

.prefix-intro { margin: 0 0 9px; color: #5c6b68; font-size: .78rem; }
.prefix-table { display: flex; flex-direction: column; border: 1px solid var(--line); border-bottom: 0; }
.prefix-row {
  display: grid;
  grid-template-columns: 72px 1fr 54px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: #fffdf5;
  cursor: pointer;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: .78rem;
  text-align: left;
}
.prefix-row:nth-child(even) { background: #f7f3e6; }
.prefix-row:hover, .prefix-row:focus-visible { color: var(--night); background: var(--cyan); }
.prefix-row.is-base { color: #7d8a87; cursor: default; font-style: italic; }
.prefix-row.is-base:hover { color: #7d8a87; background: #f0ebdc; }
.prefix-power { font-variant-numeric: tabular-nums; }
.prefix-power sup { font-size: .68em; }
.prefix-name { font-weight: 700; }
.prefix-symbol { font-weight: 800; text-align: right; }
.prefix-empty { padding: 10px; color: #5c6b68; font-size: .8rem; }

/* 2026-09-25: click-to-copy on the element tile and the calculator answer */
.element-tile-preview:hover { box-shadow: 0 0 0 2px var(--cyan); }
.element-tile-preview:active { transform: translateY(1px); }
.calculator-result[data-value]:not([data-value=""]) { cursor: copy; }
.calculator-result[data-value]:not([data-value=""]):hover { text-decoration: underline; text-underline-offset: 3px; }
.calculator-popover.is-floating { position: fixed; right: auto; }
.calculator-popover-heading { cursor: grab; touch-action: none; user-select: none; }
.calculator-popover-heading:active { cursor: grabbing; }
.calculator-popover-heading button { cursor: pointer; }
/* 2026-09-25: bigger tile so the mass clears the bottom edge and the ion charge fits top-right */
.element-detail { grid-template-columns: 78px 1fr; }
.element-tile-preview { width: 78px; height: 78px; padding: 7px 8px 9px; column-gap: 4px; }
.element-tile-preview span { font-size: .78rem; line-height: 1; }
.element-tile-preview .tile-charge { grid-column: 2; grid-row: 1; justify-self: end; font-style: normal; font-size: .64rem; font-weight: 700; line-height: 1; white-space: nowrap; }
.element-tile-preview strong { font-size: 1.8rem; }
.element-tile-preview small { font-size: .62rem; line-height: 1; }
.element-detail .nowrap { white-space: nowrap; }

/* Steps open in the main editor: tools in the step heading, clickable step cards. */
.active-step-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
#active-step-number { white-space: nowrap; }
.active-step-tools { display: flex; align-items: center; gap: 5px; }
.step-tool-button { min-height: 24px; padding: 0 8px; border: 1px solid rgba(16,39,43,.35); color: #087478; background: #fffdf5; cursor: pointer; font-family: "Cascadia Code", Consolas, monospace; font-size: .6rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.step-tool-button:hover { color: var(--night); border-color: var(--cyan); background: var(--cyan); }
.step-tool-button[hidden] { display: none; }
.step-delete-button { color: #9e4a30; }
.step-delete-button:hover { color: #fffdf5; border-color: #9e4a30; background: #9e4a30; }
.active-work-step.is-earlier { box-shadow: inset 4px 0 0 #087478; }
.active-work-step.is-earlier .active-step-heading { background: rgba(87,217,219,.18); }
.work-step-content { cursor: text; }
.work-step-content:hover { background: rgba(87,217,219,.08); }
.work-step-number small { display: block; margin-top: 4px; color: #60716f; font-size: .56rem; letter-spacing: .06em; }
.work-step-empty { color: #8c9892; font-style: italic; }
@media (min-width: 821px) {
  /* Keep the writing tools in reach while editing a step further down the page. */
  .notepad-toolbar { position: sticky; top: 0; z-index: 6; }
}
@media (max-width: 560px) {
  .active-step-heading { gap: 8px; }
  .step-tool-button { padding: 0 6px; }
  .active-step-heading { padding-inline: 10px; }
  .active-work-step.is-earlier #active-step-state { display: none; }
}

/* 2026-10-17: Lewis dot diagrams - toolbar button, the inline diagram, Lewis mode (replaces the writing area; the reference shelf stays open) */
.lewis-icon { width: 22px; height: 22px; fill: currentColor; }
.lewis-diagram { display: inline-block; max-width: 100%; margin: 3px 4px; vertical-align: middle; line-height: 0; cursor: pointer; }
.lewis-diagram img { display: block; max-width: 100%; height: auto; }
/* The student's formula under the diagram (NH4+ -> NH₄⁺). */
.lewis-caption { display: block; margin-top: 2px; color: var(--ink); font-family: Georgia, serif; font-size: .9rem; line-height: 1.25; text-align: center; white-space: nowrap; }
.lewis-caption sub, .lewis-caption sup { color: inherit; font-weight: 400; font-size: .72em; }
.lewis-formula { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-bottom: 10px; color: #087478; font-family: "Cascadia Code", Consolas, monospace; font-size: .64rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.lewis-formula input { min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--ink); color: var(--ink); background: #fffdf5; font-family: Georgia, serif; font-size: 1rem; letter-spacing: 0; text-transform: none; }
.lewis-formula input:focus-visible { outline: 3px solid var(--acid); outline-offset: 1px; }
.lewis-formula output { min-width: 3ch; color: var(--ink); font-family: Georgia, serif; font-size: 1.25rem; font-weight: 400; letter-spacing: 0; text-transform: none; white-space: nowrap; }
.lewis-formula output sub, .lewis-formula output sup { font-size: .68em; }
.notepad-editor .lewis-diagram:hover, .work-step-content .lewis-diagram:hover { outline: 2px solid var(--cyan); outline-offset: 2px; }
.notepad-editor .lewis-diagram:focus-visible { outline: 3px solid var(--acid); }

.composer-wrap.is-lewis-mode > .mode-badge,
.composer-wrap.is-lewis-mode > .notepad-toolbar,
.composer-wrap.is-lewis-mode > .active-work-step,
.composer-wrap.is-lewis-mode .work-step-actions { display: none; }
.composer-wrap.is-lewis-mode .work-step-content { cursor: default; }
.composer-wrap.is-lewis-mode .work-step-content:hover { background: transparent; }
.lewis-mode { container-type: inline-size; display: grid; gap: 16px; padding: 22px 24px 24px; background: #fbf8ef; }
#work-steps:not(:empty) ~ .lewis-mode { border-top: 2px solid var(--ink); }
.lewis-mode[hidden] { display: none; }
.lewis-mode { scroll-margin-top: 84px; }
.lewis-mode-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.lewis-mode-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 1.6rem; font-weight: 500; line-height: 1.1; }
.lewis-mode-heading .eyebrow { margin-bottom: 6px; color: #087478; }
.lewis-back { min-height: 34px; padding: 0 12px; }
.lewis-table-tip { margin: 0; color: var(--muted); font-size: .74rem; }
.lewis-layout { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 18px; align-items: start; }
.lewis-canvas { min-width: 0; }
.lewis-grid { display: block; width: 100%; height: auto; border: 1px solid var(--ink); background: #fffdf5; cursor: pointer; touch-action: manipulation; }
.lewis-grid:focus-visible { outline: 3px solid var(--acid); outline-offset: 2px; }
.lewis-cell-line { stroke: rgba(16,39,43,.1); stroke-width: 1; stroke-dasharray: 3 4; }
.lewis-cursor { fill: rgba(87,217,219,.1); stroke: #087478; stroke-width: 2; }
.lewis-zone { fill: rgba(87,217,219,.32); }
.lewis-zone.is-place { fill: rgba(216,255,79,.28); }
.lewis-ghost { fill: #087478; opacity: .45; }
.lewis-status { min-height: 2.6em; margin: 8px 0 0; color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .74rem; line-height: 1.35; }
.lewis-panel { display: grid; gap: 12px; min-width: 0; }
.lewis-section { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.lewis-section h3 { display: flex; justify-content: space-between; gap: 8px; margin: 0; color: #087478; font-family: "Cascadia Code", Consolas, monospace; font-size: .64rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.lewis-section h3 strong { color: var(--ink); letter-spacing: .02em; text-transform: none; font-size: .72rem; }
.lewis-elements { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.lewis-elements button { min-height: 34px; padding: 0; border: 1px solid rgba(16,39,43,.28); color: var(--ink); background: #fffdf5; cursor: pointer; font-family: Georgia, serif; font-size: 1rem; }
.lewis-elements button:hover { border-color: var(--ink); }
.lewis-elements button[aria-pressed="true"] { color: var(--night); border-color: var(--ink); background: var(--cyan); font-weight: 700; }
.lewis-other { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .7rem; }
.lewis-other input { width: 64px; height: 32px; padding: 0 8px; border: 1px solid var(--ink); color: var(--ink); background: #fffdf5; font-family: Georgia, serif; font-size: 1rem; text-align: center; }
.lewis-other input:focus-visible { outline: 3px solid var(--acid); outline-offset: 1px; }
.lewis-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink); font-size: .84rem; }
.lewis-row-buttons { justify-content: stretch; }
.lewis-row-buttons > button { flex: 1 1 0; }
.lewis-stepper { display: inline-grid; grid-template-columns: 32px 44px 32px; border: 1px solid var(--ink); background: #fffdf5; }
.lewis-stepper button { height: 30px; border: 0; color: #087478; background: transparent; cursor: pointer; font-size: 1.05rem; font-weight: 800; }
.lewis-stepper button:hover:not(:disabled) { color: var(--night); background: var(--cyan); }
.lewis-stepper output { display: grid; place-items: center; border-inline: 1px solid var(--line); font-family: Georgia, serif; font-size: .95rem; }
.lewis-chip-button { min-height: 32px; padding: 0 8px; border: 1px solid rgba(16,39,43,.35); color: #087478; background: #fffdf5; cursor: pointer; font-family: "Cascadia Code", Consolas, monospace; font-size: .62rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.lewis-chip-button:hover:not(:disabled), .lewis-chip-button[aria-pressed="true"] { color: var(--night); border-color: var(--ink); background: var(--cyan); }
.lewis-remove { color: #9e4a30; }
.lewis-remove:hover:not(:disabled) { color: #fffdf5; border-color: #9e4a30; background: #9e4a30; }
.lewis-mode button:disabled { opacity: .4; cursor: default; }
.lewis-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.lewis-keys { margin: 0; color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: .66rem; line-height: 1.6; }
.lewis-keys kbd { padding: 0 3px; border: 1px solid rgba(16,39,43,.3); border-radius: 2px; font-size: .62rem; }
.lewis-insert { flex: 0 0 auto; min-width: 170px; padding: 0 18px; }

@container (max-width: 640px) {
  .lewis-layout { grid-template-columns: 1fr; }
  .lewis-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
  .lewis-panel > .lewis-section:first-child { grid-column: 1 / -1; }
  .lewis-elements { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .lewis-keys { display: none; }
  .lewis-footer { justify-content: stretch; }
  .lewis-insert { flex: 1 1 auto; }
  /* Stacked, the panel is taller than the screen: keep Add in reach while scrolling. */
  .lewis-footer { position: sticky; bottom: 0; z-index: 2; margin: 0 -24px -24px; padding: 12px 24px 16px; background: #fbf8ef; box-shadow: 0 -1px 0 var(--line); }
}
@media (max-width: 560px) {
  .lewis-mode { gap: 12px; padding: 16px 12px 14px; }
  .lewis-mode-heading h2 { font-size: 1.3rem; }
  .lewis-status { min-height: 2.7em; font-size: .68rem; }
  .lewis-panel { grid-template-columns: 1fr 1fr; }
  .lewis-section { padding-bottom: 10px; }
  .lewis-panel > .lewis-section:nth-child(2) { grid-column: 1 / -1; }
  .lewis-stepper { grid-template-columns: 34px 36px 34px; }
  .lewis-row { font-size: .78rem; }
  /* Keep the one action that matters in reach while scrolling the panel. */
  .lewis-footer { position: sticky; bottom: 0; z-index: 2; margin: 0 -12px -14px; padding: 10px 12px 12px; background: #fbf8ef; }
}

/* 2026-10-17: typed bond directions for the selected atom (no presets, by design) */
.lewis-bond-angles { display: grid; gap: 6px; }
.lewis-bond-angles[hidden] { display: none; }
.lewis-angle-key { margin: 2px 0 0; color: var(--muted); font-size: .72rem; }
.lewis-angle-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px auto; align-items: center; gap: 6px; color: var(--ink); font-family: Georgia, serif; font-size: .95rem; }
.lewis-angle-row input { width: 100%; height: 30px; padding: 0 8px; border: 1px solid var(--ink); color: var(--ink); background: #fffdf5; font-family: "Cascadia Code", Consolas, monospace; font-size: .85rem; text-align: right; }
.lewis-angle-row input:focus-visible { outline: 3px solid var(--acid); outline-offset: 1px; }
.lewis-angle-row b { font-weight: 400; }
