:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --surface: #ffffff;
  --bubble-ai: #f4f4f5;
  --text: #09090b;
  --text-dim: #71717a;
  --text-faint: #a1a1aa;
  --accent: #18181b;          /* near-black */
  --accent-hover: #000000;
  --user-bubble: #18181b;
  --user-text: #fafafa;
  --line: #ececec;
  --line-strong: #e4e4e7;
  --ring: rgba(0, 0, 0, 0.10);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --max-w: 720px;
  --sidebar-w: 280px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Nanum Gothic", "NanumGothic", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #fff; }

/* 얇은 스크롤바 */
.order-list, .messages { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.order-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 8px; }
.order-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* ── 전체 레이아웃: 좌(사이드바) + 우(채팅) ── */
.layout {
  display: flex;
  height: 100dvh;
}

/* ── 좌측: 주문(이전 대화) 목록 ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-subtle);
  border-right: 1px solid var(--line);
}
.sidebar-head {
  height: 60px;
  padding: 0 18px;
  display: flex;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { color: var(--accent); font-size: 1.25rem; line-height: 1; }
.brand-name { font-weight: 700; font-size: 1.08rem; letter-spacing: -0.02em; }
.brand-accent { color: var(--accent); }

.new-order {
  margin: 6px 14px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.1s ease, box-shadow 0.16s ease;
}
.new-order:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.new-order:active { transform: scale(0.98); }

.order-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  transition: background 0.14s ease;
}
.order-item:hover { background: rgba(0, 0, 0, 0.045); }
.order-item.active { background: rgba(0, 0, 0, 0.075); }
.order-info { min-width: 0; flex: 1; overflow: hidden; }
.order-title {
  display: block;          /* inline 이면 말줄임이 안 먹음 */
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.14s ease;
}
.order-item:hover .order-title { color: var(--text); }
.order-item.active .order-title { color: var(--text); font-weight: 600; }

/* ── 상태 알약(공통: 미니멀 무채색 + 컬러 점) ── */
.status-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  white-space: nowrap;
  background: #f1f1f2;
  color: #52525b;
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-pill[data-status="talking"]   { color: #3f3f46; }
.status-pill[data-status="talking"]::before { background: #18181b; animation: live 1.5s ease-in-out infinite; }
.status-pill[data-status="paid"]::before     { background: #71717a; }
.status-pill[data-status="shipping"]::before { background: #a1a1aa; }
.status-pill[data-status="delivered"]::before { background: #18181b; }
@keyframes live { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

/* 모바일 사이드바 오버레이 */
.sidebar-overlay { display: none; }

/* ── 우측: 채팅 ── */
.app {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* 헤더 */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.chat-header-inner {
  /* 풀폭 — 로그인 버튼을 실제 우측 상단 코너에 배치 */
  height: 60px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.header-order {
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-spacer { flex: 1; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.15rem;
  color: var(--text);
  transition: background 0.14s ease;
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.05); }
.sidebar-toggle { display: none; }

/* 우측 상단 로그인 버튼 */
.login-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 15px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.login-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.login-btn:active { transform: scale(0.97); }
.login-btn svg { display: block; }

/* 우측 상단 개발비용 버튼 (보조) */
.cost-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.cost-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--text); }
.cost-btn:active { transform: scale(0.97); }

/* 대화 목록(메시지) */
.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.messages-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 30px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 84%;
}
.message.assistant { align-self: flex-start; }
.message.user { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  background: var(--accent);
}
/* 내 메시지 아바타는 군더더기 — 숨김 (깔끔) */
.message.user .avatar { display: none; }

.bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  line-height: 1.62;
  font-size: 0.96rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.message.assistant .bubble {
  background: var(--bubble-ai);
  color: var(--text);
  border-bottom-left-radius: 5px;
}
.message.user .bubble {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 5px;
}

/* 타이핑 표시 */
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: blink 1.3s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

/* ── 클릭형 선택지 ── */
.choices {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-left: 40px; /* 아바타(30) + gap(10) */
  max-width: 88%;
  animation: choices-in 0.25s ease both;
}
@keyframes choices-in { from { opacity: 0; transform: translateY(6px); } }
.choice-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 15px 8px 13px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.choice-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.choice-btn:active { transform: scale(0.96); }

/* 업종 추천 분위기 강조 */
.choice-btn.recommended {
  border-color: var(--accent);
  font-weight: 600;
}
.rec-badge {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 1px;
  transition: background 0.15s ease, color 0.15s ease;
}
.choice-btn:hover .rec-badge { background: #fff; color: var(--accent); }

/* 색감 스와치 (배경색 원 + 텍스트색 점) */
.swatch {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.14);
  display: grid;
  place-items: center;
}
.swatch-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* 마지막 직접 입력칸 */
.choice-input-row {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 3px;
}
.choice-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.choice-input::placeholder { color: var(--text-faint); }
.choice-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}
.choice-input-btn {
  flex-shrink: 0;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 17px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.choice-input-btn:hover { background: var(--accent-hover); }
.choice-input-btn:active { transform: scale(0.96); }

/* ── 기본입력 폼 카드 ── */
.form-card {
  align-self: stretch;
  max-width: 100%;
  margin-left: 40px; /* AI 메시지와 정렬 */
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: choices-in 0.25s ease both;
}
.form-card.submitted { opacity: 0.55; }

.form-section { display: flex; flex-direction: column; gap: 9px; }
.form-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.form-section-hint {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-faint);
  margin-left: 4px;
}

.form-row { display: flex; align-items: center; gap: 10px; }
.form-check,
.form-row-label {
  flex-shrink: 0;
  width: 136px;            /* 라벨이 줄바꿈되지 않도록 (예: "이메일·연락처 필수") */
  font-size: 0.88rem;
  color: var(--text);
  white-space: nowrap;
}
@media (max-width: 560px) {
  .form-row { flex-direction: column; align-items: stretch; gap: 4px; }
  .form-check, .form-row-label { width: auto; justify-content: flex-start; }
}
.form-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.form-check.static { cursor: default; justify-content: flex-start; gap: 8px; }
.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.contact-icon { width: 18px; text-align: center; }
.req {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.64rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 1px 6px;
}

.form-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.form-input::placeholder { color: var(--text-faint); }
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.form-input:disabled { background: var(--bg-subtle); color: var(--text-faint); cursor: not-allowed; }
.form-input.error { border-color: #18181b; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12); }

/* 로고 세그먼트 */
.seg {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: var(--bg-subtle);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.seg-btn {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.seg-btn.active { background: var(--accent); color: #fff; }

.form-submit {
  align-self: stretch;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.form-submit:hover:not(:disabled) { background: var(--accent-hover); }
.form-submit:active:not(:disabled) { transform: scale(0.99); }
.form-submit:disabled { cursor: default; }

@media (max-width: 540px) {
  .form-card { margin-left: 0; }
  .form-row { flex-wrap: wrap; }
  .form-check, .form-row-label { width: auto; }
  .form-check.static { width: 100%; }
  .form-input { flex-basis: 100%; }
}

/* ── 입력창(텍스트박스) ── */
.composer {
  background: var(--bg);
  padding: 10px 18px calc(14px + env(safe-area-inset-bottom));
}
.composer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 7px 7px 7px 18px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.composer-inner:focus-within {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}
.composer-inner.disabled { opacity: 0.55; }
.composer-inner.disabled:focus-within {
  background: var(--bg-subtle);
  border-color: var(--line-strong);
  box-shadow: none;
}
.composer-input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 0.96rem;
  line-height: 1.5;
  color: var(--text);
  max-height: 160px;
  padding: 7px 0;
}
.composer-input::placeholder { color: var(--text-faint); }

.send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.32; cursor: not-allowed; }

.composer-hint {
  max-width: var(--max-w);
  margin: 9px auto 0;
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-faint);
}

/* ── 로그인 모달 (중앙 세로형 카드) ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(9, 9, 11, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: overlay-in 0.2s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes overlay-in { from { opacity: 0; } }

.login-card {
  position: relative;
  width: 100%;
  max-width: 380px;          /* 약간 세로형 카드 */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  padding: 44px 34px 26px;
  text-align: center;
  animation: card-in 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes card-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.modal-close:hover { background: rgba(0, 0, 0, 0.05); color: var(--text); }

.login-brand {
  font-size: 2.1rem;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 18px;
}
.login-title {
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.login-sub {
  margin-top: 9px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.google-btn {
  margin-top: 28px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.google-btn:hover { background: #f7f7f8; border-color: #d4d4d8; box-shadow: var(--shadow-sm); }
.google-btn:active { transform: scale(0.99); }
.google-icon { display: block; }

.login-terms {
  margin-top: 22px;
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--text-faint);
}
.login-terms a { color: var(--text-dim); text-decoration: underline; text-underline-offset: 2px; }
.login-terms a:hover { color: var(--text); }

/* ── 반응형: 사이드바 오프캔버스 ── */
@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.22);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.26s ease;
  }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
  .sidebar-toggle { display: grid; }
}

@media (max-width: 540px) {
  .message { max-width: 90%; }
  .composer-hint { display: none; }
}
