:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #5d6b63;
  --line: #d8ded7;
  --paper: #f8faf7;
  --surface: #ffffff;
  --accent: #0d7c66;
  --accent-dark: #085a4a;
  --warm: #e7b44f;
  --danger: #c44938;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #edf5f1 0%, #f8faf7 34%, #f6f1e8 100%);
  color: var(--ink);
}

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

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 0 18px;
}

.kicker {
  margin: 0 0 3px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.1rem;
}

h2 {
  font-size: 1.05rem;
}

.health-pill,
.status-strip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
}

.health-pill {
  min-width: 92px;
  padding: 8px 11px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 700;
}

.health-pill.ok {
  color: var(--accent-dark);
  border-color: rgba(13, 124, 102, 0.25);
}

.health-pill.bad {
  color: var(--danger);
}

.status-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.tab,
.primary,
.secondary,
.icon-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.tab {
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.panel.active {
  display: block;
}

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

.panel-head h2 {
  margin-bottom: 0;
}

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

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 220px;
  margin-bottom: 12px;
  border: 1px dashed #9fb0a6;
  border-radius: 8px;
  background: #f2f6f3;
  color: var(--muted);
  overflow: hidden;
  text-align: center;
  cursor: pointer;
}

.drop-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-zone img {
  width: 100%;
  height: 260px;
  object-fit: cover;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fbfcfb;
  color: var(--ink);
  font-weight: 500;
}

.field textarea {
  resize: vertical;
}

.field-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
}

.primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 800;
}

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

.secondary {
  width: 100%;
  margin-top: 10px;
  background: #fff8e8;
  color: #624613;
  border-color: #edd08f;
  font-weight: 800;
}

.secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.recorder {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f3;
}

.icon-button {
  width: 54px;
  min-width: 54px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 1.2rem;
  line-height: 1;
}

.icon-button.recording {
  background: var(--ink);
}

.recorder p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-area {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

.result-main,
.citations {
  min-height: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.result-main dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  margin: 0;
}

.result-main dt {
  color: var(--muted);
  font-weight: 800;
}

.result-main dd {
  margin: 0;
}

.safety {
  margin-top: 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--warm);
  background: #fff9ea;
  color: #5c481e;
  border-radius: 6px;
}

.citations ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

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

.citations a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.loading {
  opacity: 0.7;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 1.72rem;
  }

  .status-strip,
  .result-area,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .status-strip {
    display: grid;
  }

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

  .result-main dl {
    grid-template-columns: 1fr;
  }
}
