:root {
  color-scheme: dark;
  --bg: #080b12;
  --panel: rgba(14, 18, 29, 0.88);
  --panel-solid: #101521;
  --panel-soft: #151b29;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f7f8fb;
  --muted: #9aa3b5;
  --accent: #d9ff66;
  --accent-dark: #161d06;
  --violet: #8b7bff;
  --danger: #ff7c83;
  --radius-lg: 28px;
  --radius-md: 18px;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, #171d2f 0%, transparent 34rem),
    linear-gradient(145deg, #080a10, #0b101a 64%, #080b12);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
  pointer-events: none;
}

.ambient-one {
  top: -10rem;
  right: 8vw;
  width: 28rem;
  height: 28rem;
  background: var(--violet);
}

.ambient-two {
  bottom: -14rem;
  left: 22vw;
  width: 30rem;
  height: 30rem;
  background: #79d8ff;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  width: min(1500px, calc(100vw - 24px));
  height: calc(100vh - 24px);
  margin: 12px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(8, 11, 18, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 18px 20px;
  border-right: 1px solid var(--line);
  background: rgba(10, 13, 21, 0.86);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 13px;
  background: var(--accent);
  color: #0b0e08;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 8px 28px rgba(217, 255, 102, 0.18);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.new-chat {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  color: var(--text);
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease;
}

.new-chat:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.sidebar-settings > label,
.dialog-card > label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar select,
.dialog-card select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-soft);
  color: var(--text);
}

.sidebar select {
  padding: 12px;
}

.key-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  width: 100%;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.key-card:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.025);
}

.key-card strong,
.key-card small {
  display: block;
}

.key-card strong {
  font-size: 13px;
}

.key-card small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.key-card.connected small {
  color: var(--accent);
}

.key-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: rgba(139, 123, 255, 0.14);
  color: #bcb3ff;
  font-size: 20px;
}

.privacy-note {
  margin: 14px 4px 0;
  color: #737d90;
  font-size: 11px;
  line-height: 1.55;
}

.workspace {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  grid-template-rows: auto 1fr auto;
}

.mobile-header {
  display: none;
}

.conversation {
  grid-row: 2;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.welcome {
  display: grid;
  width: min(760px, calc(100% - 40px));
  min-height: 100%;
  margin: 0 auto;
  align-content: center;
  padding: 64px 0 180px;
  text-align: center;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.welcome h1 {
  max-width: 720px;
  margin: 18px auto 16px;
  font-size: clamp(38px, 5vw, 68px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.welcome > p {
  max-width: 600px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 36px;
}

.suggestions button {
  min-height: 102px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(19, 25, 39, 0.72);
  color: var(--text);
  font-weight: 750;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.suggestions button:hover {
  border-color: var(--line-strong);
  background: #171e2d;
  transform: translateY(-2px);
}

.suggestions span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
  line-height: 1.4;
}

.connect-button {
  justify-self: center;
  margin-top: 24px;
}

.messages {
  width: min(850px, calc(100% - 36px));
  margin: 0 auto;
  padding: 54px 0 190px;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 32px;
}

.message.user {
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
}

.message-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.message-body {
  min-width: 0;
}

.message.user .message-body {
  max-width: min(680px, 86%);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 18px 18px 5px 18px;
  background: #1c2333;
}

.message-content {
  margin: 0;
  overflow-wrap: anywhere;
  color: #ebedf3;
  font-size: 15px;
  line-height: 1.72;
  white-space: pre-wrap;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: #6f788b;
  font-size: 11px;
}

.copy-button {
  padding: 3px 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.copy-button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.thinking {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
}

.thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.2s infinite ease-in-out;
}

.thinking span:nth-child(2) {
  animation-delay: 160ms;
}

.thinking span:nth-child(3) {
  animation-delay: 320ms;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.28;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

.composer-wrap {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 18px 24px 17px;
  background: linear-gradient(transparent, rgba(8, 11, 18, 0.96) 32%);
}

.composer {
  position: relative;
  display: flex;
  width: min(850px, 100%);
  align-items: flex-end;
  gap: 10px;
  margin: 0 auto;
  padding: 11px 11px 11px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 21px;
  background: rgba(19, 25, 39, 0.97);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.composer:focus-within {
  border-color: rgba(217, 255, 102, 0.48);
}

.composer textarea {
  width: 100%;
  max-height: 180px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.55;
}

.composer textarea::placeholder {
  color: #737d90;
}

.send-button,
.stop-button {
  flex: 0 0 auto;
  min-width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #0b0e08;
  font-weight: 900;
}

.stop-button {
  padding: 0 13px;
  background: #f0f2f6;
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.composer-note {
  margin: 8px auto 0;
  color: #6e7788;
  font-size: 10px;
  text-align: center;
}

.error-banner {
  width: min(850px, 100%);
  margin: 0 auto 9px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 124, 131, 0.28);
  border-radius: 12px;
  background: rgba(255, 124, 131, 0.1);
  color: #ffc2c5;
  font-size: 12px;
}

.settings-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(3, 5, 10, 0.76);
  backdrop-filter: blur(9px);
}

.dialog-card {
  padding: 26px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.dialog-heading h2 {
  margin: 8px 0 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.close-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
}

.dialog-card > label {
  margin-top: 18px;
}

.dialog-card label span {
  color: #6f788b;
  font-weight: 500;
  text-transform: none;
}

.dialog-card input,
.dialog-card textarea,
.dialog-card select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: #0c111b;
  color: var(--text);
}

.dialog-card textarea {
  resize: vertical;
  line-height: 1.5;
}

.secret-input {
  display: flex;
  gap: 8px;
}

.secret-input button {
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--muted);
}

.field-help {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.settings-notice {
  margin: 0 0 18px;
  padding: 11px 13px;
  border: 1px solid rgba(217, 255, 102, 0.24);
  border-radius: 12px;
  background: rgba(217, 255, 102, 0.08);
  color: #e9ffab;
  font-size: 12px;
  line-height: 1.5;
}

.settings-notice[data-kind="warning"] {
  border-color: rgba(255, 198, 91, 0.28);
  background: rgba(255, 198, 91, 0.08);
  color: #ffe0a2;
}

.settings-notice[data-kind="error"] {
  border-color: rgba(255, 124, 131, 0.28);
  background: rgba(255, 124, 131, 0.1);
  color: #ffc2c5;
}

.dialog-primary-action {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}

.vault-section {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.vault-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.vault-heading > strong {
  font-size: 14px;
}

.vault-heading > span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  text-align: right;
}

.vault-section p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.vault-connect {
  margin-top: 14px;
}

.vault-connect > label,
.sync-code-panel > label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sync-code-panel {
  margin-top: 14px;
}

.sync-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.sync-code-row input {
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.sync-code-row button {
  padding-inline: 12px;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}
.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
}

.primary,
.secondary,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 800;
}

.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #0b0e08;
}

.secondary,
.icon-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border: 1px solid rgba(255, 124, 131, 0.32);
  border-radius: 12px;
  background: rgba(255, 124, 131, 0.08);
  color: #ffc2c5;
  font-weight: 800;
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  body {
    overflow: hidden;
  }

  .shell {
    grid-template-columns: 1fr;
    width: 100vw;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    grid-template-rows: 64px 1fr auto;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(9, 12, 19, 0.88);
  }
  .mobile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-actions select {
    max-width: 116px;
    padding: 9px 28px 9px 10px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--panel-soft);
    color: var(--text);
    font-size: 13px;
  }

  .brand.compact .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .welcome {
    width: min(100% - 28px, 620px);
    padding: 44px 0 180px;
  }

  .welcome h1 {
    font-size: clamp(38px, 11vw, 56px);
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .suggestions button {
    min-height: 78px;
  }

  .messages {
    width: calc(100% - 28px);
    padding-top: 30px;
  }

  .message.user .message-body {
    max-width: 92%;
  }

  .composer-wrap {
    padding: 16px 12px 12px;
  }

  .composer-note {
    display: none;
  }
}

@media (max-width: 480px) {
  .brand.compact strong {
    display: none;
  }

  .welcome > p {
    font-size: 14px;
  }

  .suggestions {
    margin-top: 26px;
  }

  .dialog-card {
    padding: 21px;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }

  .dialog-actions button {
    width: 100%;
  }
}
