:root {
  color-scheme: light;
  --bg-button: #c1d3fe;
  --bg-accent: #abc4ff;
  --text-primary: #20304a;
  --text-secondary: rgba(32, 48, 74, 0.72);
  --text-soft: rgba(32, 48, 74, 0.55);
  --glass-surface: rgba(255, 255, 255, 0.44);
  --glass-strong: rgba(255, 255, 255, 0.66);
  --glass-border: rgba(255, 255, 255, 0.38);
  --shadow-soft: 0 24px 70px rgba(110, 146, 214, 0.2);
  --shadow-glow: 0 0 42px rgba(171, 196, 255, 0.45);
  --error: #8a3146;
  --backdrop-blur: blur(20px);
}

body.dark-theme {
  color-scheme: dark;
  --text-primary: #eff5ff;
  --text-secondary: rgba(239, 245, 255, 0.76);
  --text-soft: rgba(239, 245, 255, 0.56);
  --glass-surface: rgba(10, 19, 34, 0.46);
  --glass-strong: rgba(18, 31, 52, 0.74);
  --glass-border: rgba(171, 196, 255, 0.18);
  --shadow-soft: 0 28px 80px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 45px rgba(121, 165, 255, 0.24);
  --error: #ffcad7;
  background:
    radial-gradient(circle at top left, rgba(121, 165, 255, 0.16), transparent 26%),
    radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.08), transparent 18%),
    linear-gradient(145deg, #07111f 0%, #0d1729 52%, #14243c 100%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-primary);
  background:
    radial-gradient(circle at top left, rgba(171, 196, 255, 0.85), transparent 26%),
    radial-gradient(circle at 85% 12%, rgba(255, 255, 255, 0.85), transparent 20%),
    linear-gradient(145deg, #edf2fa 0%, #d7e3fc 54%, #ccdbfd 100%);
}

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

.app-shell { position: relative; min-height: 100vh; overflow: hidden; }

.glass {
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--glass-border);
  background: linear-gradient(145deg, var(--glass-strong), rgba(255, 255, 255, 0.12));
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.inset-card { background: linear-gradient(145deg, var(--glass-surface), rgba(255, 255, 255, 0.12)); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  width: min(1220px, calc(100% - 2rem));
  margin: 1.2rem auto 0;
  padding: 1rem 1.2rem;
  border-radius: 20px;
}

.brand { display: flex; gap: 1rem; align-items: center; }
.brand h1, .intro-card h2, .settings-header h2 { margin: 0; letter-spacing: -0.04em; }

.brand-badge {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(171, 196, 255, 0.95), rgba(255, 255, 255, 0.6));
  box-shadow: var(--shadow-glow);
  font-weight: 700;
}

.eyebrow, .floating-label {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.topbar-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; justify-content: flex-end; }

.ghost-button, .mode-card, .suggestion-card, .field-input, .send-button {
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.ghost-button, .field-input, .suggestion-card {
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.18);
  color: var(--text-primary);
}

.ghost-button { padding: 0.75rem 1rem; }

.workspace {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  width: min(1240px, calc(100% - 2rem));
  min-height: calc(100vh - 7.6rem);
  margin: 1.1rem auto 0;
  padding-bottom: 1.2rem;
}

.chat-shell {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: min(100%, 920px);
  min-height: calc(100vh - 9rem);
  border-radius: 24px;
  overflow: hidden;
}

.chat-header { padding: 1.2rem; border-bottom: 1px solid rgba(255, 255, 255, 0.22); }
.status-row, .mode-grid, .suggestion-grid { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.status-row { margin-bottom: 1rem; }

.status-pill {
  padding: 0.6rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 600;
}

.status-pill-accent { background: rgba(171, 196, 255, 0.34); }

.mode-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }

.mode-card {
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-primary);
  text-align: left;
}

.mode-card strong, .mode-card small { display: block; }
.mode-card strong { margin-bottom: 0.25rem; }
.mode-card small { color: var(--text-soft); line-height: 1.45; }

.mode-card.active {
  background: linear-gradient(145deg, rgba(171, 196, 255, 0.48), rgba(255, 255, 255, 0.26));
  border-color: rgba(171, 196, 255, 0.66);
  box-shadow: var(--shadow-glow);
}

.message-stream { flex: 1; overflow-y: auto; padding: 1.25rem; }

.intro-card { padding: 1.3rem; border-radius: 22px; margin-bottom: 1.4rem; }
.intro-copy { margin: 0.9rem 0 1.1rem; color: var(--text-secondary); line-height: 1.7; }
.suggestion-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.suggestion-card { padding: 1rem; text-align: left; line-height: 1.55; }

.message-row { display: flex; margin-bottom: 1rem; }
.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }

.message-bubble {
  max-width: min(80%, 700px);
  padding: 1rem;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 16px 45px rgba(94, 129, 196, 0.12);
}

.message-bubble.user { background: linear-gradient(145deg, rgba(171, 196, 255, 0.72), rgba(193, 211, 254, 0.92)); color: #173053; }
.message-bubble.assistant { background: linear-gradient(145deg, rgba(255, 255, 255, 0.46), rgba(215, 227, 252, 0.45)); }
.message-bubble.error { background: linear-gradient(145deg, rgba(255, 232, 232, 0.72), rgba(255, 246, 246, 0.56)); color: var(--error); }
body.dark-theme .message-bubble.error { background: linear-gradient(145deg, rgba(120, 40, 58, 0.65), rgba(72, 25, 37, 0.82)); }

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.message-bubble p { margin: 0; white-space: pre-wrap; line-height: 1.7; }

.typing-dots { display: inline-flex; gap: 0.45rem; }
.typing-dots span {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--bg-accent);
  animation: blink 1s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }

.composer-zone { padding: 0 1.25rem 1.25rem; }
.assistant-note { margin-bottom: 0.8rem; color: var(--text-soft); font-size: 0.9rem; }
.assistant-note.error { color: var(--error); }
.composer-actions { display: flex; justify-content: flex-end; margin-bottom: 0.75rem; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.95rem;
  padding: 0.9rem;
  border-radius: 22px;
}

.composer-input, .field-input { width: 100%; border: 1px solid transparent; outline: none; }
.composer-input {
  min-height: 3.5rem;
  max-height: 10rem;
  background: transparent;
  color: var(--text-primary);
  resize: none;
  line-height: 1.6;
}

.send-button {
  border: 0;
  border-radius: 18px;
  padding: 0.95rem 1.25rem;
  background: linear-gradient(145deg, var(--bg-accent), var(--bg-button));
  color: #143152;
  font-weight: 700;
  box-shadow: var(--shadow-glow);
}

.send-button:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.floating-card { align-self: center; width: 170px; padding: 1rem; border-radius: 22px; }
.floating-card-right { margin-bottom: 4rem; }
.floating-card strong { display: block; margin-bottom: 0.35rem; }
.floating-card p, .settings-copy { margin: 0; color: var(--text-secondary); line-height: 1.65; }


.hidden { display: none; }
.field-input:disabled { opacity: 0.7; cursor: not-allowed; }

.bg-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(18px);
  opacity: 0.7;
  pointer-events: none;
}

.orb-one { top: 7rem; left: -6rem; width: 18rem; height: 18rem; background: rgba(171, 196, 255, 0.46); }
.orb-two { top: 10rem; right: 8rem; width: 16rem; height: 16rem; background: rgba(255, 255, 255, 0.42); }
.orb-three { right: -4rem; bottom: 3rem; width: 14rem; height: 14rem; background: rgba(193, 211, 254, 0.5); }

.ghost-button:hover, .field-input:hover, .suggestion-card:hover, .mode-card:hover, .send-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

@media (max-width: 1120px) { .floating-card { display: none; } }

@media (max-width: 880px) {
  .topbar, .workspace { width: calc(100% - 1rem); }
  .topbar { margin-top: 0.7rem; padding: 1rem; }
  .mode-grid, .suggestion-grid { grid-template-columns: 1fr; }
  .chat-shell { min-height: calc(100vh - 8rem); }
  .message-bubble { max-width: 100%; }
}

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .composer { flex-direction: column; align-items: stretch; }
}

@keyframes blink {
  0%, 100% { opacity: 0.35; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}
