@layer controls {
  .symptom-workspace {
    max-width: 1120px;
    margin-inline: auto;
  }
  .symptom-panel {
    border-radius: var(--radius);
    padding: clamp(20px, 3vw, 36px);
    margin-block: 24px;
    min-width: 0;
  }
  .symptom-panel label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 10px;
  }
  .symptom-panel textarea,
  .symptom-panel input {
    width: 100%;
    min-height: 48px;
    padding: 16px;
    font: inherit;
    color: var(--ink);
    line-height: 1.7;
  }
  .symptom-panel textarea {
    resize: vertical;
  }
  .symptom-panel .helper {
    font-size: 13px;
    line-height: 1.8;
    margin-block: 12px;
  }
  .symptom-panel .form-actions {
    margin-block: 18px 8px;
    gap: 14px;
    flex-wrap: wrap;
  }
  .symptom-panel h2 {
    margin-block: 24px 14px;
  }
  .symptom-panel h3 {
    margin-block: 26px 14px;
  }
  .symptom-panel .section-heading h2 {
    margin-block: 0 8px;
  }
  #symptom-status:empty {
    display: none;
  }
  #symptom-status {
    margin-block: 18px;
    font-size: 14px;
  }
  .symptom-add {
    border-top: 1px solid var(--line);
    margin-top: 24px;
    padding-top: 22px;
  }
  .symptom-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding-block: 16px;
    border-bottom: 1px solid var(--line);
  }
  .symptom-chip > div:first-child {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .symptom-chip small,
  #symptom-suggestions small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
  }
  .symptom-chip-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
  }
  .symptom-chip-actions select {
    width: 130px;
  }
  #symptom-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 16px;
  }
  #symptom-suggestions:empty {
    display: none;
  }
  #symptom-suggestions button {
    text-align: left;
    white-space: normal;
    justify-content: flex-start;
    max-width: 100%;
  }
  .symptom-unmatched:not(:empty) {
    margin-top: 18px;
    font-size: 14px;
    overflow-wrap: anywhere;
  }
  .symptom-boundary {
    font-size: 14px;
    color: var(--muted);
    margin: 24px 0 36px;
    line-height: 1.9;
    max-width: 78ch;
  }
  .symptom-urgent {
    margin-block: 22px;
    padding: 18px 20px;
    border: 2px solid #a33838;
    border-radius: 12px;
    color: #832727;
    line-height: 1.85;
  }
  [data-theme="dark"] .symptom-urgent {
    color: #ffb6b6;
    border-color: #df8888;
  }
  #symptom-result-groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 36px;
    margin-top: 28px;
  }
  .symptom-group {
    min-width: 0;
  }
  .symptom-group > h3 {
    padding-bottom: 18px;
    border-bottom: 2px solid var(--line);
  }
  .symptom-group > h3 small {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
    margin-top: 8px;
  }
  .symptom-result {
    padding-block: 26px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }
  .symptom-result h4 {
    font-size: 18px;
    line-height: 1.6;
    margin: 0 0 8px;
  }
  .symptom-result-heading > span {
    font-size: 13px;
    color: var(--accent);
  }
  .symptom-result .helper {
    font-size: 12px;
    line-height: 1.8;
    margin-block: 10px;
  }
  .symptom-evidence {
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.85;
  }
  .symptom-evidence small {
    display: inline;
    color: var(--muted);
    font-size: 12px;
    margin-left: 6px;
  }
  .symptom-conflict {
    font-size: 13px;
    color: #8b3030;
    line-height: 1.8;
  }
  [data-theme="dark"] .symptom-conflict {
    color: #ffb6b6;
  }
  .symptom-detail-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    text-decoration: underline;
    text-underline-offset: 4px;
  }
  .symptom-group > button {
    margin-top: 20px;
  }
  .symptom-coverage p {
    max-width: 78ch;
    margin-block: 16px;
    line-height: 1.85;
  }
  .symptom-browse {
    display: grid;
    grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)) auto;
    gap: 18px;
    align-items: end;
  }
  .symptom-browse .field {
    min-width: 0;
  }
  .symptom-browse select {
    width: 100%;
  }
  .disease-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 4px;
    border-bottom: 1px solid var(--line);
  }
  .disease-row h2 {
    font-size: 16px;
    line-height: 1.7;
  }
  .disease-row h2 a {
    display: inline-block;
    padding-block: 6px;
  }
  .disease-row p {
    font-size: 12px;
    color: var(--muted);
    overflow-wrap: anywhere;
  }
  .disease-row small {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 13px;
  }
  .disease-phenotypes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 28px;
    padding: 0;
    list-style: none;
    max-height: 480px;
    overflow-y: auto;
  }
  .disease-phenotypes li {
    padding-block: 10px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }
  .disease-phenotypes small {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 5px;
  }
  #disease-detail {
    scroll-margin-top: 110px;
  }
  #disease-detail h2 {
    overflow-wrap: anywhere;
  }
  #disease-detail .term-chips {
    gap: 12px;
  }
  #disease-detail summary {
    cursor: pointer;
    padding: 18px 0;
    font-weight: 600;
  }
  .evidence-scroll {
    overflow: auto;
    max-height: 540px;
    margin-block: 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  .evidence-scroll table {
    border-collapse: collapse;
    width: 100%;
    font-size: 12px;
  }
  .evidence-scroll th,
  .evidence-scroll td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    min-width: 90px;
  }
  .evidence-scroll caption {
    text-align: left;
    padding: 12px;
  }
  .evidence-scroll th {
    background: var(--surface);
    position: sticky;
    top: 0;
  }
  .symptom-methods {
    max-width: 960px;
    margin-inline: auto;
  }
  .symptom-methods p {
    max-width: 78ch;
  }
  .symptom-methods dd {
    margin: 8px 0 18px;
    overflow-wrap: anywhere;
  }
  .symptom-methods code {
    display: block;
    overflow-wrap: anywhere;
    font-size: 12px;
  }
  .symptom-methods details {
    margin-top: 28px;
  }
  .symptom-methods summary {
    min-height: 44px;
    cursor: pointer;
  }
  .hpo-logo {
    object-fit: contain;
    object-position: left;
    background: white;
    padding: 8px;
    border-radius: 8px;
  }
  [hidden] {
    display: none !important;
  }
  @media (max-width: 800px) {
    #symptom-result-groups {
      grid-template-columns: 1fr;
    }
    .symptom-browse {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .symptom-browse .field:first-child {
      grid-column: 1/-1;
    }
    .symptom-browse > button {
      justify-self: start;
    }
  }
  @media (max-width: 540px) {
    .symptom-chip {
      align-items: flex-start;
      flex-direction: column;
      gap: 12px;
    }
    .symptom-chip-actions {
      width: 100%;
    }
    .symptom-chip-actions select {
      flex: 1;
    }
    .symptom-panel .form-actions > button {
      flex: 1 1 auto;
    }
    .disease-row {
      align-items: flex-start;
    }
    .disease-row small {
      max-width: 65px;
    }
    .disease-phenotypes {
      grid-template-columns: 1fr;
    }
    #disease-detail .section-heading {
      align-items: flex-start;
      flex-direction: column;
    }
  }
}
