/* 풀하우스 크루 상담실 — 홈페이지와 같은 브랜드 토큰을 씁니다 */

:root {
  --bg: #0d0d0d;
  --surface: #17171a;
  --surface-2: #1f1f23;
  --line: rgba(249, 252, 252, 0.1);
  --line-2: rgba(249, 252, 252, 0.18);
  --fg: #f9fcfc;
  --fg-2: rgba(249, 252, 252, 0.72);
  --fg-3: rgba(249, 252, 252, 0.5);
  --accent: #ff4e40;
  --accent-2: #ff7566;
  --accent-soft: rgba(255, 78, 64, 0.14);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --f: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  /* 아이폰 노치·홈바 영역 */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/**
 * hidden 속성이 항상 이기게 합니다.
 *
 * 이 앱은 화면 전환을 el.hidden 으로 합니다. 그런데 .gate/.app/.chips 처럼
 * display 를 직접 지정한 규칙이 있으면, 저작자 스타일이 브라우저 기본
 * [hidden]{display:none} 을 이겨버려서 숨겨야 할 화면이 계속 보입니다.
 * (로그인 후에도 로그인 화면이 남아 있는 증상이 바로 이것이었습니다.)
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

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

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

/* ───────── 로그인 ───────── */

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
}

.gate-box { width: 100%; max-width: 360px; text-align: center; }
.gate-mark { display: block; margin: 0 auto 20px; border-radius: 12px; }

.gate h1 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.gate-sub { margin: 0 0 28px; color: var(--fg-2); font-size: 0.9375rem; line-height: 1.6; }

#gate-form { display: grid; gap: 10px; }

#code {
  width: 100%;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  text-align: center;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: border-color 0.2s var(--ease);
}
#code::placeholder { color: var(--fg-3); letter-spacing: 0.08em; font-weight: 400; }
#code:focus { outline: none; border-color: var(--accent); }

#gate-submit {
  padding: 15px 16px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--r);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}
#gate-submit:hover:not(:disabled) { background: var(--accent-2); }
#gate-submit:disabled { opacity: 0.5; cursor: default; }

.gate-error {
  margin: 4px 0 0;
  color: var(--accent-2);
  font-size: 0.875rem;
  line-height: 1.5;
}

.gate-help { margin: 24px 0 0; color: var(--fg-3); font-size: 0.8125rem; }

/* ───────── 레이아웃 ───────── */

.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  max-width: 720px;
  margin: 0 auto;
}

/* ───────── 헤더 ───────── */

.hdr {
  padding: calc(12px + var(--safe-t)) 16px 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.hdr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
}

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

.who-name {
  font-weight: 700;
  font-size: 0.9375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who-tag {
  flex: none;
  padding: 3px 8px;
  background: var(--accent-soft);
  color: var(--accent-2);
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.ghost {
  flex: none;
  padding: 7px 12px;
  background: transparent;
  color: var(--fg-3);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.ghost:hover { color: var(--fg); border-color: var(--fg-3); }

.tabs { display: flex; gap: 4px; margin-top: 10px; }

.tab {
  position: relative;
  padding: 10px 16px 12px;
  background: none;
  border: 0;
  color: var(--fg-3);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}
.tab::after {
  content: '';
  position: absolute;
  left: 8px; right: 8px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.2s var(--ease);
}
.tab.is-on { color: var(--fg); }
.tab.is-on::after { background: var(--accent); }

/* ───────── 대화 ───────── */

.thread {
  overflow-y: auto;
  padding: 20px 16px 8px;
  -webkit-overflow-scrolling: touch;
}

.msg { margin: 0 0 18px; }
.msg:last-child { margin-bottom: 0; }

.msg.me {
  margin-left: auto;
  max-width: 85%;
  padding: 11px 15px;
  background: var(--surface-2);
  border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg);
  width: fit-content;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.msg.ai { line-height: 1.72; color: var(--fg); overflow-wrap: anywhere; }
.msg.ai > :first-child { margin-top: 0; }
.msg.ai > :last-child { margin-bottom: 0; }
.msg.ai p { margin: 0 0 0.85em; }
.msg.ai h3 { margin: 1.4em 0 0.5em; font-size: 1rem; font-weight: 700; }
.msg.ai ul, .msg.ai ol { margin: 0 0 0.9em; padding-left: 1.35em; }
.msg.ai li { margin-bottom: 0.4em; }
.msg.ai li::marker { color: var(--fg-3); }
.msg.ai strong { font-weight: 700; }
.msg.ai code {
  padding: 1px 5px;
  background: var(--surface-2);
  border-radius: 5px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.msg.ai a { color: var(--accent-2); }

.msg.err {
  padding: 11px 15px;
  background: var(--accent-soft);
  border-radius: var(--r);
  color: var(--accent-2);
  font-size: 0.9375rem;
  line-height: 1.6;
}

/* 생각 중 표시 — 답변 본문이 시작되면 사라집니다 */
.status {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  color: var(--fg-3);
  font-size: 0.875rem;
  line-height: 1.6;
}
.status .dot {
  flex: none;
  width: 7px; height: 7px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s var(--ease) infinite;
}
.status .txt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .status .dot { animation: none; opacity: 0.8; }
}

/* 빈 화면 안내 */
.intro { padding: 8px 0 4px; color: var(--fg-2); }
.intro h2 { margin: 0 0 8px; font-size: 1.1875rem; font-weight: 700; color: var(--fg); letter-spacing: -0.01em; }
.intro p { margin: 0; font-size: 0.9375rem; line-height: 1.65; }

/* ───────── 추천 질문 ───────── */

.chips {
  display: flex;
  gap: 8px;
  padding: 10px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg-2);
  font-size: 0.875rem;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--fg); }

/* ───────── 입력 ───────── */

.composer {
  padding: 10px 16px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.notice {
  margin: 0 0 10px;
  padding: 9px 12px;
  background: var(--accent-soft);
  border-radius: var(--r-sm);
  color: var(--accent-2);
  font-size: 0.8125rem;
  line-height: 1.5;
}

#ask-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  transition: border-color 0.2s var(--ease);
}
#ask-form:focus-within { border-color: var(--accent); }

#ask {
  flex: 1;
  min-width: 0;
  max-height: 132px;
  padding: 9px 0;
  background: none;
  border: 0;
  resize: none;
  line-height: 1.55;
  font-size: 1rem; /* iOS 확대 방지: 16px 미만이면 포커스 시 확대됩니다 */
}
#ask:focus { outline: none; }
#ask::placeholder { color: var(--fg-3); }

#send {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s var(--ease), opacity 0.2s var(--ease);
}
#send:hover:not(:disabled) { background: var(--accent-2); }
#send:disabled { opacity: 0.35; cursor: default; }

.disclaim {
  margin: 10px 2px 0;
  color: var(--fg-3);
  font-size: 0.75rem;
  line-height: 1.55;
  text-align: center;
}

.link {
  padding: 0;
  background: none;
  border: 0;
  color: var(--accent-2);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* 데스크톱에서는 여백을 조금 넉넉하게 */
@media (min-width: 600px) {
  .hdr { padding-left: 24px; padding-right: 24px; }
  .thread { padding-left: 24px; padding-right: 24px; }
  .chips { padding-left: 24px; padding-right: 24px; }
  .composer { padding-left: 24px; padding-right: 24px; }
}
