:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --panel: #111113;
  --panel-2: #171719;
  --text: #f4f4f5;
  --muted: #8d8d93;
  --line: #2a2a2e;
  --soft-line: #202024;
  --button: #f4f4f5;
  --button-text: #0b0b0c;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; }
a { color: inherit; }
button, select, a { -webkit-tap-highlight-color: transparent; }
.site-shell { width: min(820px, calc(100% - 40px)); min-height: 100vh; margin: 0 auto; display: grid; grid-template-rows: auto 1fr auto; }
.site-header { height: 70px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--soft-line); }
.brand { color: var(--text); text-decoration: none; font-weight: 730; letter-spacing: -0.035em; font-size: 19px; }
.header-icon, .icon-button {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); display: grid; place-items: center; cursor: pointer;
}
.header-icon { width: 38px; height: 38px; border-radius: 10px; }
.header-icon svg { width: 17px; height: 17px; fill: currentColor; }
.header-icon:hover, .icon-button:hover { border-color: #48484e; }
.main-content { width: min(690px, 100%); margin: auto; padding: 66px 0 78px; }
.generator-card { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); overflow: hidden; }
.result-row { min-height: 120px; padding: 26px; display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); }
.result-wrap { min-width: 0; }
.preview-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.preview-label, .char-count { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.char-count { margin-left: auto; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.result { display: inline-block; min-width: 0; overflow-wrap: anywhere; font-size: clamp(22px, 4.5vw, 31px); line-height: 1.15; letter-spacing: -0.038em; transform-origin: left center; }
.result-pop { animation: resultPop .34s cubic-bezier(.2,.8,.2,1); }
@keyframes resultPop { 0% { opacity: .35; transform: translateY(5px) scale(.985); } 100% { opacity: 1; transform: none; } }
.icon-button { width: 44px; height: 44px; border-radius: 11px; }
.icon-button:active, .primary-button:active, .header-icon:active { transform: translateY(1px); }
.icon-button svg { width: 18px; height: 18px; fill: currentColor; }
.icon-button[data-copied="true"] { background: #1a2d22; border-color: #315941; color: #a8f1bf; }
.controls { padding: 22px 24px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-label { display: flex; align-items: center; gap: 6px; margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 650; }
.info-button { width: 17px; height: 17px; padding: 0; border: 1px solid #3a3a40; border-radius: 50%; background: transparent; color: #a1a1a8; font-size: 10px; line-height: 15px; cursor: pointer; }
.info-button:hover { color: var(--text); border-color: #5a5a61; }
select { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); cursor: pointer; }
.primary-button { min-height: 48px; border: 0; border-radius: 10px; background: var(--button); color: var(--button-text); font-weight: 680; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.primary-button:hover { background: #dedee1; }
.generator-card > .primary-button { width: calc(100% - 48px); margin: 16px 24px 24px; }
.site-footer { min-height: 62px; display: flex; align-items: center; border-top: 1px solid var(--soft-line); color: #64646b; font-size: 11px; }
.modal-layer { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.72); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); opacity: 0; transition: opacity .18s ease; }
.modal-layer[hidden] { display: none; }
.modal-layer.is-open { opacity: 1; }
.modal-card { width: min(410px, 100%); padding: 25px; border: 1px solid var(--line); border-radius: 16px; background: rgba(16,16,18,.96); box-shadow: 0 24px 70px rgba(0,0,0,.35); opacity: 0; transform: translateY(14px) scale(.975); transition: opacity .2s ease, transform .24s cubic-bezier(.2,.8,.2,1); }
.modal-layer.is-open .modal-card { opacity: 1; transform: none; }
.modal-card h2 { margin: 0; font-size: 22px; letter-spacing: -0.035em; }
.modal-card p { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.acknowledgement { margin-top: 14px; padding: 12px 13px; border: 1px solid var(--soft-line); border-radius: 10px; background: #0e0e10; color: #b0b0b6; font-size: 11px; line-height: 1.5; }
.modal-action { width: 100%; margin-top: 20px; }
.compact-modal { width: min(380px, 100%); }
.motion-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
.motion-option { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--muted); cursor: pointer; font-weight: 650; }
.motion-option.active { color: var(--text); border-color: #686870; background: #222226; }
.secondary-action { width: 100%; min-height: 44px; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--text); cursor: pointer; font-weight: 650; }
.copy-toast { position: fixed; left: 50%; bottom: 28px; z-index: 40; transform: translate(-50%, 18px) scale(.96); display: inline-flex; align-items: center; gap: 8px; padding: 11px 14px; border: 1px solid rgba(126,221,158,.28); border-radius: 999px; background: rgba(27,82,46,.72); color: #d8ffe4; box-shadow: 0 12px 34px rgba(0,0,0,.28); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 12px; font-weight: 650; opacity: 0; filter: blur(3px); transition: opacity .22s ease, transform .28s cubic-bezier(.2,.8,.2,1), filter .22s ease; }
.copy-toast[hidden] { display: none; }
.copy-toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); filter: blur(0); }
.toast-check { font-size: 13px; }
.error-page { min-height: 100vh; width: min(720px, calc(100% - 40px)); margin: 0 auto; display: grid; place-items: center; padding: 44px 0; }
.error-card { width: 100%; text-align: center; }
.question-mark { margin: 0 auto 16px; font-size: clamp(120px, 27vw, 210px); line-height: .78; font-weight: 760; letter-spacing: -0.08em; color: #efeff1; }
.error-code { margin: 22px 0 8px; color: #66666d; font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.error-card h1 { margin: 0 auto; max-width: 520px; font-size: clamp(25px, 4vw, 34px); line-height: 1.04; letter-spacing: -0.045em; font-weight: 720; }
.error-card > p:not(.error-code) { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.link-primary { margin-top: 22px; padding: 0 22px; text-decoration: none; }
select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
body[data-motion="reduced"] .modal-card { transform: translateY(4px); transition-duration: .1s; }
body[data-motion="reduced"] .modal-layer { transition-duration: .1s; }
body[data-motion="reduced"] .result-pop { animation-duration: .14s; }
body[data-motion="reduced"] .copy-toast { transform: translate(-50%, 5px); filter: none; transition-duration: .12s; }
body[data-motion="reduced"] .copy-toast.show { transform: translate(-50%, 0); }
body[data-motion="off"] *, body[data-motion="off"] *::before, body[data-motion="off"] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
body[data-motion="off"] .modal-layer, body[data-motion="off"] .modal-card, body[data-motion="off"] .copy-toast { transform: none; filter: none; }
@media (max-width: 680px) {
  .site-shell { width: min(100% - 28px, 820px); }
  .main-content { padding: 46px 0 60px; }
  .result-row { min-height: 102px; padding: 20px; grid-template-columns: minmax(0, 1fr) 42px; gap: 12px; }
  .result { font-size: 20px; }
  .controls { grid-template-columns: 1fr; padding: 20px 20px 0; }
  .generator-card > .primary-button { width: calc(100% - 40px); margin: 14px 20px 20px; }
  .site-footer { padding: 12px 0; }
  .copy-toast { bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  body:not([data-motion="full"]) *, body:not([data-motion="full"]) *::before, body:not([data-motion="full"]) *::after { scroll-behavior: auto !important; }
}

/* v5: three-column controls and saved preferences */
.controls-three { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); }
.settings-card { width: min(440px, 100%); max-height: min(680px, calc(100vh - 40px)); overflow: auto; }
.settings-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--soft-line); }
.settings-section:first-of-type { margin-top: 16px; }
.settings-heading { margin-bottom: 10px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.settings-field { display: grid; grid-template-columns: 1fr minmax(140px, 180px); gap: 12px; align-items: center; min-height: 54px; border-bottom: 1px solid var(--soft-line); color: #d4d4d8; font-size: 12px; }
.settings-field:last-of-type { border-bottom: 0; }
.settings-field select { height: 38px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 0 2px; cursor: pointer; }
.toggle-row span { display: grid; gap: 3px; }
.toggle-row b { font-size: 12px; font-weight: 650; }
.toggle-row small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.toggle-row input { width: 18px; height: 18px; accent-color: #f4f4f5; }
@media (max-width: 680px) {
  .controls-three { grid-template-columns: 1fr; }
  .settings-field { grid-template-columns: 1fr; gap: 6px; padding: 9px 0 12px; }
  .settings-field select { width: 100%; }
}


/* v6: shuffle mix, saved themes, and copy-state polish */
.drug-picker-row { display: grid; grid-template-columns: minmax(0,1fr) 44px; gap: 8px; }
.save-drug-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: #9d9da4; cursor: pointer; font-size: 20px; line-height: 1; }
.save-drug-button:hover:not(:disabled) { color: #fff; border-color: #55555c; }
.save-drug-button.saved { color: #f1f1f2; background: #242428; }
.save-drug-button:disabled { opacity: .38; cursor: default; }
.mix-hint { margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.mix-settings { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0 8px; border-top: 1px solid var(--soft-line); }
.mix-settings > div { display: grid; gap: 3px; }
.mix-settings b { font-size: 12px; font-weight: 650; }
.mix-settings small { max-width: 260px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.mini-action { min-height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: #b8b8be; cursor: pointer; font-size: 10px; font-weight: 650; white-space: nowrap; }
.mini-action:disabled { opacity: .35; cursor: default; }
.saved-mix-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; padding: 3px 0 8px; }
.mix-chip { min-height: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; background: #18181b; color: #c8c8cd; cursor: pointer; font-size: 10px; }
.mix-chip:hover { border-color: #55555d; color: #fff; }
.mix-empty { color: #73737a; font-size: 10px; align-self: center; }
.copy-toast { will-change: opacity, transform, filter; }
.icon-button[data-copied="true"] { transition: background .2s ease, border-color .2s ease, color .2s ease; }
@media (max-width: 680px) {
  .mix-settings { align-items: flex-start; }
  .mix-settings small { max-width: 220px; }
}
