/* Mole ATM: an ATM that exchanges amounts of a substance between grams, moles and particles. Light and dark. */
html {
  --ma-body1: #23896a; --ma-body2: #165c47; --ma-line: #0f3d2e; --ma-dark: #0f2a22; --ma-slot: #4a5a54; --ma-gold: #ffd23f; --ma-green: #3ed18e; --ma-red: #ff6b5b;
  --ma-screen: #0f2a22; --ma-screen-ink: #d9fbe9; --ma-screen-dim: #8fc9ad; --ma-strike: #ff8a7a;
  --ma-ink: #10241c; --ma-panel-bg1: #f3faf6; --ma-panel-bg2: #e3f2ea; --ma-accent: #1f7a5c; --ma-ok: #13704a; --ma-bad: #b3261e;
  --ma-chip: #ffffff; --ma-chip-on: #d5efe2; --ma-paper: #fffdf6;
}
html[data-theme="dark"] {
  --ma-body1: #1d6e56; --ma-body2: #114536; --ma-line: #0a1f17;
  --ma-ink: #e2f3ea; --ma-panel-bg1: #18241f; --ma-panel-bg2: #121c18; --ma-accent: #7fd6b0; --ma-ok: #4fd08c; --ma-bad: #ff8a80;
  --ma-chip: #0f1814; --ma-chip-on: #1f3d31; --ma-paper: #f3efe2;
}
.ma { position: absolute; inset: 0; display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 12px; padding: 10px; color: var(--tlg-text); font-size: 16px; }
.ma input, .ma button { font: inherit; }
.ma-controls { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; padding: 8px 12px;
  background: linear-gradient(var(--ma-panel-bg1), var(--ma-panel-bg2)); color: var(--ma-ink); border: 3px solid var(--ma-accent); border-radius: 14px; box-shadow: 0 3px 8px rgba(0,0,0,.16); }
.ma-right { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; overflow: auto; }
.ma-kicker { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ma-accent); }
.ma-step { display: grid; gap: 4px; }
.ma-step-b { display: grid; gap: 5px; }
.ma-step-h { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 17px; line-height: 1.2; }
.ma-n { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ma-accent); color: #fff; font-size: 16px; font-weight: 800; }
html[data-theme="dark"] .ma-n { color: #0c1f17; }
.ma-step.is-done .ma-n { background: var(--ma-ok); }
.ma-mark { margin-left: auto; font-weight: 800; }
.ma-fmark { font-weight: 800; }
.ma-fmark.is-ok { color: var(--ma-ok); }
.ma-fmark.is-bad { color: var(--ma-bad); }
.ma-q { margin: 2px 0 0; font-weight: 700; }
.ma-hint { margin: 0; font-size: 16px; opacity: .85; }

/* factor cards */
.ma-trays { display: grid; gap: 6px; }
.ma-tray { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 8px; }
.ma-tray-h { margin: 0; font-weight: 800; }
.ma-note { margin: 0; }
.ma-cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.ma-card { position: relative; display: grid; place-items: center; min-height: 64px; min-width: 0; padding: 2px; border: 2px solid #8fb3a3; border-radius: 10px;
  background: var(--ma-chip); color: var(--ma-ink); font-size: 16px; cursor: pointer; }
html[data-theme="dark"] .ma-card { border-color: #3f5d50; }
.ma-card:hover:not(:disabled) { border-color: var(--ma-accent); }
.ma-card:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.ma-card.is-on { border-color: var(--ma-accent); background: var(--ma-chip-on); box-shadow: inset 0 0 0 2px var(--ma-accent); }
.ma-card .ma-frac { font-size: 16px; min-width: 0; }
.ma-card .ma-fv, .ma-card .ma-fu { display: block; line-height: 1.1; }
.ma-card .ma-top, .ma-card .ma-bot { padding: 1px 4px; }
.ma-none { font-weight: 700; line-height: 1.1; text-align: center; }
.ma-chips { display: grid; gap: 5px; }
.ma-chips--3 { grid-template-columns: repeat(3, 1fr); }
.ma-chip { position: relative; display: flex; align-items: center; justify-content: center; min-height: 44px; min-width: 0; padding: 4px 16px 4px 6px; border: 2px solid #8fb3a3;
  border-radius: 10px; background: var(--ma-chip); color: var(--ma-ink); font-size: 16px; line-height: 1.15; text-align: center; cursor: pointer; }
html[data-theme="dark"] .ma-chip { border-color: #3f5d50; }
.ma-chip:hover:not(:disabled) { border-color: var(--ma-accent); }
.ma-chip:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.ma-chip.is-on { border-color: var(--ma-accent); background: var(--ma-chip-on); font-weight: 700; box-shadow: inset 0 0 0 1px var(--ma-accent); }
.ma-chip-m { position: absolute; right: 4px; bottom: 2px; font-weight: 800; }
.is-key { border-color: var(--ma-ok) !important; box-shadow: inset 0 0 0 2px var(--ma-ok) !important; }
.is-key > .ma-chip-m { color: var(--ma-ok); }
.is-wrong { border-color: var(--ma-bad) !important; border-style: dashed !important; }
.is-wrong > .ma-chip-m { color: var(--ma-bad); }
.ma-chip:disabled, .ma-card:disabled { cursor: default; opacity: 1; }

/* numbers */
.ma-num { display: flex; align-items: center; gap: 6px; }
.ma-num-row { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; }
.ma-num input { flex: 1 1 auto; min-width: 0; font-size: 17px; min-height: 44px; padding: 5px 8px; border: 2px solid #7fa596; border-radius: 8px; background: #fff; color: #10241c; }
html[data-theme="dark"] .ma-num input { background: #0b1410; color: #e2f3ea; border-color: #4f7465; }
.ma-num input:focus-visible { outline: 3px solid var(--tlg-focus, #1a73e8); outline-offset: 2px; }
.ma-unit { flex: none; min-width: 70px; font-weight: 700; }

/* the ATM */
.ma-atm { flex: none; display: grid; gap: 8px; padding: 12px 14px; border-radius: 18px; background: linear-gradient(var(--ma-body1), var(--ma-body2)); border: 4px solid var(--ma-line); color: #fff; box-shadow: 0 6px 14px rgba(0,0,0,.2); }
.ma-atm-top { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; }
.ma-atm-sub { margin-left: auto; font-size: 16px; font-weight: 700; opacity: .9; }
.ma-info { margin: 0; padding: 6px 10px; border-radius: 8px; background: rgba(0,0,0,.22); line-height: 1.35; }
.ma-screen { padding: 12px 14px; border-radius: 12px; background: var(--ma-screen); color: var(--ma-screen-ink); border: 3px solid #0a1a14; box-shadow: inset 0 0 18px rgba(62,209,142,.25); min-height: 120px; }
.ma-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-size: 20px; }
.ma-x { font-size: 24px; font-weight: 800; color: var(--ma-screen-dim); }
.ma-start, .ma-out { padding: 6px 10px; border-radius: 8px; border: 2px solid var(--ma-screen-dim); font-weight: 700; }
.ma-out { border-color: var(--ma-gold); }
.ma-sub { font-weight: 800; color: var(--ma-gold); }
.ma-frac { display: inline-grid; justify-items: center; min-width: 90px; }
.ma-top { padding: 0 6px 3px; border-bottom: 2px solid currentColor; white-space: nowrap; }
.ma-bot { padding: 3px 6px 0; white-space: nowrap; }
.ma-fu { font-weight: 800; }
.ma-fu.is-struck { text-decoration: line-through; text-decoration-color: var(--ma-strike); text-decoration-thickness: 3px; opacity: .85; }
.ma-card .ma-fu.is-struck { text-decoration-color: var(--ma-bad); }
.ma-empty { font-style: italic; color: var(--ma-screen-dim); }
.ma-left { margin: 12px 0 0; font-size: 17px; }
.ma-slotrow svg { display: block; width: 100%; height: auto; }
.ma-slot-t { font-family: var(--tlg-font); font-size: 16px; font-weight: 700; fill: #ffffff; }
.ma-receipt { justify-self: center; width: min(100%, 520px); padding: 8px 14px; border-radius: 4px; background: var(--ma-paper); color: #1d1d1d; font-family: ui-monospace, Menlo, monospace; font-size: 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,.25); animation: ma-print .6s ease-out; }
.ma-receipt p { margin: 2px 0; }
.ma-rh { text-align: center; font-weight: 800; letter-spacing: .2em; }
@keyframes ma-print { from { transform: translateY(-14px); opacity: 0; } }
.ma-about { flex: none; padding: 4px 10px; border: 1px solid var(--tlg-border); border-radius: 8px; }
.ma-about summary { cursor: pointer; min-height: 32px; font-weight: 700; display: flex; align-items: center; }
.ma-about p { margin: 4px 0; }
.ma-chain--ex { color: #10241c; }
.ma-chain--ex .ma-x { color: #3f6d5a; }

@media (max-width: 900px) {
  .ma { position: static; grid-template-columns: 1fr; }
  .ma-controls, .ma-right { overflow: visible; }
  .ma-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .ma *, .ma *::before { animation: none !important; transition: none !important; } }
