/* === ChronicSense / 慢病先知 — base styles === */

html, body { -webkit-font-smoothing: antialiased; }
html { scroll-behavior: smooth; }
body { font-feature-settings: "tnum" 0, "ss01" 1; }

/* Numeric/code style */
.num { font-family: "IBM Plex Mono", ui-monospace, monospace; font-feature-settings: "tnum" 1; letter-spacing: 0; }
.num-tabular { font-variant-numeric: tabular-nums; }

/* Serif accent for headings */
.serif-zh { font-family: "Noto Serif SC", Georgia, serif; }

/* Subtle textured background for "clinical paper" */
.bg-grid {
  background-image:
    linear-gradient(rgba(11,27,43,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11,27,43,0.025) 1px, transparent 1px);
  background-size: 24px 24px;
}
.bg-dots {
  background-image: radial-gradient(rgba(11,27,43,0.08) 1px, transparent 1px);
  background-size: 14px 14px;
}

/* App shell */
.app-shell { min-width: 0; }
.app-main { min-width: 0; }
.app-content { margin-inline: auto; }
.mobile-nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  color: #22364F;
  background: #FFFFFF;
  border: 1px solid #D5DDE8;
  border-radius: 8px;
}

/* Frosted card hover */
.card { background: #fff; border: 1px solid #E5EBF3; border-radius: 8px; }
.card-tight { background: #fff; border: 1px solid #E5EBF3; border-radius: 8px; }

/* Pill ROI tag */
.roi-pill {
  display:inline-flex; align-items:center; gap:6px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
  border: 1px solid currentColor; background: rgba(255,255,255,0.85);
}

/* Animated scan line */
@keyframes scan {
  0%   { transform: translateY(-4%); opacity: 0.0; }
  10%  { opacity: 0.9; }
  50%  { transform: translateY(96%); opacity: 0.9; }
  60%  { opacity: 0.0; }
  100% { transform: translateY(96%); opacity: 0.0; }
}
.scan-bar {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, #1E7AC8, transparent);
  box-shadow: 0 0 24px 4px rgba(30,122,200,0.35);
  animation: scan 2.2s ease-in-out infinite;
}

/* Pulse dot */
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.85); opacity: 0.6; }
}
.pulse-dot { animation: pulse-dot 1.4s ease-in-out infinite; }

/* Marquee for "data flow" */
@keyframes flow {
  from { stroke-dashoffset: 24; }
  to   { stroke-dashoffset: 0; }
}
.flow-line { stroke-dasharray: 4 4; animation: flow 0.8s linear infinite; }

/* Custom scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D5DDE8; border-radius: 999px; border: 2px solid #FAFBFD; }
::-webkit-scrollbar-thumb:hover { background: #B3C2D6; }

/* Elderly mode — applies larger type and more spacing */
body.elderly {
  font-size: 17px;
}
body.elderly .text-xs { font-size: 13px; }
body.elderly .text-sm { font-size: 15px; }
body.elderly .text-base { font-size: 17px; }
body.elderly .text-lg { font-size: 20px; }
body.elderly .text-xl { font-size: 24px; }
body.elderly .text-2xl { font-size: 28px; }
body.elderly .text-3xl { font-size: 34px; }
body.elderly .text-4xl { font-size: 42px; }
body.elderly button { min-height: 48px; }

/* SHAP bar transitions */
.shap-bar { transition: width 700ms cubic-bezier(.2,.7,.2,1); }

/* Risk level color helpers */
.risk-high  { color: #C9342B; background: #FDECEA; }
.risk-mid   { color: #C2761A; background: #FBEFD9; }
.risk-low   { color: #0E8367; background: #E1F3EC; }

/* Active nav item */
.nav-item-active {
  background: linear-gradient(180deg, #F2F7FC, #E3F0FB);
  border-color: #BEDCF2;
}

/* Stepper line */
.stepper-line {
  background: repeating-linear-gradient(to right, #D5DDE8 0 6px, transparent 6px 12px);
}

/* Smooth fade-in for screens */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-up 380ms cubic-bezier(.2,.7,.2,1) both; }

/* gauge needle */
.needle {
  transform-origin: 50% 100%;
  transition: transform 1.4s cubic-bezier(.2,.7,.2,1);
}

/* shimmer for "analyzing" placeholders */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.shimmer {
  background: linear-gradient(90deg, #EEF2F8 0%, #F7FAFD 50%, #EEF2F8 100%);
  background-size: 200px 100%;
  animation: shimmer 1.6s linear infinite;
}

/* monospace key:val table rows */
.kv {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px dashed #E5EBF3;
  font-size: 13px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: #5C7390; }
.kv .v { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: #15263A; }

/* prevent text selection on shell chrome */
.nosel { user-select: none; }

/* small ascii corners for technical panels */
.tech-frame {
  position: relative;
  border: 1px solid #D5DDE8;
  background: linear-gradient(180deg, #FFFFFF, #FAFBFD);
  border-radius: 8px;
}
.tech-frame::before, .tech-frame::after {
  content: ""; position: absolute; width: 8px; height: 8px;
  border: 1px solid #5C7390;
}
.tech-frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.tech-frame::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

@media (max-width: 1180px) {
  .app-sidebar { width: 230px !important; }
  .app-content { padding: 24px 20px !important; }
  .app-status { display: none !important; }
}

@media (max-width: 960px) {
  .app-shell { flex-direction: column; }
  .app-sidebar {
    width: 100% !important;
    height: auto !important;
    position: relative !important;
    top: auto !important;
    overflow: visible !important;
    border-right: 0 !important;
    border-bottom: 1px solid #E8EEF6;
    z-index: 20;
  }
  .app-sidebar > .px-5 { padding: 12px 16px !important; }
  .app-sidebar.is-collapsed .app-nav,
  .app-sidebar.is-collapsed .demo-note { display: none; }
  .mobile-nav-toggle { display: inline-flex; }
  .app-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 14px 16px !important;
  }
  .app-nav .space-y-0\.5 > :not([hidden]) ~ :not([hidden]) {
    margin-top: 4px !important;
  }
  .demo-note { padding: 12px 16px !important; }
  .app-topbar {
    top: 0;
    min-height: 52px;
    height: auto !important;
    padding: 10px 16px !important;
    gap: 12px;
  }
  .app-divider,
  .user-mini { display: none !important; }
  .app-content { padding: 20px 16px !important; }
  .app-footer {
    flex-direction: column;
    gap: 6px;
    padding: 16px !important;
  }
  .grid-cols-5,
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .col-span-5,
  .col-span-4,
  .col-span-3,
  .col-span-2 { grid-column: span 2 / span 2 !important; }
}

@media (max-width: 680px) {
  .app-topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .app-nav,
  .grid-cols-5,
  .grid-cols-4,
  .grid-cols-3,
  .grid-cols-2 { grid-template-columns: 1fr !important; }
  .col-span-5,
  .col-span-4,
  .col-span-3,
  .col-span-2 { grid-column: span 1 / span 1 !important; }
  .card,
  .card-tight,
  .tech-frame { min-width: 0; }
  .card table { min-width: 640px; }
  .card .overflow-y-auto { overflow-x: auto; }
  .flex.items-end.justify-between.mb-5 {
    align-items: flex-start !important;
    flex-direction: column;
    gap: 12px;
  }
  .stepper-line { min-width: 16px; }
}
