:root {
  --bg: #f8f6fb;
  --surface: #ffffff;
  --surface-soft: #f1edf7;
  --text: #2f2937;
  --muted: #746c7f;
  --primary: #76609a;
  --primary-strong: #624d86;
  --primary-soft: #ebe5f4;
  --border: #e5dfeb;
  --danger-soft: #fff1f1;
  --shadow: 0 14px 40px rgba(61, 47, 78, 0.08);
  --radius: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
    "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button, textarea { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: 100%;
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  background:
    radial-gradient(circle at 100% 0%, rgba(161, 135, 197, 0.12), transparent 28%),
    var(--bg);
  position: relative;
}

.screen {
  display: none;
  min-height: 100dvh;
  padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}

.screen.active { display: flex; flex-direction: column; }

.hero {
  padding: 34px 4px 28px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 21px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.eyebrow.small {
  font-size: 12px;
  margin-bottom: 3px;
}

h1, h2, p { word-break: keep-all; }

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.14;
  letter-spacing: -0.05em;
}

.hero-copy {
  margin: 18px 0 0;
  color: #534b5c;
  font-size: 18px;
  line-height: 1.62;
  letter-spacing: -0.025em;
}

.start-card,
.feedback-card {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(229,223,235,0.9);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.start-card h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.035em;
}

.subtle {
  margin: 8px 0 18px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 20px;
}

.chip {
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: white;
  color: #514958;
  cursor: pointer;
}

.chip-wide { grid-column: span 3; }

.chip.selected {
  border-color: var(--primary);
  color: var(--primary-strong);
  background: var(--primary-soft);
  font-weight: 700;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 54px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 750;
  border: 0;
}

.primary-button {
  background: var(--primary);
  color: white;
}

.primary-button:active,
.send-button:active { transform: translateY(1px); }

.secondary-button {
  margin-top: 9px;
  background: var(--surface-soft);
  color: var(--primary-strong);
}

.privacy-note {
  margin: 18px 3px 0;
  padding: 14px 15px;
  border-radius: 16px;
  background: rgba(255,255,255,0.55);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.privacy-note strong {
  display: block;
  color: #5e5667;
  margin-bottom: 3px;
}

.privacy-note p { margin: 0; }

/* Chat */
.chat-screen {
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.chat-header {
  padding: max(18px, env(safe-area-inset-top)) 20px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(248,246,251,0.95);
  backdrop-filter: blur(12px);
  z-index: 2;
}

.chat-header h1 {
  font-size: 21px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 3px 9px 10px;
  cursor: pointer;
  font-size: 13px;
}

.topic-line {
  margin: 12px 20px 0;
  width: fit-content;
  max-width: calc(100% - 40px);
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 650;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 14px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.message-row {
  display: flex;
  margin-bottom: 14px;
}

.message-row.user { justify-content: flex-end; }

.message {
  max-width: 86%;
  padding: 13px 15px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.018em;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.assistant {
  background: white;
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 5px 16px rgba(67,51,84,0.04);
}

.message.user {
  color: white;
  background: var(--primary);
  border-bottom-right-radius: 6px;
}

.mode-wrap {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 7px 20px 10px;
  scrollbar-width: none;
}

.mode-wrap::-webkit-scrollbar { display: none; }

.mode-button {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  padding: 0 13px;
  color: #625a6a;
  cursor: pointer;
  font-size: 12.5px;
}

.mode-button.active {
  background: var(--primary-soft);
  border-color: #cfc1df;
  color: var(--primary-strong);
  font-weight: 700;
}

.typing {
  padding: 0 20px 8px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
}

.typing[hidden] { display: none; }

.typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #a99cb7;
  animation: blink 1.1s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.12s; }
.typing span:nth-child(3) { animation-delay: 0.24s; }

.typing em {
  font-style: normal;
  margin-left: 4px;
  font-size: 11.5px;
}

@keyframes blink {
  0%, 70%, 100% { opacity: .25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.96);
}

.composer textarea {
  width: 100%;
  min-height: 46px;
  max-height: 126px;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 12px 14px;
  outline: none;
  color: var(--text);
  background: #fbfafc;
  line-height: 1.45;
}

.composer textarea:focus {
  border-color: #b9a8cd;
  box-shadow: 0 0 0 3px rgba(118,96,154,0.08);
}

.send-button {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border: 0;
  border-radius: 16px;
  color: white;
  background: var(--primary);
  cursor: pointer;
  font-size: 22px;
  font-weight: 800;
}

.send-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.microcopy {
  margin: 0;
  padding: 0 18px calc(8px + env(safe-area-inset-bottom));
  text-align: center;
  color: #948b9d;
  background: white;
  font-size: 9.5px;
  line-height: 1.35;
}

/* Feedback */
.feedback-head {
  padding: 34px 3px 24px;
}

.feedback-head h1 {
  font-size: 28px;
}

.feedback-head > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
}

fieldset {
  margin: 0 0 26px;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  margin-bottom: 12px;
  font-weight: 750;
  line-height: 1.45;
  letter-spacing: -0.025em;
}

.option-stack,
.reason-grid {
  display: grid;
  gap: 8px;
}

.option-stack button,
.reason-grid button {
  min-height: 45px;
  text-align: left;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
  color: #514958;
  cursor: pointer;
}

.option-stack button.selected,
.reason-grid button.selected {
  background: var(--primary-soft);
  border-color: #c8b8da;
  color: var(--primary-strong);
  font-weight: 700;
}

.feedback-actions { margin-top: 6px; }

.copy-status {
  min-height: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0 0;
}

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

@media (min-width: 600px) {
  body {
    padding: 24px 0;
  }
  .app-shell {
    min-height: calc(100dvh - 48px);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 18px 60px rgba(57, 43, 73, 0.12);
  }
  .screen {
    min-height: calc(100dvh - 48px);
  }
  .chat-screen {
    height: calc(100dvh - 48px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
