:root {
  --bg: #f4f7ff;
  --surface: #ffffff;
  --panel: rgba(255, 255, 255, 0.88);
  --ink: #0c1d3a;
  --muted: #51607a;
  --accent: #0f7bff;
  --accent-2: #0ac9a3;
  --outline: #d6e2ff;
  --outline-strong: #bcd2ff;
  --shadow-lg: 0 24px 60px rgba(7, 35, 94, 0.12);
  --shadow-sm: 0 12px 28px rgba(7, 35, 94, 0.08);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "SF Pro Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(120% 120% at 20% 20%, rgba(15, 123, 255, 0.14), transparent),
    radial-gradient(120% 120% at 80% 10%, rgba(10, 201, 163, 0.12), transparent),
    var(--bg);
  color: var(--ink);
  font-size: clamp(15px, 0.8vw + 14px, 17px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 4vw, 44px);
  padding-bottom: clamp(88px, 12vh, 140px);
  position: relative;
}

.app-layout {
  width: min(1200px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vw, 20px);
  flex: 1 0 auto;
  position: relative;
  z-index: 1;
}

.app-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1.4vw, 14px);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.84));
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  padding: clamp(10px, 1.7vw, 14px);
  box-shadow: var(--shadow-lg);
}

.title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
}

.toolbar-meta {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex-shrink: 0;
}

.app-title {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  font-weight: 700;
  color: var(--ink);
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1;
}

.app-subtitle {
  margin: 2px 0 0;
  font-size: 1rem;
  color: var(--muted);
  max-width: 720px;
}

.language-select-inline {
  flex-shrink: 0;
  appearance: none;
  border: 1px solid var(--outline-strong);
  border-radius: 10px;
  padding: 3px 18px 3px 8px;
  font-size: 0.8rem;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #f4f7ff);
  box-shadow: inset 0 1px 2px rgba(16, 33, 70, 0.08);
  cursor: pointer;
  min-width: 82px;
  height: 30px;
}

.data-update-status {
  font-size: 0.62rem;
  line-height: 1;
  color: var(--muted);
  text-align: right;
  min-height: 1em;
  max-width: none;
  white-space: nowrap;
}

.language-select-inline:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tablist {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: clamp(50px, 6vh, 62px);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--outline);
  border-radius: var(--radius-lg);
  padding: 6px;
  width: 100%;
  box-shadow: var(--shadow-sm);
}

.tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  background: #f2f5ff;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 0.94em;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab:hover,
.tab:focus-visible {
  color: var(--ink);
  border-color: var(--outline);
  background: #e8f1ff;
  outline: none;
}

.tab-active {
  background: linear-gradient(120deg, #e6f0ff, #e4fff8);
  color: var(--ink);
  border-color: var(--outline-strong);
  box-shadow: 0 8px 18px rgba(7, 35, 94, 0.1);
}

.pill-clear {
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid #f3cbd0;
  background: #fdecee;
  color: #a02a3b;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
  margin-left: 6px;
  flex-shrink: 0;
}

.pill-clear:hover,
.pill-clear:focus-visible {
  background: #fbd9de;
  border-color: #eea8b2;
  box-shadow: 0 6px 14px rgba(160, 42, 59, 0.16);
  outline: none;
}

#central-frame {
  width: 100%;
  min-height: clamp(320px, 50vh, 620px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: clamp(8px, 1.4vw, 16px);
  justify-content: center;
  align-items: start;
  border: 1px solid var(--outline);
  padding: clamp(10px, 2vw, 20px);
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 250, 255, 0.96));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.category-container {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(244, 249, 255, 0.96));
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: 0 10px 26px rgba(16, 33, 70, 0.06);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.category-container::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  background: radial-gradient(closest-side, rgba(15, 123, 255, 0.08), transparent 70%);
  transform: rotate(8deg);
  pointer-events: none;
}

.category-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #eef4ff;
  border: 1px solid var(--outline);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.94rem;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.category-header:hover:not(.static-header) {
  background: #e2edff;
  border-color: var(--outline-strong);
  transform: translateY(-1px);
}

.category-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.static-header {
  cursor: default;
}

.category-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.category-icon {
  flex: 0 0 auto;
  font-size: 1.15em;
  line-height: 1;
}

.category-title {
  pointer-events: none;
  min-width: 0;
}

.category-indicator {
  font-size: 0.9em;
  margin-left: 10px;
}

.category-content {
  display: none;
  margin-top: 6px;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.category-content.open {
  display: flex;
}

.fixed-size-button {
  flex: 1 1 140px;
  min-width: 130px;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: linear-gradient(150deg, #ffffff, #f5f8ff);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border 0.18s ease, color 0.18s ease, background 0.18s ease;
  box-shadow: 0 8px 22px rgba(15, 123, 255, 0.05);
  position: relative;
}

.symptom-button {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.symptom-button-high {
  border-color: rgba(214, 59, 59, 0.35);
  background: linear-gradient(150deg, #fff7f7, #fffdfd);
  box-shadow: 0 10px 24px rgba(214, 59, 59, 0.08);
}

.symptom-icon {
  flex: 0 0 auto;
  font-size: 1.05em;
  line-height: 1;
}

.symptom-label {
  min-width: 0;
  padding-right: 20px;
}

.fixed-size-button:hover:not(.disabled-button) {
  background: linear-gradient(150deg, #f7fbff, #ebf3ff);
  border-color: var(--outline-strong);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(7, 35, 94, 0.12);
}

.fixed-size-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


.active-button {
  background: linear-gradient(140deg, rgba(15, 123, 255, 0.16), rgba(10, 201, 163, 0.18));
  border-color: var(--accent);
  color: #0b2f62;
  box-shadow: 0 12px 30px rgba(15, 123, 255, 0.16);
}

.active-button::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 0.9em;
  color: #0b2f62;
  opacity: 0.9;
}

.disabled-button {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f0f3f9;
  border-color: var(--outline);
  color: #7787a4;
  box-shadow: none;
}

.env-button {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  text-align: left;
}

.env-icon {
  font-size: 1.05em;
  line-height: 1;
}

.env-label {
  display: block;
  line-height: 1.2;
}

#bottom-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 18px;
  width: min(1200px, calc(100% - 32px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--outline);
  box-shadow: 0 -8px 30px rgba(7, 35, 94, 0.14);
  border-radius: 16px;
  z-index: 99;
}

#bottom-text {
  font-size: 0.96em;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  padding: 0;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre-line;
  line-height: 1.35;
}

#pathogen-list {
  font-size: 0.95em;
  font-weight: 500;
  margin-top: 4px;
  line-height: 1.3;
  color: var(--muted);
  max-height: 110px;
  overflow-y: auto;
  padding-right: 6px;
}

.pathogen-result {
  display: grid;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px dashed rgba(81, 96, 122, 0.18);
}

.pathogen-result:first-child {
  border-top: none;
}

.pathogen-result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.pathogen-result-name {
  color: var(--ink);
}

.pathogen-result-meta {
  font-size: 0.9em;
  color: var(--muted);
  text-align: right;
}

.pathogen-result-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 123, 255, 0.1);
  overflow: hidden;
}

.pathogen-result-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.pathogen-result-note {
  font-size: 0.84rem;
  color: var(--muted);
}

#btn-ppe {
  font-size: 0.98em;
  padding: 12px 18px;
  height: auto;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #ffffff;
  border: none;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(15, 123, 255, 0.24);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
  cursor: pointer;
  flex-shrink: 0;
}

#btn-ppe:hover,
#btn-ppe:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow: 0 16px 36px rgba(10, 201, 163, 0.24);
  outline: none;
}

#btn-ppe:disabled {
  cursor: not-allowed;
  filter: grayscale(0.15);
  opacity: 0.6;
  box-shadow: none;
  transform: none;
}

/* PPE view */

.ppe-layout {
  gap: clamp(18px, 3vw, 30px);
}

.ppe-content {
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 2.5vw, 30px);
  width: 100%;
}

#ppe-summary {
  background: linear-gradient(135deg, rgba(15, 123, 255, 0.08), rgba(10, 201, 163, 0.08));
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin: 4px auto 12px auto;
  max-width: 740px;
  font-size: 1.02em;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

#ppe-info {
  margin-bottom: 30px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.pathogen-container {
  border: 1px solid var(--outline);
  padding: 12px;
  border-radius: var(--radius-md);
  margin: 0 auto;
  width: 100%;
  max-width: 760px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(244, 249, 255, 0.96));
  box-shadow: var(--shadow-sm);
}

.pathogen-header {
  background: #eef4ff;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  border-radius: 10px;
  font-size: 1.05em;
  outline: none;
  width: 100%;
  border: 1px solid var(--outline);
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
}

.pathogen-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pathogen-header-name {
  min-width: 0;
}

.pathogen-match-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(15, 123, 255, 0.12);
  border: 1px solid rgba(15, 123, 255, 0.18);
  color: #0b4ea3;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.pathogen-header:hover,
.pathogen-header:focus {
  background: #e2edff;
  border-color: var(--outline-strong);
  transform: translateY(-1px);
}

.pathogen-content {
  display: none;
  padding: 12px 16px 6px 16px;
  background: #f9fbff;
  border-radius: 0 0 10px 10px;
  margin-top: 7px;
  font-size: 0.98em;
  color: var(--muted);
  animation: fadeIn 0.2s;
  border: 1px solid var(--outline);
  border-top: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ppe-section-title {
  font-weight: 700;
  margin-top: 10px;
  margin-bottom: 6px;
  color: var(--ink);
}

.ppe-list {
  margin-left: 12px;
  margin-bottom: 8px;
  font-size: 0.97em;
}

.no-ppe {
  color: #b23333;
  font-style: italic;
  margin: 8px 0;
}

#return-btn {
  margin: 12px auto 8px auto;
  display: block;
  font-size: 1.05em;
  padding: 12px 26px;
  border-radius: 12px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #ffffff;
  border: none;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(15, 123, 255, 0.2);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  cursor: pointer;
}

#return-btn:hover,
#return-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(10, 201, 163, 0.22);
  outline: none;
}

@media (max-width: 820px) {
  body {
    padding: 12px;
    padding-bottom: 116px;
  }

  .app-toolbar {
    gap: 8px;
  }

  .toolbar-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }

  #central-frame {
    min-height: 60vh;
    padding: 10px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }

  #bottom-bar {
    position: fixed;
    left: 16px;
    right: 16px;
    transform: none;
    width: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  #btn-ppe {
    width: 100%;
  }
}

@media (max-width: 700px) {
  .app-toolbar {
    padding: 12px 14px;
  }

  .title-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title meta";
    align-items: start;
    gap: 8px 12px;
  }

  .app-title {
    grid-area: title;
    font-size: 1.28rem;
    white-space: normal;
  }

  .toolbar-meta {
    grid-area: meta;
    align-items: flex-end;
    justify-self: end;
    max-width: none;
  }

  .language-select-inline {
    min-width: 82px;
    padding: 4px 18px 4px 8px;
    font-size: 0.8rem;
  }

  .data-update-status {
    max-width: none;
    text-align: right;
  }

  .tab {
    font-size: 0.9em;
    padding: 9px 10px;
  }

  .pill-clear {
    height: 32px;
    min-width: 32px;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 14px;
  }

  .app-layout {
    gap: 9px;
  }

  .app-toolbar {
    padding: 8px 9px 7px;
    gap: 4px;
  }

  .title-group {
    gap: 0;
  }

  .app-title {
    font-size: 0.98rem;
    line-height: 1;
  }

  .title-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 4px;
  }

  .toolbar-meta {
    grid-column: 3;
    gap: 1px;
    max-width: none;
    justify-self: end;
  }

  .app-title {
    grid-column: 2;
    text-align: center;
    justify-self: center;
  }

  .category-container {
    padding: 8px;
  }

  .fixed-size-button {
    min-width: 110px;
    padding: 9px 10px;
    font-size: 0.88rem;
  }

  .env-label,
  .symptom-label {
    line-height: 1.15;
  }

  .tablist {
    gap: 6px;
    padding: 5px;
    min-height: 44px;
  }

  .tab {
    font-size: 0.86em;
    padding: 7px 8px;
  }

  .pill-clear {
    margin-left: 0;
    height: 30px;
    min-width: 30px;
    border-radius: 10px;
  }

  .language-select-inline {
    min-width: 72px;
    height: 26px;
    padding: 2px 14px 2px 6px;
    font-size: 0.72rem;
    border-radius: 9px;
  }

  .data-update-status {
    max-width: none;
    font-size: 0.54rem;
    line-height: 1;
    white-space: nowrap;
  }

  .pathogen-container {
    padding: 8px;
  }

  .pathogen-content {
    font-size: 0.95em;
    padding: 10px 10px 6px 10px;
  }

  .pathogen-result {
    gap: 4px;
  }

  .pathogen-result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .pathogen-result-meta {
    text-align: left;
  }

  #bottom-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 12px;
    gap: 10px;
  }

  #bottom-text {
    font-size: 0.92em;
  }

  #btn-ppe {
    font-size: 0.94em;
    padding: 11px 16px;
  }
}
