:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #1a1d22;
  --panel-strong: #22262d;
  --text: #f1f3f5;
  --muted: #aab0ba;
  --line: #343a44;
  --accent: #d6b15d;
  --accent-strong: #f2ca72;
  --danger: #d96d6d;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 20px;
}

.query-panel,
.answer-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 20px;
}

.query-panel {
  align-self: start;
  position: sticky;
  top: 24px;
}

.title-row,
.form-footer,
.field-header,
.answer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.8rem;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.2rem;
}

.health-badge {
  flex: 0 0 auto;
  min-width: 72px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.health-badge.ok {
  border-color: rgba(214, 177, 93, 0.65);
  color: var(--accent-strong);
}

.health-badge.error {
  border-color: rgba(217, 109, 109, 0.7);
  color: var(--danger);
}

.ask-form {
  margin-top: 24px;
  display: grid;
  gap: 12px;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 140px;
  padding: 12px;
  line-height: 1.45;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
}

.compact-field {
  display: grid;
  grid-template-columns: auto 72px;
  align-items: center;
  gap: 8px;
}

.compact-field input {
  text-align: center;
}

button {
  height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #15120a;
  font-weight: 800;
  cursor: pointer;
}

.icon-button {
  width: 52px;
  min-width: 52px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--accent-strong);
  font-size: 0.78rem;
}

.icon-button.recording {
  border-color: var(--danger);
  color: #fff;
  background: #8d3030;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.answer-text {
  min-height: 220px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #121417;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.5;
}

.sources {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

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

.source h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.source p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.source-meta {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

@media (max-width: 760px) {
  .app-shell {
    min-height: auto;
    padding: 14px;
    grid-template-columns: 1fr;
  }

  .query-panel {
    position: static;
  }

  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-field {
    grid-template-columns: 1fr 88px;
  }

  button {
    width: 100%;
  }
}
