:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #626660;
  --line: #d9d9d2;
  --accent: #167c80;
  --accent-dark: #0f5c5f;
  --user: #e2f4f2;
  --assistant: #ffffff;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 380px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  display: grid;
  gap: 18px;
  box-shadow: 0 16px 40px rgba(32, 33, 36, 0.08);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 750;
}

.login-card h1 {
  font-size: 28px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

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

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 124, 128, 0.16);
}

.login-card input {
  min-height: 44px;
  padding: 0 12px;
}

.login-card button,
.new-chat,
.send-button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.login-card button,
.new-chat {
  min-height: 44px;
}

.login-card button:hover,
.new-chat:hover,
.send-button:hover {
  background: var(--accent-dark);
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.chat-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
}

.sidebar {
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: #eeeeea;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand-row,
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.brand-row h1 {
  font-size: 24px;
}

.conversation-list {
  flex: 1;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.conversation-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  overflow: hidden;
}

.conversation-item:hover,
.conversation-item.active {
  background: var(--panel);
  border-color: var(--line);
}

.conversation-open,
.conversation-delete {
  border: 0;
  background: transparent;
  color: inherit;
}

.conversation-open {
  min-width: 0;
  padding: 10px;
  text-align: left;
}

.conversation-delete {
  align-self: center;
  width: 36px;
  height: 36px;
  margin-right: 6px;
  padding: 0;
  border-radius: 8px;
  color: var(--danger);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.conversation-delete:hover {
  background: rgba(180, 35, 24, 0.08);
}

.conversation-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.conversation-time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.logout {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

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

.topbar {
  min-height: 72px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
}

.topbar h2 {
  max-width: min(68vw, 760px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
}

.messages {
  overflow-y: auto;
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.empty-state {
  margin: auto;
  max-width: 520px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

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

.message.user {
  justify-self: end;
}

.message.assistant {
  justify-self: start;
}

.bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--assistant);
  white-space: pre-wrap;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  background: var(--user);
}

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

.file-chips,
.suggestions,
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  width: min(760px, 100%);
}

.image-link {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.image-link img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.chip,
.suggestions button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 6px 10px;
  font-size: 13px;
}

.suggestions button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.composer {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  padding: 14px 22px 18px;
}

.attachments {
  margin-bottom: 10px;
}

.composer-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: end;
  gap: 10px;
}

.attach-button,
.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  font-size: 26px;
  font-weight: 500;
}

.attach-button input {
  display: none;
}

textarea {
  min-height: 44px;
  max-height: 160px;
  resize: none;
  padding: 11px 12px;
  line-height: 1.4;
}

.send-button {
  min-width: 76px;
  height: 44px;
  padding: 0 16px;
}

.send-button[disabled] {
  cursor: wait;
  opacity: 0.7;
}

.mobile-menu,
.mobile-close {
  display: none;
}

@media (max-width: 780px) {
  .chat-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform 160ms ease;
    box-shadow: 20px 0 40px rgba(32, 33, 36, 0.16);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu,
  .mobile-close {
    display: grid;
  }

  .topbar {
    padding: 12px 14px;
  }

  .messages {
    padding: 16px 12px;
  }

  .image-gallery {
    grid-template-columns: 1fr;
  }

  .composer {
    padding: 12px;
  }

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

  .attach-button {
    width: 40px;
    height: 40px;
  }

  .send-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}
