:root {
  --paper:#f0f5f6; --white:#fff; --ink:#19363e; --muted:#536e76;
  --cyan:#087d8a; --line:#cedfe2; --wash:#e0f1f2;
  font-family:"Segoe UI Variable","Segoe UI",Arial,sans-serif;
  color:var(--ink); background:var(--paper); font-synthesis:none; color-scheme:light;
}
* { box-sizing:border-box; }
body { margin:0; min-width:320px; }
button,input { font:inherit; }
button { cursor:pointer; border:0; border-radius:8px; padding:11px 18px; font-weight:600; }
button:hover { filter:brightness(.96); }
button:disabled { cursor:not-allowed; opacity:.45; }
button:focus-visible,a:focus-visible,input:focus-visible,.periodic-scroll:focus-visible { outline:3px solid var(--cyan); outline-offset:3px; }
.primary { color:white; background:var(--cyan); }
.secondary { color:var(--cyan); background:var(--wash); }
[hidden] { display:none!important; }
.workspace { width:min(1080px,calc(100% - 64px)); min-height:100svh; margin:auto; padding-bottom:42px; }
.header { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:34px 0 27px; border-bottom:1px solid var(--line); }
.wordmark { color:var(--ink); font-family:"Bahnschrift","Arial Narrow",sans-serif; font-size:38px; font-weight:700; letter-spacing:-2px; text-decoration:none; }
.wordmark>span { font-weight:400; }
.wordmark .brand-dot { color:var(--cyan); font-weight:700; }
.subtitle { margin:2px 0 0; color:var(--muted); font:11px/1.2 Consolas,monospace; letter-spacing:1.7px; }
.intro { padding:0 0 20px; }
.intro h1 { margin:0 0 5px; font-size:20px; font-weight:600; }
.intro p { margin:0; color:var(--muted); font-size:12px; }
.dialog-help { margin:0; color:var(--muted); font-size:14px; line-height:1.8; }
.tabs { display:flex; gap:22px; margin-top:22px; margin-bottom:28px; border-bottom:1px solid var(--line); }
.tabs button { padding:13px 0; border-bottom:3px solid transparent; border-radius:0; color:var(--muted); background:none; }
.tabs button[aria-current] { border-color:var(--cyan); color:var(--cyan); }
.tabs span { margin-left:6px; padding:2px 7px; border-radius:4px; background:var(--wash); font:12px Consolas,monospace; }
.empty-state { padding:38px 20px 52px; border:1px dashed #9ebbc0; border-radius:12px; background:var(--white); text-align:center; }
.sample { display:flex; align-items:center; justify-content:center; gap:16px; margin:0 0 22px; }
.sample>span { display:flex; width:88px; height:96px; flex-direction:column; justify-content:center; border:1px solid var(--line); border-radius:8px; color:var(--cyan); background:var(--paper); font:36px Consolas,monospace; }
.sample small { margin-top:8px; color:var(--muted); font-size:11px; }
.sample b { color:#9ebbc0; font-size:24px; font-weight:400; }
.empty-state h2 { margin:0 0 24px; font-size:20px; font-weight:600; }
.history-list { display:grid; gap:22px; }
.recipe-card { overflow:hidden; padding:26px 30px; border:1px solid var(--line); border-radius:12px; background:var(--white); }
.recipe-heading { display:flex; align-items:start; justify-content:space-between; gap:20px; margin-bottom:20px; }
.formula { display:flex; min-width:0; flex-wrap:wrap; gap:4px 12px; margin:0; overflow-wrap:anywhere; font:500 26px Consolas,"Courier New",monospace; }
.formula-part { max-width:100%; }
.formula sub { margin-left:2px; color:var(--cyan); font-size:13px; }
.recipe-number { margin-top:8px; color:var(--muted); font-size:12px; white-space:nowrap; }
.mass-row { display:grid; grid-template-columns:70px minmax(0,1fr) minmax(120px,1.2fr); align-items:center; gap:18px; padding:10px 12px; border-bottom:1px solid #e4edef; }
.table-header { padding-top:0; padding-bottom:12px; color:var(--muted); font-size:12px; }
.symbol { color:var(--cyan); font:19px Consolas,monospace; }
.ratio-value { overflow-wrap:anywhere; font:14px Consolas,monospace; }
.mass-input { width:100%; min-width:0; padding:10px 12px; border:1px solid var(--line); border-radius:6px; color:var(--ink); background:#f9fbfc; font:16px Consolas,monospace; }
.mass-input::placeholder { color:var(--muted); font:13px "Segoe UI",Arial,sans-serif; }
.mass-input[readonly] { color:var(--muted); background:var(--paper); }
.source-row { background:#eef8f8; }
.source-row input { border-color:var(--cyan); background:white; }
.card-bottom { display:flex; align-items:center; justify-content:flex-end; margin-top:12px; }
.card-bottom button { flex:none; font-size:13px; }
.error { margin:12px 0 0; color:#ad2938; font-size:13px; line-height:1.6; }
.error:empty { display:none; }
input[aria-invalid=true] { border-color:#ad2938; }
.section-heading { display:flex; align-items:end; justify-content:space-between; gap:24px; margin-bottom:20px; }
.section-heading h2 { margin:0 0 5px; font-size:20px; }
.section-heading p { margin:0; color:var(--muted); font-size:12px; }
.legend { display:flex; flex-wrap:wrap; gap:16px; color:var(--muted); font-size:11px; }
.legend span { display:flex; align-items:center; gap:6px; }
.legend i { width:12px; height:12px; border:1px solid var(--line); border-radius:3px; background:var(--white); }
.legend .selected-key { border-color:var(--cyan); background:var(--cyan); }
.periodic-scroll { overflow-x:auto; padding:5px 5px 14px; border-radius:8px; scrollbar-color:#9ebbc0 transparent; }
.periodic-table { display:grid; grid-template-columns:repeat(18,50px); grid-template-rows:repeat(10,56px); gap:5px; width:max-content; min-width:100%; justify-content:center; }
.periodic-element { position:relative; display:grid; min-width:0; place-items:center; padding:0; border:1px solid var(--line); border-radius:5px; color:#789097; background:rgba(255,255,255,.48); }
.periodic-element small { position:absolute; top:4px; left:5px; font:8px Consolas,monospace; }
.periodic-element strong { font:600 17px Consolas,monospace; }
.periodic-element.is-metal { color:var(--cyan); background:var(--white); box-shadow:0 2px 6px rgba(25,54,62,.06); }
.periodic-element.is-metal:hover { border-color:var(--cyan); filter:none; transform:translateY(-1px); }
.periodic-element.is-selected { border-color:var(--cyan); color:white; background:var(--cyan); box-shadow:0 4px 10px rgba(8,125,138,.24); }
.periodic-element.is-selected:hover { background:#076f7a; }
.periodic-element.is-reference { pointer-events:none; opacity:.36; }
.periodic-element.series-marker { border-style:dashed; color:#8ba0a5; background:transparent; }
.periodic-element.series-marker strong { font-size:10px; }
.periodic-element.series { margin-top:7px; }
dialog { width:min(640px,calc(100% - 32px)); max-height:calc(100svh - 40px); padding:28px; border:1px solid var(--line); border-radius:16px; color:var(--ink); background:var(--white); box-shadow:0 24px 90px #19363e33; }
dialog::backdrop { background:#15363d80; }
.dialog-heading { display:flex; align-items:center; justify-content:space-between; }
.eyebrow { margin:0 0 6px; color:var(--cyan); font:11px Consolas,monospace; letter-spacing:2px; }
.dialog-heading h2 { margin:0; font-size:25px; }
.icon-button { padding:3px 12px; background:var(--paper); font-size:25px; font-weight:400; }
.dialog-help { margin:16px 0 22px; }
.ratio-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.ratio-field { display:flex; align-items:center; gap:8px; overflow:hidden; padding-left:12px; border:1px solid var(--line); border-radius:7px; background:var(--paper); }
.ratio-field span { width:26px; flex:none; color:var(--cyan); font:19px Consolas,monospace; }
.ratio-field input { width:100%; min-width:0; padding:13px 10px; border:0; border-left:1px solid var(--line); border-radius:0; color:var(--ink); background:white; font:16px Consolas,monospace; }
.ratio-field:focus-within { outline:2px solid var(--cyan); outline-offset:2px; }
.ratio-field input:focus { outline:0; }
.dialog-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:24px; }
@media(max-width:640px) {
  .workspace { width:calc(100% - 32px); padding-bottom:28px; }
  .header { padding:22px 0; }
  .wordmark { font-size:32px; }
  .header>.primary { padding:11px 13px; font-size:12px; }
  .section-heading { display:block; }
  .legend { margin-top:14px; }
  .periodic-scroll { margin-right:-16px; margin-left:-16px; padding-right:16px; padding-left:16px; border-radius:0; }
  .periodic-table { justify-content:start; }
  .recipe-card { padding:20px 12px; }
  .recipe-heading { gap:12px; padding:0 5px; }
  .formula { font-size:23px; }
  .mass-row { grid-template-columns:38px minmax(0,.85fr) minmax(110px,1.2fr); gap:9px; padding-right:5px; padding-left:5px; }
  .table-header { font-size:10px; }
  .mass-input { padding:10px 8px; }
  .ratio-value { font-size:12px; }
  .card-bottom { padding:0 5px; }
  .ratio-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  dialog { padding:22px 18px; }
  .ratio-field { padding-left:9px; }
  .ratio-field input { padding-left:8px; }
  .empty-state { padding:30px 12px; }
  .recipe-number { font-size:10px; }
}
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { transition-duration:.001ms!important; } }
