:root {
  --bg: #f3f7fc;
  --ink: #0f2744;
  --muted: rgba(15, 39, 68, 0.58);
  --line: rgba(37, 99, 235, 0.14);
  --blue: #1d4ed8;
  --blue-bright: #2563eb;
  --blue-deep: #0b3a82;
  --blue-soft: rgba(37, 99, 235, 0.1);
  --ok: #0f9f6e;
  --panel: #ffffff;
  --shadow: 0 18px 48px rgba(15, 39, 68, 0.1);
  --font-display: "Syne", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", sans-serif;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

/* —— Atmosphere —— */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(110% 70% at 50% -20%, rgba(37, 99, 235, 0.16), transparent 55%),
    radial-gradient(70% 50% at 100% 20%, rgba(59, 130, 246, 0.1), transparent 50%),
    radial-gradient(60% 40% at 0% 90%, rgba(14, 165, 233, 0.08), transparent 45%),
    linear-gradient(180deg, #eef4fb 0%, #f7fafc 48%, #ffffff 100%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite;
  will-change: transform;
}

.orb-a {
  width: min(62vw, 560px);
  height: min(62vw, 560px);
  left: -10%;
  top: 4%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.28), transparent 68%);
}

.orb-b {
  width: min(50vw, 460px);
  height: min(50vw, 460px);
  right: -8%;
  bottom: 6%;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.22), transparent 70%);
  animation-delay: -8s;
}

.orb-c {
  width: min(36vw, 280px);
  height: min(36vw, 280px);
  left: 42%;
  top: 48%;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.2), transparent 70%);
  animation-delay: -3s;
  opacity: 0.4;
}

.vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(15, 39, 68, 0.04) 100%);
}

.grid-fade {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.05) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse at 40% 30%, black 15%, transparent 72%);
  opacity: 0.7;
}

.noise {
  position: absolute;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' 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");
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(2.5%, -3.5%, 0) scale(1.06);
  }
}

/* —— Stage —— */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 64px) clamp(20px, 5vw, 56px) calc(96px + var(--safe-b));
  max-width: 880px;
  margin: 0 auto;
}

.brand-block {
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand-mark {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.36em;
  font-size: 0.68rem;
  color: var(--blue);
  text-indent: 0.36em;
}

.brand-name {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 900;
  font-size: clamp(2.75rem, 11vw, 5.2rem);
  line-height: 1.05;
  letter-spacing: 0.14em;
  background: linear-gradient(115deg, #0f2744 8%, #1d4ed8 48%, #0284c7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-rule {
  width: min(120px, 28vw);
  height: 3px;
  margin-top: 20px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--blue-bright), transparent);
}

.brand-tag {
  margin: 16px 0 0;
  font-size: clamp(0.92rem, 2.3vw, 1.05rem);
  color: var(--muted);
  letter-spacing: 0.16em;
}

.lead {
  margin: clamp(20px, 3.5vw, 28px) 0 clamp(26px, 4.5vw, 38px);
  max-width: 26em;
  font-size: clamp(0.98rem, 2.4vw, 1.12rem);
  line-height: 1.75;
  color: rgba(15, 39, 68, 0.72);
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.entries {
  display: grid;
  gap: 12px;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}

.entry {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px 18px;
  padding: 19px 22px;
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 28px rgba(15, 39, 68, 0.05);
  backdrop-filter: blur(12px);
  overflow: hidden;
  transition:
    border-color 0.28s ease,
    background 0.28s ease,
    transform 0.28s ease,
    box-shadow 0.28s ease;
}

.entry::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, transparent, var(--blue-bright), transparent);
  opacity: 0.45;
  transition: opacity 0.28s ease, top 0.28s ease, bottom 0.28s ease;
}

a.entry:hover,
a.entry:focus-visible {
  border-color: rgba(37, 99, 235, 0.35);
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(37, 99, 235, 0.12);
  outline: none;
}

a.entry:hover::before,
a.entry:focus-visible::before {
  opacity: 1;
  top: 12%;
  bottom: 12%;
}

.entry-support {
  align-items: start;
}

.entry-support::before {
  opacity: 0.7;
}

.entry-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: var(--blue);
  background: linear-gradient(145deg, rgba(37, 99, 235, 0.12), rgba(14, 165, 233, 0.08));
  border: 1px solid rgba(37, 99, 235, 0.14);
  flex-shrink: 0;
  transition: background 0.28s ease, color 0.28s ease, transform 0.28s ease;
}

a.entry:hover .entry-icon,
a.entry:focus-visible .entry-icon {
  color: #ffffff;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  border-color: transparent;
  transform: scale(1.04);
}

.entry-support .entry-icon {
  color: #0b3a82;
}

.entry-title {
  display: block;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.entry-desc {
  display: block;
  margin-top: 5px;
  font-size: 0.86rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.entry-arrow {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid rgba(37, 99, 235, 0.14);
  opacity: 0.9;
  transition: transform 0.28s ease, opacity 0.28s ease, background 0.28s ease;
}

a.entry:hover .entry-arrow {
  transform: translateX(3px);
  opacity: 1;
  background: rgba(37, 99, 235, 0.16);
}

.entry-actions {
  grid-column: 2 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}

.mini-btn {
  appearance: none;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: var(--blue-soft);
  color: var(--blue-deep);
  border-radius: 999px;
  padding: 9px 17px;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.mini-btn:hover,
.mini-btn:focus-visible {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
  outline: none;
  transform: translateY(-1px);
}

.mini-btn-ghost {
  background: transparent;
  border-color: rgba(15, 39, 68, 0.14);
  color: var(--ink);
}

.mini-btn-ghost:hover,
.mini-btn-ghost:focus-visible {
  border-color: rgba(37, 99, 235, 0.4);
  background: rgba(37, 99, 235, 0.06);
  color: var(--blue-deep);
}

.foot {
  margin-top: clamp(32px, 6vw, 48px);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  color: rgba(15, 39, 68, 0.4);
  letter-spacing: 0.1em;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}

.visit-count strong {
  color: var(--blue);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.55);
}

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

/* —— FAB dock —— */
.fab-dock {
  position: fixed;
  right: calc(16px + var(--safe-r));
  bottom: calc(72px + var(--safe-b));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.fab-dock.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.fab-tip {
  appearance: none;
  margin: 0;
  max-width: 12.5em;
  padding: 11px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-align: left;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  box-shadow:
    0 12px 28px rgba(37, 99, 235, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.18) inset;
  cursor: pointer;
  position: relative;
  animation:
    tip-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.5s both,
    tip-pulse 2.2s ease-in-out 1.2s infinite;
}

.fab-tip::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  width: 12px;
  height: 12px;
  background: #1d4ed8;
  transform: translateY(-50%) rotate(45deg);
  border-radius: 2px;
  z-index: -1;
}

.fab-tip:hover,
.fab-tip:focus-visible {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  outline: none;
  transform: translateY(-1px);
}

.fab {
  position: relative;
  flex-shrink: 0;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  cursor: pointer;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease;
}

.fab:hover,
.fab:focus-visible {
  transform: scale(1.06);
  outline: none;
}

.fab-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid rgba(37, 99, 235, 0.35);
  animation: pulse 2.4s ease-out infinite;
}

@keyframes tip-in {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes tip-pulse {
  0%,
  100% {
    box-shadow:
      0 12px 28px rgba(37, 99, 235, 0.35),
      0 0 0 0 rgba(37, 99, 235, 0.35);
  }
  50% {
    box-shadow:
      0 14px 32px rgba(37, 99, 235, 0.45),
      0 0 0 8px rgba(37, 99, 235, 0);
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.75;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

/* —— Chat panel —— */
.chat-panel {
  position: fixed;
  right: calc(16px + var(--safe-r));
  bottom: calc(72px + var(--safe-b));
  z-index: 50;
  width: min(370px, calc(100vw - 28px));
  height: min(540px, calc(100svh - 36px));
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid rgba(37, 99, 235, 0.14);
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(15, 39, 68, 0.16);
  overflow: hidden;
  transform-origin: bottom right;
  animation: pop 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.chat-panel[hidden] {
  display: none !important;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 14px 13px 16px;
  border-bottom: 1px solid rgba(37, 99, 235, 0.1);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent);
}

.chat-title {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.chat-status {
  margin: 4px 0 0;
  font-size: 0.74rem;
  color: var(--ok);
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-tg,
.chat-close {
  appearance: none;
  border: 1px solid rgba(15, 39, 68, 0.12);
  background: #ffffff;
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.chat-tg:hover,
.chat-close:hover {
  border-color: rgba(37, 99, 235, 0.35);
  background: var(--blue-soft);
  color: var(--blue-deep);
}

.chat-tg {
  padding: 6px 11px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.chat-close {
  width: 32px;
  height: 32px;
  font-size: 1.25rem;
  line-height: 1;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
}

.bubble {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-user {
  align-self: flex-end;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  border: 1px solid rgba(29, 78, 216, 0.35);
  border-bottom-right-radius: 4px;
}

.bubble-agent,
.bubble-system {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid rgba(15, 39, 68, 0.1);
  color: var(--ink);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(15, 39, 68, 0.04);
}

.bubble-system {
  color: var(--muted);
  font-size: 0.82rem;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(37, 99, 235, 0.1);
  background: #ffffff;
}

.chat-form input {
  width: 100%;
  border: 1px solid rgba(15, 39, 68, 0.12);
  border-radius: 12px;
  background: #f7faff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

.chat-form input:focus {
  border-color: rgba(37, 99, 235, 0.45);
  background: #ffffff;
}

.chat-form button {
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.chat-form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (min-width: 720px) {
  .entry-support {
    grid-template-columns: auto 1fr auto;
    align-items: center;
  }

  .entry-actions {
    grid-column: auto;
    margin-top: 0;
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  .brand-mark {
    letter-spacing: 0.22em;
    text-indent: 0.22em;
    font-size: 0.62rem;
  }

  .brand-name {
    letter-spacing: 0.1em;
  }

  .entry {
    padding: 16px 16px 16px 18px;
    gap: 12px 14px;
  }

  .entry-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .entry-arrow {
    width: 32px;
    height: 32px;
  }

  .fab-dock {
    right: 12px;
    bottom: calc(64px + var(--safe-b));
    gap: 10px;
  }

  .fab-tip {
    font-size: 0.78rem;
    max-width: 10.5em;
    padding: 9px 12px;
  }

  .fab {
    width: 54px;
    height: 54px;
  }

  .chat-panel {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: calc(64px + var(--safe-b));
    height: min(560px, calc(100svh - 88px));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
