:root {
  --bg: #f7f3e9;
  --panel: #fffcf5;
  --ink: #1f1f1f;
  --muted: #57534e;
  --accent: #2f6f53;
  --accent-soft: #d9efe2;
  --danger: #982b1c;
  --ring: #f2b45a;
  --shadow: 0 18px 34px rgba(15, 23, 42, 0.12);
}

@media all {
  :root {
    --bg: #0f1418;
    --panel: #141d23;
    --ink: #e8f0f2;
    --muted: #aab9bf;
    --accent: #56b18b;
    --accent-soft: #1d352c;
    --danger: #ff8d85;
    --ring: #f2b45a;
    --shadow: 0 20px 34px rgba(0, 0, 0, 0.38);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.app-shell {
  width: min(1100px, 92vw);
  margin: 1rem auto 2rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.4vw, 1.8rem);
}

.panel-title {
  margin: 0;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.65rem;
}

.panel-title-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.panel-title-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
}

.symptom-headline {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  width: 100%;
}

.symptom-headline #clearBtn {
  margin-left: auto;
}

.clear-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
}

.symptom-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  min-width: 46px;
}

.panel-logo {
  width: 46px;
  height: auto;
}

.panel-byline {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.panel-byline a {
  color: var(--accent);
  text-decoration: none;
}

.panel {
  background: var(--panel);
  border: 2px solid #d8cfbc;
  border-radius: 6px;
  padding: 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

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

h2 {
  margin: 0;
  font-size: 1.18rem;
}

.diagnosis-data-source {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
}

.inline-link:hover,
.inline-link:focus-visible {
  color: #78c8a4;
  text-decoration: none;
}

.ghost-btn {
  border: 1px solid #b9b2a4;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font: inherit;
}

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

.symptom-card {
  position: relative;
  border: 2px solid #d9d1bf;
  border-radius: 6px;
  background: #fff;
  min-height: 112px;
  display: grid;
  place-items: center;
  gap: 0.4rem;
  padding: 0.6rem;
  cursor: pointer;
  text-align: center;
  font: inherit;
  color: inherit;
  transition: 140ms ease;
}

.symptom-exclude {
  position: absolute;
  top: 0.28rem;
  right: 0.34rem;
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffe9ec;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 999px;
  background: #6a1f28;
  border: 1px solid #d72c43;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.symptom-grid.has-selection .symptom-card:not(:disabled) .symptom-exclude {
  opacity: 1;
  pointer-events: auto;
}

.symptom-exclude:hover,
.symptom-exclude:focus-visible {
  background: #f9dbe0;
  outline: none;
}

.symptom-grid.has-selection .symptom-card.confirmed-hint:not(:disabled) .symptom-exclude {
  opacity: 1;
  pointer-events: none;
  color: transparent;
  background: #1f6b3f;
  border: 1px solid #4bc47a;
  position: absolute;
}

.symptom-card.confirmed-hint .symptom-exclude::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.36rem;
  height: 0.2rem;
  border-left: 2px solid #e7ffef;
  border-bottom: 2px solid #e7ffef;
  transform: translate(-50%, -58%) rotate(-45deg);
}

.symptom-card:hover {
  transform: translateY(-2px);
  border-color: #998f7b;
}

.symptom-card.excluded {
  border-color: #d8727d;
  background: #fff0f2;
}

.symptom-card.incompatible,
.symptom-card:disabled {
  border-color: #d2cdc2;
  background: #f0ede6;
  color: #9a9589;
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

.symptom-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.symptom-card:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.icon {
  width: 50px;
  height: 50px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.icon-image {
  object-fit: contain;
  image-rendering: auto;
  filter: brightness(0) invert(1) drop-shadow(0 0 1px rgba(0, 0, 0, 0.9));
}

.icon-image-preserve-edge {
  
}

.symptom-label {
  font-size: 0.88rem;
  line-height: 1.1;
}

.results,
.disease-grid {
  display: grid;
  gap: 0.8rem;
}

.results {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-items: start;
}

.disease-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.placeholder {
  color: var(--muted);
  margin: 0;
}

.result-card,
.disease-card {
  border: 1px solid #d8cfbc;
  border-radius: 6px;
  padding: 0.72rem;
  background: #fff;
}

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.7rem;
}

.result-title {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  flex-wrap: wrap;
}

.disease-icon {
  width: 1.05rem;
  height: 1.05rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  color: var(--accent);
  flex: 0 0 auto;
}

h3 {
  margin: 0;
}

.illness-link-btn,
.code-proof-btn {
  position: relative;
  border: 1px solid #9cb8dd;
  background: #eaf2ff;
  color: #1f3f66;
  border-radius: 6px;
  width: 1.9rem;
  height: 1.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.illness-link-btn:hover,
.code-proof-btn:hover {
  transform: translateY(-1px);
}

.illness-link-btn svg,
.code-proof-btn svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.illness-link-glyph {
  width: 1rem;
  height: 1rem;
  display: inline-block;
  background-color: currentColor;
  -webkit-mask: url("./icons/status/link.svg") no-repeat center / contain;
  mask: url("./icons/status/link.svg") no-repeat center / contain;
}

.code-proof-glyph {
  width: 1rem;
  height: 1rem;
  display: inline-block;
  background-color: currentColor;
  -webkit-mask: url("./icons/status/code.svg") no-repeat center / contain;
  mask: url("./icons/status/code.svg") no-repeat center / contain;
}

.illness-link-btn.copied {
  border-color: #9cb8dd;
  background: #eaf2ff;
  color: #1f3f66;
}

.score-pill {
  background: #fbe8c4;
  border: 1px solid #efc884;
  border-radius: 6px;
  padding: 0.22rem 0.55rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.score-pill.pill-definitive {
  background: #e6f5eb;
  border-color: #6fb389;
  color: #1f6b3f;
}

.score-pill.pill-possible {
  background: #fbe8c4;
  border-color: #efc884;
  color: #5c4316;
}

.pill-check {
  margin-left: 0.3rem;
  font-weight: 700;
}

.label {
  margin: 0.65rem 0 0.35rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: #57534e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chip-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip-list li {
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
}

.matched li,
.symptoms li {
  border: 1px solid #bdb7a8;
  background: #efebe1;
  color: #6b6558;
}

.matched li.hit {
  border-color: #7fb996;
  background: #e6f5eb;
  color: #214f38;
}

.symptoms li.hit {
  border-color: #7fb996;
  background: #e6f5eb;
  color: #214f38;
}

.treatment li {
  border: 1px solid #f2c6a3;
  background: #fff2e8;
}

.prevention-list li {
  border: 1px solid #9cb8dd;
  background: #eaf2ff;
  color: #1f3f66;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.prevention-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.45rem;
}

.prevention-list {
  min-height: 4.25rem;
  align-content: flex-start;
}

.code-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  min-height: 4.25rem;
  gap: 0.45rem;
}

.code-proof-btn::after,
.illness-link-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: #1f6b3f;
  color: #e7ffef;
  border: 1px solid #4bc47a;
  border-radius: 6px;
  padding: 0.24rem 0.42rem;
  font-size: 0.72rem;
  line-height: 1.1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 80ms linear;
}

.code-proof-btn::before,
.illness-link-btn::before {
  content: "";
  position: absolute;
  right: calc(100% + 2px);
  top: 50%;
  transform: translateY(-50%);
  border-width: 5px 0 5px 6px;
  border-style: solid;
  border-color: transparent transparent transparent #1f6b3f;
  opacity: 0;
  pointer-events: none;
  transition: opacity 80ms linear;
}

.code-proof-btn:hover::after,
.code-proof-btn:hover::before,
.illness-link-btn:hover::after,
.illness-link-btn:hover::before,
.code-proof-btn:focus-visible::after,
.code-proof-btn:focus-visible::before,
.illness-link-btn:focus-visible::after,
.illness-link-btn:focus-visible::before {
  opacity: 1;
}

.definitive-jump {
  position: fixed;
  right: 0.9rem;
  bottom: 1rem;
  z-index: 940;
  width: 4.8rem;
  height: 4.8rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #1f3f66;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
}

.definitive-jump img {
  width: 4.2rem;
  height: 4.2rem;
  object-fit: contain;
}

.definitive-jump.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
}

.modal-panel {
  position: relative;
  width: min(600px, 60vw);
  max-height: 84vh;
  overflow: auto;
  margin: 6vh auto 0;
  background: #fff;
  border: 1px solid #d8cfbc;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-panel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 4;
  background: inherit;
  padding: 0.85rem 0.85rem 0.45rem;
  border-bottom: 1px solid #d8cfbc;
}

.modal-close {
  border: 1px solid #d8cfbc;
  background: #fff;
  color: #1f1f1f;
  border-radius: 6px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
}

.modal-body {
  margin-top: 0;
  padding: 0.55rem 0.85rem 0.85rem;
  display: grid;
  gap: 0.7rem;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.changelog-content {
  display: block;
  line-height: 1.4;
}

.changelog-content h2,
.changelog-content h3,
.changelog-content h4 {
  margin: 0.35rem 0 0.45rem;
}

.changelog-content p {
  margin: 0 0 0.5rem;
}

.changelog-content ul {
  margin: 0 0 0.6rem 1.1rem;
  padding: 0;
}

.changelog-content li {
  margin: 0 0 0.3rem;
}

.code-block {
  border: 1px solid #2a3440;
  border-radius: 6px;
  background: #1e1e1e;
  padding: 0.45rem 0;
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-x: hidden;
  overflow-y: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #d4d4d4;
  line-height: 1;
  tab-size: 2;
}

.code-line-no {
  color: #858585 !important;
  min-width: 3.2ch;
  text-align: right;
  user-select: none;
  padding-right: 0.9rem;
  border-right: 1px solid #2d2d2d;
  margin-right: 0.9rem;
}

.code-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  padding: 0 0.65rem;
  line-height: 1;
  min-height: 1em;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.code-line-text {
  color: #d4d4d4;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tok-keyword {
  color: #569cd6;
}

.tok-type {
  color: #4ec9b0;
}

.tok-fn {
  color: #dcdcaa;
}

.tok-string {
  color: #ce9178;
}

.tok-number {
  color: #b5cea8;
}

.code-line-no .tok-number {
  color: inherit !important;
}

.tok-comment {
  color: #6a9955;
}

.code-meta {
  padding: 0 0.65rem;
  color: #9cdcfe;
  line-height: 1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.code-file-tag {
  color: #4fc1ff;
}

.code-line-tag {
  color: #858585;
}

.progression {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.stage-wrap {
  margin-top: 0.45rem;
}

.stage-rail {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  margin-top: 0.35rem;
}

.stage-node {
  display: grid;
  justify-items: center;
  gap: 0.24rem;
  min-width: 56px;
}

.stage-dot {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 999px;
  border: 1px solid #b7b0a1;
  background: #fff;
  color: #615b50;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
}

.stage-dot.complete {
  border-color: #7ab792;
  background: #e7f6ec;
  color: #24553d;
}

.stage-dot.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  transform: scale(1.05);
}

.stage-name {
  font-size: 0.68rem;
  text-align: center;
  line-height: 1.1;
  color: var(--muted);
  max-width: 82px;
}

.stage-line {
  height: 2px;
  flex: 1;
  min-width: 16px;
  background: #cfc6b4;
  border-radius: 6px;
}

.stage-line.complete {
  background: #70b388;
}

.no-match {
  border: 1px solid #ecc7c2;
  background: #fff1ef;
  color: var(--danger);
  border-radius: 6px;
  padding: 0.75rem;
}

.all-illnesses-wrap {
  margin-top: 0.85rem;
  border: 1px solid #d8cfbc;
  border-radius: 6px;
  background: #fff;
}

.all-illnesses-grid {
  padding: 0.75rem;
}

@media (max-width: 760px) {
  .panel-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-title-side {
    align-items: flex-start;
  }

  .panel-byline {
    text-align: left;
    text-decoration:none;
  }

  .definitive-jump {
    display: inline-flex;
  }
}

@media (max-width: 414px) {
  .panel-title-row {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .panel-title-main {
    flex: 1 1 auto;
    gap: 0.45rem;
  }

  .panel-logo {
    width: 34px;
  }

  .panel-title {
    font-size: 1.08rem;
    line-height: 1.15;
  }

  .panel-title-side {
    flex: 0 0 auto;
    max-width: 45%;
    align-items: flex-end;
  }

  .panel-byline {
    font-size: 0.67rem;
    line-height: 1.2;
    text-align: right;
  }

}

@media (max-width: 375px) {
  .panel-logo {
    width: 30px;
  }

  .panel-title {
    font-size: 1.01rem;
  }

  .panel-byline {
    font-size: 0.62rem;
  }
}

@media all {
  .panel,
  .result-card,
  .disease-card {
    border-color: #31434e;
  }

  .ghost-btn,
  .symptom-card,
  .result-card,
  .disease-card {
    background: #18232b;
  }

  .ghost-btn {
    border-color: #3a4b55;
  }

  .symptom-card {
    border-color: #334650;
  }

  .symptom-card:hover {
    border-color: #4d6673;
  }

  .symptom-card.excluded {
    border-color: #8e5056;
    background: #2d1f24;
  }

  .symptom-exclude {
    color: #ffe9ec;
  }

  .symptom-exclude:hover,
  .symptom-exclude:focus-visible {
    background: #5a2530;
    
  }

  .symptom-grid.has-selection .symptom-card:not(:disabled) .symptom-exclude {
    background: #5f1f2a;
    border-color: #b43c4e;
    color: #ffe9ec;
  }

  .symptom-card.confirmed-hint .symptom-exclude {
    background: #1d5a39;
    border-color: #48bf78;
  }

  .symptom-card.incompatible,
  .symptom-card:disabled {
    border-color: #2f3e46;
    background: #141d23;
    color: #6f8791;
  }

  .score-pill {
    background: #2f271a;
    border-color: #5e4a28;
    color: #ffd9a0;
  }

  .score-pill.pill-definitive {
    background: #173429;
    border-color: #2d6a52;
    color: #cfeede;
  }

  .score-pill.pill-possible {
    background: #2f271a;
    border-color: #5e4a28;
    color: #ffd9a0;
  }

  .matched li,
  .symptoms li {
    border-color: #4a5c66;
    background: #1b242b;
    color: #9db0b9;
  }

  .matched li.hit {
    border-color: #2d6a52;
    background: #173429;
    color: #cfeede;
  }

  .symptoms li.hit {
    border-color: #2d6a52;
    background: #173429;
    color: #cfeede;
  }

  .treatment li {
    border-color: #735339;
    background: #36271d;
    color: #ffe2c6;
  }

  .label,
  .progression {
    color: #bbcad0;
  }

  .prevention-list li {
    border-color: #3c587f;
    background: #1a2738;
    color: #cde0ff;
  }

  .code-proof-btn,
  .illness-link-btn,
  .illness-link-btn.copied {
    border-color: #3c587f;
    background: #1a2738;
    color: #cde0ff;
  }

  .definitive-jump {
    background: transparent;
    color: #cde0ff;
  }

  .modal-panel {
    background: #18232b;
    border-color: #31434e;
  }

  .modal-head {
    border-bottom-color: #31434e;
  }

  .modal-close {
    border-color: #3a4b55;
    background: #18232b;
    color: #e8f0f2;
  }

  .code-block {
    border-color: #2a3440;
    background: #1e1e1e;
    color: #d4d4d4;
  }

  .stage-dot {
    border-color: #4b5f6b;
    background: #1a242b;
    color: #a9bbc3;
  }

  .stage-name {
    color: #9cb0b9;
  }

  .stage-dot.complete {
    border-color: #3a8363;
    background: #1a3b2f;
    color: #ccf2df;
  }

  .stage-dot.active {
    border-color: #63c59b;
    background: #56b18b;
    color: #0f1c17;
  }

  .stage-line {
    background: #3d515d;
  }

  .stage-line.complete {
    background: #3a8363;
  }

  .no-match {
    border-color: #6d3f3b;
    background: #2c1b1a;
  }

  .all-illnesses-wrap {
    border-color: #31434e;
    background: #18232b;
  }
}

@media (max-width: 680px) {
  .symptom-brand {
    align-items: center;
  }

  .app-shell {
    width: min(100%, 96vw);
    margin-top: 1rem;
  }

  .panel {
    padding: 0.85rem;
  }

  .symptom-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .results,
  .disease-grid {
    grid-template-columns: 1fr;
  }
}
