:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f4f4f4;
  --text: #171717;
  --muted: #6b6b6b;
  --line: #e5e5e5;
  --accent: #171717;
  --accent-dark: #000000;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
textarea {
  font: inherit;
}

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

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

.new-chat,
.thread {
  width: 100%;
  border: 0;
  color: var(--text);
  text-align: left;
  cursor: default;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 13px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.new-chat span:first-child {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ececec;
  color: var(--accent-dark);
  font-size: 20px;
  line-height: 1;
}

.threads {
  display: grid;
  gap: 4px;
}

.thread {
  min-height: 38px;
  padding: 9px 12px;
  border-radius: 7px;
  background: transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread.active,
.thread:hover {
  background: #ececec;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(229, 229, 229, 0.8);
}

.menu-button {
  display: none;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
}

.menu-button span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 5px auto;
  background: var(--muted);
}

.messages {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 44px 22px 150px;
}

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

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

.bubble {
  min-height: 44px;
  padding: 4px 0;
  font-size: 17px;
  line-height: 1.7;
}

.bubble p {
  display: inline;
  margin: 0;
  white-space: pre-line;
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 20px;
  margin-left: 3px;
  vertical-align: -3px;
  border-radius: 2px;
  background: var(--accent);
  animation: blink 0.9s steps(2, start) infinite;
}

.cursor.done {
  display: none;
}

.cursor.waiting {
  display: none;
}

.composer {
  position: fixed;
  left: calc(50% + 140px);
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 42px 42px minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: end;
  width: min(760px, calc(100vw - 330px));
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.icon-button,
.send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: var(--panel-2);
}

.icon-button {
  font-size: 25px;
  line-height: 1;
}

.attach svg,
.send svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.input-wrap {
  min-width: 0;
}

textarea {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 2px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
}

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

.send {
  background: var(--accent);
  color: #fff;
  opacity: 0.86;
}

.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
}

.welcome-modal.hidden {
  display: none;
}

.welcome-panel {
  width: min(480px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.welcome-panel h1 {
  margin: 0 0 22px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.welcome-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.primary-action,
.secondary-action {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  cursor: pointer;
}

.primary-action {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.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;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

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

  .sidebar {
    display: none;
  }

  .menu-button {
    display: block;
  }

  .topbar {
    padding: 0 14px;
  }

  .messages {
    padding: 34px 18px 132px;
  }

  .composer {
    left: 50%;
    width: calc(100vw - 24px);
    bottom: 12px;
    grid-template-columns: 40px 40px minmax(0, 1fr) 40px;
    border-radius: 18px;
  }

  .icon-button,
  .send {
    width: 40px;
    height: 40px;
  }

  .welcome-panel {
    padding: 22px;
  }

  .welcome-panel h1 {
    font-size: 21px;
  }

  .welcome-actions {
    display: grid;
  }
}
