* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text-primary);
  height: 100dvh;
  /* 防止页面切换时白屏闪烁 */
  opacity: 1;
}

/* ── Global Touch Feedback ─────────────────────── */
button, .drawer-action-btn, [role="button"] {
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--duration-fast) var(--easing-standard),
              opacity var(--duration-fast) var(--easing-standard);
}
button:active, .drawer-action-btn:active, [role="button"]:active {
  transform: scale(0.97);
  opacity: 0.85;
}

/* ── Login Screen ──────────────────────────────────────── */

#login-screen,
#scan-screen,
#invite-invalid-screen,
#nickname-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px;
  background: var(--color-bg);
}

/* 按钮对齐 LINE 登录页的同一位置（约 55% 高度） */
.login-spacer {
  flex: 0 0 28vh;
}

.login-card {
  max-width: 320px;
  width: 100%;
  padding: var(--space-8) var(--space-6);
  text-align: center;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

.login-brand {
  margin-bottom: 48px;
}

.login-divider {
  width: 32px;
  height: 1px;
  background: var(--color-border);
  margin: 0 auto 14px;
}

.login-brand .login-divider:last-child {
  margin: 14px auto 0;
}

.login-logo-img {
  width: 64px;
  height: auto;
  margin: 0 auto 12px;
  display: block;
}

.login-logo {
  font-family: var(--font-family-serif);
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: var(--font-size-sm);
  letter-spacing: 0.04em;
  color: var(--ink-4);
}

.login-tagline {
  font-size: 13px;
  color: var(--color-text-tertiary);
  margin-bottom: 32px;
}

.line-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  min-height: var(--touch-min);
  background: var(--color-success);
  color: var(--color-text-inverse);
  font-size: var(--font-size-md);
  font-weight: 600;
  border-radius: var(--radius-lg);
  text-decoration: none;
  cursor: pointer;
  transition: background var(--duration-fast) var(--easing-standard),
              transform var(--duration-fast) var(--easing-standard),
              opacity var(--duration-fast) var(--easing-standard);
}

.line-login-btn:hover {
  background: #05b34c;
}

.line-login-btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.line-login-btn:focus-visible {
  outline: 2px solid var(--color-success);
  outline-offset: 2px;
}

#login-error {
  color: var(--color-error);
  font-size: 13px;
  margin-top: 16px;
  display: none;
}


#app {
  max-width: 680px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  #app { max-width: 720px; }
}

/* Drawer styles → drawer.css */

/* ── Header ────────────────────────────────────── */

header {
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(245, 245, 240, 0.85);  /* match --color-bg #f5f5f0 */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

@media (prefers-color-scheme: dark) {
  header {
    background: rgba(26, 22, 18, 0.85);
  }
}

.header-icon-btn {
  width: var(--touch-min);
  height: var(--touch-min);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--color-brand-dark);
  cursor: pointer;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}

.header-icon-btn:hover {
  background: var(--color-surface-hover);
}

header h1 {
  font-size: var(--font-size-lg);
  font-weight: 500;
  color: var(--color-brand-dark);
  flex: 1;
  text-align: center;
  font-family: var(--font-family-serif);
  letter-spacing: 1px;
}

/* .scroll-region-flex applied in HTML — iOS Safari touch scroll safe */
#messages {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Message row: avatar + bubble */
.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 88%;
  animation: messageIn var(--duration-normal) var(--easing-decelerate) both;
}

.msg-row.assistant { align-self: flex-start; }
.msg-row.user { align-self: flex-end; }

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  margin-top: 2px;
  background: var(--color-surface-secondary);
  color: var(--color-brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family-serif);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

/* Bubbles — LINE-style asymmetric corners */
.msg {
  line-height: 1.8;
  white-space: pre-wrap;
  font-size: 15px;
  padding: 10px 14px;
  flex: 1;
  min-width: 0;
}

.msg.assistant {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-xl) var(--radius-xl) var(--radius-xl);  /* 13 21 21 21 — tail:main = φ⁻¹ */
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.msg.user {
  background: var(--color-bubble-user);
  color: var(--color-bubble-user-text);
  border-radius: var(--radius-xl) var(--radius-lg) var(--radius-xl) var(--radius-xl);  /* 21 13 21 21 — tail:main = φ⁻¹ */
}

.msg.user strong { color: var(--color-surface-secondary); }
.msg strong { color: var(--color-brand-dark); }

/* ── Markdown prose in chat bubbles ──────────── */
.msg p { margin: 0 0 0.5em; }
.msg p:last-child { margin-bottom: 0; }

.msg ul, .msg ol {
  margin: 0.4em 0;
  padding-left: 1.4em;
}
.msg li { margin: 0.2em 0; }

.msg table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: var(--font-size-sm);
}
.msg th, .msg td {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  text-align: left;
}
.msg th {
  background: var(--color-surface-secondary);
  font-weight: var(--font-weight-semibold);
}

.msg code {
  background: var(--color-surface-secondary);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}
.msg pre {
  background: var(--color-surface-secondary);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 0.5em 0;
}
.msg pre code {
  background: none;
  padding: 0;
}

.msg blockquote {
  margin: 0.5em 0;
  padding-left: var(--space-3);
  border-left: 3px solid var(--color-brand-light);
  color: var(--color-text-secondary);
}

.msg hr {
  border: none;
  border-top: 1px solid var(--color-border-light);
  margin: 0.6em 0;
}

/*
 * ── Chat Input Bar ──────────────────────────────────
 * Apple HIG compliance notes:
 *
 * [HIG Buttons] "A button needs a hit region of at least 44x44 pt"
 *   → All interactive elements maintain 44×44pt tap targets.
 *     Visual size can be smaller; padding extends the hit region.
 *
 * [HIG Layout] Standard sibling spacing = 8pt
 *   → gap: 8px between form children.
 *
 * [HIG Layout] View-to-superview-edge spacing = 16pt (relaxed) / 20pt (standard)
 *   → padding: 6px 8px (compact bar, safe-area handles bottom).
 *
 * [iMessage reference] Input bar visual height ~36pt, send button ~30pt circle
 *   → Input height = 36px (8px padding × 2 + 16px font + 2px border + 2px rounding).
 *   → Send button = 30px filled circle inside 44×44pt tap target.
 *   → Button vertically centered (centerY alignment, not pinned).
 *
 * [HIG Accessibility / WCAG 2.5.5] Touch target ≥ 44×44 CSS px
 *   → All buttons use min 44×44 tap area even when visually smaller.
 *
 * [Apple optical alignment] Elements use optical centering, not mathematical.
 *   → Send arrow icon offset 1px right to compensate visual weight.
 */
#form {
  display: flex;
  gap: 8px;                                          /* HIG: standard sibling spacing = 8pt */
  padding: 6px 8px;
  padding-bottom: calc(6px + var(--safe-bottom));    /* env(safe-area-inset-bottom) via viewport-fit=cover */
  border-top: 1px solid var(--color-border);
  position: relative;
  align-items: center;                               /* HIG: centerY alignment for mixed-height siblings */
}

#input-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}

#input {
  width: 100%;
  box-sizing: border-box;
  height: 44px;                                      /* HIG tap target; iOS no-zoom requires ≥16px font */
  padding: 0 16px;
  border-radius: 22px;                               /* capsule: radius = height/2 */
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-size: 16px;                                   /* iOS Safari no-zoom threshold; overrides token */
  line-height: 44px;                                 /* vertically center text within fixed height */
  outline: none;
  transition: border-color var(--duration-fast) var(--easing-standard),
              box-shadow var(--duration-fast) var(--easing-standard);
}

#input:focus {
  border-color: var(--color-brand-light);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-brand) 12%, transparent);
}

#send-btn {
  /* Visual: 40px circle — matches 44px input height for balanced bar */
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: var(--color-brand);
  color: var(--color-text-inverse);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: -2px;                                      /* expand tap area: (44-40)/2 = 2px each side */
  outline-offset: 2px;
  position: relative;
  transition: background var(--duration-fast) var(--easing-standard);
  -webkit-tap-highlight-color: transparent;
}
#send-btn::before {
  /* Invisible tap-target expander — HIG 44×44pt minimum */
  content: '';
  position: absolute;
  inset: -2px;                                       /* 40 + 2×2 = 44px hit region */
}
#send-btn svg {
  width: 18px;
  height: 18px;
  transform: translateX(0.5px);                      /* optical offset: arrow visual weight compensation */
}
#send-btn:hover { background: var(--color-brand-dark); }

#form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Typing dots loading */
.typing-dots {
  display: flex;
  gap: 5px;
  padding: 4px 0;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--color-brand-light);
  border-radius: 50%;
  animation: dotBounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Error cards */
.err-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--status-cancelled-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.err-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.err-body { flex: 1; min-width: 0; }

.err-msg {
  font-size: 14px;
  color: var(--color-brand-dark);
  line-height: 1.5;
}

.err-code {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 10px;
  color: var(--color-brand-light);
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.err-retry {
  display: inline-block;
  font-size: 10px;
  color: var(--status-confirmed);
  background: var(--status-confirmed-bg);
  padding: 1px 6px;
  border-radius: 3px;
  margin-top: 4px;
  margin-left: 8px;
}

/* Card containers — reset msg bubble for cards */
.msg.assistant:has(.menu-card),
.msg.assistant:has(.invitation-card),
.msg.assistant:has(.menu-skeleton) {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  white-space: normal;
}

/* Cards & skeletons — mobile: full width, desktop: golden ratio */
.msg-row.assistant:has(.menu-card),
.msg-row.assistant:has(.menu-skeleton),
.msg-row.assistant:has(.invitation-card) {
  max-width: 100%;
  align-self: stretch;
}

@media (min-width: 480px) {
  .msg-row.assistant:has(.menu-card),
  .msg-row.assistant:has(.menu-skeleton),
  .msg-row.assistant:has(.invitation-card) {
    /* stretch 撑开 + max-width 限宽 = 精确控制 */
    /* 不能用 flex-start：骨架屏没有文字内容会缩到 0 */
    max-width: 61.8%;          /* φ⁻¹ of container */
  }
}

/* Menu card styles → menu-card.css */

@keyframes skPulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.65; }
}

/* Invitation Card — rendered images */
.invitation-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: menuCardIn 400ms ease both;
}

.inv-img-wrap {
  aspect-ratio: 2928 / 5338;
  border-radius: var(--card-radius);
  border: 1px solid var(--card-border-color);
  background: var(--color-surface-secondary);
  animation: skPulse 2.618s ease-in-out infinite;
  overflow: hidden;
}

.invitation-card.loaded .inv-img-wrap {
  background: none;
  animation: none;
}

.inv-img {
  width: 100%;
  display: block;
  opacity: 0;
  cursor: pointer;
}

/* 有wrapper → 等loaded再显示；无wrapper（旧格式）→ 直接显示 */
/* 2026-04-11 用户指令：骨架屏消失那一刻必须是邀请函可预览那一刻 — 删除 fade transition, 原子切换 */
.invitation-card.loaded .inv-img,
.invitation-card > .inv-img {
  opacity: 1;
}

/* Chat-friendly thumbnail: 旧消息+新消息统一限制尺寸（微信/飞书范式）
   !important 覆盖旧消息的 inline style="max-width:100%" */
.msg .inv-img,
.msg .invitation-card .inv-img {
  max-width: 200px !important;
  max-height: 260px !important;
  width: auto !important;
  opacity: 1 !important;
}
.msg .inv-img-wrap {
  aspect-ratio: auto !important;
  max-width: 200px !important;
  border: none !important;
  background: none !important;
  animation: none !important;
}
/* 邀请函图片间距 */
.msg .inv-img + .inv-img {
  margin-top: 8px;
}
/* 隐藏旧消息中空菜谱页图片（render endpoint 无菜品数据时渲染空模板） */
.msg .invitation-card + .invitation-card {
  display: none;
}

/* ── Lightbox ────────────────────────────────── */
#lightbox[open] {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--duration-normal) var(--easing-standard);
  border: none;
}

#lightbox.lb-hidden {
  opacity: 0;
  pointer-events: none;
}

.lb-close {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  right: 16px;
  z-index: 10;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
  opacity: 0.7;
}

.lb-close:hover { opacity: 1; }

.lb-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 32px;
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity var(--duration-fast) var(--easing-standard);
}

.lb-arrow:hover { opacity: 1; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }

/* Hide arrows on mobile — use swipe */
@media (max-width: 640px) {
  .lb-arrow { display: none; }
}

.lb-track {
  position: absolute;
  inset: 0;
  display: flex;
}

.lb-slide {
  width: 100vw;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 16px 80px;
}

.lb-slide img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
  -webkit-user-select: none;
  user-select: none;
}

.lb-bottom {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom, 16px), 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lb-dots {
  display: flex;
  gap: 8px;
}

.lb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  cursor: pointer;
  transition: background var(--duration-fast) var(--easing-standard);
}

.lb-dot.active {
  background: #fff;
}

.lb-dl-btn {
  padding: 8px 24px;
  min-height: var(--touch-min);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 0.05em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background var(--duration-fast) var(--easing-standard);
}

.lb-dl-btn:hover { background: rgba(255,255,255,0.22); }
.lb-dl-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Status Screens (pending / rejected) ───────── */

#pending-screen,
#rejected-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.status-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.status-msg {
  font-size: 16px;
  color: var(--color-brand-dark);
  font-weight: 600;
  margin-bottom: 4px;
}

.status-hint {
  font-size: 13px;
  color: var(--color-gold-muted);
  margin-bottom: 24px;
}

.status-btn {
  display: block;
  width: 100%;
  height: var(--touch-min);
  min-height: var(--touch-min);
  border-radius: 8px;
  border: 1px solid var(--color-gold-soft);
  background: var(--color-brand);
  color: var(--color-text-inverse);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background var(--duration-fast) var(--easing-standard);
}

.status-btn:hover { background: var(--color-brand-dark); }

.status-btn-secondary {
  background: var(--color-surface);
  color: var(--color-brand-dark);
}

.status-btn-secondary:hover {
  background: var(--color-surface-hover);
}

/* ── Mic Prepare Animation (reused by #plus-btn.preparing) ── */

@keyframes micPrepare {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ── Voice Recording ─────────────────────────────────── */

#mic-hint {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(61, 46, 30, 0.85);
  color: var(--color-text-inverse);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--easing-standard);
  margin-bottom: 6px;
}

#mic-hint.mic-hint-show {
  opacity: 1;
}

.rec-hidden { display: none !important; }

#rec-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--color-error);
  background: var(--color-surface);
  z-index: 2;
}

#rec-cancel, #rec-confirm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

#rec-cancel { background: var(--color-surface-secondary); color: var(--color-brand); }
#rec-cancel:hover { background: var(--color-surface-hover); }


#rec-confirm { background: var(--color-success); color: #fff; }
#rec-confirm:hover { background: var(--color-success); }

#rec-dot {
  color: var(--color-error);
  font-size: 10px;
  animation: recPulse 1s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

#rec-live {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

#rec-bars {
  display: flex;
  gap: 3px;
  height: 20px;
  align-items: center;
}

#rec-text {
  font-size: 13px;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  text-align: left;
  display: none;
}

#rec-live.has-text #rec-text { display: block; }
#rec-live.has-text #rec-bars { display: none; }

#rec-bars span {
  width: 3px;
  background: var(--color-success);
  border-radius: 2px;
  transition: height 0.1s;
  min-height: 3px;
}

#rec-timer {
  font-size: 13px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

#rec-processing {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  z-index: 2;
  color: var(--ink-4);
  font-size: 14px;
}

.rec-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-surface-secondary);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

#input.polishing {
  border-color: var(--color-brand-light);
  background: linear-gradient(90deg, var(--color-surface) 0%, var(--color-surface-secondary) 50%, var(--color-surface) 100%);
  background-size: 200% 100%;
  animation: polishShimmer 1.5s ease-in-out infinite;
}

@keyframes polishShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Screen Transitions ────────────────────────────────── */

.screen-fade-out {
  animation: screenFadeOut var(--duration-fast) var(--easing-standard) forwards;
}
.screen-fade-in {
  animation: screenFadeIn var(--duration-normal) var(--easing-decelerate) forwards;
}
@keyframes screenFadeOut {
  to { opacity: 0; }
}
@keyframes screenFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .screen-fade-out, .screen-fade-in { animation: none; }
}

/* ── Empty State ───────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  text-align: center;
  color: var(--ink-4);
}
.empty-state-logo {
  width: 56px;
  height: 56px;
  margin-bottom: var(--space-3);
}
.empty-state-brand {
  font-family: var(--font-family-serif);
  font-size: var(--font-size-lg);
  color: var(--color-brand);
  letter-spacing: 2px;
}
.empty-state-divider {
  width: 40px;
  height: 1px;
  background: var(--color-gold-muted);
  margin: var(--space-3) 0;
}
.empty-state-text {
  font-size: var(--font-size-sm);
  color: var(--ink-4);
}

/* ── Toast ────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  padding: 10px 24px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: #fff;
  animation: toastIn var(--duration-normal) var(--easing-decelerate);
  white-space: nowrap;
  pointer-events: auto;
}
.toast-success { background: var(--status-confirmed); }
.toast-error { background: var(--status-cancelled); }
.toast-info { background: rgba(0, 0, 0, 0.8); }
.toast-exit { animation: toastOut var(--duration-fast) var(--easing-standard) forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-10px); }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .toast-exit { animation: none; }
}

/* Nickname screen */
.nickname-label {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--ink-2);
}

#nickname-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

#nickname-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--ink-6);
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
  box-sizing: border-box;
}

#nickname-input:focus {
  outline: none;
  border-color: var(--color-success);
}

.nickname-submit-btn {
  text-decoration: none;
  text-align: center;
}

/* ── Dark Mode ────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1c1a17;
    --color-surface: #2c2824;
    --color-surface-secondary: #3a342d;
    --color-surface-hover: #443d35;
    --color-text-primary: #e8e0d4;
    --color-text-secondary: #9a8a6e;
    --color-text-tertiary: #6b5d4d;
    --color-text-inverse: #1c1a17;
    --color-border: #3a342d;
    --color-border-light: #2c2824;
    --color-bubble-ai: #3a342d;
    --color-bubble-user: #8b6f47;
    --color-bubble-user-text: #fff;
    --color-brand: #a08968;
    --color-brand-dark: #c9b99a;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.5);
  }
}

/* ── Accessibility ────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    animation-delay: 0ms !important;
  }
}

/* Global focus ring */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.4);
}

/* Press feedback */
button:active:not(:disabled),
a:active {
  transform: scale(0.97);
}

/* Touch optimization */
html {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Share panel ── */
.share-panel {
  margin: var(--space-3, 12px) 0;
  padding: var(--space-3, 12px);
  background: var(--bg-secondary, #f5f5f5);
  border-radius: var(--radius-2, 12px);
}
@media (prefers-color-scheme: dark) {
  .share-panel { background: var(--bg-secondary, #1e1e2e); }
}
.share-panel-title {
  font-size: 13px;
  color: var(--text-secondary, #888);
  margin-bottom: 8px;
}
.share-panel-buttons {
  display: flex;
  gap: 8px;
}
.share-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border, #ddd);
  border-radius: var(--radius-1, 8px);
  background: var(--bg, #fff);
  color: var(--text, #333);
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.share-btn:active { opacity: 0.7; }
.share-btn-wechat { border-color: #07c160; color: #07c160; }
@media (prefers-color-scheme: dark) {
  .share-btn { background: var(--bg, #111); border-color: var(--border, #333); color: var(--text, #eee); }
  .share-btn-wechat { border-color: #07c160; color: #07c160; }
}
.share-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 9999;
  animation: shareToastIn 0.2s ease;
  pointer-events: none;
}
@keyframes shareToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}


/* ── Follow-up Suggestions (Perplexity-style) ──── */
.followup-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-light);
}
.followup-chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-brand);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--easing-standard);
  -webkit-tap-highlight-color: transparent;
}
.followup-chip:hover { background: var(--color-surface-hover); }
.followup-chip:active { transform: scale(0.97); opacity: 0.85; }
.followup-chip:disabled { cursor: default; }

/* ── Command Cards ────────────────────────────── */
/* Command cards removed — all commands in slash menu */

/* ── Command Capsule (input prefix) ──────────── */
.command-capsule {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  background: var(--color-brand);
  color: #ffffff;
  font-size: 12px;
  font-weight: var(--font-weight-medium);
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 1;
}

/* Static per-command padding — matches capsule width + left(8) + gap(6).
   SSOT: widths derived from monospace-ish sans at font-size:12px, padding 0 8px.
   /room=62  /menu=62  /share=68  /adjust=72  /customer=82  /invitation=92 */
#input.has-command { padding-left: 78px; }  /* default: covers /room /menu /share /adjust */
#input.has-command[data-command="customer"]   { padding-left: 96px; }
#input.has-command[data-command="invitation"] { padding-left: 108px; }


/* ── Slash Command Menu ── */
/* Slash menu — popover top layer needs fixed positioning */
#slash-panel,
#slash-menu {
  position: fixed;
  bottom: 60px;
  left: 0;
  right: 0;
  top: auto;
  margin: 0;
  border: none;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  max-height: 280px;
  z-index: var(--z-dropdown);
  padding: var(--space-3);
}
.slash-menu-hidden { display: none !important; }

.slash-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.slash-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--duration-fast) var(--easing-standard),
              border-color var(--duration-fast) var(--easing-standard),
              transform var(--duration-fast) var(--easing-standard);
}
.slash-grid-item:hover {
  border-color: var(--color-brand);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.slash-grid-item:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.slash-grid-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
}
.slash-grid-icon svg { width: 16px; height: 16px; }

.slash-grid-label {
  font-size: 12px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  line-height: 1;
}

/* ── Quick Result (Haiku response) ───────────── */
.quick-result {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: var(--space-2);
}

.quick-result-header {
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  background: var(--color-surface-secondary);
  border-bottom: 1px solid var(--color-border-light);
}

.quick-result-row {
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--color-border-light);
}

.quick-result-row:last-child {
  border-bottom: none;
}

.quick-result-row.available {
  color: var(--color-success);
}

.quick-result-row.booked {
  color: var(--color-text-secondary);
}

.quick-result-row .booking-detail {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-medium);
}

/* ── Plus Button + Extension Panel (WeChat-style) ─ */

/* HIG: 44×44pt tap target, visual icon ~20pt centered */
#plus-btn,
#slash-btn {
  background: none;
  border: none;
  color: var(--color-brand);
  width: 44px;                                       /* HIG: minimum hit region */
  height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  margin: -4px -6px;                                 /* optical: tighten visual gap while keeping 44px tap */
  transition: background var(--duration-fast) var(--easing-standard),
              transform var(--duration-fast) var(--easing-standard);
  -webkit-tap-highlight-color: transparent;
}
#plus-btn:active,
#slash-btn:active { background: rgba(139, 111, 71, 0.15); }
#plus-btn.active,
#slash-btn.active {
  transform: rotate(45deg);
  color: var(--color-text-secondary);
}
#slash-btn.active {
  transform: none;
  background: rgba(139, 111, 71, 0.12);
}
#plus-btn.preparing {
  color: var(--color-error);
  animation: micPrepare 0.6s ease-in-out infinite;
}

/* Popover panel — override UA top-layer positioning */
#plus-panel {
  position: fixed;
  bottom: 60px;
  left: 0;
  right: 0;
  top: auto;
  margin: 0;
  border: none;
  background: var(--color-surface-secondary);
  border-top: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-4) var(--space-3);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-dropdown);
  animation: plusSlideUp var(--duration-normal) var(--easing-standard);
}
.plus-panel-hidden { display: none !important; }

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

.plus-grid {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
}

.plus-grid-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--color-surface);
  cursor: pointer;
  min-width: 72px;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--duration-fast) var(--easing-standard);
}
.plus-grid-item:active {
  background: var(--color-border-light);
}

.plus-grid-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--color-surface-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
}

.plus-grid-label {
  font-size: 12px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  line-height: 1;
}

/* Photo preview above input */
.photo-preview {
  position: relative;
  display: inline-block;
  margin: var(--space-1) var(--space-4);
}
.photo-preview img {
  max-width: 120px;
  max-height: 90px;
  border-radius: var(--radius-md);
  object-fit: cover;
}
.photo-preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0;
}
.photo-preview-remove:hover {
  color: var(--color-error);
}

/* Chat photo in message bubble */
.chat-photo {
  max-width: 200px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-1);
  display: block;
}

/* Booking Sheet styles moved to components/booking-sheet/booking-sheet.css */

/* ── Booking Popup Gate (legacy) ── */
#booking-popup[open] {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  transition: opacity 0.2s;
}
#booking-popup.popup-hidden {
  opacity: 0; pointer-events: none;
}
.popup-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
}
.popup-sheet {
  position: relative; z-index: 1;
  width: 100%; max-width: 720px;
  height: 85vh;
  background: var(--color-bg, #f5f5f0);
  border-radius: var(--radius-lg, 13px) var(--radius-lg, 13px) 0 0;
  overflow: hidden;
  animation: popupSlideUp 0.25s ease-out;
}
.popup-iframe {
  width: 100%; height: 100%; border: none;
}
@keyframes popupSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
