:root {
  --night: #04170f;
  --deep: #06261a;
  --green: #0f7a45;
  --emerald: #19b36b;
  --gold: #e9c46a;
  --crimson: #c0392b;
  --ink: #e9f2ec;
  --muted: #92a89b;
  --glass: rgb(255 255 255 / 0.06);
  --glass-line: rgb(255 255 255 / 0.11);
  --user: #0f7a45;
  --danger: #ff8a80;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 50% -8%, #0f7a4555, transparent 70%),
    radial-gradient(600px 400px at 85% 110%, #e9c46a1c, transparent 70%),
    linear-gradient(180deg, var(--deep), var(--night) 70%);
  background-attachment: fixed;
}

.app { display: flex; flex-direction: column; height: 100dvh; max-width: 780px; margin: 0 auto; }

/* ---- header ---- */
.top { display: flex; align-items: center; gap: 12px; padding: 14px 18px 0; }
.brand { font-size: 1.05rem; letter-spacing: 0.4px; color: var(--ink); }
.brand b { color: var(--gold); }
.status { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.status.offline .dot { background: #6b7b72; box-shadow: none; }
.switch { display: flex; background: var(--glass); border: 1px solid var(--glass-line); border-radius: 999px; padding: 3px; }
.switch button { border: 0; background: transparent; color: var(--muted); font: 600 0.78rem system-ui, sans-serif; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.switch button[aria-pressed="true"] { background: var(--gold); color: var(--night); }
.new-chat { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--glass-line); background: var(--glass); color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.new-chat svg, .send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- the tahýa orb, top centre ---- */
.stage { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 22px 18px 6px; transition: padding 0.4s ease; }
.orb { --size: 196px; position: relative; width: var(--size); height: var(--size); transition: width 0.45s ease, height 0.45s ease; animation: breathe 5s ease-in-out infinite; }
.orb-glow { position: absolute; inset: -22%; border-radius: 50%; background: radial-gradient(circle, #19b36b55, #e9c46a22 45%, transparent 70%); filter: blur(10px); animation: glow 5s ease-in-out infinite; }
.orb-core {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, #0f7a45, #19b36b, #e9c46a, #c0392b, #0f7a45, #0b4f2f, #0f7a45);
  box-shadow: inset 0 0 40px #04170fcc, 0 0 0 1px #e9c46a55;
  animation: spin 14s linear infinite;
}
.orb-core::after { content: ""; position: absolute; inset: 9%; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #0b3b25, #04170f 75%); }
.orb-tahya { position: absolute; inset: 0; width: 100%; height: 100%; animation: spin 60s linear infinite reverse; }
.orb-tahya .ring { fill: none; stroke-width: 1.4; }
.orb-tahya .ring.gold { stroke: #e9c46acc; }
.orb-tahya .ring.soft { stroke: #ffffff40; }
.orb-tahya .diamonds use { fill: #e9c46a; }
.orb-tahya .arches use { fill: #ffffff14; stroke: #e9c46ae6; stroke-width: 1.3; }
.orb-tahya .hooks use { fill: none; stroke: #ffffffaa; stroke-width: 1.4; stroke-linecap: round; }
.orb-tahya .star rect { fill: #e9c46a; opacity: 0.92; }
.orb-tahya .heart { fill: #c0392b; stroke: #fff; stroke-width: 2; }

.orb[data-state="thinking"] .orb-core { animation-duration: 2.6s; }
.orb[data-state="thinking"] .orb-tahya { animation-duration: 12s; }
.orb[data-state="thinking"] .orb-glow { animation: glow 1.2s ease-in-out infinite; }
.orb[data-state="speaking"] { animation: speak 0.9s ease-in-out infinite; }
.orb[data-state="speaking"] .orb-core { animation-duration: 6s; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.035); } }
@keyframes speak { 50% { transform: scale(1.07); } }
@keyframes glow { 50% { opacity: 0.55; transform: scale(1.08); } }

.greeting { margin: 22px 0 6px; font-size: 1.6rem; line-height: 1.25; font-weight: 650; }
.greeting::first-line { color: var(--ink); }
.lead { margin: 0 auto; max-width: 480px; color: var(--muted); }

/* While chatting the orb stays on top, smaller. */
body.chatting .stage { padding: 6px 18px 0; }
body.chatting .orb { --size: 64px; }
body.chatting .greeting, body.chatting .lead { display: none; }

/* ---- conversation ---- */
.log { flex: 1; overflow-y: auto; padding: 16px 18px 8px; display: flex; flex-direction: column; gap: 14px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.suggestions:empty { display: none; }
.suggestions button {
  border: 1px solid var(--glass-line); background: var(--glass); color: var(--ink);
  border-radius: 16px; padding: 13px 15px; font: 0.93rem/1.4 system-ui, sans-serif; cursor: pointer; text-align: left;
  backdrop-filter: blur(6px);
}
.suggestions button:hover { border-color: #e9c46a88; background: rgb(255 255 255 / 0.09); }

.bubble { max-width: 86%; padding: 11px 15px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.assistant { align-self: flex-start; background: var(--glass); border: 1px solid var(--glass-line); border-top-left-radius: 6px; }
.bubble.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 6px; }
.bubble.pending::after { content: "● ● ●"; letter-spacing: 2px; color: var(--muted); animation: pulse 1.2s ease-in-out infinite; }
.bubble.error { color: var(--danger); }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---- input ---- */
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  margin: 8px 16px 4px; padding: 6px;
  border: 1px solid var(--glass-line); border-radius: 26px; background: rgb(255 255 255 / 0.07);
  backdrop-filter: blur(10px);
}
.composer:focus-within { border-color: #e9c46a99; }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font: 1rem/1.5 system-ui, sans-serif; padding: 9px 0; max-height: 180px; }
.composer textarea::placeholder { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--gold); color: var(--night); cursor: pointer; display: grid; place-items: center; }
.send:disabled, .composer textarea:disabled { opacity: 0.5; cursor: wait; }
/* Attach and microphone: quiet round buttons beside the text. */
.tool { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.tool:hover { color: var(--ink); background: var(--glass); }
.tool:disabled { opacity: 0.4; cursor: wait; }
.tool svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mic[data-state="recording"] { background: var(--crimson); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.mic[data-state="transcribing"] { color: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.attachment { display: flex; align-items: center; gap: 6px; align-self: flex-start; margin: 4px 16px 0; padding: 4px 6px 4px 12px; border: 1px solid var(--glass-line); border-radius: 999px; background: var(--glass); font-size: 0.86rem; max-width: calc(100% - 32px); }
.attachment[hidden] { display: none; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove { width: 26px; height: 26px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.attachment-remove:hover { color: var(--ink); background: var(--glass); }
.footnote { margin: 0; padding: 2px 18px calc(10px + env(safe-area-inset-bottom)); font-size: 0.74rem; color: var(--muted); text-align: center; }

@media (max-width: 600px) {
  .top { padding: 12px 12px 0; gap: 8px; }
  .status { font-size: 0.74rem; }
  .orb { --size: 156px; }
  .greeting { font-size: 1.35rem; margin-top: 18px; }
  .suggestions { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
  .composer { margin: 6px 10px 4px; gap: 4px; }
  .tool { width: 40px; height: 40px; }
  .attachment { margin: 4px 10px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .orb, .orb-core, .orb-tahya, .orb-glow { animation: none !important; }
}
