:root {
  --bg: #08090b;
  --panel: #101217;
  --panel-soft: #151922;
  --ink: #eef2f7;
  --muted: #9aa4b2;
  --line: rgba(238, 242, 247, 0.13);
  --accent: #58a6ff;
  --accent-deep: #1f5f9f;
  --carmine: #8b0000;
  --danger: #ff7777;
  --field: #0c0e13;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(88, 166, 255, 0.06), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea {
  font: inherit;
}

.ivie-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 22px;
  padding: 30px 18px;
}

.ivie-intro {
  width: min(960px, 100%);
  align-self: end;
}

.ivie-intro h1 {
  margin: 6px 0 10px;
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 0.95;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--carmine);
}

.ivie-intro p {
  max-width: 62ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.5vw, 1.08rem);
  line-height: 1.58;
}

.chat-panel {
  width: min(960px, 100%);
  height: min(720px, calc(100vh - 56px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
}

.site-mark,
.presence {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.chat-header h1 {
  margin: 6px 0 6px;
  font-size: clamp(2.1rem, 6vw, 4.6rem);
  line-height: 0.95;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--carmine);
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.audio-toggle {
  min-width: 0;
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1;
}

.audio-toggle[aria-pressed="true"] {
  color: rgba(238, 242, 247, 0.62);
}

.audio-toggle:hover:not(:disabled) {
  background: transparent;
  color: rgba(238, 242, 247, 0.86);
}

.iris {
  width: clamp(35px, 6.5vw, 59px);
  aspect-ratio: 1;
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 20%, rgba(0, 5, 18, 0.22) 21% 28%, transparent 29%),
    repeating-conic-gradient(
      from -12deg,
      #001d87 0deg 4deg,
      #0059ff 5deg 9deg,
      #00d8ff 10deg 13deg,
      #0028ad 14deg 20deg,
      transparent 21deg 24deg
    ),
    radial-gradient(circle, #0b5fe6 0 56%, #001a74 57% 70%, transparent 71%);
  border: 1px solid rgba(87, 171, 255, 0.36);
  box-shadow:
    inset 0 0 14px rgba(0, 237, 255, 0.22),
    0 0 34px rgba(0, 128, 255, 0.24);
  overflow: hidden;
  animation: iris-breathe 5.8s ease-in-out infinite;
}

.iris::before {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  background:
    repeating-conic-gradient(
      from 6deg,
      rgba(0, 38, 180, 0.1) 0deg 3deg,
      rgba(0, 217, 255, 0.76) 4deg 7deg,
      rgba(0, 58, 210, 0.9) 8deg 15deg,
      transparent 16deg 20deg
    );
  mix-blend-mode: screen;
  transform-origin: center;
  animation: iris-turn 18s linear infinite;
}

.iris-core {
  width: 33%;
  aspect-ratio: 1;
  display: block;
  position: relative;
  z-index: 1;
  border-radius: 50%;
  background: #020305;
  box-shadow:
    0 0 12px rgba(0, 0, 0, 0.88),
    0 0 0 5px rgba(0, 0, 0, 0.18);
}

@keyframes iris-breathe {
  0%,
  100% {
    box-shadow:
      inset 0 0 14px rgba(0, 237, 255, 0.2),
      0 0 28px rgba(0, 128, 255, 0.2);
    filter: saturate(1.02) brightness(1);
  }

  50% {
    box-shadow:
      inset 0 0 20px rgba(0, 237, 255, 0.34),
      0 0 42px rgba(0, 128, 255, 0.34);
    filter: saturate(1.22) brightness(1.08);
  }
}

@keyframes iris-turn {
  to {
    transform: rotate(360deg);
  }
}

.chat-log {
  overflow-y: auto;
  padding: 30px clamp(18px, 4vw, 42px);
}

.message {
  max-width: 78ch;
  margin: 0 0 24px;
  line-height: 1.58;
  font-size: clamp(1rem, 2.4vw, 1.06rem);
  white-space: pre-wrap;
}

.message p {
  margin: 0;
}

.message-user {
  margin-left: auto;
  color: var(--ink);
  text-align: right;
}

.message-user p {
  display: inline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
}

.message-ivie {
  color: var(--ink);
  border-left: 2px solid var(--accent);
  padding-left: 18px;
}

.message-system {
  color: var(--danger);
  font-size: 0.95rem;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px clamp(18px, 4vw, 42px) 24px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.input-wrap {
  min-width: 0;
}

textarea {
  width: 100%;
  min-height: 58px;
  max-height: 170px;
  resize: vertical;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  padding: 15px 16px;
  outline: none;
}

textarea::placeholder {
  color: rgba(154, 164, 178, 0.72);
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.14);
}

button {
  min-width: 104px;
  min-height: 58px;
  border: 1px solid rgba(88, 166, 255, 0.38);
  background: transparent;
  color: rgba(238, 242, 247, 0.82);
  padding: 0 20px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 560;
}

button:hover:not(:disabled) {
  background: rgba(88, 166, 255, 0.08);
  color: var(--ink);
}

button:disabled {
  opacity: 0.48;
  cursor: wait;
}

.status-text {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.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;
}

.site-footer {
  padding: 0 18px 28px;
  text-align: center;
}

.site-footer a {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
}

@media (max-width: 640px) {
  .ivie-shell {
    min-height: auto;
    place-items: stretch;
    padding: 22px 0 0;
  }

  .ivie-intro {
    padding: 0 18px;
  }

  .chat-panel {
    min-height: calc(100vh - 170px);
    height: calc(100vh - 170px);
    border-left: 0;
    border-right: 0;
  }

  .chat-header {
    align-items: flex-start;
    padding-top: 20px;
  }

  .header-actions {
    align-items: center;
    gap: 12px;
  }

  .audio-toggle {
    min-height: 0;
    width: auto;
    padding: 0;
  }

  .iris {
    width: 34px;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .message-user {
    padding-left: 18px;
  }
}
