:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: rgba(26, 29, 38, 0.82);
  --panel-strong: rgba(33, 37, 48, 0.96);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --muted: #9a9aa3;
  --assistant: #232838;
  --user: #0a84ff;
  --field: rgba(118, 118, 128, 0.18);
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(10, 132, 255, 0.18), transparent 34%),
    linear-gradient(180deg, #11141c 0%, var(--bg) 50%, #07080b 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(820px, 100%);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: rgba(9, 11, 16, 0.72);
  backdrop-filter: blur(24px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 25, 0.86);
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.ghost-btn,
.icon-btn {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--field);
  border-radius: 12px;
}

.ghost-btn {
  min-width: 58px;
  padding: 8px 12px;
}

.ghost-btn.danger {
  color: #ffd4d4;
}

.icon-btn {
  width: 34px;
  height: 34px;
  font-size: 22px;
  line-height: 1;
}

.messages {
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

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

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, #5ac8fa, #0a84ff);
  color: white;
  font-weight: 700;
}

.bubble {
  max-width: min(72%, 560px);
  padding: 11px 14px;
  border-radius: 20px;
  background: var(--assistant);
  border: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-row.assistant .bubble {
  border-bottom-left-radius: 7px;
}

.message-row.user .bubble {
  border: 0;
  border-bottom-right-radius: 7px;
  background: linear-gradient(135deg, #2d9cff, var(--user));
}

.typing {
  color: var(--muted);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(16, 18, 25, 0.92);
}

.composer textarea {
  width: 100%;
  min-height: 46px;
  max-height: 132px;
  resize: none;
  border: 1px solid var(--line);
  outline: none;
  border-radius: 18px;
  padding: 12px 14px;
  background: var(--field);
  color: var(--text);
}

.composer textarea:focus,
.profile-panel input:focus,
.profile-panel textarea:focus,
.profile-panel select:focus {
  border-color: rgba(10, 132, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.12);
}

.composer button,
.primary-wide {
  border: 0;
  border-radius: 16px;
  background: var(--user);
  color: #fff;
  font-weight: 700;
}

.composer button {
  min-width: 70px;
  min-height: 46px;
  padding: 0 16px;
}

.composer button.stop {
  background: #ff453a;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.54);
  backdrop-filter: blur(16px);
}

.modal.show {
  display: flex;
}

.profile-panel {
  width: min(480px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel-strong);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

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

.profile-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.profile-panel input,
.profile-panel textarea,
.profile-panel select {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  border-radius: 14px;
  padding: 11px 12px;
  background: var(--field);
  color: var(--text);
}

.profile-panel textarea {
  resize: vertical;
  min-height: 86px;
}

.primary-wide {
  min-height: 46px;
}

@media (max-width: 560px) {
  .app {
    border: 0;
  }

  .topbar {
    padding: 14px 14px 12px;
  }

  h1 {
    font-size: 18px;
  }

  .ghost-btn {
    min-width: 48px;
    padding: 7px 10px;
  }

  .messages {
    padding: 16px 12px;
  }

  .bubble {
    max-width: 82%;
    font-size: 15px;
  }
}
