@layer workspace {
  .brand-image {
    width: 240px;
    height: 56px;
    object-fit: contain;
  }
  .brand-dark {
    display: none;
  }
  .header-inner {
    gap: 24px;
    min-height: 92px;
  }
  .desktop-nav {
    gap: 8px;
  }
  .desktop-nav a {
    padding-inline: 12px;
    min-height: 46px;
    line-height: 1.4;
  }
  .header-actions {
    gap: 10px;
  }
  .header-actions .icon-button {
    min-width: 44px;
    min-height: 44px;
  }
  .language-toggle {
    display: inline-flex;
    gap: 6px;
    padding: 10px;
    width: auto;
    font-size: 12px;
  }
  .language-toggle svg {
    width: 18px;
  }
  .medical-notice {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 20px auto 0;
    max-width: 1280px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #fff6d7, #f5dfa4);
    border: 1px solid #b88930;
    border-left: 5px solid #986215;
    border-radius: 12px;
    color: #513804;
    box-shadow:
      4px 5px 12px #00000015,
      inset 1px 1px 1px #fff;
  }
  .medical-notice p {
    flex: 1;
    font-weight: 650;
    font-size: 14px;
  }
  .medical-notice .icon-button {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: transparent;
    box-shadow: none;
    border: 1px solid #98621570;
  }
  .notice-symbol {
    display: flex;
  }
  [data-notice-dismissed="true"] .medical-notice {
    display: none;
  }
  .language-note {
    display: none;
    max-width: 1280px;
    margin: 0 auto 20px;
    color: var(--muted);
    font-size: 13px;
  }
  [data-language="en"] .language-note {
    display: block;
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --surface: #242b34;
    --glass-solid: #242b34;
    --ink: #edf2f6;
    --muted: #b8c5d0;
    --accent: #b6dce8;
    --shadow: #131820;
    --light: #424d5a;
    --line: #53616f;
    --glass: linear-gradient(145deg, #303945, #232a33);
    --glass-edge: #58657290;
    --control: linear-gradient(155deg, #465361 0%, #303a46 48%, #202630 100%);
    --control-pressed: linear-gradient(145deg, #19222b, #303c47);
    --control-selected: linear-gradient(145deg, #19232e, #364553);
    --control-shadow:
      -4px -4px 9px #46536180, 5px 6px 10px #10141b, 0 3px 1px #111720,
      inset 1px 1px 2px #64728370, inset -1px -2px 3px #101722;
    --control-inset:
      inset 4px 4px 8px #101721, inset -4px -4px 8px #425261, 0 1px 0 #526270;
    --raised:
      8px 8px 18px #121820, -8px -8px 18px #424e5b70,
      inset 1px 1px 2px #67788a55, inset -1px -1px 2px #101722;
    --inset: inset 4px 4px 9px #111822, inset -4px -4px 9px #46546180;
    --scroll-track: #1b222b;
    --scroll-thumb: #95aabc;
    --scroll-hover: #c6d7e4;
  }
  [data-theme="dark"] .brand-light {
    display: none;
  }
  [data-theme="dark"] .brand-dark {
    display: block;
  }
  [data-theme="dark"] .app-header {
    background: #242b34f2;
    border-color: #53616f;
    box-shadow: 0 5px 16px #0004;
  }
  [data-theme="dark"]
    :is(
      .inset,
      .reader,
      .field input,
      .field textarea,
      .field select,
      .results-toolbar select
    ) {
    border-color: var(--glass-edge);
  }
  [data-theme="dark"]
    :is(
      .tool-symbol,
      .tool-symbol.human,
      .tool-symbol.animal,
      .tool-symbol.plant,
      .task-symbol,
      .brand-mark
    ) {
    color: #d4e3ee;
  }
  [data-theme="dark"] .mode-tag {
    color: #dfedf4;
    background: #3b4a58;
  }
  [data-theme="dark"] .mode-tag.external {
    color: #ffe2ab;
    background: #58472f;
  }
  [data-theme="dark"] :is(select, select::picker(select), option) {
    color: var(--ink);
    background: #2d3743;
    border-color: var(--line);
    box-shadow: var(--raised);
  }
  [data-theme="dark"] option:checked {
    background: #435569;
    color: #fff;
  }
  [data-theme="dark"] :is(.button.primary, .search-submit) {
    background: linear-gradient(145deg, #50677b, #304253);
    border-color: #8dabbf;
  }
  [data-theme="dark"] .medical-notice {
    color: #ffe2a7;
    background: linear-gradient(145deg, #4a3b23, #322b20);
    border-color: #ac8241;
    box-shadow:
      4px 5px 12px #1118,
      inset 1px 1px 1px #8a744a;
  }
  [data-theme="dark"] .medical-notice .icon-button {
    color: #ffe2a7;
    border-color: #ac8241;
  }
  [data-theme="dark"] :is(.status-note, .helper, .tool-meta, .source-label) {
    color: var(--muted);
  }
  [data-theme="dark"] :is(input, textarea)::placeholder,
  [data-theme="dark"] .popular > span {
    color: #b8c5d0;
    opacity: 1;
  }
  [data-theme="dark"] :is(.field-error, .error) {
    color: #ffb8ab;
  }
  [data-theme="dark"] .switch-track {
    background: #182431;
    border-color: #647686;
  }
  [data-theme="dark"] ::selection {
    background: #516e82;
    color: #fff;
  }
  [data-theme="dark"] :is(.plot-container, .chart-box) {
    background: #eef1f4;
    color: #222;
  }
  [data-theme="dark"] :is(button, a, input, select, textarea):focus-visible {
    outline-color: #b6e6ff;
  }
  /* One tactile control scale: crisp bevel, contact shadow and inset press. */
  :root {
    --control-shadow:
      -4px -4px 9px #ffffffec, 5px 6px 11px #bdc1c6b3, 0 2px 1px #abb1b8,
      inset 0 1px 1px #fff, inset 0 -1px 2px #b7bec680;
    --control-hover:
      -5px -5px 11px #fff, 6px 7px 13px #b8bec5, 0 2px 1px #9fa8b2,
      inset 0 1px 1px #fff, inset 0 -1px 2px #c3c9cf;
  }
  :root[data-theme="dark"] {
    --control-hover:
      -5px -5px 11px #53637270, 6px 7px 13px #0c121b, 0 2px 1px #090f18,
      inset 0 1px 1px #8394a470, inset 0 -1px 2px #14202b;
  }
  .button,
  .search-submit,
  .domain-tabs button {
    min-height: 48px;
    padding: 12px 20px;
    border-radius: 12px;
    line-height: 1.5;
    gap: 9px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-wrap: pretty;
    text-shadow: none;
    transition:
      box-shadow 140ms ease,
      background-color 140ms ease,
      border-color 140ms ease;
  }
  .button .icon,
  .search-submit .icon,
  .domain-tabs .icon {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
  }
  .icon-button,
  .save-button {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }
  .language-toggle {
    width: auto;
  }
  .form-actions {
    gap: 14px;
    row-gap: 16px;
    align-items: center;
  }
  .form-actions .button {
    max-width: 100%;
  }
  .filter-row {
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
  }
  .domain-tabs {
    gap: 12px;
    flex-wrap: wrap;
  }
  .domain-tabs button {
    padding-inline: 16px;
  }
  .local-switch {
    min-height: 44px;
    gap: 10px;
    line-height: 1.5;
  }
  .search-bar {
    gap: 14px;
    padding: 8px 10px 8px 18px;
    min-height: 66px;
  }
  .search-bar input {
    min-width: 0;
    line-height: 1.5;
    padding-block: 12px;
  }
  .search-submit {
    min-width: 80px;
    flex-shrink: 0;
  }
  .catalog-filter-bar {
    gap: 18px;
    padding-top: 24px;
    margin-top: 24px;
  }
  .catalog-filter-bar > label:not(.button) {
    font-size: 13px;
  }
  .catalog-filter-bar select,
  .results-toolbar select {
    min-height: 48px;
    padding-block: 12px;
  }
  .results-toolbar {
    gap: 20px;
    align-items: center;
    padding-block: 24px;
  }
  .results-actions {
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .results-actions > label {
    display: flex;
    min-width: 0;
    margin: 0;
  }
  .results-actions #sort {
    min-width: 172px;
    margin: 0;
    font-size: 14px;
  }
  .view-switch {
    gap: 10px;
    align-items: center;
  }
  .view-switch .icon-button {
    width: 48px;
    height: 48px;
  }
  .term-chips {
    gap: 12px;
    row-gap: 14px;
  }
  a.chip {
    min-height: 44px;
    justify-content: center;
    padding: 10px 16px;
    line-height: 1.5;
    gap: 4px;
  }
  .reference-nav {
    margin-block: 8px 28px;
  }
  .reference-nav a.chip,
  nav[aria-label="资料库分类"] a.chip {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    background: var(--control);
    box-shadow: var(--control-shadow);
    border: 1px solid var(--glass-edge);
  }
  nav[aria-label="资料库分类"] a[aria-current] {
    background: var(--control-selected);
    box-shadow: var(--control-inset);
    font-weight: 700;
  }
  .tool-card-top {
    gap: 12px;
    align-items: center;
  }
  .tool-card h3 {
    line-height: 1.6;
  }
  .tool-card p {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.75;
  }
  .tool-meta {
    gap: 12px;
    padding-top: 16px;
    margin-top: 18px;
    font-size: 12px;
  }
  .task-card p {
    font-size: 13px;
    line-height: 1.75;
  }
  .related-link {
    gap: 12px;
    padding: 14px;
  }
  .related-link > svg {
    flex-shrink: 0;
  }
  .related-link > span {
    min-width: 0;
    line-height: 1.6;
  }
  .reader-controls {
    gap: 10px;
    flex-wrap: wrap;
  }
  .reader-controls a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    line-height: 1.5;
  }
  .section-heading {
    gap: 18px;
    row-gap: 14px;
  }
  .reference-sources {
    display: grid;
    gap: 12px;
    margin-top: 18px;
  }
  .reference-sources a {
    text-decoration: underline;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
  }
  @media (hover: hover) and (pointer: fine) {
    .tool-card:hover {
      box-shadow: var(--raised);
      border-color: var(--line);
    }
    :is(
        .button,
        .icon-button,
        .save-button,
        .search-submit,
        .domain-tabs button,
        .reference-nav a.chip
      ):hover:not(:disabled):not([aria-pressed="true"]):not(:active) {
      box-shadow: var(--control-hover);
      border-color: var(--line);
    }
  }
  :is(
    .button,
    .icon-button,
    .save-button,
    .search-submit,
    .domain-tabs button
  ):active,
  :is(
    .button,
    .icon-button,
    .save-button,
    .domain-tabs button
  )[aria-pressed="true"] {
    box-shadow: var(--control-inset);
    background: var(--control-pressed);
    transform: none;
    color: var(--ink);
  }
  @media (max-width: 650px) {
    .button {
      padding-inline: 16px;
    }
    .results-toolbar {
      align-items: stretch;
      gap: 16px;
    }
    .results-actions {
      justify-content: space-between;
      gap: 16px;
      width: 100%;
    }
    .results-actions > label {
      flex: 1;
      justify-content: flex-end;
    }
    .results-actions #sort {
      width: 100%;
      min-width: 0;
      max-width: 210px;
    }
    .search-bar {
      gap: 9px;
      padding-left: 12px;
    }
    .search-submit {
      min-width: 64px;
      padding-inline: 14px;
    }
    .domain-tabs {
      gap: 12px;
    }
    .domain-tabs button {
      padding-inline: 12px;
    }
    .task-card {
      padding: 20px;
      min-height: 180px;
    }
    .task-card h3 {
      line-height: 1.6;
      font-size: 15px;
    }
    .task-card > .icon {
      right: 16px;
    }
    .reference-nav {
      gap: 12px;
    }
    .reference-nav a.chip {
      font-size: 13px;
      padding-inline: 12px;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    .button,
    .icon-button,
    .save-button,
    .search-submit,
    .domain-tabs button {
      transition: none;
    }
  }
  .reference-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
    margin-top: 24px;
  }
  .reference-card {
    padding: 24px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }
  .reference-card h2 {
    font-size: 18px;
    line-height: 1.55;
    margin: 10px 0 8px;
    overflow-wrap: anywhere;
  }
  .reference-card p {
    color: var(--muted);
    font-size: 14px;
  }
  .reference-card .chip {
    margin: 16px 0 12px;
    padding: 6px 10px;
    font-size: 12px;
    min-height: 0;
    border-radius: 8px;
    box-shadow: none;
    background: var(--control-selected);
  }
  .reference-controls {
    padding: 24px;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: end;
  }
  .reference-controls label {
    display: grid;
    gap: 8px;
    flex: 1;
    min-width: 180px;
  }
  .reference-controls input,
  .reference-controls select {
    min-height: 48px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    background: var(--surface);
    box-shadow: var(--inset);
  }
  .reference-controls select {
    padding-right: 42px;
  }
  .reference-controls label:first-child {
    flex: 1.5;
  }
  .reference-controls button {
    flex-shrink: 0;
  }
  [data-medical-count] {
    margin-top: 20px;
  }
  .reference-original {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    max-height: 650px;
    overflow: auto;
    padding: 22px;
    margin-block: 14px;
    line-height: 1.85;
    font-size: 15px;
    scrollbar-gutter: stable;
  }
  .reference-record section {
    margin-bottom: 28px;
  }
  @media (min-width: 1101px) and (max-width: 1360px) {
    .header-inner {
      padding-inline: 20px;
      gap: 16px;
    }
    .desktop-nav a {
      padding: 12px 8px;
    }
    .desktop-nav .icon {
      display: none;
    }
    .brand-image {
      width: 216px;
      height: auto;
    }
  }
  @media (max-width: 1360px) {
    .medical-notice,
    .language-note {
      margin-left: 40px;
      margin-right: 40px;
    }
  }
  @media (max-width: 900px) {
    .reference-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }
  @media (max-width: 650px) {
    .brand-image {
      width: clamp(132px, 43vw, 176px);
      height: auto;
    }
    .header-inner {
      padding-inline: 16px;
      gap: 8px;
      min-height: 80px;
    }
    .header-actions {
      gap: 8px;
    }
    .language-toggle svg {
      display: none;
    }
    .medical-notice {
      margin: 16px 18px 0;
      padding: 10px 12px;
      gap: 10px;
      align-items: flex-start;
    }
    .medical-notice p {
      font-size: 13px;
    }
    .notice-symbol {
      display: none;
    }
    .language-note {
      margin-inline: 18px;
    }
    .reference-grid {
      grid-template-columns: 1fr;
    }
    .reference-controls {
      padding: 20px;
      gap: 16px;
    }
    .reference-controls label {
      flex-basis: 100%;
      min-width: 0;
    }
    .reference-controls button {
      width: 100%;
    }
    .reference-original {
      padding: 16px;
    }
  }
  @media (max-width: 360px) {
    .brand-image {
      width: 124px;
    }
    .header-inner {
      padding-inline: 12px;
    }
    .header-actions {
      gap: 6px;
    }
  }
  @media print {
    .medical-notice {
      display: flex !important;
      color: #000 !important;
      background: #fff !important;
      box-shadow: none !important;
    }
    .medical-notice button {
      display: none;
    }
  }
}
