:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: rgba(15, 23, 42, 0.86);
  --panel-strong: #101b31;
  --border: rgba(148, 163, 184, 0.22);
  --text: #e5eefc;
  --muted: #8ea3bf;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --user: #2563eb;
  --danger: #fb7185;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.24), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.18), transparent 28rem),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(920px, 100%);
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  box-shadow: 0 0 28px rgba(56, 189, 248, 0.42);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.28rem;
  letter-spacing: 0.02em;
}

.brand p,
.notice,
.token-card p {
  color: var(--muted);
}

.brand p {
  font-size: 0.86rem;
  margin-top: 2px;
}

.ghost-button {
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(15, 23, 42, 0.55);
}

.ghost-button:hover {
  border-color: rgba(56, 189, 248, 0.55);
}

.notice {
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 0 6px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.68);
}

.mode-switch button {
  border: 0;
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.mode-switch button.active {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 8px 22px rgba(2, 132, 199, 0.28);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}

.message {
  display: flex;
}

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

.bubble {
  max-width: min(82%, 680px);
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
}

.user .bubble {
  background: linear-gradient(135deg, var(--user), #1d4ed8);
  border-color: rgba(147, 197, 253, 0.35);
  border-bottom-right-radius: 6px;
}

.assistant .bubble {
  border-bottom-left-radius: 6px;
}

.message-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.45;
}

.message-content code,
code {
  color: #7dd3fc;
}

.loading .message-content::after {
  content: "";
  display: inline-block;
  width: 1em;
  animation: dots 1.2s steps(4) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75%, 100% { content: "..."; }
}

.quick-actions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.quick-actions button {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(15, 23, 42, 0.74);
  border-radius: 999px;
  padding: 8px 12px;
}

.quick-actions button:hover {
  border-color: rgba(56, 189, 248, 0.58);
  color: #bae6fd;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.composer input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  padding: 12px;
}

.composer input::placeholder {
  color: #64748b;
}

.composer button,
.token-card button {
  border: 0;
  border-radius: 15px;
  padding: 11px 16px;
  color: white;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 10px 26px rgba(2, 132, 199, 0.32);
}

.composer button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.token-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(12px);
}

.token-panel.hidden {
  display: none;
}

.token-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: #0f172a;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.token-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 20px;
  box-shadow: 0 0 34px rgba(56, 189, 248, 0.5);
}

.token-card input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  outline: 0;
  color: var(--text);
  background: rgba(2, 6, 23, 0.72);
  padding: 13px 14px;
}

.token-card input:focus {
  border-color: var(--accent);
}

@media (max-width: 620px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar {
    border-radius: 18px;
  }

  .brand-icon {
    width: 42px;
    height: 42px;
  }

  .ghost-button {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .bubble {
    max-width: 92%;
  }

  .composer {
    border-radius: 18px;
    gap: 8px;
  }

  .composer button {
    padding-inline: 13px;
  }
}
