:root {
  --bg: #f4f6f8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: rgba(255, 255, 255, 0.95);
  --text: #101316;
  --muted: #5f6873;
  --line: rgba(16, 19, 22, 0.12);
  --accent: #0b7a75;
  --accent-soft: rgba(11, 122, 117, 0.12);
  --danger: #d14848;
  --ok: #2f8f6a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #d4eceb 0%, transparent 42%),
    radial-gradient(circle at 90% 90%, #d8e4ef 0%, transparent 40%),
    var(--bg);
  padding: 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1400px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.topbar {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.brand img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 110px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  padding: 18px;
  overflow: auto;
}

.control-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.intro-card,
.status-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.intro-card h1 {
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-weight: 700;
  padding: 4px 10px;
  font-size: 0.9rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, white);
  outline-offset: 1px;
}

.symptom-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.symptom-btn {
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: transform 0.18s ease, background 0.18s ease;
}

.symptom-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.98);
}

.symptom-btn.active {
  border-color: rgba(209, 72, 72, 0.45);
  background: rgba(209, 72, 72, 0.13);
  color: #7f1f1f;
}

.symptom-btn-label {
  display: block;
  line-height: 1.3;
}

.symptom-btn-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

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

.hint.large {
  font-size: 1.02rem;
}

.hidden {
  display: none !important;
}

.results-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.diagnosis-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.diagnosis-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 12px;
}

.diagnosis-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.diagnosis-meta {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.diagnosis-row {
  margin-bottom: 8px;
}

.diagnosis-row:last-child {
  margin-bottom: 0;
}

.diagnosis-label {
  display: block;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.symptom-match-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.symptom-match {
  border: 1px solid rgba(47, 143, 106, 0.36);
  background: rgba(47, 143, 106, 0.12);
  color: #18543c;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.86rem;
  cursor: default;
}

.symptom-mismatch {
  border-color: rgba(209, 72, 72, 0.36);
  background: rgba(209, 72, 72, 0.12);
  color: #7f1f1f;
  cursor: pointer;
}

.small-list {
  margin: 0;
  padding-left: 20px;
}

.small-list li {
  margin-bottom: 4px;
}

.small-list li:last-child {
  margin-bottom: 0;
}

.btn,
button.btn {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--text);
  color: #f9fbfb;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.btn:hover,
button.btn:hover {
  transform: translateY(-1px);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
}

.btn.danger {
  border-color: rgba(209, 72, 72, 0.4);
  background: rgba(209, 72, 72, 0.16);
  color: #7f1f1f;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

#scrollToTopBtn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--text);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#scrollToTopBtn.visible {
  display: inline-flex;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(16, 19, 22, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(90vh, 920px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  padding: 16px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin-bottom: 6px;
}

.modal-description {
  color: var(--muted);
  line-height: 1.45;
}

.field-grid {
  display: grid;
  gap: 10px;
}

.field-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.62);
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.field-head label {
  margin-bottom: 0;
}

.note-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  min-height: 28px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.note-pill.has-note {
  border-color: rgba(11, 122, 117, 0.4);
  background: rgba(11, 122, 117, 0.12);
  color: var(--accent);
}

.choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-list label {
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.78);
  font-weight: 500;
}

.choice-list input {
  width: auto;
  margin: 0;
}

@media (max-width: 980px) {
  .layout-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

@media (max-width: 900px) {
  body {
    padding: 10px;
  }

  .page-shell {
    gap: 10px;
  }

  .panel {
    padding: 12px;
    border-radius: 16px;
  }

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

  #scrollToTopBtn {
    right: 12px;
    bottom: 12px;
  }

  .modal-overlay {
    padding: 10px;
  }

  .modal-card {
    border-radius: 14px;
    padding: 12px;
  }
}
