/* sLin — a small stage for the bot */

:root {
  --bg: oklch(0.975 0.006 85);
  --fg: oklch(0.2 0.012 60);
  --muted: oklch(0.5 0.012 60);
  --line: oklch(0.2 0.012 60 / 0.1);
  --dot: oklch(0.2 0.012 60 / 0.09);
  --accent: oklch(0.65 0.2 38);
  --bot: oklch(0.67 0.2 38);
  --bot-eye: oklch(0.99 0.004 85);
  --blush: oklch(0.8 0.12 10);
  --shadow: oklch(0.2 0.012 60 / 0.12);
  --panel: oklch(1 0 0 / 0.75);
  --ok: oklch(0.68 0.15 150);

  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --pad: clamp(1rem, 4vw, 2.5rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(0.165 0.008 60);
    --fg: oklch(0.95 0.007 85);
    --muted: oklch(0.68 0.01 70);
    --line: oklch(0.95 0.007 85 / 0.1);
    --dot: oklch(0.95 0.007 85 / 0.08);
    --accent: oklch(0.73 0.17 42);
    --bot: oklch(0.72 0.18 42);
    --bot-eye: oklch(0.17 0.008 60);
    --blush: oklch(0.6 0.16 15);
    --shadow: oklch(0 0 0 / 0.35);
    --panel: oklch(0.22 0.01 60 / 0.8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: oklch(0.165 0.008 60);
  --fg: oklch(0.95 0.007 85);
  --muted: oklch(0.68 0.01 70);
  --line: oklch(0.95 0.007 85 / 0.1);
  --dot: oklch(0.95 0.007 85 / 0.08);
  --accent: oklch(0.73 0.17 42);
  --bot: oklch(0.72 0.18 42);
  --bot-eye: oklch(0.17 0.008 60);
  --blush: oklch(0.6 0.16 15);
  --shadow: oklch(0 0 0 / 0.35);
  --panel: oklch(0.22 0.01 60 / 0.8);
  color-scheme: dark;
}

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

html, body { height: 100%; }

body {
  position: relative;
  overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* —— top —— */
.top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem var(--pad);
}

.mark {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.035em;
  text-decoration: none;
}

.mark span { color: var(--accent); }

.top__nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.top__nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.top__nav a:hover { color: var(--fg); }

.theme {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.theme span {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--fg) 50%, transparent 50%);
  box-shadow: inset 0 0 0 1.5px var(--fg);
  transition: transform 0.5s var(--ease);
}

:root[data-theme="dark"] .theme span { transform: rotate(180deg); }

/* —— customizer —— */
.dress-btn {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.3s var(--ease);
}

.dress-btn:hover { border-color: var(--bot); transform: rotate(-8deg); }
.dress-btn svg { width: 1.15rem; height: 1.15rem; }
.dress-btn circle { fill: var(--bot); }
.dress-btn rect { fill: var(--bot-eye); }

.dress {
  position: fixed;
  top: 4rem;
  right: var(--pad);
  z-index: 6;
  display: grid;
  gap: 0.9rem;
  width: min(18.5rem, calc(100vw - 2 * var(--pad)));
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 24px 50px -24px var(--shadow);
  font-size: 0.8125rem;
  transform-origin: calc(100% - 4rem) 0;
  animation: pop 0.3s var(--ease);
}

.dress[hidden] { display: none; }

.dress__row {
  display: grid;
  gap: 0.45rem;
}

.dress__row > span {
  color: var(--muted);
  font-size: 0.75rem;
}

.dress__name {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.9375rem;
  outline: none;
}

.dress__name:focus { border-color: var(--bot); }

.dress__colors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.swatch {
  width: 1.4rem;
  height: 1.4rem;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px oklch(0 0 0 / 0.08);
  cursor: pointer;
  transition: transform 0.2s var(--ease);
}

.swatch:hover { transform: scale(1.12); }

.swatch[aria-checked="true"] {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c);
}

.dress__shapes {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
}

.shape-opt {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.shape-opt:hover { background: var(--line); }
.shape-opt[aria-checked="true"] { border-color: var(--bot); }
.shape-opt svg { width: 70%; height: 70%; overflow: visible; }
.shape-opt path { fill: var(--bot); }

.dress__reset {
  justify-self: start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.dress__reset:hover { color: var(--fg); }

/* —— stage —— */
.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

.bot-body {
  fill: var(--bot);
  pointer-events: visiblePainted;
  cursor: grab;
  transition: fill 0.4s ease;
}

.is-dragging, .is-dragging .bot-body { cursor: grabbing; }

.bot-eye {
  fill: var(--bot-eye);
  stroke: none;
  pointer-events: none;
}

.bot-eye.is-line {
  fill: none;
  stroke: var(--bot-eye);
  stroke-width: 5;
  stroke-linecap: round;
}

.bot-mouth {
  fill: none;
  stroke: var(--bot-eye);
  stroke-width: 4;
  stroke-linecap: round;
  pointer-events: none;
}

.bot-mouth.is-open {
  fill: var(--bot-eye);
  stroke: none;
}

.bot-blush {
  fill: var(--blush);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.bot-shadow { fill: var(--shadow); }

.bot-zzz {
  fill: var(--muted);
  font-family: var(--mono);
  font-weight: 500;
}

/* —— speech bubble —— */
.bubble {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 4;
  max-width: min(20rem, calc(100vw - 2rem));
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px -16px var(--shadow);
  font-size: 0.9375rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  pointer-events: none;
  transform-origin: 50% 100%;
  animation: pop 0.35s var(--ease);
}

.bubble[hidden] { display: none; }

.bubble.is-thinking::after {
  content: "";
  display: inline-block;
  width: 1.4em;
  text-align: left;
  animation: dots 1s steps(4) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

@keyframes pop {
  from { opacity: 0; scale: 0.85; }
}

/* —— chat —— */
.chat {
  position: fixed;
  left: 50%;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: min(34rem, calc(100vw - 2 * var(--pad)));
  padding: 0.4rem 0.4rem 0.4rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 18px 40px -24px var(--shadow);
  translate: -50% 0;
  transition: border-color 0.2s ease;
}

.chat:focus-within { border-color: var(--accent); }

.chat__status {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.5;
}

.chat__status.is-online {
  background: var(--ok);
  opacity: 1;
}

.chat__status.is-locked {
  background: oklch(0.8 0.14 80);
  opacity: 1;
}

.chat input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  outline: none;
}

.chat input::placeholder { color: var(--muted); }

.chat button {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 50%;
  background: var(--fg);
  color: var(--bg);
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s ease;
}

.chat button:hover { background: var(--accent); }
.chat button:active { transform: scale(0.92); }
.chat button:disabled { opacity: 0.4; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .bubble { animation: none; }
  .bubble.is-thinking::after { animation: none; content: "..."; }
}
