:root {
  color-scheme: light;
  --page: #f1f4f2;
  --surface: #ffffff;
  --line: #c9d2cd;
  --strong-line: #879a91;
  --text: #17231e;
  --muted: #596961;
  --quiet: #7c8b84;
  --accent: #147f72;
  --accent-soft: #dceee9;
  --amber: #a66a08;
  --danger: #c83f57;
  --shadow: rgba(20, 40, 31, .09);
}

body.dark {
  color-scheme: dark;
  --page: #0d1412;
  --surface: #18231f;
  --line: #34473f;
  --strong-line: #61756c;
  --text: #f1f4ef;
  --muted: #acb8b2;
  --quiet: #7f9088;
  --accent: #5bd0bd;
  --accent-soft: #173a33;
  --amber: #efbc5b;
  --danger: #ff7287;
  --shadow: rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--page); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.topbar { position: sticky; top: 0; z-index: 20; width: min(calc(100% - 40px), 1120px); height: 72px; margin: auto; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--page); }
.brand { padding: 0; display: inline-flex; align-items: center; border: 0; background: transparent; color: var(--text); text-align: left; text-decoration: none; cursor: pointer; }
.brand > span { display: grid; gap: 4px; }
.brand strong { font-size: 19px; line-height: 1; }
.brand strong .sim-mark, .home-content h1 .sim-mark { color: var(--accent); }
.brand small { color: var(--quiet); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; }
.sim-mark { position: relative; display: inline-block; }
.brand-atom { position: absolute; top: -9px; right: -15px; width: 18px; height: 18px; color: var(--accent); transform-origin: center; animation: brand-atom-spin 20s linear infinite; }
.home-atom { top: -13px; right: -23px; width: 26px; height: 26px; }
@keyframes brand-atom-spin { to { transform: rotate(360deg); } }
.mode-toggle { width: 37px; height: 37px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--text); cursor: pointer; }
.mode-toggle span { font-size: 17px; line-height: 1; }
.topbar-actions { display: flex; align-items: center; gap: 7px; }
.member-profile { height: 37px; padding: 0 10px 0 5px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); cursor: pointer; }
.member-profile[hidden] { display: none; }
.member-profile span { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 3px; background: var(--accent-soft); color: var(--accent); font: 800 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.member-profile b { font-size: 10px; }
#sign-out[hidden], #reset-entry[hidden], #reset-request-form[hidden], #reset-confirm-form[hidden], #admin-shortcut[hidden] { display: none; }
.resend-verification[hidden] { display: none; }

main { min-height: calc(100vh - 72px); }
.screen { display: none; }
.screen.active { display: grid; }
.home-screen { min-height: calc(100vh - 72px); place-items: center; padding: 44px 20px 92px; }
.home-content { width: min(100%, 570px); }
.eyebrow { margin: 0 0 10px; color: var(--accent); font: 800 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; }
.home-content h1 { margin: 0 0 31px; font-size: 36px; line-height: 1; letter-spacing: 0; }
.entry-links { border-top: 1px solid var(--line); }
.entry-link { width: 100%; min-height: 76px; padding: 0 4px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.entry-link > span { display: grid; gap: 6px; }
.entry-link small { color: var(--quiet); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.entry-link strong { font-size: 16px; }
.entry-link b { color: var(--quiet); font-size: 20px; font-weight: 400; transition: transform 150ms ease, color 150ms ease; }
.entry-link:hover b { color: var(--accent); transform: translateX(4px); }
.free-link strong { color: var(--accent); }
.join-link { margin-top: 16px; min-height: 58px; padding: 0 15px; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent); color: var(--page); }
.join-link small, .join-link b { color: currentColor; opacity: .78; }

.account-screen { min-height: calc(100vh - 72px); place-items: start center; padding: 56px 20px 80px; }
.account-shell { width: min(100%, 420px); }
.back-button { width: 36px; height: 36px; margin-bottom: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--text); cursor: pointer; }
.account-shell h2 { margin: 0; font-size: 27px; line-height: 1.2; }
.account-tabs { height: 42px; margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.account-tab { border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; }
.account-tab.active { background: var(--accent-soft); color: var(--accent); }
.account-form { display: none; margin-top: 19px; }
.account-form.active { display: grid; gap: 13px; }
.account-form > label { display: grid; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.account-form > label[hidden] { display: none; }
.account-form label small { color: var(--quiet); font-size: 8px; font-weight: 500; }
.account-form input:not([type="checkbox"]) { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 4px; outline: 0; background: var(--surface); color: var(--text); font-size: 12px; }
.account-form input:not([type="checkbox"]):focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check-line { display: flex !important; grid-template-columns: auto 1fr; align-items: flex-start; gap: 8px !important; color: var(--muted); font-size: 10px !important; font-weight: 500 !important; line-height: 1.45; }
.check-line input { margin: 1px 0 0; accent-color: var(--accent); }
.form-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.submit-button { height: 44px; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent); color: var(--page); font-size: 11px; font-weight: 800; cursor: pointer; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 10px; font-weight: 700; cursor: pointer; }
.reset-back { margin-top: 20px; }
.admin-shortcut { display: inline-block; margin-top: 14px; color: var(--accent); font-size: 10px; font-weight: 700; }
.resend-verification { margin-top: 12px; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 10px; font-weight: 700; cursor: pointer; }

.access-pending[hidden] { display: none; }
.access-pending { padding-top: 15px; text-align: center; }
.status-mark { width: 44px; height: 44px; margin: 0 auto 20px; display: grid; place-items: center; border: 1px solid var(--amber); border-radius: 50%; color: var(--amber); font: 700 19px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.access-pending h2 { margin: 0; }
.access-pending > p:not(.eyebrow) { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.payment-placeholder { min-height: 100px; margin-top: 24px; padding: 17px; display: grid; place-items: center; align-content: center; gap: 8px; border: 1px dashed var(--strong-line); }
.payment-placeholder strong { color: var(--amber); font: 700 9px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.payment-placeholder span { color: var(--quiet); font-size: 9px; line-height: 1.5; }
.return-account { margin-top: 18px; }
.catalog-screen { min-height: calc(100vh - 72px); justify-items: center; padding: 34px 20px 80px; }
.catalog-shell { width: min(100%, 1120px); }
.catalog-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.catalog-heading h2 { margin: 0; font-size: 29px; line-height: 1.1; }
.access-status { min-height: 34px; padding: 0 10px 0 7px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.access-status strong { color: var(--muted); font-size: 9px; }
.mini-lock, .card-lock { position: relative; display: block; color: var(--quiet); }
.mini-lock { width: 20px; height: 20px; }
.mini-lock:before, .card-lock:before { content: ""; position: absolute; left: 50%; border: 2px solid currentColor; border-bottom: 0; border-radius: 8px 8px 0 0; transform: translateX(-50%); }
.mini-lock:before { top: 2px; width: 8px; height: 7px; }
.mini-lock i, .card-lock i { position: absolute; left: 50%; border-radius: 2px; background: currentColor; transform: translateX(-50%); }
.mini-lock i { top: 9px; width: 13px; height: 9px; }
.access-status.locked .mini-lock, .lock-badge.locked { color: #c83f57; }
.access-status.open .mini-lock, .lock-badge.open { color: #168267; }
body.dark .access-status.locked .mini-lock, body.dark .lock-badge.locked { color: #ff7287; }
body.dark .access-status.open .mini-lock, body.dark .lock-badge.open { color: #58d0b5; }
.access-status.open .mini-lock:before { left: 57%; transform: translateX(-50%) rotate(-17deg); transform-origin: left bottom; }
.catalog-tools { position: sticky; top: 72px; z-index: 10; margin-top: 24px; padding: 10px 0; display: grid; grid-template-columns: minmax(0, 1fr) 210px; align-items: center; gap: 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--page); }
.topic-jump { min-width: 0; display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; }
.topic-jump::-webkit-scrollbar { display: none; }
.topic-jump button { height: 34px; padding: 0 11px; flex: 0 0 auto; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 750; cursor: pointer; }
.topic-jump button:hover, .topic-jump button.active { background: var(--accent-soft); color: var(--accent); }
.catalog-search { position: relative; }
.catalog-search span { position: absolute; left: 10px; top: 6px; color: var(--quiet); font-size: 20px; }
.catalog-search input { width: 100%; height: 36px; padding: 0 10px 0 34px; border: 1px solid var(--line); border-radius: 4px; outline: 0; background: var(--surface); color: var(--text); font-size: 10px; }
.catalog-search input:focus { border-color: var(--accent); }
.catalog-sections { padding-top: 10px; }
.topic-section { padding: 25px 0 7px; scroll-margin-top: 140px; }
.topic-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-bottom: 11px; }
.topic-heading h3 { margin: 0; color: var(--text); font-size: 16px; }
.topic-heading span { color: var(--quiet); font: 700 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.simulation-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 8px; }
.simulation-card { position: relative; min-width: 0; min-height: 138px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.simulation-card:hover { border-color: var(--strong-line); }
.simulation-card:active { transform: translateY(1px); }
.card-visual { position: relative; height: 58px; overflow: hidden; border-bottom: 1px solid var(--line); background-color: var(--page); background-image: linear-gradient(rgba(20,45,35,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(20,45,35,.045) 1px, transparent 1px); background-size: 18px 18px; }
body.dark .card-visual { background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px); }
.card-visual:before { content: ""; position: absolute; left: 14%; right: 14%; top: 29px; border-top: 2px solid var(--card-accent); transform: rotate(-7deg); }
.lock-badge { position: absolute; top: 7px; right: 7px; z-index: 2; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 4px; background: var(--surface); }
.card-lock { width: 18px; height: 18px; }
.card-lock:before { top: 1px; width: 7px; height: 7px; }
.card-lock i { top: 8px; width: 12px; height: 8px; }
.lock-badge.open .card-lock:before { left: 57%; transform: translateX(-50%) rotate(-17deg); transform-origin: left bottom; }
.card-copy { min-height: 79px; padding: 10px 11px; display: flex; flex-direction: column; }
.card-copy small { margin-bottom: 5px; color: var(--card-accent); font: 750 7px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }
.card-copy strong { overflow: hidden; font-size: 11px; line-height: 1.3; text-overflow: ellipsis; }
.card-state { margin-top: auto; padding-top: 7px; color: var(--quiet); font-size: 7px; font-weight: 700; text-transform: uppercase; }
.simulation-card[data-access="open"] .card-state { color: #168267; }
body.dark .simulation-card[data-access="open"] .card-state { color: #58d0b5; }
.no-results { min-height: 180px; place-items: center; color: var(--quiet); font-size: 11px; }
.no-results:not([hidden]) { display: grid; }
.notice { position: fixed; left: 50%; bottom: 24px; z-index: 10; width: min(calc(100% - 30px), 440px); padding: 12px 14px; border: 1px solid var(--strong-line); border-radius: 5px; background: var(--surface); color: var(--muted); box-shadow: 0 10px 30px var(--shadow); font-size: 10px; line-height: 1.45; transform: translateX(-50%); }

@media (max-width: 560px) {
  .topbar { width: calc(100% - 28px); }
  .brand small { display: none; }
  .member-profile b { display: none; }
  .home-screen { place-items: start center; padding-top: 70px; }
  .home-content h1 { font-size: 32px; }
  .account-screen { padding-top: 34px; }
  .catalog-screen { padding: 27px 14px 60px; }
  .catalog-heading { align-items: flex-start; flex-direction: column; gap: 13px; }
  .catalog-tools { grid-template-columns: 1fr; }
  .catalog-search { grid-row: 1; }
  .simulation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 700px) and (max-width: 1100px) {
  .simulation-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

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