:root {
  --page: #f7f8f6;
  --panel: #ffffff;
  --ink: #17201d;
  --muted: #64736d;
  --line: #dce3df;
  --accent: #167c6b;
  --accent-dark: #0f5f52;
  --soft: #e8f3ef;
  --warm: #c06444;
  --shadow: 0 20px 60px rgba(24, 39, 33, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px;
}

.topbar,
.control-band,
.term-list,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.topbar {
  padding: 22px 24px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 3px 0 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: end;
  margin-top: 18px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: #34443e;
  font-size: 0.9rem;
  font-weight: 750;
}

.field input {
  min-height: 46px;
  width: 100%;
  border: 1px solid #cbd7d2;
  border-radius: 6px;
  padding: 0 13px;
  background: #fbfcfb;
  color: var(--ink);
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 124, 107, 0.16);
}

.disease-search-field {
  align-self: start;
}

.disease-matches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 30px;
}

.disease-match {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: white;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.disease-match:hover,
.disease-match.active {
  border-color: #a7cec2;
  background: var(--soft);
}

.disease-match.closest {
  color: var(--warm);
}

.dictionary-line {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.dictionary-line a {
  color: var(--accent-dark);
  font-weight: 800;
}

.term-layout {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.term-list,
.detail-panel {
  min-height: 560px;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  background: #fbfcfb;
}

.panel-heading p {
  margin: 0;
  font-weight: 850;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.86rem;
}

#termList {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.empty-list {
  color: var(--muted);
  line-height: 1.55;
}

.term-row {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.term-row:hover,
.term-row.active {
  border-color: #a7cec2;
  background: var(--soft);
}

.term-row strong {
  font-size: 0.98rem;
}

.term-row span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.match-note {
  color: var(--warm);
  font-size: 0.78rem;
  font-weight: 800;
}

.term-detail {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.term-detail h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.12;
}

.term-detail h3 {
  margin: 0;
  color: var(--accent-dark);
  font-size: 1rem;
}

.term-detail p {
  margin: 0;
  color: #40504a;
  line-height: 1.62;
}

.pronunciation-text {
  border-left: 4px solid var(--warm);
  padding: 12px 0 12px 14px;
  background: linear-gradient(90deg, rgba(192, 100, 68, 0.09), rgba(255, 255, 255, 0));
}

.speak-button {
  min-height: 46px;
  width: fit-content;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-weight: 800;
}

.speak-button:hover {
  background: var(--accent-dark);
}

.empty-detail {
  align-content: center;
  min-height: 500px;
  color: var(--muted);
}

.app-footer {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding: 16px 4px 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.app-footer p {
  margin: 0;
}

.app-footer p + p {
  margin-top: 4px;
}

@media (max-width: 820px) {
  .app { padding: 14px; }
  .control-band { grid-template-columns: 1fr; }
  .term-layout { grid-template-columns: 1fr; }
}
