@import url("https://fonts.googleapis.com/css2?family=Orbitron:wght@500;650&family=Noto+Sans+TC:wght@400;500;600&display=swap");

:root {
  --bg: #07060a;
  --ink: #f4ecec;
  --muted: #9a8b8d;
  --panel: rgba(16, 12, 16, 0.88);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #d41f38;
  --accent-2: #ff4d63;
  --glow: rgba(212, 31, 56, 0.35);
  --glow-soft: rgba(212, 31, 56, 0.14);
  --bot: rgba(255, 255, 255, 0.045);
  --user: #d41f38;
  --user-ink: #fff;
  --danger: #ff8a8a;
  --font: "Noto Sans TC", "PingFang HK", "Segoe UI", sans-serif;
  --font-display: "Orbitron", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

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

/* 背景 C＋網格：深色實底＋頂部柔紅光暈＋淡噪點＋靜態網格 */
body {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 28px 16px;
  overflow-x: hidden;
  background-color: #09080b;
  background-image:
    radial-gradient(ellipse 85% 50% at 50% -8%, rgba(212, 31, 56, 0.2), transparent 58%),
    radial-gradient(ellipse 70% 45% at 50% 100%, rgba(20, 12, 16, 0.9), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: auto, auto, 56px 56px, 56px 56px;
  background-repeat: no-repeat, no-repeat, repeat, repeat;
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  z-index: 0;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

body::after {
  content: none;
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  height: min(720px, calc(100vh - 56px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 0 0 1px rgba(212, 31, 56, 0.12),
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 80px var(--glow-soft);
}

.shell::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  opacity: 0.85;
  z-index: 3;
  animation: scan-pulse 3.2s ease-in-out infinite;
}

@keyframes scan-pulse {
  0%,
  100% {
    opacity: 0.35;
    filter: brightness(1);
  }
  50% {
    opacity: 1;
    filter: brightness(1.35);
  }
}

.top {
  position: relative;
  z-index: 4;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 10, 14, 0.92), rgba(10, 8, 9, 0.55));
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

a.ghost.home-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

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

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.top h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: none;
  background: linear-gradient(100deg, #fff 20%, var(--accent-2) 55%, #fff 90%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-shine 6s linear infinite;
}

@keyframes title-shine {
  to {
    background-position: 200% center;
  }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(212, 31, 56, 0.35);
  background: rgba(212, 31, 56, 0.1);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-family: var(--font-display);
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3dff9a;
  box-shadow: 0 0 10px rgba(61, 255, 154, 0.9);
  animation: live-dot 1.6s ease-in-out infinite;
}

@keyframes live-dot {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.7);
    opacity: 0.55;
  }
}

.top p {
  margin: 7px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.log {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.bubble {
  max-width: 88%;
  padding: 10px 12px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 12px;
  animation: bubble-in 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.bubble.bot {
  align-self: flex-start;
  background: var(--bot);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.bubble.bot strong {
  color: #fff;
  font-weight: 600;
}

.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #c41b32 0%, #e8354c 100%);
  color: var(--user-ink);
  box-shadow: 0 6px 22px var(--glow);
}

.bubble.err {
  align-self: flex-start;
  background: rgba(212, 31, 56, 0.12);
  color: var(--danger);
  border: 1px solid rgba(212, 31, 56, 0.28);
}

.bubble.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 52px;
  padding: 12px 14px;
}

.bubble.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-dot 1.1s ease-in-out infinite;
}

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

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

@keyframes typing-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
    background: var(--accent-2);
  }
}

.composer {
  position: relative;
  z-index: 4;
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 12, 13, 0.7), #0c090a);
}

.composer input[type="text"] {
  flex: 1;
  border: 1px solid var(--line);
  background: rgba(8, 6, 8, 0.9);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.composer input[type="text"]::placeholder {
  color: var(--muted);
}

.composer input[type="text"]:focus {
  outline: none;
  border-color: rgba(212, 31, 56, 0.65);
  box-shadow: 0 0 0 3px rgba(212, 31, 56, 0.18), 0 0 24px var(--glow-soft);
}

.composer button,
.book button[type="submit"],
.lead-action button {
  border: 0;
  background: linear-gradient(135deg, #b8182e, var(--accent) 45%, #ff5a6c);
  background-size: 160% 160%;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 10px;
  box-shadow: 0 0 20px var(--glow);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
  animation: cta-breathe 3.5s ease-in-out infinite;
}

@keyframes cta-breathe {
  0%,
  100% {
    box-shadow: 0 0 16px var(--glow);
  }
  50% {
    box-shadow: 0 0 28px rgba(212, 31, 56, 0.55);
  }
}

.composer button:hover:not(:disabled),
.book button[type="submit"]:hover:not(:disabled),
.lead-action button:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.composer button:active:not(:disabled) {
  transform: translateY(0);
}

.composer button:disabled,
.book button:disabled,
.lead-action button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
  animation: none;
}

.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 8px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.ghost:hover {
  border-color: rgba(212, 31, 56, 0.45);
  color: var(--ink);
  background: rgba(212, 31, 56, 0.1);
}

.lead-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.v2-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.v2-choice-btn {
  border: 1px solid #fff;
  background: #fff;
  color: #1a1214;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  cursor: pointer;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* 只喺真滑鼠先用 hover；手機 tap 唔好留低「白底紅字」sticky hover */
@media (hover: hover) and (pointer: fine) {
  .v2-choice-btn:hover:not(:disabled):not(.is-selected):not(.v2-choice-confirm) {
    background: #fff;
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 16px var(--glow);
  }
}

.v2-choice-btn:active:not(:disabled):not(.is-selected):not(.v2-choice-confirm) {
  background: #f4ecec;
  color: #1a1214;
}

.v2-choice-btn.is-selected,
.v2-choice-btn.is-selected:hover,
.v2-choice-btn.is-selected:active,
.v2-choice-btn.is-selected:focus {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 14px var(--glow);
}

.v2-choice-confirm:not(:disabled),
.v2-choice-confirm:not(:disabled):hover,
.v2-choice-confirm:not(:disabled):active,
.v2-choice-confirm:not(:disabled):focus {
  background: linear-gradient(135deg, #b8182e, var(--accent));
  border-color: transparent;
  color: #fff;
}

.v2-choice-btn:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

.lead-inline {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.lead-inline button,
.bubble.bot .lead-inline button {
  border: 0;
  background: linear-gradient(135deg, #b8182e, var(--accent));
  color: #fff;
  font: inherit;
  font-size: 14px;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 10px;
  box-shadow: 0 0 18px var(--glow);
}

.lead-inline button:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}

.lead-note {
  margin: 0;
}

.book {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 64px;
  max-height: min(70%, calc(100% - 140px));
  overflow: hidden;
  padding: 12px 16px 0;
  border-top: 1px solid var(--line);
  background: rgba(14, 10, 12, 0.96);
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.45), 0 0 40px var(--glow-soft);
  z-index: 5;
  flex-direction: column;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.book.open {
  display: flex;
}

#lead-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}

.book-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.book h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.book label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 4px;
}

.book input,
.book textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  background: #0c0a0b;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.book textarea {
  min-height: 3.2em;
  max-height: 7.5em;
  resize: vertical;
  display: block;
}

.book input:focus,
.book textarea:focus {
  outline: none;
  border-color: rgba(212, 31, 56, 0.55);
  box-shadow: 0 0 0 3px rgba(212, 31, 56, 0.15);
}

.book-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  position: sticky;
  bottom: 0;
  padding: 10px 0 12px;
  background: linear-gradient(180deg, rgba(14, 10, 12, 0) 0%, #0e0a0c 28%, #0e0a0c 100%);
  z-index: 2;
}

.book-hint {
  margin: 0 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  text-align: right;
}

.book-hint.warn {
  color: var(--accent);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  padding: 0 16px 12px;
}

@media (prefers-reduced-motion: reduce) {
  .shell::after,
  .top h1,
  .status-pill .dot,
  .bubble,
  .composer button {
    animation: none !important;
  }
}
