/* ============ TPH Generator — App styles ============ */
:root {
  --brand: #6366f1;
  --brand-600: #4f46e5;
  --violet: #7c3aed;
}
* { -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  background: #f6f7fb;
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
html.dark body { background: #0b1020; color: #e2e8f0; }

/* Ambient background wash */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(124,58,237,0.10), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(99,102,241,0.10), transparent 55%);
}
html.dark body::before {
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(124,58,237,0.22), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(79,70,229,0.20), transparent 55%);
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(99,102,241,.4) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(99,102,241,.35); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,.6); background-clip: content-box; }

/* ============ Motion ============ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulseDot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.view-enter { animation: fadeUp .34s cubic-bezier(.22,1,.36,1) both; }
.stagger > * { animation: fadeUp .4s cubic-bezier(.22,1,.36,1) both; }
.stagger > *:nth-child(1){animation-delay:.02s}.stagger > *:nth-child(2){animation-delay:.06s}
.stagger > *:nth-child(3){animation-delay:.10s}.stagger > *:nth-child(4){animation-delay:.14s}
.stagger > *:nth-child(5){animation-delay:.18s}.stagger > *:nth-child(6){animation-delay:.22s}
.stagger > *:nth-child(7){animation-delay:.26s}.stagger > *:nth-child(8){animation-delay:.30s}
.anim-scale { animation: scaleIn .22s cubic-bezier(.22,1,.36,1) both; }
.anim-fade { animation: fadeIn .2s ease both; }
.anim-slide-right { animation: slideInRight .28s cubic-bezier(.22,1,.36,1) both; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============ Skeleton shimmer ============ */
.skeleton {
  position: relative; overflow: hidden;
  background: rgba(99,102,241,.10);
  border-radius: 8px;
}
html.dark .skeleton { background: rgba(148,163,184,.12); }
.skeleton::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: shimmer 1.5s infinite;
}
html.dark .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.09), transparent); }

/* ============ Cards / surfaces ============ */
.card {
  background: #fff; border: 1px solid rgba(15,23,42,.07);
  border-radius: 16px; box-shadow: 0 1px 2px rgba(16,24,40,.05);
}
html.dark .card { background: rgba(17,24,39,.72); border-color: rgba(148,163,184,.12); backdrop-filter: blur(6px); }

.hover-raise { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.hover-raise:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -12px rgba(79,70,229,.30); border-color: rgba(99,102,241,.35); }

/* Glass topbar */
.glass {
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
}
html.dark .glass { background: rgba(11,16,32,.72); }

/* ============ Buttons ============ */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:.5rem; font-weight:600; font-size:.875rem;
  padding:.55rem .95rem; border-radius:10px; transition:.16s ease; cursor:pointer; white-space:nowrap; border:1px solid transparent; }
.btn:disabled { opacity:.55; cursor:not-allowed; }
.btn-primary { background:linear-gradient(135deg,#6366f1,#7c3aed); color:#fff; box-shadow:0 6px 16px -6px rgba(99,102,241,.6); }
.btn-primary:hover:not(:disabled){ filter:brightness(1.06); box-shadow:0 10px 22px -8px rgba(99,102,241,.7); transform:translateY(-1px); }
.btn-ghost { background:transparent; color:#475569; border-color:rgba(15,23,42,.12); }
.btn-ghost:hover:not(:disabled){ background:rgba(99,102,241,.08); color:#4f46e5; border-color:rgba(99,102,241,.35); }
html.dark .btn-ghost { color:#cbd5e1; border-color:rgba(148,163,184,.18); }
html.dark .btn-ghost:hover:not(:disabled){ background:rgba(99,102,241,.16); color:#c7d2fe; }
.btn-soft { background:rgba(99,102,241,.12); color:#4f46e5; }
.btn-soft:hover:not(:disabled){ background:rgba(99,102,241,.2); }
html.dark .btn-soft { color:#c7d2fe; }
.btn-danger { background:#e11d48; color:#fff; }
.btn-danger:hover:not(:disabled){ background:#be123c; }
.btn-sm { padding:.35rem .6rem; font-size:.78rem; border-radius:8px; }

/* Inputs */
.inp {
  width:100%; font-size:.9rem; padding:.6rem .8rem; border-radius:10px;
  border:1px solid rgba(15,23,42,.14); background:#fff; color:#0f172a; transition:.15s ease;
}
.inp:focus { outline:none; border-color:#6366f1; box-shadow:0 0 0 4px rgba(99,102,241,.15); }
html.dark .inp { background:rgba(15,23,42,.6); border-color:rgba(148,163,184,.2); color:#e2e8f0; }
.inp::placeholder { color:#94a3b8; }
.lbl { font-size:.78rem; font-weight:600; color:#64748b; margin-bottom:.3rem; display:block; }
html.dark .lbl { color:#94a3b8; }

/* Nav links */
.nav-link { display:flex; align-items:center; gap:.7rem; padding:.6rem .8rem; border-radius:10px;
  font-size:.9rem; font-weight:500; color:#475569; transition:.15s ease; position:relative; }
.nav-link:hover { background:rgba(99,102,241,.08); color:#4f46e5; }
.nav-link.active { background:linear-gradient(135deg,rgba(99,102,241,.14),rgba(124,58,237,.14)); color:#4f46e5; font-weight:600; }
.nav-link.active::before { content:''; position:absolute; left:-8px; top:20%; bottom:20%; width:3px; border-radius:3px; background:linear-gradient(#6366f1,#7c3aed); }
html.dark .nav-link { color:#94a3b8; }
html.dark .nav-link:hover { background:rgba(99,102,241,.14); color:#c7d2fe; }
html.dark .nav-link.active { color:#c7d2fe; }

/* Table */
.tbl { width:100%; border-collapse:separate; border-spacing:0; font-size:.875rem; }
.tbl thead th { text-align:left; font-size:.72rem; text-transform:uppercase; letter-spacing:.05em; color:#94a3b8; font-weight:600; padding:.65rem .8rem; border-bottom:1px solid rgba(15,23,42,.08); position:sticky; top:0; }
html.dark .tbl thead th { border-color:rgba(148,163,184,.14); }
.tbl tbody td { padding:.7rem .8rem; border-bottom:1px solid rgba(15,23,42,.06); }
html.dark .tbl tbody td { border-color:rgba(148,163,184,.08); }
.tbl tbody tr { transition:background .12s ease; }
.tbl tbody tr:hover { background:rgba(99,102,241,.05); }
html.dark .tbl tbody tr:hover { background:rgba(99,102,241,.10); }

/* Badge */
.badge { display:inline-flex; align-items:center; gap:.35rem; font-size:.72rem; font-weight:600; padding:.2rem .55rem; border-radius:999px; line-height:1.2; border:1px solid transparent; white-space:nowrap; }
.badge .dot { width:6px; height:6px; border-radius:50%; background:currentColor; }

/* Toasts */
.toast-stack { position:fixed; top:1rem; right:1rem; z-index:9999; display:flex; flex-direction:column; gap:.6rem; max-width:min(92vw,380px); }
.toast { display:flex; gap:.7rem; align-items:flex-start; padding:.8rem .9rem; border-radius:12px; box-shadow:0 16px 40px -12px rgba(2,6,23,.4); border:1px solid rgba(15,23,42,.08); background:#fff; }
html.dark .toast { background:#111827; border-color:rgba(148,163,184,.16); color:#e2e8f0; }
.toast-out { animation: fadeIn .2s reverse both; }

/* Modal */
.modal-backdrop { position:fixed; inset:0; z-index:9000; background:rgba(15,23,42,.5); backdrop-filter:blur(3px); display:flex; align-items:center; justify-content:center; padding:1rem; }
html.dark .modal-backdrop { background:rgba(2,6,23,.65); }

/* Overlay */
.spinner { width:38px; height:38px; border-radius:50%; border:3px solid rgba(99,102,241,.25); border-top-color:#6366f1; animation:spin .8s linear infinite; }
.spinner-sm { width:16px; height:16px; border-width:2px; }

/* Off-canvas */
.drawer-right { position:fixed; top:0; right:0; height:100%; z-index:8500; box-shadow:-20px 0 50px -20px rgba(2,6,23,.5); }

/* Progress bar */
.pbar { height:8px; border-radius:999px; background:rgba(99,102,241,.15); overflow:hidden; }
.pbar > span { display:block; height:100%; border-radius:999px; background:linear-gradient(90deg,#6366f1,#7c3aed); transition:width .4s ease; }

/* Live dot */
.live-dot { width:8px; height:8px; border-radius:50%; background:#10b981; box-shadow:0 0 0 0 rgba(16,185,129,.5); animation:pulseDot 1.6s ease-in-out infinite; }

/* Wizard steps */
.wz-step { display:flex; align-items:center; gap:.55rem; font-size:.82rem; font-weight:600; color:#94a3b8; }
.wz-step .num { width:26px; height:26px; border-radius:50%; display:grid; place-items:center; font-size:.78rem; border:2px solid rgba(148,163,184,.4); }
.wz-step.active { color:#4f46e5; }
.wz-step.active .num { border-color:#6366f1; background:rgba(99,102,241,.12); }
.wz-step.done { color:#10b981; }
.wz-step.done .num { border-color:#10b981; background:#10b981; color:#fff; }

/* Preview iframe */
.preview-frame { width:100%; height:100%; border:0; background:#fff; border-radius:8px; }

/* Utility */
.tabular { font-variant-numeric: tabular-nums; }
.line-clamp-2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.no-scrollbar::-webkit-scrollbar { display:none; }
.chip { display:inline-flex; align-items:center; gap:.3rem; font-size:.72rem; font-weight:600; padding:.2rem .5rem; border-radius:8px; background:rgba(99,102,241,.1); color:#4f46e5; cursor:pointer; transition:.12s; }
.chip:hover { background:rgba(99,102,241,.2); }
html.dark .chip { color:#c7d2fe; }

/* ============================ User Guide ============================ */
.guide-layout { display: grid; grid-template-columns: 232px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .guide-layout { grid-template-columns: 1fr; } .guide-toc { display: none; } }
.guide-toc-link.active { background: rgba(99,102,241,.12); color: var(--brand-600); font-weight: 600; }
html.dark .guide-toc-link.active { background: rgba(99,102,241,.18); color: #c7d2fe; }

.guide-body { color: #334155; line-height: 1.65; font-size: 14px; }
html.dark .guide-body { color: #cbd5e1; }
.guide-body h4 { font-weight: 700; font-size: 14px; color: #0f172a; margin: 0 0 6px; }
html.dark .guide-body h4 { color: #f1f5f9; }
.guide-body p { margin: 0 0 10px; }
.guide-body .lead { font-size: 15.5px; color: #1e293b; }
html.dark .guide-body .lead { color: #e2e8f0; }
.guide-body a { color: var(--brand-600); }
.guide-body strong { color: #0f172a; }
html.dark .guide-body strong { color: #f1f5f9; }
.guide-body .mono, .guide-body code.mono { font-family: ui-monospace, 'Cascadia Code', monospace; font-size: 12.5px;
  background: rgba(148,163,184,.14); padding: 1px 6px; border-radius: 6px; }

.guide-body .bul { list-style: none; margin: 8px 0; padding: 0; }
.guide-body .bul li { position: relative; padding-left: 20px; margin: 6px 0; }
.guide-body .bul li::before { content: ''; position: absolute; left: 4px; top: 9px; width: 6px; height: 6px;
  border-radius: 999px; background: var(--brand); }

.guide-body .callout { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; padding: 12px 14px;
  border-radius: 12px; background: rgba(99,102,241,.08); border: 1px solid rgba(99,102,241,.18); font-size: 13.5px; }
.guide-body .callout svg { color: var(--brand-600); flex-shrink: 0; margin-top: 1px; }
.guide-body .callout.warn { background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.28); }
.guide-body .callout.warn svg { color: #d97706; }

.guide-body .gtable { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13.5px; }
.guide-body .gtable th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: #94a3b8; padding: 6px 12px; border-bottom: 1px solid rgba(148,163,184,.25); }
.guide-body .gtable td { padding: 8px 12px; border-bottom: 1px solid rgba(148,163,184,.14); vertical-align: top; }
.guide-body .gtable td:first-child { white-space: nowrap; }

.guide-body .tokwrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; margin: 8px 0; }
.guide-body .tokrow { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.guide-body .tokrow span { color: #64748b; }
html.dark .guide-body .tokrow span { color: #94a3b8; }

.flowgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.flowcard { display: block; padding: 14px; border-radius: 14px; border: 1px solid rgba(148,163,184,.2);
  background: rgba(255,255,255,.5); transition: transform .15s, box-shadow .15s, border-color .15s; }
html.dark .flowcard { background: rgba(15,23,42,.4); border-color: rgba(148,163,184,.14); }
.flowcard:hover { transform: translateY(-2px); border-color: rgba(99,102,241,.4); box-shadow: 0 8px 24px rgba(2,6,23,.10); }
.flowcard .fc-t { font-weight: 700; color: #0f172a; font-size: 14px; }
html.dark .flowcard .fc-t { color: #f1f5f9; }
.flowcard .fc-d { font-size: 12.5px; color: #64748b; margin-top: 4px; line-height: 1.5; }
html.dark .flowcard .fc-d { color: #94a3b8; }

.guide-body .faq dt { font-weight: 700; color: #0f172a; margin-top: 12px; }
html.dark .guide-body .faq dt { color: #f1f5f9; }
.guide-body .faq dd { margin: 4px 0 0; color: #475569; }
html.dark .guide-body .faq dd { color: #cbd5e1; }

/* Nav badge (support unread) */
.nav-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; font-size: 11px;
  font-weight: 700; display: inline-grid; place-items: center; background: #6366f1; color: #fff; line-height: 1; }
.nav-link .nav-badge { margin-left: auto; }
