:root {
  /* Signature */
  --pink: #ff1493;            /* hot pink — the one bold accent */
  --pink-deep: #d80f73;       /* text/links on paper (accessible) */
  --pink-soft: #ff8cc6;
  --pink-wash: #ffe9f4;
  --pink-glow: rgba(255, 20, 147, .22);

  /* Warm editorial paper */
  --paper: #faf6f1;
  --card: #fffdfb;
  --ink: #1d1b18;
  --ink-soft: #46423c;
  --muted: #8b8479;
  --line: #ece4d9;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, Cambria, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 19px;
  --shadow: 0 1px 2px rgba(40, 30, 25, .04), 0 10px 30px rgba(60, 40, 45, .06);
  --shadow-pink: 0 8px 24px rgba(255, 20, 147, .22);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, var(--pink-wash) 0%, transparent 42%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* faint grain for warmth/depth */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--pink-wash); }

#app {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  background: linear-gradient(var(--card), var(--card));
  box-shadow: var(--shadow);
}

/* ---------- Masthead ---------- */
header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 24px 16px;
  border-bottom: 1px solid var(--line);
  animation: rise .5s .02s both cubic-bezier(.2,.7,.2,1);
}
.brand { display: flex; align-items: center; gap: 11px; }
.spark { color: var(--pink); font-size: 15px; line-height: 1; transform: translateY(1px); }
header h1 {
  margin: 0; font-family: var(--serif); font-weight: 400;
  font-size: 22px; letter-spacing: .2px; display: flex; align-items: baseline; gap: 8px;
}
header .mark { color: var(--ink); }
header .mark::after { content: "."; color: var(--pink); }
header .sub { color: var(--muted); font-style: italic; font-size: 18px; }

/* refined pill switch (Deep / Opus) */
.switch { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 38px; height: 22px; border-radius: 999px;
  background: #e7ded3; border: 1px solid var(--line); position: relative; transition: background .2s;
}
.switch .thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.18); transition: transform .2s, background .2s;
}
.switch input:checked + .track { background: var(--pink); border-color: var(--pink); }
.switch input:checked + .track .thumb { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--pink-glow); }
.switch-label { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.ghost-btn {
  border: 0; background: transparent; cursor: pointer; font: inherit;
  font-size: 12px; letter-spacing: .03em; text-transform: uppercase; font-weight: 600;
  color: var(--muted); padding: 6px 9px; border-radius: 9px; transition: color .15s, background .15s;
}
.ghost-btn:hover { color: var(--pink-deep); background: var(--pink-wash); }

/* ---------- Conversation ---------- */
#log {
  flex: 1; overflow-y: auto;
  padding: 28px 24px 20px;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth;
}
.msg { display: flex; animation: rise .42s both cubic-bezier(.2,.7,.2,1); }
.msg.user { justify-content: flex-end; }
.intro { animation-delay: .1s; }

.bubble {
  max-width: 78%;
  padding: 13px 17px;
  line-height: 1.62;
  font-size: 15.5px;
  border-radius: var(--radius);
  word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.assistant .bubble {
  background: var(--card);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
}
.msg.user .bubble {
  background: linear-gradient(135deg, #ff2a9b, var(--pink) 60%, #e91383);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-pink);
}

/* markdown — headings borrow the serif for editorial character */
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: .55em 0; }
.bubble h1, .bubble h2, .bubble h3 {
  font-family: var(--serif); font-weight: 600; font-size: 16.5px;
  margin: .7em 0 .35em; color: var(--ink);
}
.bubble ul, .bubble ol { margin: .45em 0; padding-left: 1.25em; }
.bubble li { margin: .2em 0; }
.bubble li::marker { color: var(--pink-soft); }
.bubble strong { font-weight: 650; color: var(--ink); }
.msg.user .bubble strong { color: #fff; }
.bubble code { font-family: var(--mono); font-size: 13px; background: var(--paper); border: 1px solid var(--line); padding: 1px 5px; border-radius: 6px; }
.bubble a { color: var(--pink-deep); text-underline-offset: 2px; }
.wiki {
  color: var(--pink-deep); background: var(--pink-wash);
  border-radius: 6px; padding: 1px 6px; font-size: 13.5px; white-space: nowrap;
}
.msg.user .wiki { color: #fff; background: rgba(255,255,255,.22); }

/* streaming caret */
.bubble.streaming::after {
  content: ""; display: inline-block; width: 2px; height: 1.05em;
  margin-left: 2px; vertical-align: -2px; background: var(--pink);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* typing indicator (before first token) */
.typing { display: inline-flex; gap: 5px; padding: 3px 1px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--pink-soft); animation: bob 1.1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%,80%,100% { transform: translateY(0); opacity:.45 } 40% { transform: translateY(-5px); opacity:1 } }

/* ---------- Composer ---------- */
#composer {
  display: flex; align-items: flex-end; gap: 8px;
  margin: 0 16px 16px;
  padding: 8px 8px 8px 12px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  transition: border-color .18s, box-shadow .18s;
  animation: rise .5s .06s both cubic-bezier(.2,.7,.2,1);
}
#composer:focus-within { border-color: var(--pink); box-shadow: var(--shadow), 0 0 0 4px var(--pink-glow); }

#composer textarea {
  flex: 1; resize: none; max-height: 184px;
  border: 0; background: transparent; outline: none;
  font: inherit; font-size: 15.5px; line-height: 1.5; color: var(--ink);
  padding: 9px 4px;
}
#composer textarea::placeholder { color: var(--muted); }

#attach, #send {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 13px; cursor: pointer;
  transition: transform .12s, background .18s, color .18s, box-shadow .18s;
}
#attach { border: 0; background: transparent; color: var(--muted); }
#attach:hover { background: var(--pink-wash); color: var(--pink-deep); }

#send { border: 0; background: var(--pink); color: #fff; box-shadow: var(--shadow-pink); }
#send:hover { transform: translateY(-1px); background: var(--pink-deep); }
#send:active { transform: translateY(0); }
#send:disabled { background: var(--pink-soft); box-shadow: none; cursor: default; transform: none; }
#send.loading svg { display: none; }
#send.loading::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Drop overlay ---------- */
#drop {
  position: fixed; inset: 0; z-index: 50; display: none;
  align-items: center; justify-content: center;
  background: rgba(255, 20, 147, .07); backdrop-filter: blur(3px);
}
#drop.show { display: flex; animation: fade .15s both; }
.drop-card {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--serif); font-size: 23px; color: var(--pink-deep);
  background: var(--card); border: 2.5px dashed var(--pink);
  padding: 38px 56px; border-radius: 26px; box-shadow: var(--shadow-pink);
  animation: pop .2s both cubic-bezier(.2,.8,.2,1.2);
}
.drop-card .spark { font-size: 22px; }

/* ---------- misc ---------- */
#log::-webkit-scrollbar { width: 10px; }
#log::-webkit-scrollbar-thumb { background: var(--pink-soft); border-radius: 10px; border: 3px solid var(--card); }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 24px; }
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: var(--shadow); padding: 34px 30px 30px;
  display: flex; flex-direction: column; gap: 14px;
  animation: rise .5s both cubic-bezier(.2,.7,.2,1);
}
.login-brand { justify-content: center; margin-bottom: 2px; }
.login-hint { text-align: center; color: var(--muted); font-size: 13px; margin: -4px 0 8px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.login-card input {
  font: inherit; font-size: 15px; padding: 11px 13px;
  border: 1.5px solid var(--line); border-radius: 13px; outline: none; background: var(--paper); color: var(--ink);
}
.login-card input:focus { border-color: var(--pink); box-shadow: 0 0 0 4px var(--pink-glow); background: var(--card); }
#code { letter-spacing: .18em; font-variant-numeric: tabular-nums; }
#signin {
  margin-top: 6px; height: 46px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--pink); color: #fff; font: inherit; font-weight: 650; font-size: 15px;
  box-shadow: var(--shadow-pink); transition: background .18s, transform .12s;
}
#signin:hover { background: var(--pink-deep); transform: translateY(-1px); }
#signin:disabled { background: var(--pink-soft); transform: none; }
.login-err { color: var(--pink-deep); font-size: 13px; min-height: 18px; text-align: center; }
