:root {
  color-scheme: light;
  --ink: #0d0d0d;
  --muted: #6f6f6f;
  --line: #e7e7e7;
  --panel: #ffffff;
  --sidebar: #f7f7f7;
  --hover: #ececec;
  --active: #e9e9e9;
  --accent: #111111;
  --bubble: #f4f4f4;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--panel);
  color: var(--ink);
}

button,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  padding: 0 4px;
}

.brand h1,
.chat-header h2 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  font-weight: 700;
}

.sidebar-action,
.new-chat,
.conversation-item,
.icon-button,
.composer button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
}

.sidebar-action {
  width: 34px;
  height: 34px;
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.sidebar-action:hover,
.icon-button:hover,
.new-chat:hover,
.conversation-item:hover {
  background: var(--hover);
}

.new-chat {
  background: transparent;
  padding: 11px 12px;
  text-align: left;
  font-size: 14px;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: auto;
  min-height: 0;
}

.conversation-item {
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  color: var(--ink);
  font-size: 14px;
}

.conversation-item.active {
  background: var(--active);
}

.conversation-item span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item small {
  color: var(--muted);
  display: none;
}

.chat-panel {
  background: var(--panel);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.chat-header {
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h2 {
  font-size: 18px;
  font-weight: 600;
  max-width: min(680px, 72vw);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  background: transparent;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
}

.messages-shell {
  overflow: auto;
}

.messages {
  width: min(100%, 820px);
  min-height: 100%;
  margin: 0 auto;
  padding: 32px 20px 36px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.empty {
  margin: auto;
  max-width: 680px;
  text-align: center;
  color: var(--ink);
  font-size: 30px;
  font-weight: 650;
  letter-spacing: 0;
}

.message-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--accent);
  color: white;
}

.message-row.assistant .avatar {
  background: #10a37f;
}

.bubble {
  max-width: 100%;
  padding: 3px 0;
  line-height: 1.75;
  white-space: pre-wrap;
  font-size: 16px;
}

.message-row.user {
  grid-template-columns: minmax(0, 1fr);
}

.message-row.user .avatar {
  display: none;
}

.message-row.user .bubble {
  justify-self: end;
  max-width: min(72%, 620px);
  background: var(--bubble);
  border-radius: 18px;
  padding: 10px 14px;
}

.composer {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 10px 20px 20px;
}

.composer-box {
  min-height: 58px;
  border: 1px solid #d9d9d9;
  border-radius: 28px;
  background: var(--panel);
  display: grid;
  grid-template-columns: 38px 1fr 42px;
  align-items: end;
  gap: 10px;
  padding: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.08);
}

.composer-box:focus-within {
  border-color: #c5c5c5;
}

.composer textarea {
  width: 100%;
  resize: none;
  max-height: 180px;
  min-height: 32px;
  border: 0;
  padding: 7px 0;
  background: transparent;
  color: var(--ink);
  outline: none;
  line-height: 1.5;
  font-size: 16px;
}

.attach-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--hover);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.attach-button:hover {
  background: var(--active);
}

.file-input {
  display: none;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.attachment-chip {
  border: 1px solid var(--line);
  background: #f7f7f7;
  border-radius: 14px;
  padding: 6px 9px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(100%, 280px);
  font-size: 13px;
}

.attachment-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip button {
  width: 20px;
  height: 20px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
}

.composer textarea::placeholder {
  color: #8a8a8a;
}

.composer button {
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: white;
  padding: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}

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

.composer-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 780px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    max-height: 170px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px;
  }

  .conversation-list {
    flex-direction: row;
    overflow-x: auto;
  }

  .conversation-item {
    min-width: 150px;
  }

  .messages {
    padding: 24px 14px 28px;
  }

  .message-row.user .bubble {
    max-width: 88%;
  }

  .empty {
    font-size: 24px;
  }
}
