:root {
  color-scheme: light;
  --paper: #f4f0e8;
  --paper-deep: #e8e0d3;
  --ink: #22201d;
  --muted: #777069;
  --line: rgba(34, 32, 29, 0.12);
  --bubble: #ffffff;
  --accent: #ff5c35;
  --accent-dark: #d93f1d;
  --user: #24211e;
  --shadow: 0 24px 70px rgba(45, 37, 28, 0.16);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 92, 53, 0.14), transparent 28rem),
    radial-gradient(circle at 86% 88%, rgba(49, 116, 255, 0.1), transparent 25rem),
    var(--paper);
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
}

.phone {
  width: min(100%, 430px);
  height: min(820px, calc(100vh - 56px));
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  background: #faf8f4;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 34px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 22px 14px;
}

.identity, .name-row { display: flex; align-items: center; }
.identity { gap: 12px; }

.avatar {
  width: 96px;
  height: 96px;
  flex: 0 0 96px;
  display: grid;
  place-items: center;
}
.cat-rig { display: block; width: 100%; height: 100%; overflow: visible; }
.cat-tail {
  transform-box: view-box;
  transform-origin: 89.55% 69.06%;
  animation: cat-tail-idle 7s linear infinite;
}
/* A deliberate lift, a brief hold, then a quick weighted landing and long rest. */
@keyframes cat-tail-idle {
  0%, 5% { transform: rotate(0deg); animation-timing-function: cubic-bezier(.3, 0, .3, 1); }
  23% { transform: rotate(25deg); }
  28% { transform: rotate(25deg); animation-timing-function: cubic-bezier(.65, 0, 1, 1); }
  32%, 100% { transform: rotate(0deg); }
}
.identity { min-width: 0; }
.icon-button { flex-shrink: 0; }
.message.system .bubble {
  max-width: 100%; background: #eeeae2; color: #454039;
  border: 1px solid var(--line); border-radius: 12px; box-shadow: none; font-size: 12px;
}
.message.system strong { font-size: 12px; }
button:disabled { opacity: 0.5; cursor: wait; }

.name-row { gap: 8px; }
h1 { margin: 0; font-size: 18px; letter-spacing: -0.04em; }
.identity p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #43aa68;
  box-shadow: 0 0 0 3px rgba(67, 170, 104, 0.14);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { background: rgba(34, 32, 29, 0.06); }
.icon-button svg, .send-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat {
  min-height: 0;
  overflow-y: auto;
  padding: 24px 20px 14px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  margin: 0 0 12px;
  animation: bubble-in 240ms ease-out both;
}
.message.user { justify-content: flex-end; }

.bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 18px 18px 18px 5px;
  background: var(--bubble);
  box-shadow: 0 5px 16px rgba(34, 32, 29, 0.06);
  font-size: 15px;
  line-height: 1.48;
  letter-spacing: -0.025em;
  white-space: pre-wrap;
}
.user .bubble {
  color: white;
  background: var(--user);
  border-radius: 18px 18px 5px 18px;
}

.typing .bubble { display: flex; gap: 5px; padding: 15px 17px; }
.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #aaa29a;
  animation: blink 900ms infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 120ms; }
.typing i:nth-child(3) { animation-delay: 240ms; }

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  padding: 0 16px;
}

.composer input {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  outline: none;
  background: white;
  color: var(--ink);
}
.composer input:focus { border-color: rgba(255, 92, 53, 0.65); box-shadow: 0 0 0 3px rgba(255, 92, 53, 0.1); }

.send-button {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 17px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 92, 53, 0.24);
}
.send-button:active { transform: translateY(1px); }

.prototype-note {
  margin: 8px 0 0;
  padding: 0 16px 14px;
  color: #99918a;
  text-align: center;
  font-size: 10px;
}

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

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes blink {
  0%, 60%, 100% { opacity: 0.32; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 520px) {
  .app-shell { padding: 0; }
  .phone {
    width: 100%;
    height: 100dvh;
    min-height: 540px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .topbar { padding-top: max(18px, env(safe-area-inset-top)); }
  .prototype-note { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; }
  .cat-tail { animation: none !important; transform: none !important; }
}

@media (max-width: 380px) {
  .topbar { padding-left: 14px; padding-right: 14px; }
  .identity { gap: 8px; }
  .avatar { width: 76px; height: 76px; flex-basis: 76px; }
  .identity p { font-size: 11px; }
}
