:root {
  --bg: #f8f4ec;
  --bg-soft: #fbf8f2;
  --rose: #c9a0a0;
  --rose-soft: #e6c9c9;
  --rose-deep: #a87d7d;
  --ink: #3d3a36;
  --ink-soft: #6f6a62;
  --ink-faint: #a8a39a;
  --line: #ece5d6;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(61, 58, 54, 0.06);
  --shadow-md: 0 6px 18px rgba(61, 58, 54, 0.08);
  --shadow-lg: 0 12px 32px rgba(61, 58, 54, 0.12);
  --radius-bubble: 20px;
  --radius-card: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

/* ===== layout ===== */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: var(--bg);
  position: relative;
}

@media (min-width: 520px) {
  .app {
    min-height: 100dvh;
    box-shadow: var(--shadow-lg);
    background: var(--bg);
  }
}

/* ===== topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(248, 244, 236, 0.92);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  padding: 14px 18px;
  padding-top: calc(14px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), var(--rose-soft));
  color: var(--white);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(201, 160, 160, 0.4);
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-family: "Gowun Batang", serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: var(--ink-soft);
}

.reset-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.reset-btn:hover {
  background: var(--white);
  color: var(--rose-deep);
  border-color: var(--rose-soft);
}

.reset-btn:active {
  transform: scale(0.97);
}

/* ===== chat area ===== */
.chat {
  padding: 20px 16px 8px;
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: flex;
  width: 100%;
  animation: fadeUp 0.32s ease-out both;
}

.row.me {
  justify-content: flex-end;
}

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

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: var(--radius-bubble);
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.bubble.bot {
  background: var(--white);
  color: var(--ink);
  border-bottom-left-radius: 6px;
  border: 1px solid #f1ead9;
}

.bubble.me {
  background: var(--rose);
  color: var(--white);
  border-bottom-right-radius: 6px;
}

.bubble .time {
  display: block;
  font-size: 10.5px;
  margin-top: 5px;
  opacity: 0.7;
  font-weight: 400;
}

.bubble.me .time {
  color: rgba(255, 255, 255, 0.85);
  text-align: right;
}

.bubble.bot .time {
  color: var(--ink-faint);
}

.intro {
  text-align: center;
  padding: 24px 8px 12px;
  color: var(--ink-soft);
  font-size: 13px;
}

.intro-emoji {
  font-family: "Gowun Batang", serif;
  font-size: 28px;
  color: var(--rose-deep);
  margin-bottom: 6px;
  letter-spacing: 4px;
}

/* ===== typing indicator ===== */
.typing {
  margin-top: 4px;
  display: flex;
  justify-content: flex-start;
  animation: fadeUp 0.25s ease-out both;
}

.typing-bubble {
  padding: 14px 16px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rose);
  display: inline-block;
  opacity: 0.35;
  animation: dotBlink 1.2s infinite ease-in-out;
}

.typing .dot:nth-child(2) {
  animation-delay: 0.18s;
}

.typing .dot:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes dotBlink {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ===== suggestions ===== */
.suggestions {
  display: flex;
  gap: 8px;
  padding: 8px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.suggestions::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.chip:hover {
  background: var(--rose-soft);
  color: var(--ink);
  border-color: var(--rose-soft);
}

.chip:active {
  transform: scale(0.96);
}

/* ===== composer ===== */
.composer {
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.composer-inner {
  padding: 12px 14px 10px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.input {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 22px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 120px;
  min-height: 44px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input::placeholder {
  color: var(--ink-faint);
}

.input:focus {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(201, 160, 160, 0.18);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--rose);
  color: var(--white);
  border: none;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(201, 160, 160, 0.45);
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--rose-deep);
}

.send-btn:active {
  transform: scale(0.94);
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--rose);
}

.footer-note {
  margin: 0;
  padding: 0 18px 10px;
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
}

/* ===== modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(61, 58, 54, 0.45);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
  animation: modalFade 0.18s ease-out;
}

@keyframes modalFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius-card);
  padding: 22px 22px 18px;
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.22s ease-out;
}

@keyframes modalPop {
  from {
    transform: translateY(8px) scale(0.97);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-card h2 {
  margin: 0 0 8px;
  font-family: "Gowun Batang", serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.modal-card p {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-ghost,
.btn-danger {
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: var(--bg-soft);
}

.btn-danger {
  background: var(--rose);
  color: var(--white);
}

.btn-danger:hover {
  background: var(--rose-deep);
}

.btn-ghost:active,
.btn-danger:active {
  transform: scale(0.97);
}

/* ===== toast ===== */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(61, 58, 54, 0.92);
  color: var(--white);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
