:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  background: #0c111b;
  color: #eef4ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 12% -10%, rgba(49, 163, 255, 0.26), transparent 34rem),
    radial-gradient(circle at 100% 0%, rgba(41, 214, 152, 0.18), transparent 28rem),
    #0c111b;
}

button,
textarea,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px 12px;
}

.title-block {
  min-width: 0;
  flex: 1;
}

.eyebrow {
  margin: 0 0 2px;
  color: #83d9ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.conversation-title {
  max-width: 100%;
  margin: 4px 0 0;
  overflow: hidden;
  color: #9fb0c8;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #eef4ff;
}

.icon-button.compact {
  width: 36px;
  height: 36px;
}

.sidebar {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  background: rgba(3, 7, 18, 0.58);
}

.sidebar.open {
  display: block;
}

.sidebar-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  width: min(84vw, 340px);
  height: 100%;
  padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  background: #0d1623;
  box-shadow: 24px 0 80px rgba(0, 0, 0, 0.35);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-head h2 {
  margin: 0;
  font-size: 20px;
}

.new-chat-wide {
  height: 42px;
  margin: 14px 0;
  border: 0;
  border-radius: 8px;
  background: #eef4ff;
  color: #0c111b;
  font-weight: 850;
}

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

.conversation-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  min-height: 58px;
  padding: 10px 38px 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #eef4ff;
  text-align: left;
}

.conversation-item.active {
  border-color: rgba(119, 220, 255, 0.62);
  background: rgba(119, 220, 255, 0.13);
}

.conversation-name {
  grid-column: 1 / 3;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta {
  color: #8fa1ba;
  font-size: 12px;
}

.conversation-delete {
  position: absolute;
  top: 8px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: #9fb0c8;
  font-size: 18px;
  font-weight: 700;
}

.conversation-delete:active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 0;
  scroll-behavior: smooth;
}

.message {
  display: flex;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(82%, 560px);
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
}

.assistant .bubble {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #eef4ff;
}

.user .bubble {
  background: linear-gradient(135deg, #38d7b6, #77dcff);
  color: #08111d;
  font-weight: 650;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(13, 22, 35, 0.88);
  box-shadow: 0 -16px 50px rgba(0, 0, 0, 0.22);
}

textarea {
  width: 100%;
  max-height: 132px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #eef4ff;
  line-height: 1.5;
}

textarea::placeholder {
  color: #75849a;
}

#sendBtn {
  min-width: 64px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: #eef4ff;
  color: #0c111b;
  font-weight: 800;
}

#sendBtn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 24px;
    padding-bottom: 24px;
  }
}
