:root {
  color-scheme: light;
  --ink: #10243f;
  --muted: #66768d;
  --line: #d8e7f4;
  --panel: #ffffff;
  --wash: #f5fbff;
  --accent: #2876f0;
  --accent-2: #22bee6;
  --deep: #1d4ed8;
  --danger: #2876f0;
  --shadow: 0 18px 50px rgba(28, 109, 220, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% -10%, rgba(34, 190, 230, 0.2), transparent 260px),
    linear-gradient(180deg, rgba(40, 118, 240, 0.11), transparent 360px),
    var(--wash);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 18px;
  padding: 18px 0 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  width: 100%;
}

.brand-lockup > div {
  min-width: 0;
  flex: 1 1 auto;
}

.brand-logo {
  width: clamp(74px, 10vw, 112px);
  height: clamp(74px, 10vw, 112px);
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(40, 118, 240, 0.14);
  display: block;
}

.brand-logo-link {
  flex: 0 0 auto;
  border-radius: 8px;
  text-decoration: none;
}

.brand-logo-link:focus-visible {
  outline: 3px solid rgba(40, 118, 240, 0.35);
  outline-offset: 4px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--deep);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.02;
  letter-spacing: 0;
}

.source-documents {
  max-width: 100%;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.top-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  align-items: start;
  justify-items: end;
}

.mode-switcher,
.language-switcher {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.mode-switcher {
  grid-column: 1 / -1;
  gap: 10px;
  width: 100%;
  max-width: none;
}

.accessibility-tools {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.mode-btn,
.language-btn,
.accessibility-btn {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #4b6684;
  font-size: 12px;
  font-weight: 800;
}

.accessibility-btn {
  min-height: 42px;
  border-color: #b8d4ea;
  background: #ffffff;
  color: #17416d;
  padding: 0 14px;
  font-size: 13px;
}

.accessibility-btn.active {
  border-color: #10243f;
  background: #10243f;
  color: #ffffff;
}

.mode-btn {
  min-width: 300px;
  max-width: 360px;
  min-height: 52px;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  line-height: 1.18;
  white-space: normal;
  text-align: center;
  box-shadow: 0 10px 24px rgba(16, 36, 63, 0.08);
}

.language-btn.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(34, 190, 230, 0.16), rgba(40, 118, 240, 0.12));
  color: var(--deep);
}

.mode-btn[data-mode="disease"] {
  border-color: #74d5ec;
  background: #e9fbff;
  color: #0b657d;
}

.mode-btn[data-mode="identify"] {
  border-color: #86d9a5;
  background: #ecf9f0;
  color: #126b36;
}

.mode-btn[data-mode="disease"].active {
  border-color: #22bee6;
  background: linear-gradient(135deg, #22bee6, #2876f0);
  color: #ffffff;
}

.mode-btn[data-mode="identify"].active {
  border-color: #24a148;
  background: linear-gradient(135deg, #24a148, #87d37c);
  color: #ffffff;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span,
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  padding: 9px 13px;
  color: var(--deep);
  font-size: 13px;
  font-weight: 650;
}

.notice {
  border-left: 4px solid var(--accent-2);
  background: linear-gradient(90deg, rgba(34, 190, 230, 0.12), rgba(255, 255, 255, 0.84));
  color: #23425f;
  padding: 14px 16px;
  margin: 0 0 18px;
  line-height: 1.45;
}

.search-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.format-hint {
  border: 2px solid #1d4ed8;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff7d6, #e8f8ff);
  color: #10243f;
  padding: 14px 16px;
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: uppercase;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  font: inherit;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(40, 118, 240, 0.15);
}

.identify-mode .search-panel {
  padding: 24px;
}

.identify-mode .search-row {
  grid-template-columns: 1fr 58px;
  gap: 14px;
}

.identify-mode input {
  min-height: 68px;
  padding: 0 20px;
  font-size: 24px;
  font-weight: 850;
  letter-spacing: 0;
}

.identify-mode #clearButton {
  min-height: 68px;
  font-size: 30px;
}

.accessible-mode {
  background: #ffffff;
  color: #050b14;
}

.accessible-mode .shell {
  width: min(1280px, calc(100vw - 24px));
}

.accessible-mode .source-documents,
.accessible-mode .results-head p,
.accessible-mode .card p,
.accessible-mode .languages,
.accessible-mode label {
  color: #263a57;
}

.accessible-mode .format-hint {
  border-width: 3px;
  background: #fff0a8;
  color: #000000;
  font-size: 22px;
  line-height: 1.42;
}

.accessible-mode h1 {
  font-size: clamp(38px, 5vw, 64px);
}

.accessible-mode .mode-btn,
.accessible-mode .language-btn,
.accessible-mode .accessibility-btn,
.accessible-mode .stats span {
  font-size: 16px;
  min-height: 48px;
}

.accessible-mode .search-panel,
.accessible-mode .card,
.accessible-mode .match-band {
  border-width: 2px;
}

.accessible-mode input {
  min-height: 64px;
  font-size: 24px;
  font-weight: 850;
}

.accessible-mode.identify-mode input {
  min-height: 76px;
  font-size: 30px;
}

.accessible-mode .card h3 {
  font-size: 22px;
}

.accessible-mode .identify-frequency strong,
.accessible-mode .freq strong {
  font-size: 24px;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fcff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  max-height: 172px;
  overflow: auto;
  padding-right: 4px;
}

.chip {
  min-height: 36px;
  border-radius: 999px;
  padding: 0 13px;
  color: #4b6684;
  font-size: 14px;
  font-weight: 700;
}

.chip.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(34, 190, 230, 0.16), rgba(40, 118, 240, 0.12));
  color: var(--accent);
}

.results-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 14px;
}

.results-head h2 {
  font-size: 22px;
  line-height: 1.2;
}

.results-head p {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.match-band {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.match-band + .match-band {
  margin-top: 10px;
}

.match-band.exact {
  border-color: #a9dfbd;
  background: rgba(222, 248, 229, 0.78);
}

.match-band.high {
  border-color: #eadb8c;
  background: rgba(255, 249, 219, 0.82);
}

.match-band.preview {
  border-color: #e5be34;
  background: rgba(255, 232, 135, 0.72);
}

.match-band-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: start;
  margin: 4px 0 12px;
}

.match-band-head h3 {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1.2;
}

.match-band-head p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.match-band-count {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--deep);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.band-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(16, 36, 63, 0.05);
}

.match-band.exact .card {
  border-color: #9edab5;
  background: linear-gradient(180deg, #f7fff9, #e9f9ee);
}

.match-band.high .card {
  border-color: #e8d87d;
  background: linear-gradient(180deg, #fffef5, #fff8dc);
}

.match-band.preview .card {
  border-color: #d8ae1e;
  background: linear-gradient(180deg, #fff9d9, #ffe88a);
}

.card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.25;
}

.languages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: -2px 0 10px;
  color: #58708b;
  font-size: 12px;
  line-height: 1.45;
}

.languages b {
  color: var(--deep);
  font-weight: 800;
}

.card p {
  color: var(--muted);
  line-height: 1.45;
}

.source-line {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.4;
}

.identify-frequency {
  border: 1px solid rgba(40, 118, 240, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  padding: 10px 12px;
  margin: 10px 0 8px;
}

.identify-frequency span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.identify-frequency strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.match-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 0 0 12px;
  color: #4b6684;
  font-size: 12px;
  line-height: 1.45;
}

.match-summary span {
  border-radius: 999px;
  background: rgba(34, 190, 230, 0.12);
  padding: 5px 8px;
}

.match-summary b {
  color: var(--deep);
  font-weight: 850;
}

.freq-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.freq.wide {
  grid-column: 1 / -1;
}

.freq {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f6fbff;
}

.freq span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.freq-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.freq-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 112px), 1fr));
  gap: 6px;
  width: 100%;
}

.copy-btn,
.pt3-btn,
.pt2-btn {
  min-height: 28px;
  border-color: rgba(40, 118, 240, 0.24);
  border-radius: 6px;
  background: #ffffff;
  color: var(--deep);
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  white-space: normal;
  text-align: center;
}

.pt3-btn {
  background: var(--deep);
  border-color: var(--deep);
  color: #ffffff;
}

.pt2-btn {
  background: #d92828;
  border-color: #d92828;
  color: #ffffff;
}

.copy-btn:disabled,
.pt3-btn:disabled,
.pt2-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

.copy-btn.copied,
.pt3-btn.downloaded,
.pt2-btn.downloaded {
  border-color: var(--accent-2);
  background: rgba(34, 190, 230, 0.14);
  color: #126d9a;
}

.freq strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  overflow-wrap: anywhere;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.info-note {
  border-top: 1px solid var(--line);
  margin-top: 34px;
  padding: 26px 0 8px;
  color: var(--muted);
}

.info-note h2 {
  color: var(--ink);
  font-size: 18px;
  margin: 0 0 16px;
}

.info-note h3 {
  color: var(--deep);
  font-size: 14px;
  margin: 22px 0 8px;
}

.info-note p {
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 10px;
}

.legal-note[hidden] {
  display: none;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  border-radius: 999px;
  background: rgba(34, 190, 230, 0.12);
  color: #126d9a;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 750;
}

.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.compact-empty {
  flex: 1 0 100%;
  padding: 12px;
  font-size: 13px;
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 20px, 1160px);
    padding-top: 12px;
  }

  .topbar,
  .results-head {
    display: block;
  }

  .top-actions {
    justify-items: start;
    margin-top: 14px;
  }

  .mode-switcher,
  .accessibility-tools,
  .language-switcher,
  .stats {
    justify-content: flex-start;
  }

  .mode-switcher,
  .accessibility-tools {
    width: 100%;
  }

  .accessibility-btn {
    flex: 1 1 180px;
  }

  .mode-btn {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .brand-logo {
    width: 68px;
    height: 68px;
  }

  .stats {
    justify-content: flex-start;
    margin-top: 14px;
  }

  .results-head p {
    text-align: left;
    margin-top: 6px;
  }

  .freq-grid {
    grid-template-columns: 1fr;
  }

  .identify-mode .search-panel {
    padding: 18px;
  }

  .identify-mode .search-row {
    grid-template-columns: 1fr 52px;
  }

  .identify-mode input {
    min-height: 58px;
    font-size: 20px;
  }

  .identify-mode #clearButton {
    min-height: 58px;
    font-size: 26px;
  }

  .match-band-head {
    grid-template-columns: 1fr;
  }
}
