:root {
  --paper: #f7f5f1;
  --ink: #1c1a16;
  --ink-soft: #5b5648;
  --line: rgba(28, 26, 22, 0.10);
  --gold: #b9842a;
  --gold-soft: #cf9f3f;
  --gold-tint: rgba(185, 132, 42, 0.10);
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: "Hanken Grotesk", "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  font-feature-settings: "cv01", "cv03", "ss01";
  overflow-x: hidden;
  position: relative;
}

/* Layered ambient background — warm radial bloom + faint grain texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px 600px at 12% -5%, rgba(185, 132, 42, 0.10), transparent 60%),
    radial-gradient(1100px 700px at 100% 0%, rgba(28, 26, 22, 0.05), transparent 55%),
    linear-gradient(180deg, #faf8f3 0%, #f4f1ea 45%, #f1ede4 100%);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.5;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

::selection { background: rgba(185, 132, 42, 0.22); color: #2b2823; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(28, 26, 22, 0.18); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(28, 26, 22, 0.34); }

/* ---- Typography helpers ---- */
.font-display { font-family: "Fraunces", "Songti SC", Georgia, serif; font-optical-sizing: auto; }
.font-mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.tracking-kicker { letter-spacing: 0.24em; }

/* ---- Accent utilities ---- */
.text-gold { color: var(--gold); }
.bg-gold { background-color: var(--gold); }
.bg-gold-tint { background-color: var(--gold-tint); }
.border-gold { border-color: rgba(185, 132, 42, 0.45); }
.ring-gold { box-shadow: 0 0 0 1px rgba(185, 132, 42, 0.40), 0 6px 20px -8px rgba(185, 132, 42, 0.32); }
.gold-rule { background: linear-gradient(90deg, transparent, rgba(185, 132, 42, 0.55), transparent); }
.text-gradient-ink {
  background: linear-gradient(135deg, #1c1a16 0%, #423d33 55%, #7c7565 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hairline { border-color: var(--line); }
.surface-card {
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(28, 26, 22, 0.03), 0 10px 30px -22px rgba(28, 26, 22, 0.18);
}
.ink-panel {
  background:
    radial-gradient(700px 360px at 85% -10%, rgba(185, 132, 42, 0.16), transparent 60%),
    linear-gradient(165deg, #211e19 0%, #161410 100%);
}
.dot-grid {
  background-image: radial-gradient(rgba(28, 26, 22, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* ---- Keyframes ---- */
@keyframes fade-in-up { 0% { opacity: 0; transform: translateY(14px); } 100% { opacity: 1; transform: translateY(0); } }
.animate-fade-in-up { animation: fade-in-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } }
.animate-fade-in { animation: fade-in 0.25s ease-out forwards; }

@keyframes slide-in-right { 0% { transform: translateX(100%); } 100% { transform: translateX(0); } }
.animate-slide-in-right { animation: slide-in-right 0.34s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes scale-in { 0% { opacity: 0; transform: scale(0.94); } 100% { opacity: 1; transform: scale(1); } }
.animate-scale-in { animation: scale-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes dialog-overlay-show { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-content-show { from { opacity: 0; transform: scale(0.965) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.animate-dialog-overlay { animation: dialog-overlay-show 0.22s ease-out forwards; }
.animate-dialog-content { animation: dialog-content-show 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes slide-in-right-kf { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.animate-\[slide-in-right_1s_ease-in-out_infinite\] { animation: slide-in-right-kf 1.1s ease-in-out infinite; }

/* Staggered entrance — apply .stagger to a parent, children fade up in sequence */
.stagger > * { opacity: 0; animation: fade-in-up 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.stagger > *:nth-child(1) { animation-delay: 0.04s; }
.stagger > *:nth-child(2) { animation-delay: 0.10s; }
.stagger > *:nth-child(3) { animation-delay: 0.16s; }
.stagger > *:nth-child(4) { animation-delay: 0.22s; }
.stagger > *:nth-child(5) { animation-delay: 0.28s; }
.stagger > *:nth-child(6) { animation-delay: 0.34s; }
.stagger > *:nth-child(7) { animation-delay: 0.40s; }
.stagger > *:nth-child(8) { animation-delay: 0.46s; }

@keyframes draw-line { to { stroke-dashoffset: 0; } }
.draw-line { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw-line 1.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards; }

@keyframes rise-bar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.rise-bar { transform-origin: bottom; animation: rise-bar 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes ring-sweep { to { stroke-dashoffset: var(--target, 0); } }

@keyframes shimmer { 0% { background-position: -260px 0; } 100% { background-position: 260px 0; } }
.shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(185,132,42,0.16) 50%, rgba(255,255,255,0) 100%);
  background-size: 520px 100%;
  animation: shimmer 2.4s linear infinite;
}

@keyframes pulse-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(185,132,42,0.42); } 50% { box-shadow: 0 0 0 7px rgba(185,132,42,0); } }
.pulse-glow { animation: pulse-glow 2s ease-out infinite; }

@keyframes float-soft { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.float-soft { animation: float-soft 5s ease-in-out infinite; }

@keyframes ticker { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }
.ticker-track { display: inline-flex; animation: ticker 26s linear infinite; }

.arrow-down::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid rgba(185, 132, 42, 0.5);
}

.overflow-hidden { overflow: hidden; padding-right: 6px; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.glass-panel {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.phone-shell-pda { width: 380px; height: 740px; }
.phone-shell-customer { width: 340px; height: 720px; }
.phone-stage-pda { height: 740px; }
.phone-stage-customer { height: 720px; }
.dashboard-shell { height: 860px; }

@media (max-width: 760px) {
  .branch-flow { height: 360px; }
  .branch-flow svg { transform: scaleX(0.92); transform-origin: center; }
}

@media (max-height: 860px) {
  .app-shell { padding-top: 22px; padding-bottom: 22px; }
  .app-heading { margin-bottom: 22px; }
  .app-heading h1 { font-size: 30px; line-height: 1.12; }
  .industry-switch { margin-bottom: 22px; }
  .view-tabs { margin-bottom: 22px; }
  .phone-stage-pda { height: calc(740px * 0.74); margin-top: 0.25rem; }
  .phone-shell-pda { transform: scale(0.74); transform-origin: top center; }
  .phone-stage-customer { height: calc(720px * 0.78); margin-top: 0; }
  .phone-shell-customer { transform: scale(0.78); transform-origin: top center; }
  .dashboard-shell { height: calc(100vh - 92px); min-height: 580px; }
  .dashboard-main { padding: 24px !important; }
}

/* Narrow + tall screens (e.g. 412×915): the height rules above never fire, so
   guard the fixed-width phone shells against horizontal overflow by width. */
@media (max-width: 480px) and (min-height: 861px) {
  .phone-stage-pda { height: calc(740px * 0.78) !important; margin-top: 0; }
  .phone-shell-pda { transform: scale(0.78); transform-origin: top center; }
  .phone-stage-customer { height: calc(720px * 0.84) !important; }
  .phone-shell-customer { transform: scale(0.84); transform-origin: top center; }
}

@media (max-height: 760px) {
  .app-shell { padding-top: 12px !important; }
  .app-heading { display: none !important; }
  .industry-switch { display: none !important; }
  .view-tabs { margin-bottom: 14px !important; }
  .phone-stage-pda { height: calc(740px * 0.72) !important; margin-top: 0 !important; }
  .phone-shell-pda { transform: scale(0.72); }
  .phone-stage-customer { height: calc(720px * 0.72) !important; }
  .phone-shell-customer { transform: scale(0.72); }
  .dashboard-shell { height: calc(100vh - 88px) !important; min-height: 560px; }
  .dashboard-main { padding: 20px !important; }
}
