:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --text: #202124;
  --muted: #666b70;
  --line: #dcded8;
  --accent: #176b5d;
  --accent-2: #1d4f8f;
  --danger: #a64237;
  --code: #17201d;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

button,
select,
textarea {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: #e9ebe5;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
}

.brand h1,
.topbar h2,
.empty h3 {
  margin: 0;
}

.brand p,
.topbar p,
.empty p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.composer button,
.copy {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  padding: 11px 12px;
  background: var(--text);
  color: #fff;
  text-align: left;
}

.panel,
.command-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
}

.panel label,
.model-health label,
.context-panel label,
.command-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.context-panel {
  display: grid;
  gap: 10px;
}

.context-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8ddd3;
}

.context-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
  transition: width 180ms ease;
}

.health-head {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.health-head label {
  margin-bottom: 2px;
}

.health-head strong {
  font-size: 14px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #9ca3af;
  box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.16);
}

.dot.ok {
  background: #1f8f5f;
  box-shadow: 0 0 0 3px rgba(31, 143, 95, 0.18);
}

.dot.down {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(166, 66, 55, 0.16);
}

.model-health {
  display: grid;
  gap: 10px;
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
}

.compact {
  display: grid;
  gap: 10px;
}

.kv {
  display: grid;
  gap: 3px;
}

.kv span {
  color: var(--muted);
  font-size: 12px;
}

.kv strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.command-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.command-group {
  margin-top: 14px;
}

pre {
  margin: 0;
  max-height: 160px;
  overflow: auto;
  border-radius: 8px;
  background: var(--code);
  color: #d9eee7;
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.copy {
  margin-top: 8px;
  padding: 7px 9px;
  background: #d8ddd3;
  color: var(--text);
  font-size: 12px;
}

.app {
  min-height: 100%;
  margin-left: 320px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 24px;
  background: rgba(247, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.status {
  min-width: 82px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.messages {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 30px 24px 120px;
}

.empty {
  margin-top: 18vh;
  text-align: center;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 750;
}

.message.assistant .avatar {
  background: #dfece8;
  color: var(--accent);
}

.bubble {
  min-width: 0;
}

.role {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.content {
  line-height: 1.64;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-stats {
  min-height: 18px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.tool-call {
  margin-top: 12px;
}

.tool-call summary {
  cursor: pointer;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
}

.tool-call pre {
  margin-top: 8px;
}

.composer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 320px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: min(920px, calc(100% - 320px));
  margin: 0 auto;
  padding: 18px 24px 24px;
  background: linear-gradient(to top, var(--bg) 78%, rgba(247, 247, 244, 0));
}

textarea {
  width: 100%;
  max-height: 180px;
  min-height: 52px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 15px;
  background: var(--surface);
  color: var(--text);
  line-height: 1.5;
}

.composer button {
  align-self: end;
  min-width: 82px;
  height: 52px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.composer button:disabled {
  cursor: default;
  opacity: 0.55;
}

.error {
  color: var(--danger);
}

@media (max-width: 820px) {
  .sidebar {
    position: static;
    width: 100%;
    max-height: none;
  }

  .app {
    margin-left: 0;
  }

  .composer {
    position: sticky;
    left: auto;
    right: auto;
    bottom: 0;
    width: 100%;
    grid-template-columns: minmax(0, 1fr);
    padding: 12px;
  }

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

  .messages {
    padding-bottom: 32px;
  }

  .composer button {
    width: 100%;
  }
}
