:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel-soft: #f1f1ee;
  --text: #20211f;
  --muted: #6b6d67;
  --muted-strong: #4f514c;
  --line: #deded8;
  --accent: #0f7f68;
  --accent-strong: #075b4c;
  --accent-soft: #dff3ee;
  --danger: #a64b32;
  --shadow: 0 18px 45px rgba(24, 25, 23, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

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

.sidebar-top {
  display: grid;
  gap: 10px;
}

.brand-button,
.new-chat,
.nav-item,
.history-item,
.profile-button,
.model-button,
.share-button,
.icon-button,
.prompt-card {
  transition:
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.brand-button,
.new-chat,
.nav-item,
.profile-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.brand-button:hover,
.nav-item:hover,
.history-item:hover,
.profile-button:hover {
  background: rgba(32, 33, 31, 0.07);
}

.brand-mark,
.welcome-mark,
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 760;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: white;
}

.brand-name {
  font-weight: 720;
  letter-spacing: 0;
}

.new-chat {
  justify-content: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(24, 25, 23, 0.03);
}

.new-chat:hover {
  background: #fafafa;
}

.main-nav {
  display: grid;
  gap: 2px;
}

.nav-item {
  min-height: 38px;
  color: var(--muted-strong);
}

.nav-item.active {
  background: rgba(15, 127, 104, 0.12);
  color: var(--accent-strong);
}

.history-section {
  display: grid;
  gap: 3px;
}

.section-label {
  padding: 6px 10px 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.history-item {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 8px;
  overflow: hidden;
  color: var(--muted-strong);
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item.selected {
  background: rgba(32, 33, 31, 0.08);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
}

.profile-button {
  align-items: center;
}

.profile-button strong,
.profile-button small {
  display: block;
}

.profile-button strong {
  font-size: 0.92rem;
}

.profile-button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #30332f;
  color: #fff;
  font-size: 0.82rem;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 10px 18px;
  border-bottom: 1px solid transparent;
}

.menu-toggle {
  display: none;
}

.model-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 48vw;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-weight: 680;
}

.model-button:hover,
.icon-button:hover {
  background: var(--panel-soft);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-strong);
}

.share-button {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 8px;
  background: #20211f;
  color: white;
  font-weight: 650;
}

.share-button:hover {
  background: #3a3b37;
}

.chat-scroll {
  overflow-y: auto;
  padding: 22px 18px 28px;
}

.welcome {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: calc(100vh - 230px);
  max-width: 860px;
  margin: 0 auto;
  text-align: center;
}

.welcome.hidden {
  display: none;
}

.welcome-mark {
  width: 44px;
  height: 44px;
  margin-bottom: 20px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow);
}

h1 {
  margin: 0 0 28px;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(680px, 100%);
}

.prompt-card {
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbfa;
  color: var(--muted-strong);
  text-align: left;
  line-height: 1.25;
}

.prompt-card:hover {
  border-color: rgba(15, 127, 104, 0.35);
  background: var(--accent-soft);
  color: var(--accent-strong);
  transform: translateY(-1px);
}

.messages {
  display: grid;
  gap: 22px;
  width: min(830px, 100%);
  margin: 0 auto;
}

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

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

.message.user .message-avatar {
  grid-column: 2;
  background: #30332f;
}

.message.user .message-body {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  max-width: min(620px, 100%);
  border-radius: 18px;
  background: var(--panel-soft);
  padding: 11px 14px;
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 750;
  font-size: 0.84rem;
}

.message-body {
  min-width: 0;
  color: var(--text);
  line-height: 1.55;
}

.message-body p {
  margin: 0;
}

.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.message-actions .icon-button {
  width: 30px;
  height: 30px;
  color: var(--muted);
}

.composer-wrap {
  padding: 12px 18px 18px;
  background: linear-gradient(to top, #fff 76%, rgba(255, 255, 255, 0));
}

.composer {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: end;
  gap: 6px;
  width: min(830px, 100%);
  margin: 0 auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.composer-tool,
.send-button {
  align-self: end;
  border-radius: 12px;
}

textarea {
  width: 100%;
  max-height: 190px;
  min-height: 40px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 10px 4px;
  background: transparent;
  color: var(--text);
  line-height: 1.35;
}

textarea::placeholder {
  color: #8c8d88;
}

.send-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: var(--text);
  color: #fff;
}

.send-button:disabled {
  cursor: not-allowed;
  background: #d4d5cf;
  color: #8c8d88;
}

.fine-print {
  width: min(830px, 100%);
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(310px, 86vw);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 28px 0 70px rgba(24, 25, 23, 0.18);
  }

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

  .menu-toggle {
    display: grid;
  }

  .topbar {
    padding-inline: 10px;
  }

  .share-button {
    display: none;
  }

  .chat-scroll {
    padding-inline: 12px;
  }

  .welcome {
    min-height: calc(100vh - 205px);
  }

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

  .composer-wrap {
    padding-inline: 10px;
  }

  .message,
  .message.user {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 9px;
  }

  .message.user .message-avatar {
    grid-column: 1;
  }

  .message.user .message-body {
    grid-column: 2;
  }
}

@media (max-width: 520px) {
  .topbar-actions {
    gap: 2px;
  }

  .model-button {
    max-width: 58vw;
  }

  h1 {
    font-size: 2rem;
  }

  .composer {
    border-radius: 15px;
  }
}
