:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #171717;
  --muted: #6b6f73;
  --line: #dfe4dc;
  --accent: #0f7b5c;
  --accent-strong: #0a5c46;
  --warn: #bd4b3a;
  --violet: #6b5bd6;
  --shadow: 0 18px 50px rgba(23, 23, 23, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding: 22px;
  background: #fbfcfa;
  border-right: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button,
.send-button {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  width: 34px;
  height: 34px;
  background: #edf1ea;
  color: var(--ink);
}

.models {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  max-height: 36vh;
  padding-right: 2px;
}

.model-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.model-card:hover {
  border-color: rgba(15, 123, 92, 0.45);
}

.model-card.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.model-title {
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.model-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.settings {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

textarea:focus,
select:focus,
input[type="range"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 92, 0.12);
}

#systemPrompt {
  min-height: 92px;
  resize: vertical;
  padding: 10px;
  line-height: 1.45;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.secondary-button {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf1ea;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 70px;
  padding: 16px 22px;
  background: rgba(246, 247, 244, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

#modelSelect {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 520px;
  min-height: 42px;
  padding: 0 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf1ea;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status.online {
  background: rgba(15, 123, 92, 0.12);
  color: var(--accent-strong);
}

.status.error {
  background: rgba(189, 75, 58, 0.12);
  color: var(--warn);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 28px min(6vw, 72px);
}

.empty {
  margin: auto;
  width: min(100%, 620px);
  max-width: 620px;
  text-align: center;
}

.empty h2 {
  margin: 0;
  font-size: clamp(32px, 7vw, 76px);
  line-height: 0.95;
}

.empty p {
  margin: 14px auto 0;
  max-width: min(100%, 500px);
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.message {
  display: grid;
  gap: 6px;
  max-width: min(820px, 100%);
}

.message.user {
  align-self: flex-end;
}

.message.assistant {
  align-self: flex-start;
}

.bubble {
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow);
}

.user .bubble {
  background: var(--ink);
  color: #ffffff;
}

.assistant .bubble {
  background: var(--panel);
  border: 1px solid var(--line);
}

.message-meta {
  color: var(--muted);
  font-size: 11px;
}

.user .message-meta {
  text-align: right;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
  padding: 16px 22px 22px;
  background: rgba(246, 247, 244, 0.92);
  border-top: 1px solid var(--line);
}

#messageInput {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  min-height: 46px;
  max-height: 180px;
  overflow-y: hidden;
  resize: none;
  padding: 12px 14px;
  line-height: 1.45;
}

.send-button {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  background: var(--accent);
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
}

.send-button:disabled {
  background: #a7b5ac;
  cursor: wait;
}

@media (max-width: 860px) {
  .app {
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    width: 100%;
    max-width: 100vw;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .section-head {
    display: none;
  }

  .models,
  .settings {
    display: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  h1 {
    font-size: 18px;
  }

  .chat-shell {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100vw;
    height: auto;
    min-height: 0;
    overflow-x: hidden;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100vw;
    min-height: 58px;
    padding: 10px 14px;
    overflow-x: hidden;
  }

  #modelSelect {
    width: 100%;
    max-width: none;
  }

  .status {
    display: none;
  }

  .messages {
    width: 100%;
    max-width: 100vw;
    padding: 20px 14px 92px;
    overflow-x: hidden;
  }

  .composer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    width: 100vw;
    max-width: 100vw;
    padding: 12px 14px 16px;
  }

  #messageInput {
    padding-right: 66px;
  }

  .send-button {
    position: fixed;
    right: 14px;
    bottom: 16px;
    z-index: 11;
  }
}
