:root {
  color-scheme: dark;
  --bg: #100a14;
  --panel: rgba(31, 18, 38, 0.92);
  --panel-2: #26172f;
  --line: rgba(255, 255, 255, 0.1);
  --text: #fff8ff;
  --muted: #c9b7cf;
  --pink: #f0a5d7;
  --pink-hot: #ff74c7;
  --gold: #e7c66c;
  --danger: #ff9cae;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(240, 165, 215, 0.13), transparent 34rem),
    radial-gradient(circle at 80% 90%, rgba(231, 198, 108, 0.09), transparent 32rem),
    linear-gradient(145deg, #0c0710, var(--bg));
}

button, textarea { font: inherit; }

.shell {
  width: min(760px, calc(100% - 28px));
  margin: 0 auto;
  padding: 34px 0 24px;
}

.chat-card {
  min-height: min(760px, calc(100vh - 96px));
  display: grid;
  grid-template-rows: auto auto 1fr auto auto auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.koa-avatar {
  position: relative;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid rgba(231, 198, 108, 0.75);
  border-radius: 50%;
  color: #1b0d20;
  background: linear-gradient(145deg, var(--gold), var(--pink));
  font-size: 25px;
  font-weight: 900;
  box-shadow: 0 8px 25px rgba(240, 165, 215, 0.24);
}

.horn {
  position: absolute;
  top: -7px;
  width: 10px;
  height: 18px;
  border-radius: 8px 8px 3px 3px;
  background: var(--gold);
}

.horn-left { left: 9px; transform: rotate(-20deg); }
.horn-right { right: 9px; transform: rotate(20deg); }

.header-copy { min-width: 0; }
.header-copy h1 { margin: 0; font-size: 1.18rem; letter-spacing: 0.01em; }
.header-copy p { margin: 4px 0 0; color: var(--muted); font-size: 0.84rem; }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: #8ff3b0;
  box-shadow: 0 0 12px rgba(143, 243, 176, 0.75);
}

.version {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
}

.attention-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 22px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.018);
}

.hearts {
  color: var(--pink-hot);
  letter-spacing: 2px;
  white-space: nowrap;
}

.messages {
  min-height: 330px;
  overflow-y: auto;
  padding: 22px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0 0 16px;
}

.message.user { align-items: flex-end; }

.speaker {
  margin: 0 10px 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bubble {
  max-width: min(84%, 590px);
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 17px 17px 17px 5px;
  line-height: 1.47;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--panel-2);
}

.message.user .bubble {
  border-radius: 17px 17px 5px 17px;
  color: #21101f;
  background: linear-gradient(145deg, #f2b3da, #e6c671);
}

.message.system .bubble {
  max-width: 100%;
  border-style: dashed;
  color: var(--muted);
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.025);
}

.typing .bubble { color: var(--muted); }
.typing-dots { letter-spacing: 4px; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: 0.35; } }

.turnstile-wrap {
  padding: 12px 22px 2px;
  border-top: 1px solid var(--line);
}

.turnstile-wrap p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
}

textarea {
  width: 100%;
  min-height: 48px;
  max-height: 140px;
  resize: none;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  color: var(--text);
  background: rgba(7, 3, 10, 0.44);
}

textarea:focus { border-color: rgba(240, 165, 215, 0.72); }
textarea:disabled { opacity: 0.55; cursor: not-allowed; }

button {
  border: 0;
  cursor: pointer;
}

#sendButton {
  align-self: end;
  min-width: 88px;
  height: 48px;
  padding: 0 18px;
  border-radius: 15px;
  color: #24101f;
  font-weight: 850;
  background: linear-gradient(145deg, var(--pink), var(--gold));
  box-shadow: 0 8px 24px rgba(240, 165, 215, 0.19);
}

#sendButton:hover:not(:disabled) { transform: translateY(-1px); }
#sendButton:disabled { opacity: 0.48; cursor: not-allowed; }

.chat-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 16px;
  color: var(--muted);
  font-size: 0.76rem;
}

.text-button {
  padding: 0;
  color: var(--pink);
  background: transparent;
}

.fine-print {
  margin: 13px 0 0;
  color: rgba(255, 255, 255, 0.46);
  text-align: center;
  font-size: 0.75rem;
}

.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }

@media (max-width: 560px) {
  .shell { width: 100%; padding: 0; }
  .chat-card { min-height: 100vh; border: 0; border-radius: 0; }
  .messages { padding: 17px 14px; }
  .bubble { max-width: 90%; }
  .chat-header { padding-inline: 16px; }
  .attention-bar { padding-inline: 16px; }
  .composer { padding-inline: 12px; }
  .chat-footer { padding-inline: 14px; }
}

.footer-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
}

.owner-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.owner-card {
  width: min(500px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 28px;
  text-align: center;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.owner-avatar { margin: 0 auto 18px; }
.owner-kicker { margin: 0 0 5px; color: var(--gold); font-size: 0.72rem; font-weight: 850; letter-spacing: 0.18em; }
.owner-card h1 { margin: 0; font-size: 1.7rem; }
.owner-copy { margin: 13px auto 24px; color: var(--muted); line-height: 1.55; }
.owner-form { display: grid; gap: 10px; text-align: left; }
.owner-form label { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.owner-form input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: none;
  color: var(--text);
  background: rgba(7, 3, 10, 0.44);
}
.owner-form input:focus { border-color: rgba(240, 165, 215, 0.72); }
.owner-form button {
  height: 48px;
  margin-top: 4px;
  border-radius: 15px;
  color: #24101f;
  font-weight: 850;
  background: linear-gradient(145deg, var(--pink), var(--gold));
}
.owner-form button:disabled { opacity: 0.55; cursor: wait; }
.owner-status { min-height: 1.4em; margin: 16px 0 0; color: var(--pink); }
.owner-link { display: inline-block; margin-top: 16px; color: var(--muted); }
