:root {
  color-scheme: dark;
  --ink: #050608;
  --paper: #f4f7fb;
  --muted: rgba(244, 247, 251, 0.58);
  --line: rgba(244, 247, 251, 0.2);
  --glass: rgba(7, 9, 12, 0.66);
  --focus: #bce8ff;
  --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
  --display: "Arial Narrow", "Bahnschrift SemiCondensed", "Aptos Narrow", Arial, sans-serif;
  --body: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--body);
}

button, textarea, a { color: inherit; font: inherit; }
button { border: 0; }
a:focus-visible, button:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }

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

.ing-background,
.ing-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.ing-background {
  background: url("../assets/hero-ing-gate-v1.png") center / cover no-repeat;
  transform: scale(1.02);
  animation: breathe 18s var(--ease) infinite alternate;
}

.ing-vignette {
  background:
    linear-gradient(180deg, rgba(5, 6, 8, 0.7), rgba(5, 6, 8, 0.22) 36%, rgba(5, 6, 8, 0.9)),
    linear-gradient(90deg, rgba(5, 6, 8, 0.75), transparent 45%, rgba(5, 6, 8, 0.28));
}

@keyframes breathe {
  from { transform: scale(1.02) translate3d(0, 0, 0); }
  to { transform: scale(1.065) translate3d(-0.5%, -0.25%, 0); }
}

.ing-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 56px);
  background: linear-gradient(180deg, rgba(5, 6, 8, 0.78), transparent);
}

.ing-brand {
  display: inline-flex;
  width: 80px;
  height: 44px;
  align-items: center;
}

.ing-brand img { width: 78px; height: 38px; object-fit: contain; }

.ing-state {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font: 700 11px/1 var(--display);
  letter-spacing: 0;
}

.ing-state-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bce8ff;
  box-shadow: 0 0 14px rgba(188, 232, 255, 0.9);
}

body[data-route="searching"] .ing-state-dot { animation: signalPulse 0.8s ease-in-out infinite alternate; }
body[data-route="offline"] .ing-state-dot { background: #ff8e8e; box-shadow: 0 0 14px rgba(255, 142, 142, 0.9); }

@keyframes signalPulse { to { opacity: 0.2; transform: scale(0.6); } }

.ing-more {
  justify-self: end;
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(5, 6, 8, 0.28);
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.ing-more span { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }

.ing-shell {
  position: relative;
  z-index: 5;
  display: grid;
  width: min(900px, 100%);
  height: 100dvh;
  margin: 0 auto;
  padding: 92px clamp(16px, 4vw, 34px) max(22px, env(safe-area-inset-bottom));
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 18px;
}

.ing-conversation {
  min-height: 0;
  overflow: hidden;
}

.ing-empty {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ing-empty[hidden] { display: none; }

.fluid-mark { width: clamp(96px, 16vw, 150px); filter: drop-shadow(0 0 28px rgba(188, 232, 255, 0.18)); }
.fluid-mark svg { display: block; width: 100%; overflow: visible; }
.fluid-outline, .fluid-line { fill: none; stroke: rgba(244, 247, 251, 0.82); stroke-linecap: round; stroke-linejoin: round; }
.fluid-outline { stroke-width: 1.25; stroke-dasharray: 230; animation: flow 8s linear infinite; }
.fluid-line { stroke-width: 1.1; stroke-dasharray: 70; animation: flow 3.6s linear infinite reverse; }
.fluid-light { fill: #dff5ff; filter: drop-shadow(0 0 10px #bce8ff); animation: lightPulse 2.6s ease-in-out infinite; }

@keyframes flow { to { stroke-dashoffset: -230; } }
@keyframes lightPulse { 50% { opacity: 0.25; transform: scale(0.55); transform-origin: 54px 42px; } }

.ing-empty h1 {
  margin: 26px 0 0;
  font: 700 clamp(54px, 11vw, 104px)/0.9 var(--display);
  letter-spacing: 0;
}

.ing-empty p { margin: 18px 0 0; color: var(--muted); font-size: 15px; }

.ing-messages {
  display: flex;
  height: 100%;
  margin: 0;
  padding: 6vh 0 16px;
  overflow-y: auto;
  flex-direction: column;
  gap: 14px;
  list-style: none;
  scrollbar-width: thin;
}

.ing-messages[hidden] { display: none; }

.ing-message {
  display: grid;
  width: min(78%, 620px);
  padding: 15px 17px 11px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(18px);
  animation: messageIn 380ms var(--ease) both;
}

.ing-message.is-ping { align-self: flex-end; border-radius: 18px 4px 18px 18px; }
.ing-message.is-pong { align-self: flex-start; border-radius: 4px 18px 18px 18px; background: rgba(237, 247, 252, 0.11); }
.ing-message span { color: var(--muted); font: 700 10px/1 var(--display); }
.ing-message p { margin: 8px 0 4px; white-space: pre-wrap; font-size: clamp(15px, 2vw, 17px); line-height: 1.55; }
.ing-message time { justify-self: end; color: rgba(244, 247, 251, 0.36); font-size: 10px; }

@keyframes messageIn { from { opacity: 0; transform: translateY(14px); } }

.ing-composer {
  display: grid;
  min-height: 62px;
  padding: 8px 8px 8px 20px;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: end;
  gap: 10px;
  border: 1px solid rgba(244, 247, 251, 0.34);
  border-radius: 28px;
  background: rgba(5, 6, 8, 0.76);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(24px);
}

.ing-composer textarea {
  width: 100%;
  min-height: 45px;
  max-height: 160px;
  padding: 11px 0 8px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--paper);
  font-size: 16px;
  line-height: 1.45;
}

.ing-composer textarea::placeholder { color: rgba(244, 247, 251, 0.42); }

.ing-send {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: transform 180ms var(--ease), opacity 180ms var(--ease);
}

.ing-send:hover { transform: scale(1.04); }
.ing-send:disabled { opacity: 0.38; cursor: wait; }
.ing-send svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.ing-panel { position: fixed; inset: 0; z-index: 50; }
.ing-panel[hidden] { display: none; }
.ing-panel-backdrop { position: absolute; inset: 0; width: 100%; background: rgba(0, 0, 0, 0.52); backdrop-filter: blur(5px); cursor: default; }

.ing-panel-sheet {
  position: absolute;
  inset: 0 0 0 auto;
  display: flex;
  width: min(420px, 92vw);
  padding: 28px;
  flex-direction: column;
  gap: 22px;
  border-left: 1px solid var(--line);
  background: rgba(5, 6, 8, 0.94);
  backdrop-filter: blur(28px);
  animation: panelIn 340ms var(--ease) both;
}

@keyframes panelIn { from { transform: translateX(100%); } }

.ing-panel-sheet header { display: flex; align-items: center; justify-content: space-between; }
.ing-panel-sheet header p { margin: 0; font: 700 19px/1 var(--display); }
.ing-panel-sheet header button { width: 44px; height: 44px; border-radius: 50%; background: transparent; font-size: 30px; cursor: pointer; }
.ing-panel-sheet nav { display: grid; gap: 1px; background: var(--line); }
.ing-panel-sheet nav a { display: grid; padding: 22px; gap: 5px; background: #090b0e; text-decoration: none; }
.ing-panel-sheet nav span { font: 700 28px/1 var(--display); }
.ing-panel-sheet nav small { color: var(--muted); font-size: 13px; }
.ing-panel-sheet details { border-block: 1px solid var(--line); }
.ing-panel-sheet summary { padding: 18px 0; cursor: pointer; font: 700 12px/1 var(--display); }
.ing-trace { padding: 0 0 18px; }
.ing-trace p { display: flex; margin: 10px 0; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 12px; }
.ing-trace strong { color: var(--paper); }
.ing-clear { margin-top: auto; padding: 16px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font: 700 11px/1 var(--display); }

@media (max-width: 600px) {
  .ing-header { min-height: 66px; padding-inline: 16px; }
  .ing-brand { width: 66px; }
  .ing-brand img { width: 64px; height: 34px; }
  .ing-shell { padding: 74px 12px max(12px, env(safe-area-inset-bottom)); gap: 12px; }
  .ing-state { font-size: 9px; }
  .ing-more { width: 40px; height: 40px; }
  .ing-messages { padding-top: 3vh; }
  .ing-message { width: 88%; }
  .ing-composer { min-height: 58px; padding-left: 16px; grid-template-columns: minmax(0, 1fr) 44px; }
  .ing-send { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}
