:root, [data-theme="night"] {
  --bg: #120910;
  --bg-2: #1a1018;
  --panel: #24151f;
  --line: #3a2433;
  --ink: #fff6fb;
  --mute: #c9a8bb;
  --rose: #f43f8e;
  --rose-2: #ff7ab8;
  --rose-deep: #c81e6a;
  --you: #6b2a52;
  --them: #3f2a38;
  --glow: rgba(244, 63, 142, 0.45);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --rail: 56px;
  --dock: 48px;
  --header: 46px;
}
[data-theme="wine"] {
  --bg: #14080c; --bg-2: #1c0c12; --panel: #2a1218; --line: #4a2030;
  --ink: #fff5f7; --mute: #d4a3b0; --rose: #e11d48; --rose-2: #fb7185;
  --rose-deep: #9f1239; --you: #7a2038; --them: #3a1822;
  --glow: rgba(225, 29, 72, 0.45);
}
[data-theme="dusk"] {
  --bg: #16100e; --bg-2: #1e1612; --panel: #2a1e18; --line: #4a342c;
  --ink: #fff7ed; --mute: #d4b8a8; --rose: #fb7185; --rose-2: #fdba74;
  --rose-deep: #c2410c; --you: #5a3a2c; --them: #3a2a22;
  --glow: rgba(251, 113, 133, 0.4);
}
[data-theme="ink"] {
  --bg: #0b1020; --bg-2: #12182c; --panel: #1a2240; --line: #2a3560;
  --ink: #eef2ff; --mute: #a5b4d4; --rose: #818cf8; --rose-2: #c4b5fd;
  --rose-deep: #4f46e5; --you: #2a3a70; --them: #1e2848;
  --glow: rgba(129, 140, 248, 0.4);
}
[data-theme="bloom"] {
  --bg: #1a1016; --bg-2: #24141e; --panel: #301c28; --line: #4a3040;
  --ink: #fff1f7; --mute: #d4a8c0; --rose: #f472b6; --rose-2: #f9a8d4;
  --rose-deep: #db2777; --you: #5a3048; --them: #3a2432;
  --glow: rgba(244, 114, 182, 0.45);
}
[data-theme="ember"] {
  --bg: #140e0a; --bg-2: #1c1410; --panel: #2a1c14; --line: #4a3020;
  --ink: #fff7ed; --mute: #d4b49a; --rose: #fb923c; --rose-2: #fdba74;
  --rose-deep: #c2410c; --you: #5a3824; --them: #3a2a1c;
  --glow: rgba(251, 146, 60, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: block;
  background: #120910;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.splash.gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.splash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 46%, transparent 18%, rgba(18, 9, 16, 0.35) 62%, rgba(18, 9, 16, 0.55) 100%);
  pointer-events: none;
}


.lock {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #120910;
  overflow: hidden;
}
.lock[hidden] { display: none !important; }
.lock-sky {
  position: absolute;
  inset: -28px;
  width: calc(100% + 56px);
  height: calc(100% + 56px);
  object-fit: cover;
  opacity: 0.95;
  filter: blur(22px) saturate(1.18) brightness(0.88);
  transform: scale(1.08);
  will-change: filter, transform;
}
.lock::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 50% 28%, rgba(244, 63, 142, 0.18), transparent 52%),
    linear-gradient(180deg, rgba(18, 9, 16, 0.28), rgba(18, 9, 16, 0.72) 58%, rgba(18, 9, 16, 0.88) 100%);
  pointer-events: none;
}
.lock::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  pointer-events: none;
}
.lock-card {
  position: relative;
  z-index: 1;
  width: min(340px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 22px 22px;
  border-radius: 24px;
  border: 1px solid color-mix(in srgb, var(--rose) 22%, var(--line));
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  backdrop-filter: blur(28px) saturate(1.2);
  -webkit-backdrop-filter: blur(28px) saturate(1.2);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(244, 63, 142, 0.12),
    inset 0 1px 0 rgba(255, 246, 251, 0.06);
  text-align: center;
}
.lock-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 24px var(--glow);
  animation: heartpulse 1.6s ease-in-out infinite;
}
.lock-card h1 {
  font-family: Georgia, Palatino, serif;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
}
.lock-lede {
  color: var(--mute);
  font-size: 0.9rem;
}
.pin-dots {
  display: flex;
  gap: 14px;
  margin: 6px 0 2px;
}
.pin-dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--rose) 55%, var(--line));
  background: transparent;
  transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}
.pin-dots i.on {
  background: var(--rose);
  box-shadow: 0 0 12px var(--glow);
  transform: scale(1.08);
}
.lock-note {
  min-height: 1.1em;
  color: #ffb4d4;
  font-size: 0.82rem;
}
.lock-note[hidden] { display: none !important; }
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}
.pin-pad button {
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.pin-pad button:hover {
  border-color: var(--rose);
  background: color-mix(in srgb, var(--rose) 14%, var(--panel));
}
.pin-pad button:active { transform: scale(0.96); }
.pin-pad button.ghost {
  color: var(--mute);
  font-size: 0.95rem;
}
.lock.shake .lock-card {
  animation: lockshake 0.38s ease;
}
@keyframes lockshake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-5px); }
}

button, textarea, input { font: inherit; color: inherit; }

.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(244, 63, 142, 0.14), transparent 55%),
    radial-gradient(800px 500px at 0% 100%, rgba(120, 30, 70, 0.18), transparent 50%);
}

/* Left icon rail (desktop) */
.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: calc(8px + var(--safe-t)) 6px 10px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: none;
  background: #120910;
  color: #8a7380;
  box-shadow: none;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  cursor: pointer;
  transition: 0.2s ease;
  overflow: hidden;
  padding: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-mark.live {
  background: #120910;
  box-shadow: 0 0 18px var(--glow);
  animation: liveorbit 4.8s ease-in-out infinite;
}

.ico {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--mute);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.18s ease;
}
.ico svg { width: 18px; height: 18px; }
.ico:hover, .ico.on { background: var(--panel); color: var(--ink); }
.ico.on { color: var(--rose-2); box-shadow: inset 0 0 0 1px rgba(244, 63, 142, 0.35); }
.ico:disabled { opacity: 0.4; cursor: not-allowed; }

.rail-spacer { flex: 1; }

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top"
    "chat"
    "composer";
  height: 100dvh;
}
.top { grid-area: top; }
.chat { grid-area: chat; }
.composer-wrap { grid-area: composer; }
.dock { grid-area: dock; }

.chat {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(4px + var(--safe-t)) 10px 4px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(18px);
  min-height: var(--header);
}

.who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--panel);
  border: 1.5px solid #5b4a55;
  color: #8a7380;
  display: grid;
  place-items: center;
  position: relative;
  flex-shrink: 0;
}
.avatar .av-ico { width: 16px; height: 16px; display: block; }
.avatar.lg { width: 56px; height: 56px; }
.avatar.lg .av-ico { width: 26px; height: 26px; }
.avatar.live {
  border-color: var(--rose);
  color: var(--rose-2);
  animation: liveorbit 4.8s ease-in-out infinite;
}

.who-text { min-width: 0; }
.who-text h1 {
  font-family: Georgia, "Palatino Linotype", Palatino, serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.presence {
  font-size: 0.72rem;
  color: var(--mute);
  margin-top: 1px;
  letter-spacing: 0.02em;
}
.presence.live { color: var(--rose-2); }

.top-actions { display: flex; gap: 4px; flex-shrink: 0; }

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px clamp(12px, 4vw, 24px) 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--rose) 40%, transparent) transparent;
}
.thread::-webkit-scrollbar { width: 8px; }
.thread::-webkit-scrollbar-track { background: transparent; }
.thread::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--rose) 38%, #3a2433);
  border-radius: 8px;
}
.thread::before {
  content: "";
  flex: 1 1 auto;
}

.msg {
  display: flex;
  gap: 8px;
  max-width: min(85%, 26rem);
  align-self: flex-start;
  align-items: flex-end;
  animation: rise 0.28s ease;
}
.msg.you { flex-direction: row-reverse; align-self: flex-end; }
.msg .col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  max-width: 100%;
}
.msg.you .col { align-items: flex-end; }
.msg .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--rose-2);
  display: grid; place-items: center; flex-shrink: 0;
}
.msg .av svg { width: 14px; height: 14px; display: block; }

.bubble {
  display: inline-block;
  max-width: 100%;
  padding: 8px 13px;
  border-radius: 18px 18px 18px 5px;
  background: var(--them);
  border: 1px solid color-mix(in srgb, var(--rose) 28%, var(--line));
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
  color: var(--ink);
}
.msg.you .bubble {
  border-radius: 18px 18px 5px 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--rose) 42%, var(--you)), var(--you));
  border-color: color-mix(in srgb, var(--rose) 45%, var(--line));
}

.md {
  font-size: 0.95rem;
  line-height: 1.45;
  overflow-wrap: break-word;
}
.md p { margin: 0 0 0.55em; }
.md p:last-child { margin-bottom: 0; }
.md em {
  color: var(--rose-2);
  font-style: italic;
  font-weight: 500;
}
.md strong { color: #fff; font-weight: 650; }
.md code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.86em;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1em 0.4em;
  border-radius: 6px;
}
.md pre {
  background: rgba(0, 0, 0, 0.28);
  border-radius: 12px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 0.5em 0;
}
.md pre code { background: none; padding: 0; }
.md blockquote {
  margin: 0.4em 0;
  padding: 0.15em 0 0.15em 0.8em;
  border-left: 3px solid var(--rose);
  color: var(--mute);
}
.md ul, .md ol { padding-left: 1.2em; margin: 0.4em 0; }
.md li { margin: 0.15em 0; }
.md a { color: var(--rose-2); }

.meta {
  display: block;
  margin-top: 4px;
  padding: 0 4px;
  font-size: 0.68rem;
  color: var(--mute);
  opacity: 0.85;
  width: max-content;
  max-width: 100%;
}

.typing {
  flex-shrink: 0;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--mute);
  font-size: 0.85rem;
  padding: 0 clamp(12px, 4vw, 24px) 8px;
}
.typing.hidden { display: none; }
.dots span {
  display: inline-block;
  width: 6px; height: 6px; margin-right: 3px;
  border-radius: 50%; background: var(--rose-2);
  animation: bounce 1s infinite;
}
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }

.composer-wrap {
  padding: 8px clamp(12px, 4vw, 24px) calc(8px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px);
}

.preview {
  max-width: 720px;
  margin: 0 auto 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(244, 63, 142, 0.08);
  border: 1px dashed rgba(244, 63, 142, 0.35);
  color: var(--mute);
  font-size: 0.88rem;
}
.preview.hidden { display: none; }
.preview .label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rose-2);
  margin-bottom: 4px;
}

.composer {
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 8px 8px 8px 14px;
}
.composer:focus-within { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(244, 63, 142, 0.15); }
.composer textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  max-height: 140px;
  min-height: 28px;
  padding: 8px 0;
  line-height: 1.45;
}
.composer textarea::placeholder { color: #9a7388; }

.send {
  width: 36px; height: 36px;
  border: none; border-radius: 12px;
  background: linear-gradient(145deg, var(--rose), var(--rose-deep));
  color: white;
  display: grid; place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.send:hover { filter: brightness(1.08); }
.send:disabled { opacity: 0.45; cursor: not-allowed; }
.send svg { width: 18px; height: 18px; }

.hint {
  max-width: 720px;
  margin: 6px auto 0;
  font-size: 0.72rem;
  color: #9a7388;
  text-align: center;
}

.dock {
  display: none;
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(8, 4, 8, 0.72);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 16px 16px calc(16px + var(--safe-b));
}
.sheet.open { display: flex; }
.card {
  width: min(520px, 100%);
  max-height: min(88dvh, 760px);
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.card h2 {
  font-family: Georgia, Palatino, serif;
  font-size: 1.35rem;
}
.card.profile {
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  height: min(88dvh, 760px);
  max-height: min(88dvh, 760px);
}
.profile-hero {
  height: 132px;
  flex-shrink: 0;
  margin: 0 -22px 0;
  position: relative;
  background:
    linear-gradient(180deg, transparent 58%, var(--bg-2) 100%),
    url("../docs/assets/howl-banner.png") center 38% / cover no-repeat;
}
.profile-hero img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  position: absolute;
  left: max(14px, calc(50% - 10rem));
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 20px var(--glow);
  border: 2px solid color-mix(in srgb, var(--rose) 42%, #120910);
}
.profile-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px 2px 18px 0;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--rose) 40%, var(--line)) transparent;
}
.profile-body > * {
  flex-shrink: 0;
}
.profile-body::-webkit-scrollbar { width: 8px; }
.profile-body::-webkit-scrollbar-track { background: transparent; }
.profile-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--rose) 38%, var(--line));
  border-radius: 99px;
}
.card.profile > h2,
.profile-body > h2 {
  margin-top: 4px;
  text-align: center;
}
.lede { color: var(--mute); font-size: 0.9rem; line-height: 1.45; }

.manual {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 4px;
}
.manual h3 {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--rose-2);
  margin-top: 4px;
}
.manual p,
.manual li {
  color: var(--mute);
  font-size: 0.86rem;
  line-height: 1.45;
}
.manual ul {
  padding-left: 1.15em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8rem; color: var(--mute); }
.field input, .field textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--rose); }
.field textarea { min-height: 88px; resize: vertical; }

.pwa-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--rose) 35%, var(--line));
  background:
    radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--rose) 22%, transparent), transparent 55%),
    var(--panel);
}
.pwa-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pwa-copy b {
  font-size: 0.92rem;
  font-weight: 650;
}
.pwa-copy span {
  font-size: 0.8rem;
  color: var(--mute);
  line-height: 1.4;
}
.pwa-banner .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.wake {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.howl-spin {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 0 24px var(--glow);
}
.howl-spin.pulse {
  animation: heartpulse 1.4s ease-in-out infinite;
}
@keyframes heartpulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.08); filter: brightness(1.18); }
}
.bar {
  height: 8px;
  background: #3a2433;
  border-radius: 99px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--rose), var(--rose-2));
  transition: width 0.2s;
}
.wake .pct { font-size: 0.8rem; color: var(--mute); }

.row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}
.btn.ghost { background: var(--panel); border: 1px solid var(--line); color: var(--ink); }
.btn.rose { background: var(--rose); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.note {
  display: none;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(244, 63, 142, 0.1);
  color: #ffd0e6;
  font-size: 0.88rem;
}
.note.show { display: block; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}
@keyframes liveorbit {
  0% {
    box-shadow: 8px -2px 18px var(--glow), 0 0 0 3px rgba(244, 63, 142, 0.16);
    filter: brightness(1);
  }
  35% {
    box-shadow: -2px 10px 18px var(--glow), 0 0 0 3px rgba(244, 63, 142, 0.22);
    filter: brightness(1.12);
  }
  70% {
    box-shadow: -10px -4px 16px var(--glow), 0 0 0 3px rgba(244, 63, 142, 0.18);
    filter: brightness(1.06);
  }
  100% {
    box-shadow: 8px -2px 18px var(--glow), 0 0 0 3px rgba(244, 63, 142, 0.16);
    filter: brightness(1);
  }
}

.start {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(18, 9, 16, 0.42), var(--bg) 78%),
    url("../docs/assets/howl-banner.png") center / cover no-repeat,
    var(--bg);
}
.start.open { display: flex; }
.start-card {
  width: min(420px, 100%);
  max-height: min(92dvh, 780px);
  overflow-y: auto;
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.start-card h1 {
  font-family: Georgia, Palatino, serif;
  font-size: 1.7rem;
}
.start-card > p { color: var(--mute); font-size: 0.9rem; line-height: 1.4; }
.start-card .field { width: 100%; text-align: left; }
.empty-hint {
  align-self: center;
  margin: auto 0;
  color: var(--mute);
  font-size: 0.9rem;
  text-align: center;
  opacity: 0.75;
}

.agree {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agree-title {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--rose-2);
}
.agree-box {
  max-height: 140px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--mute);
  text-align: left;
}
.agree-box p { margin: 0 0 0.65em; }
.agree-box p:last-child { margin-bottom: 0; }
.agree-box a { color: var(--rose-2); }
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 99px;
  background: var(--bg);
  border: 1px solid var(--line);
  position: relative;
  flex-shrink: 0;
  transition: background 0.16s ease, border-color 0.16s ease;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--mute);
  transition: left 0.16s ease, background 0.16s ease, transform 0.12s ease;
}
.toggle.on .toggle-track,
.toggle[aria-checked="true"] .toggle-track {
  background: rgba(244, 63, 142, 0.32);
  border-color: var(--rose);
}
.toggle.on .toggle-knob,
.toggle[aria-checked="true"] .toggle-knob {
  left: 18px;
  background: var(--rose-2);
}
.toggle:hover .toggle-track { border-color: var(--rose-2); }
.toggle:active .toggle-knob { transform: scale(0.9); }
.toggle:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 3px;
}
.toggle:disabled,
.toggle[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}
.toggle:disabled:hover .toggle-track,
.toggle[aria-disabled="true"]:hover .toggle-track {
  border-color: var(--line);
}
.start-card .btn { width: 100%; }
.start-card .bar { width: 100%; }

.profile details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 12px 10px;
}
.profile summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px 8px 0;
  font-weight: 650;
}
.profile summary::-webkit-details-marker { display: none; }
.profile summary::after {
  content: "";
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-right: 2px solid var(--mute);
  border-bottom: 2px solid var(--mute);
  transform: rotate(-45deg);
  transition: transform 0.16s ease;
}
.profile details[open] summary { color: var(--rose-2); }
.profile details[open] summary::after {
  transform: rotate(45deg);
  border-color: var(--rose-2);
}
.profile details .field { margin-top: 8px; }
.profile details .persona-pick { margin-top: 8px; }
.profile details .btn { margin-top: 10px; }

.field select {
  background-color: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%), linear-gradient(135deg, var(--mute) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
.field select:focus { border-color: var(--rose); }
.field[hidden], [hidden] { display: none !important; }

.persona-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.persona-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: inherit;
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
}
.persona-card svg {
  width: 18px;
  height: 18px;
  color: var(--rose-2);
}
.persona-card strong { font-size: 0.9rem; }
.persona-card span {
  font-size: 0.74rem;
  color: var(--mute);
  line-height: 1.3;
}
.persona-card.on {
  border-color: var(--rose);
  background: rgba(244, 63, 142, 0.12);
}

.model-pick { display: grid; gap: 8px; margin: 8px 0 10px; }
.model-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}
.model-chip strong { font-size: 0.92rem; }
.model-chip span { font-size: 0.75rem; color: var(--mute); }
.model-chip.on { border-color: var(--rose); }

.icon-pick {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.icon-pick button {
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--mute);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-pick button svg { width: 18px; height: 18px; }
.icon-pick button.on {
  border-color: var(--rose);
  color: var(--rose-2);
  background: rgba(244, 63, 142, 0.12);
}

.theme-pick { display: grid; gap: 8px; }
.theme-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}
.theme-chip i {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--rose);
}
.theme-chip.on { border-color: var(--rose); }
.theme-chip.wine i { background: #e11d48; }
.theme-chip.dusk i { background: #fb7185; }
.theme-chip.ink i { background: #818cf8; }
.theme-chip.bloom i { background: #f472b6; }
.theme-chip.ember i { background: #fb923c; }

.row.left { justify-content: flex-start; }

.hist-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
}
.hist {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.hist-open {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
}
.hist.on .hist-open { border-color: var(--rose); }
.hist-av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--rose-2);
  display: grid; place-items: center; flex-shrink: 0;
}
.hist-av svg { width: 16px; height: 16px; }
.hist-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hist-copy b {
  font-size: 0.9rem;
  font-weight: 650;
}
.hist-copy span {
  font-size: 0.78rem;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-when {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--mute);
}
.hist-del {
  width: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--mute);
  border-radius: 14px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}
.hist-del:hover { color: var(--rose-2); border-color: var(--rose); }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  .stage {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "top"
      "chat"
      "composer"
      "dock";
  }
  .dock {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: calc(var(--dock) + var(--safe-b));
    padding-bottom: var(--safe-b);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
  }
  .thread { padding: 12px 12px 6px; }
  .composer-wrap { padding: 8px 12px 8px; }
  .sheet { align-items: flex-end; }
  .msg { max-width: min(88%, 20rem); }
  .card { width: 100%; border-radius: 22px 22px 0 0; max-height: min(92dvh, 760px); }
}

@media (max-width: 420px) {
  .msg { max-width: 88%; }
  .msg .av { width: 24px; height: 24px; }
  .msg .av svg { width: 12px; height: 12px; }
  .thread { padding: 10px 10px 6px; gap: 8px; }
  .composer-wrap { padding: 6px 10px 8px; }
  .who-text h1 { font-size: 0.95rem; }
  .start { padding: 10px; }
  .start-card { padding: 16px 14px; border-radius: 18px; }
  .pwa-banner { flex-wrap: wrap; }
  .pwa-banner .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .toggle-track,
  .toggle-knob,
  .msg,
  .brand-mark.live,
  .avatar.live,
  .howl-spin.pulse,
  .lock-mark { transition: none; animation: none; }
  .lock.shake .lock-card { animation: none; }
  .lock-sky { filter: blur(14px) saturate(1.1) brightness(0.9); }
  .lock::after { backdrop-filter: none; -webkit-backdrop-filter: none; }
  .avatar.live { box-shadow: 0 0 0 3px rgba(244, 63, 142, 0.18), 0 0 16px var(--glow); }
  .thread { scroll-behavior: auto; }
}
