:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #5f6b85;
  --line: #d6dceb;
  --accent: #2f5bdb;
  --accent-soft: #e7eeff;
  --danger: #b13a3a;
  --success: #1e7f53;
  --shadow: 0 14px 40px rgba(22, 32, 51, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
}

.page-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 18px 48px;
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

.hero-copy,
.hero-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-copy,
.hero-card {
  padding: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.02;
}

.hero-subtitle {
  max-width: 58ch;
  margin-bottom: 0;
  font-size: 1.04rem;
  color: var(--muted);
}

.hero-card-title {
  margin-bottom: 8px;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 0.95fr 1.25fr 0.9fr;
  gap: 18px;
}

.panel {
  padding: 20px;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.87rem;
  font-weight: 700;
}

.field-group,
.field-row,
.button-row,
.status-box,
.diagnostics-card,
.evaluation-results {
  margin-top: 14px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

select,
textarea,
button,
input[type="range"] {
  font: inherit;
}

select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 112px;
  resize: vertical;
}

textarea:focus,
select:focus,
button:focus,
input:focus {
  outline: 2px solid rgba(47, 91, 219, 0.18);
  outline-offset: 2px;
}

.helper-text {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.helper-emphasis {
  color: var(--text);
  font-weight: 500;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.switches {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  margin: 0;
}

.switch-row input {
  width: 18px;
  height: 18px;
}

.button-row,
.composer-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  background: #eef2fb;
  color: var(--text);
}

button[disabled] {
  opacity: 0.65;
  cursor: not-allowed;
}

.status-box {
  padding: 12px 14px;
  border-radius: 12px;
  background: #f1f4fa;
  color: var(--text);
  line-height: 1.45;
}

.chat-log {
  min-height: 460px;
  max-height: 62vh;
  overflow-y: auto;
  padding-right: 6px;
}

.message {
  margin-bottom: 14px;
  padding: 14px 15px;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.message.user {
  background: #f5f7ff;
}

.message.assistant {
  background: #fbfcff;
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.message-role {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.message-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.message p {
  margin-bottom: 0;
  line-height: 1.55;
  white-space: pre-wrap;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fafcff;
}

.metric-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric-value {
  font-size: 1.05rem;
  font-weight: 700;
}

.metric-value.good {
  color: var(--success);
}

.metric-value.bad {
  color: var(--danger);
}

.eval-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.eval-table th,
.eval-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.92rem;
}

.eval-pass {
  color: var(--success);
  font-weight: 700;
}

.eval-fail {
  color: var(--danger);
  font-weight: 700;
}

.footer {
  margin-top: 18px;
  padding: 18px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

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

  .chat-log {
    min-height: 300px;
    max-height: unset;
  }
}
