:root {
  color-scheme: dark;
  --bg: #0d1110;
  --panel: #151a18;
  --panel-strong: #1d2521;
  --text: #f4f7f0;
  --muted: #a7b0a8;
  --line: #2b3630;
  --accent: #74d38b;
  --accent-strong: #8ef0a5;
  --warn: #f0bd57;
  --danger: #ff8a75;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  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,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.shell {
  width: min(100vw, 600px);
  height: min(100vh, 600px);
  min-height: 420px;
  margin: 0 auto;
  display: flex;
  background:
    linear-gradient(180deg, rgba(116, 211, 139, 0.12), rgba(13, 17, 16, 0) 34%),
    var(--bg);
}

.auth-view,
.chat-view {
  width: 100%;
}

.auth-view {
  display: grid;
  place-content: center;
  gap: 18px;
  padding: 28px;
  text-align: center;
}

.auth-view h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  font-weight: 720;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: inline-grid;
  place-items: center;
  justify-self: center;
  border: 1px solid rgba(116, 211, 139, 0.45);
  border-radius: 8px;
  background: rgba(116, 211, 139, 0.14);
  color: var(--accent-strong);
  font-weight: 800;
}

.brand-mark.small {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

.auth-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: min(420px, calc(100vw - 44px));
}

.auth-form input,
.composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 26, 24, 0.96);
  color: var(--text);
  outline: none;
}

.auth-form input {
  min-height: 46px;
  padding: 0 12px;
}

.auth-form button,
.send-button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--accent);
  color: #07100a;
  font-weight: 760;
}

.chat-view {
  display: grid;
  grid-template-rows: 52px 1fr auto;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 16, 0.84);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 760;
}

.status {
  max-width: 48%;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}

.message {
  width: fit-content;
  max-width: 92%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  line-height: 1.38;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  background: #17311e;
  border-color: rgba(116, 211, 139, 0.36);
}

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

.message.error {
  align-self: center;
  border-color: rgba(255, 138, 117, 0.45);
  color: #ffd2ca;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(13, 17, 16, 0.94);
}

.composer textarea {
  min-height: 74px;
  max-height: 126px;
  padding: 10px 12px;
  resize: none;
}

.actions {
  display: grid;
  grid-template-columns: 48px;
  grid-auto-rows: 36px;
  gap: 6px;
  align-content: end;
}

.icon-button {
  width: 48px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.icon-button.active {
  color: #07100a;
  background: var(--warn);
  border-color: transparent;
}

.send-button {
  width: 48px;
  padding: 0;
  font-size: 12px;
}

button:disabled,
textarea:disabled {
  opacity: 0.58;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .shell {
    width: 100vw;
    height: 100vh;
  }

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

  .actions {
    grid-template-columns: 48px 48px 1fr;
    grid-auto-rows: 42px;
  }

  .send-button {
    width: 100%;
  }
}
