@layer reset, base, components;
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  body, h1, h2, p { margin: 0; }
  button, textarea { font: inherit; }
  button { cursor: pointer; }
  [hidden] { display: none !important; }
}
@layer base {
  :root { color-scheme: light; --ink: #183a43; --muted: #52696e; --teal: #184b59; --border: #d6e1df; --canvas: #f1f6f5; }
  body { color: var(--ink); background: var(--canvas); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; -webkit-text-size-adjust: 100%; }
  button, a, summary, textarea { -webkit-tap-highlight-color: transparent; }
  a { color: var(--teal); text-underline-offset: 3px; }
  button { color: var(--ink); border: 0; }
  button:disabled { opacity: .55; cursor: default; }
  :focus-visible { outline: 3px solid #1e817e; outline-offset: 4px; }
  svg { flex-shrink: 0; }
  button svg, .privacy-line svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .page { width: min(960px, 100%); margin-inline: auto; padding: 0 32px max(24px, env(safe-area-inset-bottom)); }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .skip-link { position: absolute; top: -100px; left: 12px; padding: 12px; background: white; z-index: 3; }
  .skip-link:focus { top: 8px; }
}
@layer components {
  .brand-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 32px 0; }
  .brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-size: 19px; font-weight: 700; letter-spacing: -.4px; }
  .brand-icon { width: 40px; height: 40px; filter: drop-shadow(0 2px 2px #184b591c); }
  .brand-subtitle { display: block; margin-top: 1px; color: var(--muted); font-size: 9px; letter-spacing: 1.4px; font-weight: 600; }
  .edition { display: flex; gap: 9px; align-items: center; font-size: 12px; font-weight: 600; color: #3f5c62; }
  .edition span { background: #e2ece9; border: 1px solid #cbded7; padding: 4px 9px; border-radius: 6px; color: #285b50; }
  .intro { padding: 26px 0 27px; }
  .eyebrow { color: #46746e; font-size: 11px; font-weight: 750; letter-spacing: 1.6px; margin-bottom: 10px; }
  h1 { font-size: clamp(28px, 4.8vw, 40px); line-height: 1.18; letter-spacing: -1.4px; font-weight: 750; }
  .intro p { font-size: 17px; margin-top: 12px; color: var(--muted); }
  .input-card, .results-card { background: white; border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 6px 24px #183a4306, 0 2px 3px #183a4304, inset 0 1px 0 #fff; }
  .input-card { padding: 24px; }
  .card-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: -8px 0 9px; }
  .card-heading label { font-size: 15px; font-weight: 700; }
  textarea { display: block; width: 100%; min-height: 132px; border: 1px solid #bacfca; border-radius: 10px; padding: 16px; background: #fbfdfc; color: #163c46; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 18px; line-height: 1.7; resize: vertical; }
  textarea::placeholder { color: #6b8588; opacity: 1; }
  textarea:focus { outline: 2px solid #2a7874; outline-offset: 1px; background: #fff; }
  textarea[aria-invalid="true"] { border-color: #9d4838; }
  .input-footer { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-top: 17px; }
  .input-footer p { font-size: 12px; color: var(--muted); max-width: 310px; }
  .input-actions, .copy-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
  .primary-button, .secondary-button, .copy-button, .text-button { display: inline-flex; justify-content: center; align-items: center; gap: 9px; min-height: 46px; border-radius: 9px; padding: 10px 15px; font-size: 14px; font-weight: 650; }
  .primary-button { color: white; background: linear-gradient(180deg, #225b68, #184b59); border: 1px solid #163f49; box-shadow: inset 0 1px 0 #ffffff20, 0 2px 3px #123f4b19; }
  .primary-button:hover { background: #123f4d; }
  .primary-button:active, .copy-button:active { transform: translateY(1px); }
  .secondary-button { color: #365b62; border: 1px solid #c8d8d4; background: white; }
  .secondary-button:hover, .copy-button:hover { background: #ecf4f2; }
  .text-button { color: #2f6d68; background: transparent; padding-inline: 7px; }
  .text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
  .privacy-line { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 13px; color: #59716e; font-size: 12px; }
  .privacy-line svg { width: 15px; height: 15px; }
  .error-message { margin-top: 15px; font-size: 14px; color: #8d3627; }
  .results-card { margin-top: 28px; overflow: hidden; scroll-margin-top: 20px; }
  .results-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px 24px; border-bottom: 1px solid #dfe8e5; }
  h2 { font-size: 19px; letter-spacing: -.4px; font-weight: 720; }
  #result-summary { color: var(--muted); font-size: 12px; margin-top: 3px; }
  .copy-button { border: 1px solid #c5d8d2; background: #f2f7f5; color: #285d53; }
  .copy-actions { gap: 15px; }
  .copy-actions .text-button { font-size: 12px; }
  .result-list { list-style: none; padding: 0; margin: 0; counter-reset: diagnoses; }
  .result-row { display: grid; grid-template-columns: 24px 98px minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 17px 24px; counter-increment: diagnoses; border-bottom: 1px solid #e5ece9; }
  .result-row:last-child { border-bottom: 0; }
  .result-row::before { content: counter(diagnoses, decimal-leading-zero); font-size: 11px; font-weight: 500; color: #68817e; font-variant-numeric: tabular-nums; }
  .result-code { color: #225a58; background: #edf5f2; border-radius: 5px; padding: 3px 7px; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 14px; font-weight: 650; overflow-wrap: anywhere; width: fit-content; max-width: 100%; }
  .result-description { font-size: 15px; color: #1f3c43; overflow-wrap: anywhere; }
  .result-meta { display: block; margin-top: 5px; color: #7d521c; font-size: 12px; }
  .result-row.unresolved .result-code { color: #8c4230; background: #fcf0e9; }
  .result-row.unresolved .result-description { color: #85402f; }
  .result-row.unresolved .result-meta { color: #765b51; }
  .result-notice { padding: 12px 24px; background: #fff8e9; color: #76511a; font-size: 13px; border-bottom: 1px solid #e9ddc2; }
  .empty-state { display: flex; align-items: center; justify-content: center; gap: 13px; color: #607873; padding: 38px 16px 32px; font-size: 14px; }
  .empty-state svg { width: 43px; height: 43px; }
  .dataset-age { font-size: 13px; margin: 20px 0; padding: 12px 16px; border: 1px solid #dfcca7; background: #fff8e9; border-radius: 8px; color: #76511a; }
  .source-details { margin-top: 22px; border-top: 1px solid #d6e2dd; padding-top: 14px; font-size: 12px; color: var(--muted); }
  .source-details summary { width: fit-content; min-height: 44px; padding: 10px 0; cursor: pointer; color: #3f625c; font-weight: 600; }
  .source-content { padding: 3px 0 4px; max-width: 760px; }
  .source-content p { margin-bottom: 12px; }
  .link-separator { margin-inline: 9px; }
  footer { display: flex; justify-content: space-between; gap: 16px; padding: 24px 0 4px; font-size: 11px; color: #617872; }
  .toast { position: fixed; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); padding: 12px 22px; max-width: calc(100% - 32px); background: #183e45; color: white; box-shadow: 0 4px 18px #183a4329; border-radius: 12px; font-size: 14px; z-index: 5; }
  dialog { width: min(600px, calc(100% - 32px)); max-height: calc(100dvh - 32px); border: 1px solid var(--border); border-radius: 16px; padding: 24px; color: var(--ink); }
  dialog::backdrop { background: #123b4866; }
  .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  dialog p { margin-block: 16px; font-size: 14px; }
  dialog textarea { font-family: inherit; font-size: 16px; }
  @media (max-width: 640px) {
    .page { padding-inline: 18px; }
    .brand-header { padding-block: 24px 15px; gap: 10px; align-items: flex-start; }
    .brand { font-size: 17px; gap: 8px; }
    .brand-icon { width: 36px; height: 36px; }
    .brand-subtitle { font-size: 8px; letter-spacing: 1.1px; }
    .edition { font-size: 10px; flex-direction: column; gap: 3px; align-items: flex-end; }
    .edition span { font-size: 10px; padding: 2px 7px; }
    .intro { padding-block: 24px; }
    h1 { letter-spacing: -.8px; }
    .intro p { font-size: 15px; line-height: 1.55; max-width: 300px; }
    .input-card { padding: 18px; border-radius: 14px; }
    textarea { padding: 12px; font-size: 17px; min-height: 152px; }
    .input-footer { flex-direction: column; align-items: stretch; gap: 16px; margin-top: 11px; }
    .input-footer p { font-size: 11px; max-width: none; }
    .input-actions { flex-direction: row-reverse; gap: 8px; }
    .input-actions .primary-button { flex: 1; min-height: 48px; }
    .input-actions .secondary-button { min-height: 48px; }
    .results-card { border-radius: 14px; margin-top: 23px; }
    .results-heading { padding: 17px 18px; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
    .copy-actions { gap: 12px; flex-wrap: wrap; }
    .copy-button { min-height: 44px; font-size: 13px; padding-inline: 12px; }
    .copy-actions .text-button { min-height: 44px; }
    .result-row { grid-template-columns: 20px minmax(0, 1fr); gap: 8px 9px; padding: 16px 18px; }
    .result-row::before { grid-row: 1 / 3; }
    .result-code { grid-column: 2; }
    .result-description { grid-column: 2; font-size: 15px; }
    .result-notice { padding-inline: 18px; }
    .empty-state { padding-block: 32px 24px; gap: 9px; font-size: 12px; }
    footer { flex-direction: column; gap: 4px; padding-top: 18px; }
  }
  @media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
  @media (forced-colors: active) { button, .input-card, .results-card, .result-code { border: 1px solid CanvasText; } }
}
