:root {
  --paper: #f7f4ed;
  --panel: #fffdfa;
  --panel-strong: #ffffff;
  --ink: #1e2524;
  --muted: #65706d;
  --line: #d8d1c4;
  --line-strong: #b9c6bf;
  --teal: #116a67;
  --teal-soft: #dcefed;
  --amber: #8a5a10;
  --amber-soft: #f8e7bd;
  --red: #9f3128;
  --shadow: 0 18px 45px rgba(54, 47, 35, 0.12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(17, 106, 103, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(17, 106, 103, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  min-height: 100vh;
}

.search-pane {
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 250, 0.92);
  backdrop-filter: blur(10px);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
}

.app-header,
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.app-header h1,
.detail-header h2 {
  margin: 0;
  font-family: "Source Han Serif SC", "Songti SC", "STSong", serif;
  font-weight: 700;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: 24px;
  line-height: 1.18;
}

.app-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  max-width: 32em;
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--teal);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.search-box {
  display: grid;
  gap: 7px;
}

.search-box label,
.renal-input-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-box input,
.renal-input-grid input,
.renal-input-grid select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

.search-box input:focus,
.renal-input-grid input:focus,
.renal-input-grid select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 106, 103, 0.15);
}

.renal-panel {
  border: 1px solid rgba(17, 106, 103, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  padding: 12px;
}

.renal-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.renal-panel-head strong {
  color: #0d5552;
  font-size: 14px;
  line-height: 1.35;
}

.renal-panel-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  text-align: right;
}

.renal-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.renal-input-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.creatinine-field,
.dialysis-field {
  grid-column: 1 / -1;
}

.renal-metric-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

.renal-calc-summary {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.calc-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 8px 10px;
}

.calc-pill.primary {
  border-color: rgba(17, 106, 103, 0.38);
  background: var(--teal-soft);
}

.calc-pill em,
.calc-pill strong {
  display: block;
  font-style: normal;
  line-height: 1.35;
}

.calc-pill em {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.calc-pill strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.notice {
  border-left: 4px solid var(--amber);
  background: var(--amber-soft);
  color: #4f3512;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
}

.result-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  min-height: 18px;
}

.results-list {
  list-style: none;
  margin: 0 -6px 0 0;
  padding: 0 6px 0 0;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.result-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  cursor: pointer;
  min-height: 46px;
  padding: 10px 12px;
  text-align: left;
  display: flex;
  align-items: center;
}

.result-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-strong);
}

.result-button.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.result-name {
  font-weight: 800;
  line-height: 1.35;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.result-use,
.result-dose {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-line;
}

.detail-pane {
  min-width: 0;
  padding: 24px;
  overflow: auto;
}

.empty-state {
  min-height: calc(100vh - 48px);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 253, 250, 0.62);
}

.drug-detail {
  display: grid;
  gap: 18px;
}

.detail-header {
  border-bottom: 2px solid var(--line);
  padding-bottom: 14px;
}

.drug-id {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.detail-header h2 {
  font-size: 30px;
  line-height: 1.22;
}

.detail-header a {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--teal);
  background: var(--panel);
  text-decoration: none;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 800;
}

.detail-header a:hover {
  border-color: var(--teal);
}

.quick-card {
  border: 2px solid rgba(17, 106, 103, 0.34);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(220, 239, 237, 0.86), rgba(255, 253, 250, 0.94));
  box-shadow: var(--shadow);
  padding: 16px;
}

.quick-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(17, 106, 103, 0.18);
  padding-bottom: 10px;
}

.quick-card h3 {
  margin: 0;
  color: #0d5552;
  font-size: 17px;
  line-height: 1.3;
}

.quick-card-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.quick-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.quick-fact {
  border: 1px solid rgba(17, 106, 103, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px 12px;
  min-width: 0;
}

.quick-fact.priority {
  border-color: rgba(17, 106, 103, 0.34);
  background: rgba(232, 246, 243, 0.78);
}

.quick-fact.injury-note,
.quick-fact.injury-core {
  border-color: rgba(159, 49, 40, 0.28);
  background: rgba(255, 248, 244, 0.86);
}

.quick-fact.injury-core {
  grid-column: 1 / -1;
  border-left: 4px solid var(--red);
}

.quick-fact span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}

.quick-fact.priority span {
  color: var(--teal);
}

.quick-fact.injury-note span,
.quick-fact.injury-core span {
  color: #8f3c2b;
}

.quick-fact strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.section-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.88);
  box-shadow: var(--shadow);
}

.section-block h3 {
  margin: 0;
  color: #2d3936;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  line-height: 1.65;
}

.band-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.band-list.compact {
  margin-top: 8px;
}

.band-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: var(--panel-strong);
}

.band-row.match {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.band-row strong {
  display: block;
  margin-bottom: 4px;
  color: var(--teal);
}

.band-row p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-line;
}

.inline-more,
.dialysis-more {
  margin-top: 2px;
}

.inline-more summary,
.dialysis-more summary {
  cursor: pointer;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  padding: 4px 2px;
}

.full-entry-wrap {
  min-width: 0;
}

.full-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.78);
  box-shadow: var(--shadow);
  padding: 0;
}

.full-entry > summary {
  cursor: pointer;
  color: var(--teal);
  font-weight: 900;
  padding: 14px 16px;
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 14px 14px;
}

.section-block {
  padding: 14px;
  min-width: 0;
}

.section-block.wide {
  grid-column: 1 / -1;
}

.section-block p {
  margin: 10px 0 0;
  white-space: pre-line;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title-row h3 {
  margin: 0;
}

.clean-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(183, 73, 50, 0.22);
  border-radius: 999px;
  background: rgba(255, 235, 226, 0.82);
  color: #8f3c2b;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 900;
}

.other-keypoints {
  margin-top: 10px;
  border: 1px solid rgba(17, 106, 103, 0.16);
  border-radius: 8px;
  background: rgba(232, 246, 243, 0.72);
  padding: 10px 12px;
}

.other-keypoints strong {
  display: block;
  color: var(--teal);
  font-size: 12px;
  margin-bottom: 6px;
}

.other-keypoints ul {
  margin: 0;
  padding-left: 18px;
}

.other-keypoints li {
  margin: 4px 0;
  line-height: 1.55;
}

.clean-note {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  padding-top: 9px;
}

.hidden-tail {
  margin-top: 8px;
}

.hidden-tail summary {
  cursor: pointer;
  color: #8f3c2b;
  font-size: 13px;
  font-weight: 900;
  padding: 4px 0;
}

.hidden-tail p {
  border: 1px solid rgba(183, 73, 50, 0.18);
  border-radius: 8px;
  background: rgba(255, 248, 244, 0.88);
  padding: 10px;
}

.muted {
  color: var(--muted);
}

.danger {
  color: var(--red);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell:not(.has-selection) .detail-pane {
    display: none;
  }

  .search-pane {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .results-list {
    max-height: 42vh;
  }

  .quick-facts,
  .sections-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .search-pane,
  .detail-pane {
    padding: 16px;
  }

  .search-pane {
    gap: 12px;
  }

  .app-header {
    gap: 10px;
  }

  .app-header h1 {
    font-size: 22px;
  }

  .app-header p {
    font-size: 12px;
    line-height: 1.45;
  }

  .renal-input-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-input {
    grid-template-columns: minmax(0, 1fr) 88px;
  }

  .result-button {
    min-height: 44px;
    padding: 10px 11px;
  }

  .detail-header {
    display: grid;
  }

  .detail-header h2 {
    font-size: 24px;
  }
}
