/* ==========================================================================
   ATLAS voice agent — 3D pulse hologram widget + conversation panel
   ========================================================================== */
#ax-root {
  --ax-bg: rgba(8, 13, 24, 0.92);
  --ax-line: rgba(125, 211, 252, 0.18);
  --ax-text: #e6f6ff;
  --ax-dim: #8aa4b8;
  --ax-cyan: #22d3ee;
  --ax-emerald: #34d399;
  --ax-gold: #fbbf24;
  --ax-sky: #7dd3fc;
  --ax-glow: var(--ax-cyan);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  font-family: 'Noto Sans KR', 'Noto Sans', system-ui, sans-serif;
  color: var(--ax-text);
}
/* same state colours as the desktop ATLAS app */
#ax-root { --ax-glow: #00e5ff; }
#ax-root[data-state="listening"] { --ax-glow: #ff5252; }
#ax-root[data-state="thinking"]  { --ax-glow: #b388ff; }
#ax-root[data-state="speaking"]  { --ax-glow: #00e676; }
#ax-root[data-state="error"]     { --ax-glow: #ff5252; }

#ax-root button { font-family: inherit; cursor: pointer; }

/* ---------- Floating orb ---------- */
.ax-orb {
  position: relative;
  width: 92px;
  height: 92px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0.6), #000 70%);
  box-shadow: 0 0 0 1px var(--ax-line), 0 0 28px -4px color-mix(in srgb, var(--ax-glow) 55%, transparent), 0 12px 30px rgba(0, 0, 0, 0.55);
  transition: transform 0.25s ease, box-shadow 0.4s ease;
}
.ax-orb:hover { transform: translateY(-2px) scale(1.04); }
.ax-orb:focus-visible { outline: 2px solid var(--ax-glow); outline-offset: 4px; }
.ax-orb::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--ax-glow) 45%, transparent);
  animation: ax-ping 2.6s ease-out infinite;
  pointer-events: none;
}
.ax-wake-on .ax-orb::before {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ax-emerald);
  box-shadow: 0 0 8px var(--ax-emerald);
  z-index: 2;
}
.ax-orb-stage { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; }
.ax-orb-badge {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 999px;
  color: #04121a;
  background: var(--ax-glow);
  box-shadow: 0 0 14px color-mix(in srgb, var(--ax-glow) 60%, transparent);
  transition: background 0.4s ease;
}
.ax-open .ax-orb { display: none; }

@keyframes ax-ping {
  0% { transform: scale(0.92); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ---------- Hologram host ---------- */
.ax-holo { position: absolute; inset: 0; }
.ax-holo-canvas { width: 100% !important; height: 100% !important; display: block; }

.ax-holo-fallback { display: grid; place-items: center; }
.ax-fb-core, .ax-fb-ring { position: absolute; border-radius: 50%; }
.ax-fb-core {
  width: 42%; height: 42%;
  background: radial-gradient(circle, #fff 0%, var(--ax-glow) 35%, transparent 72%);
  animation: ax-breathe 2.4s ease-in-out infinite;
}
.ax-fb-ring { width: 70%; height: 70%; border: 1px solid var(--ax-glow); opacity: 0.6; animation: ax-spin 6s linear infinite; border-top-color: transparent; }
.ax-fb-ring.r2 { width: 84%; height: 84%; animation-duration: 9s; animation-direction: reverse; border-bottom-color: transparent; }
.ax-holo-fallback[data-state="thinking"] .ax-fb-ring { animation-duration: 1.2s; }
.ax-holo-fallback[data-state="speaking"] .ax-fb-core,
.ax-holo-fallback[data-state="listening"] .ax-fb-core { animation-duration: 0.6s; }
@keyframes ax-breathe { 50% { transform: scale(1.18); opacity: 0.8; } }
@keyframes ax-spin { to { transform: rotate(360deg); } }

/* ---------- Panel ---------- */
.ax-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(400px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 40px));
  height: min(640px, calc(100dvh - 40px));
  display: flex;
  flex-direction: column;
  background: var(--ax-bg);
  border: 1px solid var(--ax-line);
  border-radius: 22px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03), 0 0 60px -12px color-mix(in srgb, var(--ax-glow) 45%, transparent), 0 30px 60px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
  animation: ax-in 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  transition: box-shadow 0.4s ease;
}
.ax-panel[hidden] { display: none; }
@keyframes ax-in { from { opacity: 0; transform: translateY(16px) scale(0.97); } }

.ax-head {
  position: relative;
  flex: none;
  height: 210px;
  background:
    radial-gradient(ellipse at 50% 60%, color-mix(in srgb, var(--ax-glow) 16%, transparent), transparent 65%),
    repeating-linear-gradient(0deg, rgba(125, 211, 252, 0.035) 0 1px, transparent 1px 4px);
  border-bottom: 1px solid var(--ax-line);
}
.ax-stage { position: absolute; inset: 0 70px 0 70px; }
.ax-id { position: absolute; left: 16px; top: 14px; display: flex; flex-direction: column; gap: 2px; }
.ax-id strong { font-size: 15px; letter-spacing: 0.22em; font-weight: 800; }
.ax-sub { font-size: 11px; color: var(--ax-dim); }
.ax-status {
  position: absolute;
  left: 16px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ax-glow);
}
.ax-status i {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ax-glow);
  box-shadow: 0 0 10px var(--ax-glow);
  animation: ax-breathe 1.6s ease-in-out infinite;
}
.ax-tools { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; }
.ax-icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--ax-line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ax-dim);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.ax-icon svg { width: 18px; height: 18px; fill: currentColor; }
.ax-icon:hover { color: var(--ax-text); background: rgba(255, 255, 255, 0.07); }
.ax-icon[aria-pressed="true"] { color: var(--ax-cyan); border-color: rgba(34, 211, 238, 0.45); background: rgba(34, 211, 238, 0.08); }
.ax-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.ax-icon:focus-visible, .ax-chip:focus-visible, .ax-card:focus-visible, .ax-mic:focus-visible, .ax-send:focus-visible { outline: 2px solid var(--ax-cyan); outline-offset: 2px; }
.ax-brain {
  position: absolute;
  right: 12px;
  bottom: 14px;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--ax-line);
  color: var(--ax-dim);
}
.ax-brain.on { color: var(--ax-emerald); border-color: rgba(52, 211, 153, 0.4); }

/* ---------- Log ---------- */
.ax-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 211, 252, 0.25) transparent;
}
.ax-msg { max-width: 92%; font-size: 14px; line-height: 1.6; }
.ax-msg p { padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
.ax-user { align-self: flex-end; }
.ax-user p { background: rgba(34, 211, 238, 0.14); border: 1px solid rgba(34, 211, 238, 0.3); border-bottom-right-radius: 4px; }
.ax-interim p { opacity: 0.65; font-style: italic; }
.ax-atlas { align-self: flex-start; }
.ax-atlas p { background: rgba(255, 255, 255, 0.045); border: 1px solid rgba(255, 255, 255, 0.08); border-bottom-left-radius: 4px; }
.ax-atlas.ax-ai p { border-color: rgba(52, 211, 153, 0.28); }
.ax-note { align-self: center; max-width: 100%; }
.ax-note p { font-size: 12px; color: var(--ax-dim); background: none; padding: 2px 6px; text-align: center; }

.ax-cards { display: grid; gap: 6px; margin-top: 6px; }
.ax-card {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 11px;
  border-radius: 11px;
  border: 1px solid var(--ax-line);
  background: rgba(8, 47, 73, 0.25);
  color: var(--ax-text);
  transition: border-color 0.2s, background 0.2s;
}
.ax-card:hover { border-color: rgba(34, 211, 238, 0.55); background: rgba(8, 47, 73, 0.45); }
.ax-where { font-size: 10.5px; color: var(--ax-cyan); letter-spacing: 0.04em; }
.ax-card strong { font-size: 13px; font-weight: 600; line-height: 1.4; }
.ax-snip { font-size: 12px; color: var(--ax-dim); line-height: 1.45; }
.ax-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 12.5px;
  padding: 6px 11px;
  border-radius: 9px;
  color: #04121a;
  background: var(--ax-cyan);
  text-decoration: none;
  font-weight: 700;
}

/* ---------- Chips + input ---------- */
.ax-chips {
  flex: none;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 14px 8px;
  scrollbar-width: none;
}
.ax-chips::-webkit-scrollbar { display: none; }
.ax-chip {
  flex: none;
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--ax-line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ax-dim);
  white-space: nowrap;
}
.ax-chip:hover { color: var(--ax-text); border-color: rgba(34, 211, 238, 0.45); }

.ax-input {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--ax-line);
}
.ax-input input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--ax-line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ax-text);
  font: inherit;
  font-size: 14px;
}
.ax-input input:focus { outline: none; border-color: rgba(34, 211, 238, 0.6); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12); }
.ax-input input::placeholder { color: #5f7689; }
.ax-mic, .ax-send {
  flex: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid var(--ax-line);
}
.ax-mic svg, .ax-send svg { width: 20px; height: 20px; fill: currentColor; }
.ax-mic { background: rgba(52, 211, 153, 0.1); color: var(--ax-emerald); border-color: rgba(52, 211, 153, 0.35); }
#ax-root[data-state="listening"] .ax-mic { background: #ff5252; color: #fff; border-color: transparent; box-shadow: 0 0 18px rgba(255, 82, 82, 0.6); animation: ax-breathe 1.2s ease-in-out infinite; }
.ax-mic:disabled { opacity: 0.35; cursor: not-allowed; }
.ax-send { background: var(--ax-cyan); color: #04121a; border-color: transparent; }

/* ---------- Page highlight when ATLAS points at something ---------- */
.ax-flash {
  animation: ax-flash 2.4s ease-out;
  border-radius: 14px;
}
@keyframes ax-flash {
  0%, 30% { box-shadow: 0 0 0 2px #22d3ee, 0 0 40px 4px rgba(34, 211, 238, 0.45); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; }
}

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 560px) {
  #ax-root { right: 16px; bottom: 16px; }
  .ax-orb { width: 76px; height: 76px; }
  .ax-panel {
    position: fixed;
    left: 8px; right: 8px; bottom: 8px;
    width: auto;
    height: min(78vh, 600px);
    height: min(78dvh, 600px);
  }
  .ax-head { height: 170px; }
  .ax-stage { inset: 0 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .ax-orb::after, .ax-status i, .ax-fb-core, .ax-fb-ring, #ax-root[data-state="listening"] .ax-mic { animation: none; }
  .ax-panel { animation: none; }
}
