:root {
  color-scheme: dark;
  --ink: #edf3ff;
  --muted: #a5b0c8;
  --faint: #6d7892;
  --canvas: #0b1020;
  --panel: #131a30;
  --panel-raised: #1a2340;
  --line: rgba(181, 201, 255, 0.16);
  --mint: #7ce7c8;
  --mint-deep: #1d7066;
  --gold: #ffd675;
  --danger: #ffb4ad;
  --danger-bg: rgba(171, 40, 45, 0.22);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  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;
  background:
    radial-gradient(circle at 12% -10%, rgba(82, 152, 158, 0.24), transparent 30rem),
    radial-gradient(circle at 90% 0%, rgba(99, 91, 174, 0.19), transparent 26rem),
    var(--canvas);
  color: var(--ink);
  font-size: 16px;
}

button, select, textarea { font: inherit; }

button { cursor: pointer; }

button:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.58; }

.app-shell {
  width: min(100%, 1060px);
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.75rem;
  padding: 0.75rem clamp(1rem, 3vw, 1.75rem);
  background: rgba(11, 16, 32, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 0.62rem; font-weight: 750; letter-spacing: -0.02em; white-space: nowrap; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  color: #07151a;
  font-size: 1.35rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--mint), #9fc9ff);
  border-radius: 0.65rem;
}

.topbar-actions { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }

.model-picker { min-width: min(20rem, 48vw); }

select {
  width: 100%;
  min-height: 2.5rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  outline: none;
}

select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 3px solid rgba(124, 231, 200, 0.65); outline-offset: 2px; }

.quiet-button, .icon-button {
  min-height: 2.5rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
}

.quiet-button { padding: 0.45rem 0.75rem; white-space: nowrap; }
.quiet-button:hover:not(:disabled), .icon-button:hover:not(:disabled) { background: rgba(170, 195, 255, 0.1); }

.chat-area { min-height: 0; padding: 1.5rem clamp(1rem, 3vw, 1.75rem) 0; }

.message-list { display: grid; gap: 1.25rem; padding-bottom: 1.5rem; }

.empty-state {
  min-height: min(47vh, 27rem);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.45rem;
  text-align: center;
  color: var(--muted);
}

.empty-state h1 { margin: 0.5rem 0 0; color: var(--ink); font-size: clamp(1.55rem, 4vw, 2.2rem); letter-spacing: -0.04em; }
.empty-state p { max-width: 29rem; margin: 0; line-height: 1.55; }

.empty-orbit {
  display: grid;
  place-items: center;
  width: 4.25rem;
  height: 4.25rem;
  color: var(--gold);
  font-size: 1.55rem;
  border: 1px solid rgba(124, 231, 200, 0.58);
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.45rem rgba(124, 231, 200, 0.08), 0 0 3rem rgba(124, 231, 200, 0.17);
}

.message { display: grid; gap: 0.4rem; max-width: min(48rem, 92%); }
.message.user { justify-self: end; }
.message.assistant { justify-self: start; }

.message-role { color: var(--faint); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.075em; text-transform: uppercase; }
.message.user .message-role { text-align: right; }

.bubble {
  padding: 0.85rem 1rem;
  overflow-wrap: anywhere;
  line-height: 1.55;
  box-shadow: var(--shadow);
}

.user .bubble { background: linear-gradient(145deg, #256d6a, #1d4d5d); border: 1px solid rgba(124, 231, 200, 0.38); border-radius: 1.15rem 0.3rem 1.15rem 1.15rem; }
.assistant .bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 0.3rem 1.15rem 1.15rem; }

.bubble p { margin: 0 0 0.75rem; }
.bubble p:last-child { margin-bottom: 0; }
.bubble code { padding: 0.08rem 0.28rem; color: #fcdf9a; background: rgba(0, 0, 0, 0.28); border-radius: 0.25rem; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 0.9em; }
.code-block { position: relative; margin: 0.75rem 0; overflow-x: auto; color: #ecf4ff; background: #080d1b; border: 1px solid rgba(181, 201, 255, 0.13); border-radius: 0.55rem; }
.code-block:last-child { margin-bottom: 0; }
.code-label { display: block; padding: 0.32rem 0.55rem; color: var(--faint); font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.72rem; border-bottom: 1px solid rgba(181, 201, 255, 0.11); }
.code-block pre { margin: 0; padding: 0.75rem; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 0.875rem; line-height: 1.5; white-space: pre; }

.message-assets { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.65rem; }
.message-image { width: 4.5rem; height: 4.5rem; object-fit: cover; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 0.5rem; }
.file-context-note { color: rgba(237, 243, 255, 0.78); font-size: 0.83rem; }

.composer-section {
  position: sticky;
  bottom: 0;
  padding: 0.8rem clamp(1rem, 3vw, 1.75rem) calc(0.9rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--canvas) 74%, rgba(11, 16, 32, 0));
}

.model-hint { min-height: 1.25rem; margin: 0 0 0.35rem; color: var(--muted); font-size: 0.85rem; }
.model-hint.vision-ready { color: var(--mint); }

.composer { padding: 0.65rem; background: rgba(19, 26, 48, 0.98); border: 1px solid rgba(181, 201, 255, 0.22); border-radius: 1rem; box-shadow: var(--shadow); }

textarea {
  display: block;
  width: 100%;
  max-height: 13rem;
  resize: none;
  padding: 0.45rem 0.5rem 0.65rem;
  color: var(--ink);
  line-height: 1.5;
  background: transparent;
  border: 0;
  outline: none;
}

textarea::placeholder { color: var(--faint); }

.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.attachment-actions { display: flex; gap: 0.4rem; }
.icon-button { display: inline-grid; place-items: center; width: 2.5rem; padding: 0; font-size: 1.15rem; }

.send-button { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.5rem; padding: 0.45rem 0.8rem; color: #07151a; font-weight: 750; background: var(--mint); border: 0; border-radius: 0.65rem; }
.send-button:hover:not(:disabled) { background: #a1f3db; }

.attachment-tray { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.1rem 0.1rem 0.65rem; }
.attachment-item { position: relative; display: flex; align-items: center; gap: 0.4rem; min-height: 2.2rem; max-width: 100%; padding: 0.35rem 0.45rem 0.35rem 0.35rem; background: rgba(153, 184, 255, 0.09); border: 1px solid var(--line); border-radius: 0.55rem; }
.attachment-thumb { width: 1.7rem; height: 1.7rem; object-fit: cover; border-radius: 0.35rem; }
.attachment-name { overflow: hidden; max-width: 13rem; color: var(--muted); font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove { display: grid; place-items: center; width: 1.25rem; height: 1.25rem; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 50%; }
.attachment-remove:hover { color: var(--ink); background: rgba(255, 255, 255, 0.12); }
.attachment-reading { color: var(--gold); font-size: 0.8rem; }

.notice { margin: 0 0 0.55rem; padding: 0.7rem 0.8rem; color: var(--danger); background: var(--danger-bg); border: 1px solid rgba(255, 180, 173, 0.3); border-radius: 0.65rem; line-height: 1.4; }
.notice button { margin-left: 0.6rem; color: var(--ink); text-decoration: underline; background: none; border: 0; }
.privacy-note { margin: 0.5rem 0 0; color: var(--faint); font-size: 0.75rem; text-align: center; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 560px) {
  .topbar { min-height: auto; align-items: flex-start; padding-top: calc(0.7rem + env(safe-area-inset-top)); }
  .brand { padding-top: 0.2rem; font-size: 0.94rem; }
  .brand-mark { width: 1.8rem; height: 1.8rem; }
  .topbar-actions { gap: 0.4rem; flex: 1; justify-content: flex-end; }
  .model-picker { min-width: 0; flex: 1; }
  select { font-size: 0.88rem; }
  .quiet-button { padding-inline: 0.55rem; font-size: 0.86rem; }
  .chat-area { padding-top: 1rem; }
  .message { max-width: 96%; }
  .bubble { padding: 0.75rem 0.85rem; }
  .attachment-name { max-width: 9rem; }
}
