/* ==========================================================================
   Tokens and Themes
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-alt: #eef3f1;
  --text: #16201f;
  --muted: #5a6865;
  --line: #d8e0dd;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --blue: #1d4ed8;
  --amber: #b45309;
  --danger: #b42318;
  --priority-row-accent: #1d4ed8;
  --priority-row-text: #1e3a8a;
  --priority-row-bg: #e8f1ff;
  --priority-row-border: #8bb6ff;
  --priority-row-ring: rgba(29, 78, 216, 0.16);
  --brand-icon-filter: none;
  --shadow: 0 18px 50px rgba(20, 32, 31, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111614;
  --surface: #171f1c;
  --surface-alt: #202a27;
  --text: #edf3f0;
  --muted: #b5c1bd;
  --line: #33413d;
  --accent: #55c2b6;
  --accent-strong: #78d6cc;
  --blue: #8fb3ff;
  --amber: #f1b66d;
  --danger: #ff9a8d;
  --priority-row-accent: #8fb3ff;
  --priority-row-text: #c7d8ff;
  --priority-row-bg: #17243a;
  --priority-row-border: #426aa8;
  --priority-row-ring: rgba(143, 179, 255, 0.2);
  --brand-icon-filter: invert(1);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

/* ==========================================================================
   Base and Shared Layout
   ========================================================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.container {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
}

/* ==========================================================================
   Header and Navigation
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
}

.header-grid,
.footer-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--accent-strong);
}

.brand-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 40px;
  height: 40px;
  filter: var(--brand-icon-filter);
  object-fit: contain;
  transform: translate(-50%, -50%);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.76rem;
}

.brand strong {
  font-size: 0.96rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.language-menu {
  position: relative;
  min-width: 132px;
}

.language-menu summary {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 26px 0 8px;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.language-menu summary::-webkit-details-marker {
  display: none;
}

.language-menu summary::after {
  position: absolute;
  right: 9px;
  width: 7px;
  height: 7px;
  border-inline-end: 1.5px solid var(--muted);
  border-block-end: 1.5px solid var(--muted);
  content: "";
  transform: translateY(-2px) rotate(45deg);
}

.language-menu[open] summary::after {
  transform: translateY(2px) rotate(225deg);
}

.language-menu img,
.language-menu-option img {
  width: 18px;
  height: 12px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.language-menu-list {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.language-menu-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  color: var(--text);
  padding: 0 9px;
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.language-menu-option:hover,
.language-menu-option.is-active {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent-strong);
}

.theme-toggle {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* ==========================================================================
   Accessibility Helpers
   ========================================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
}

.theme-toggle[data-active-theme="dark"] {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* ==========================================================================
   Intro and Page Sections
   ========================================================================== */

.intro-section {
  padding: 22px 0 16px;
  border-bottom: 1px solid var(--line);
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.54fr) minmax(280px, 0.46fr);
  gap: 28px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 820px;
  margin: 0;
  font-size: 2.15rem;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.16;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.25;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.intro-lead {
  max-width: 620px;
  padding-bottom: 2px;
}

.calculator-section,
.result-section,
.reference-section,
.about-section {
  padding: 28px 0;
}

.section-heading {
  margin-bottom: 16px;
}

.calculator-heading {
  margin-bottom: 10px;
}

.calculator-heading h2 {
  font-size: 1.18rem;
  line-height: 1.22;
}

/* ==========================================================================
   Calculator Form and Validation
   ========================================================================== */

.alert,
.clinical-note {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  border-inline-start: 4px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
  padding: 12px 14px;
}

.alert {
  border-inline-start-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}

.calculator-form {
  border-top: 1px solid var(--line);
}

.t2d-options {
  position: relative;
  min-width: 92px;
}

.t2d-options.has-error .genotype-option span,
.genotype-options.has-error .genotype-option span {
  border-color: color-mix(in srgb, var(--danger) 72%, var(--line));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
}

.t2d-options.has-error::after,
.marker-row.is-empty-error .genotype-options.has-error::after {
  position: absolute;
  right: 8px;
  bottom: calc(100% + 8px);
  z-index: 12;
  width: max-content;
  max-width: min(280px, 72vw);
  border: 1px solid color-mix(in srgb, var(--danger) 70%, var(--line));
  background: var(--surface);
  color: var(--danger);
  box-shadow: var(--shadow);
  content: attr(data-tooltip);
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.35;
}

.t2d-options.has-error:hover::after,
.t2d-options.has-error:focus-within::after,
.marker-row.is-empty-error .genotype-options.has-error:hover::after,
.marker-row.is-empty-error .genotype-options.has-error:focus-within::after {
  opacity: 1;
  transform: translateY(0);
}

.marker-table {
  position: relative;
  display: grid;
}

.marker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(128px, 0.28fr);
  gap: 14px;
  align-items: center;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.marker-row.has-error,
.marker-row.is-empty-error {
  border-bottom-color: var(--danger);
}

.marker-row.is-incomplete .marker-code {
  border-color: color-mix(in srgb, var(--amber) 60%, var(--line));
  background: color-mix(in srgb, var(--amber) 8%, var(--surface));
  color: var(--amber);
}

.genotype-options.is-incomplete .genotype-option span {
  border-color: color-mix(in srgb, var(--amber) 60%, var(--line));
  background: color-mix(in srgb, var(--amber) 8%, var(--surface));
  color: var(--amber);
}

.marker-main {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.marker-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  color: var(--blue);
  font-weight: 800;
}

.marker-label {
  display: block;
  font-weight: 750;
}

.marker-main p {
  margin: 6px 0 0;
  color: var(--muted);
}

.genotype-options {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  padding-inline-end: 8px;
}

.genotype-option {
  position: relative;
}

.genotype-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.genotype-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 0 6px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}

.genotype-option input:checked+span,
.genotype-options.has-error .genotype-option input:checked+span,
.genotype-options.is-incomplete .genotype-option input:checked+span {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, var(--surface));
  color: var(--accent-strong);
}

.genotype-option input:focus-visible+span,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: 2px;
}

.field-error {
  grid-column: 1 / -1;
  margin: -8px 0 0;
  margin-inline-start: 72px;
  color: var(--danger);
  font-weight: 700;
}

.marker-group-visible-error {
  margin: 10px 8px 0 0;
  text-align: right;
}

.marker-group-visible-error .field-error {
  margin: 0;
}

.marker-group-visible-warning {
  margin: 4px 0 0;
  color: var(--amber);
  font-size: 0.82rem;
  font-weight: 700;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
}

.primary-button {
  min-height: 42px;
  border: 0;
  background: var(--accent);
  color: #ffffff;
  padding: 0 20px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.secondary-link {
  color: var(--muted);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

/* ==========================================================================
   Result Output
   ========================================================================== */

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  background: var(--line);
  border: 1px solid var(--line);
}

.score-item {
  display: grid;
  gap: 8px;
  min-height: 82px;
  background: var(--surface);
  padding: 14px;
}

.score-item span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.score-item > strong {
  font-size: 1.6rem;
  overflow-wrap: anywhere;
}

.score-item.is-incomplete,
.result-row.is-incomplete {
  background: color-mix(in srgb, var(--amber) 8%, var(--surface));
}

.missing-note {
  display: block;
  margin-top: 6px;
  color: var(--amber);
  font-size: 0.82rem;
  font-weight: 700;
}

.missing-note strong {
  color: inherit;
  font-size: inherit;
  font-weight: 800;
  line-height: inherit;
}

.result-panel,
.marker-summary {
  border: 1px solid var(--line);
  background: var(--surface);
}

.result-panel {
  display: grid;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.32fr) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.result-row:first-child {
  border-top: 0;
}

.result-row-priority {
  border-block: 1px solid var(--priority-row-border);
  border-inline-start: 4px solid var(--priority-row-accent);
  background: var(--priority-row-bg);
  box-shadow: inset 0 0 0 1px var(--priority-row-ring);
  padding-inline-start: 12px;
}

.result-row-priority h3 {
  color: var(--priority-row-text);
  font-size: 1.06rem;
  font-weight: 850;
}

.result-row p,
.clinical-note p,
.reference-copy p {
  margin: 0;
  color: var(--muted);
}

.result-row-priority p {
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 820;
}

.priority-drug-value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 7px;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 820;
}

.drug-brand-disclosure {
  position: relative;
  display: inline-block;
}

.priority-inn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--priority-row-text);
  cursor: pointer;
  font: inherit;
  list-style: none;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.priority-inn::-webkit-details-marker {
  display: none;
}

.priority-inn:hover,
.drug-brand-disclosure[open] .priority-inn {
  color: var(--blue);
  text-decoration-style: solid;
}

.priority-inn-hint {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.72rem;
  font-style: normal;
  line-height: 1;
  text-decoration: none;
}

.drug-brand-popover {
  position: absolute;
  inset-block-start: calc(100% + 9px);
  inset-inline-start: 0;
  z-index: 6;
  display: grid;
  gap: 5px;
  width: min(320px, calc(100vw - 48px));
  border: 1px solid var(--priority-row-border);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 650;
}

.drug-brand-popover::before {
  position: absolute;
  inset-block-start: -5px;
  inset-inline-start: 18px;
  width: 9px;
  height: 9px;
  border-block-start: 1px solid var(--priority-row-border);
  border-inline-start: 1px solid var(--priority-row-border);
  background: var(--surface);
  content: "";
  transform: rotate(45deg);
}

.drug-brand-popover strong {
  color: var(--priority-row-text);
}

.drug-brand-popover p {
  color: var(--muted);
  font-size: inherit;
  font-weight: inherit;
}

.drug-brand-popover a {
  color: var(--accent-strong);
  font-weight: 800;
  text-underline-offset: 3px;
}

.marker-summary {
  margin-top: 16px;
  padding: 14px;
}

.marker-summary ul {
  display: grid;
  gap: 12px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.marker-summary li {
  display: grid;
  grid-template-columns: minmax(240px, 0.44fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.marker-summary-choice {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  gap: 6px;
  white-space: nowrap;
}

.marker-summary-genotype {
  color: inherit;
  font: inherit;
}

.marker-summary-arrow {
  color: var(--muted);
}

.marker-summary li.is-not-tested {
  color: var(--muted);
  opacity: 0.62;
}

.marker-summary li.is-not-tested .marker-summary-genotype,
.marker-summary li.is-not-tested .marker-summary-arrow {
  color: var(--muted);
}

.marker-summary p {
  margin: 0;
  color: var(--muted);
}

.clinical-note {
  margin-top: 16px;
  margin-bottom: 0;
  border-inline-start-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.clinical-note-highlight {
  border-inline-start: 3px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  color: var(--amber) !important;
  padding: 8px 10px;
  font-weight: 750;
}

.result-section {
  scroll-margin-top: 72px;
}

/* ==========================================================================
   Reference and About Sections
   ========================================================================== */

.source-block {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.source-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-list li {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.source-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.source-list a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.source-list span {
  color: var(--muted);
  font-size: 0.9rem;
}

.source-disclosure {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.source-disclosure summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 800;
}

.source-disclosure .source-list {
  margin-top: 10px;
}

.reference-section,
.about-section {
  border-top: 1px solid var(--line);
}

.about-section {
  background: color-mix(in srgb, var(--surface-alt) 62%, var(--bg));
}

.reference-grid,
.about-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.35fr) minmax(0, 0.65fr);
  gap: 24px;
}

.about-copy {
  display: grid;
  gap: 16px;
}

.about-copy p {
  margin: 0;
  color: var(--muted);
}

.about-copy .about-tasks-label {
  color: var(--text);
  font-weight: 800;
}

.about-points {
  display: grid;
  gap: 10px;
  margin: 4px 0 0;
  padding: 16px 0 0;
  border-block-start: 1px solid var(--line);
  list-style-position: inside;
  color: var(--text);
  font-weight: 650;
}

.about-points li {
  padding-inline-start: 2px;
}

.about-note {
  border-inline-start: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  padding: 14px 16px;
}

.muted {
  color: var(--muted);
}

/* ==========================================================================
   Global Medicine Register
   ========================================================================== */

.register-intro {
  border-bottom: 1px solid var(--line);
  padding: 30px 0 24px;
}

.register-intro-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.48fr) minmax(320px, 0.52fr);
  gap: 32px;
  align-items: end;
}

.register-intro-copy {
  display: grid;
  gap: 10px;
}

.register-updated {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.register-content {
  display: grid;
  gap: 34px;
  padding-top: 30px;
  padding-bottom: 36px;
}

.register-section {
  --register-site-header-height: 58px;
  --register-scrollbar-height: 18px;
  position: relative;
  min-width: 0;
}

.register-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 16px;
  margin-bottom: 12px;
}

.register-section-heading h2 {
  font-size: 1.3rem;
}

.register-section-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.register-table-tools {
  position: sticky;
  top: var(--register-site-header-height);
  z-index: 19;
  height: var(--register-scrollbar-height);
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface);
}

.register-scroll-top {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow-x: scroll;
  overflow-y: hidden;
  background: transparent;
  scrollbar-width: none;
}

.register-scroll-top::-webkit-scrollbar {
  display: none;
}

.register-scroll-spacer {
  height: 1px;
}

.register-scroll-track {
  position: absolute;
  top: 4px;
  right: 5px;
  left: 5px;
  z-index: 1;
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  cursor: pointer;
  touch-action: none;
}

.register-scroll-thumb {
  height: 100%;
  border-radius: inherit;
  background: color-mix(in srgb, var(--muted) 76%, var(--surface));
  cursor: grab;
  transform-origin: left center;
}

.register-scroll-track:hover .register-scroll-thumb {
  background: var(--muted);
}

.register-scroll-track.is-dragging .register-scroll-thumb {
  cursor: grabbing;
}

.register-sticky-header {
  position: absolute;
  top: 100%;
  right: -1px;
  left: -1px;
  overflow: hidden;
  overflow: clip;
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--surface-alt);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--text) 10%, transparent);
  pointer-events: auto;
}

.register-sticky-header-table {
  table-layout: fixed;
  transform-origin: top left;
  will-change: transform;
}

.register-sticky-header-table th {
  border-block-end: 0;
}

.register-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--surface);
}

.register-table-wrap:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: 3px;
}

.register-table {
  width: 100%;
  min-width: 1680px;
  border-collapse: collapse;
  font-size: 0.86rem;
  line-height: 1.4;
}

.register-table th,
.register-table td {
  border-inline-end: 1px solid var(--line);
  border-block-end: 1px solid var(--line);
  padding: 10px 12px;
  text-align: start;
  vertical-align: top;
}

.register-table th:last-child,
.register-table td:last-child {
  border-inline-end: 0;
}

.register-table tbody tr:last-child td {
  border-block-end: 0;
}

.register-table th {
  position: relative;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 850;
}

.register-column-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
}

.register-column-label {
  flex: 1 1 auto;
  padding-block: 4px;
}

.register-column-controls {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
}

.register-sort-button,
.register-filter-button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.68;
  padding: 0;
}

.register-sort-button:hover,
.register-filter-button:hover,
.register-sort-button:focus-visible,
.register-filter-button:focus-visible {
  color: var(--accent-strong);
  opacity: 1;
}

.register-sort-button:focus-visible,
.register-filter-button:focus-visible,
.register-filter-input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
}

.register-table th[aria-sort="ascending"] .register-sort-button,
.register-table th[aria-sort="descending"] .register-sort-button,
.register-sort-button[data-sort-direction="ascending"],
.register-sort-button[data-sort-direction="descending"],
.register-filter-button[data-filter-active="true"],
.register-filter-button[aria-expanded="true"] {
  color: var(--accent-strong);
  opacity: 1;
}

.register-sort-indicator,
.register-filter-icon {
  display: block;
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  background: currentColor;
}

.register-sort-indicator {
  clip-path: polygon(50% 0, 100% 38%, 67% 38%, 67% 62%, 100% 62%, 50% 100%, 0 62%, 33% 62%, 33% 38%, 0 38%);
  font-size: 0;
  line-height: 0;
}

.register-sort-button[data-sort-direction="ascending"] .register-sort-indicator {
  clip-path: polygon(50% 0, 100% 45%, 67% 45%, 67% 100%, 33% 100%, 33% 45%, 0 45%);
}

.register-sort-button[data-sort-direction="descending"] .register-sort-indicator {
  clip-path: polygon(33% 0, 67% 0, 67% 55%, 100% 55%, 50% 100%, 0 55%, 33% 55%);
}

.register-filter-icon {
  clip-path: polygon(0 0, 100% 0, 62% 46%, 62% 82%, 38% 100%, 38% 46%);
}

.register-filter-panel {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.register-filter-input {
  width: 100%;
  min-width: 140px;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 6px 8px;
  font: inherit;
  font-weight: 600;
}

.register-filter-input::placeholder {
  color: var(--muted);
  opacity: 0.9;
}

.register-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-alt) 42%, var(--surface));
}

.register-table td:first-child,
.register-table td:nth-child(2),
.register-table td:nth-child(3) {
  color: var(--text);
  font-weight: 720;
}

.register-table th:first-child,
.register-table td:first-child {
  width: 132px;
  white-space: nowrap;
}

.register-empty-row td {
  color: var(--muted);
  padding: 24px 16px;
  text-align: center;
  white-space: normal;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 18px 0 20px;
}

.site-footer .footer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 24px;
}

.site-footer .footer-grid span {
  min-width: 0;
}

/* ==========================================================================
   Responsive: Tablet and Mobile
   ========================================================================== */

@media (max-width: 860px) {
  .container {
    width: min(100% - 20px, 1180px);
  }

  .header-grid {
    gap: 10px;
    min-height: 54px;
    padding: 8px 0;
  }

  .footer-grid {
    align-items: stretch;
    flex-direction: column;
  }

  .site-footer .footer-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body {
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  body.register-page {
    padding-bottom: 0;
  }

  .form-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .form-actions .primary-button {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 16px;
    z-index: 35;
    width: auto;
    min-height: 46px;
    box-shadow: 0 12px 34px rgba(20, 32, 31, 0.24);
  }

  .has-result .form-actions .primary-button {
    position: static;
    width: 100%;
    box-shadow: none;
  }

  .priority-drug-value {
    position: relative;
  }

  .drug-brand-disclosure {
    position: static;
  }

  .drug-brand-popover {
    inset-inline: 0;
    width: 100%;
  }

  .form-actions .secondary-link {
    font-size: 0.82rem;
    white-space: nowrap;
  }

  .top-actions {
    flex: 0 0 auto;
    gap: 6px;
    margin-left: auto;
  }

  .language-menu {
    min-width: 112px;
  }

  .language-menu summary,
  .language-menu-option {
    min-height: 32px;
    font-size: 0.8rem;
  }

  .language-menu img,
  .language-menu-option img {
    width: 16px;
    height: 11px;
  }

  .theme-toggle {
    flex: 0 0 36px;
    width: 36px;
  }

  .intro-grid,
  .register-intro-grid,
  .reference-grid,
  .about-grid {
    grid-template-columns: 1fr;
  }

  .register-intro {
    padding: 22px 0 18px;
  }

  .register-content {
    gap: 28px;
    padding-top: 22px;
    padding-bottom: 28px;
  }

  .register-section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .register-section {
    --register-site-header-height: 54px;
  }

  .score-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 12px;
  }

  .score-item {
    align-content: center;
    gap: 3px;
    min-height: 58px;
    padding: 8px 6px;
  }

  .score-item span {
    font-size: 0.68rem;
    line-height: 1.15;
  }

  .score-item > strong {
    font-size: 1rem;
    line-height: 1.1;
  }

  .score-item .missing-note {
    display: none;
  }

  .intro-section {
    padding: 16px 0 12px;
  }

  .intro-lead {
    max-width: none;
    padding-bottom: 0;
  }

  h1 {
    font-size: 1.9rem;
  }

  h2 {
    font-size: 1.45rem;
  }

  .calculator-section,
  .result-section,
  .reference-section,
  .about-section {
    padding: 22px 0;
  }

  .marker-row {
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: 0;
  }

  .marker-main {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .genotype-options {
    justify-content: center;
    width: max-content;
    max-width: calc(100% - 84px);
    margin-inline: auto;
    padding-inline-end: 0;
  }

  .t2d-options.has-error::before,
  .marker-row.is-empty-error .genotype-options.has-error::before {
    position: absolute;
    left: calc(100% + 6px);
    top: 50%;
    z-index: 2;
    width: max-content;
    max-width: 72px;
    color: var(--danger);
    content: attr(data-mobile-error-short);
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1.1;
    pointer-events: none;
    transform: translateY(-50%);
  }

  .t2d-options.has-error::after,
  .marker-row.is-empty-error .genotype-options.has-error::after {
    right: 50%;
    transform: translate(50%, 4px);
  }

  .t2d-options.has-error:hover::after,
  .t2d-options.has-error:focus-within::after,
  .marker-row.is-empty-error .genotype-options.has-error:hover::after,
  .marker-row.is-empty-error .genotype-options.has-error:focus-within::after {
    transform: translate(50%, 0);
  }

  .result-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px;
  }

  .field-error {
    margin-inline-start: 0;
  }

  .marker-group-visible-error {
    margin: 8px 0 0;
    text-align: center;
  }

  .marker-summary li {
    grid-template-columns: 1fr;
  }

  .marker-summary-choice {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ==========================================================================
   Responsive: Small Screens
   ========================================================================== */

@media (max-width: 480px) {
  .brand {
    gap: 8px;
    min-width: 0;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 0.78rem;
  }

  .brand strong {
    font-size: 0.84rem;
  }

  .brand small {
    display: none;
  }

  .language-menu {
    min-width: 98px;
  }

  .theme-toggle {
    flex-basis: 34px;
    width: 34px;
  }

  h1 {
    font-size: 1.58rem;
  }

  .lead {
    font-size: 0.92rem;
  }

  .score-item {
    padding: 7px 4px;
  }

  .score-item > strong {
    font-size: 0.86rem;
  }

  .t2d-options.has-error::before,
  .marker-row.is-empty-error .genotype-options.has-error::before {
    left: auto;
    right: -2px;
    max-width: 58px;
    transform: translate(100%, -50%);
  }
}
