* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #0b1020;
  color: #e6e8ee;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.panel {
  width: 100%;
  max-width: 820px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#login { justify-content: center; max-width: 380px; }
h1 { margin: 0; font-size: 22px; letter-spacing: .3px; }
.subtle { margin: 0; color: #9aa3b2; font-size: 14px; }
.err { color: #ff7a90; font-size: 13px; min-height: 18px; margin: 0; white-space: pre-wrap; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #9aa3b2; }
input, textarea, button, select {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #2a3350;
  background: #141b33;
  color: #e6e8ee;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: #5d7cff; }
button {
  background: #4f6bff;
  border-color: #4f6bff;
  color: white;
  cursor: pointer;
  font-weight: 600;
}
button:disabled { opacity: .6; cursor: not-allowed; }
button.link { background: transparent; border: none; color: #9aa3b2; padding: 4px 8px; font-weight: 500; }
button.link:hover { color: #e6e8ee; }
select { cursor: pointer; min-width: 180px; }
.app { height: 100vh; padding: 16px 24px 24px; max-width: 1100px; gap: 10px; }
.app header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #222a45;
  padding-bottom: 10px;
}
.meta { display: flex; align-items: center; gap: 8px; }
.badge {
  font-size: 12px;
  color: #9aa3b2;
  background: #141b33;
  border: 1px solid #2a3350;
  padding: 3px 8px;
  border-radius: 999px;
}

/* Controls bar */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.model-select-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.model-select-group label {
  font-size: 12px;
  color: #9aa3b2;
  margin: 0;
}
.mode-toggle {
  display: flex;
  gap: 4px;
}
.tab {
  background: #141b33;
  border: 1px solid #2a3350;
  color: #9aa3b2;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
}
.tab.active {
  background: #4f6bff;
  border-color: #4f6bff;
  color: white;
}

/* Messages */
main#messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 2px;
}
.msg {
  padding: 10px 14px;
  border-radius: 10px;
  max-width: 80%;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.45;
}
.msg.user { align-self: flex-end; background: #2b3b82; }
.msg.assistant { align-self: flex-start; background: #1a2240; border: 1px solid #2a3350; }
.msg.error { align-self: center; background: #3a1a26; color: #ff9db0; border: 1px solid #552033; max-width: 95%; }
.msg .msg-meta {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #2a3350;
  font-size: 11px;
  color: #7a8599;
  flex-wrap: wrap;
}
.msg .msg-meta span { white-space: nowrap; }

/* Metrics panel */
.metrics-panel {
  background: #141b33;
  border: 1px solid #2a3350;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
}
.metrics-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.metric-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.metric-item .metric-label { color: #7a8599; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
.metric-item .metric-value { color: #e6e8ee; font-weight: 600; font-size: 13px; }
.metric-item .metric-value.cost { color: #5dff9a; }
.metric-item .metric-value.latency { color: #ffb85d; }

/* Compare view */
.compare-view {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.compare-card {
  background: #141b33;
  border: 1px solid #2a3350;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.compare-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #b0b8cc;
}
.compare-card .card-header .status {
  font-size: 11px;
  font-weight: 400;
  padding: 2px 6px;
  border-radius: 4px;
}
.compare-card .card-header .status.loading { background: #2a3350; color: #7a8599; }
.compare-card .card-header .status.done { background: #1a3a2a; color: #5dff9a; }
.compare-card .card-header .status.error { background: #3a1a26; color: #ff9db0; }
.compare-card .card-body {
  flex: 1;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: #e6e8ee;
  max-height: 300px;
  overflow-y: auto;
}
.compare-card .card-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #7a8599;
  border-top: 1px solid #222a45;
  padding-top: 6px;
}
.compare-card .card-metrics span { white-space: nowrap; }
.compare-card .card-metrics .cost { color: #5dff9a; }
.compare-card .card-metrics .latency { color: #ffb85d; }

/* Chat form */
#chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px solid #222a45;
  padding-top: 10px;
}
#chat-form textarea { flex: 1; resize: vertical; min-height: 44px; max-height: 200px; }
#chat-form button { align-self: stretch; min-width: 88px; }
