/* ============================================================
   AI Design Platform — Custom Styles
   Tailwind CDN handles utilities; this file covers custom
   components that can't be expressed with Tailwind alone.
   ============================================================ */

/* ---------- Root Variables ---------- */
:root {
  --color-canvas-bg: #0f172a;
  --color-node-bg: #1e293b;
  --color-node-border: #334155;
  --color-input: #3b82f6;
  --color-model: #8b5cf6;
  --color-utility: #f59e0b;
  --color-output: #10b981;
  --color-accent: #6366f1;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0f172a; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ---------- Node Canvas ---------- */
.node-canvas-wrapper {
  position: relative;
  overflow: auto;
  width: 100%;
  height: 100%;
  background: var(--color-canvas-bg);
  cursor: default;
}

.node-canvas {
  position: relative;
  width: 3000px;
  height: 2000px;
  background-image:
    radial-gradient(circle, #1e293b 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ---------- Workflow Node ---------- */
.workflow-node {
  position: absolute;
  min-width: 200px;
  max-width: 240px;
  background: var(--color-node-bg);
  border: 2px solid var(--color-node-border);
  border-radius: 10px;
  cursor: default;
  user-select: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 10;
  transition: box-shadow 0.15s;
}

.workflow-node.selected {
  box-shadow:
    0 0 0 2px var(--color-accent),
    0 4px 20px rgba(0, 0, 0, 0.5);
}

.workflow-node.running .node-status {
  background: #fbbf24;
  animation: blink 0.6s ease-in-out infinite;
}

.workflow-node.done .node-status { background: #10b981; }
.workflow-node.error .node-status { background: #ef4444; }

/* ---------- Node Header ---------- */
.node-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px 8px 0 0;
  cursor: move;
  user-select: none;
}

.node-icon { font-size: 14px; flex-shrink: 0; }

.node-label {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-status {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
}

.node-delete {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}
.node-delete:hover {
  color: #fff;
  background: rgba(239, 68, 68, 0.4);
}

/* ---------- Node Body & Ports ---------- */
.node-body {
  padding: 8px 10px;
}

.port-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  min-height: 20px;
}

.output-row { justify-content: flex-end; }

.port {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #475569;
  background: var(--color-node-bg);
  cursor: crosshair;
  flex-shrink: 0;
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
  position: relative;
}

.port:hover { transform: scale(1.4); }
.input-port  { border-color: var(--color-input); }
.output-port { border-color: var(--color-output); }

.port.port-connected  { background: #334155; }
.port.connecting-source { background: var(--color-accent); border-color: var(--color-accent); transform: scale(1.4); }

/* pulse on compatible input ports during connection mode */
.connecting-mode .input-port {
  animation: port-pulse 1s ease-in-out infinite;
}

.port-label {
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
}

/* ---------- SVG Overlay ---------- */
.node-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: visible;
}

.connection-path {
  pointer-events: stroke;
  cursor: pointer;
  transition: stroke 0.15s, stroke-width 0.15s;
}

.connection-path:hover {
  stroke: #ef4444 !important;
  stroke-width: 3px;
}

@media (max-width: 1024px) {
  .workflow-node {
    min-width: 220px;
    max-width: 260px;
  }

  .node-header {
    padding: 10px 12px;
  }

  .port-row {
    margin: 6px 0;
    min-height: 28px;
  }

  .port {
    width: 16px;
    height: 16px;
  }

  .port::after {
    content: '';
    position: absolute;
    inset: -8px;
  }

  .port-label {
    font-size: 12px;
  }

  .palette-item {
    min-height: 42px;
  }

  .config-input {
    font-size: 16px;
  }
}

/* ---------- Node Palette ---------- */
.palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: grab;
  user-select: none;
  border: 1px solid #1e293b;
  background: #0f172a;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
}
.palette-item:hover {
  background: #1e293b;
  border-color: #334155;
}
.palette-item:active { transform: scale(0.97); }

/* ---------- Config Panel ---------- */
.config-panel {
  width: 280px;
  min-width: 280px;
  background: #0f172a;
  border-left: 1px solid #1e293b;
  overflow-y: auto;
  display: flex;
  flex-direction: direction;
  flex-direction: column;
}

.config-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.config-input {
  width: 100%;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 12px;
  padding: 6px 8px;
  outline: none;
  transition: border-color 0.15s;
}
.config-input:focus { border-color: var(--color-accent); }
.config-input::placeholder { color: #475569; }

textarea.config-input { resize: vertical; min-height: 60px; }

/* ---------- Role Cards (Landing) ---------- */
.role-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 36px 48px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  cursor: pointer;
}
.role-card:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-3px);
}
.role-card .role-icon { font-size: 48px; }
.role-card h2 { font-size: 20px; font-weight: 700; color: #f1f5f9; }
.role-card p  { font-size: 13px; color: #64748b; }

/* ---------- Workflow Card ---------- */
.workflow-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 18px;
  transition: border-color 0.15s, transform 0.15s;
}
.workflow-card:hover {
  border-color: #475569;
  transform: translateY(-2px);
}

/* ---------- Status Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge-draft     { background: rgba(100, 116, 139, 0.2); color: #94a3b8; }
.badge-published { background: rgba(16, 185, 129, 0.15); color: #34d399; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: slide-in 0.2s ease;
}
.toast-success { background: #059669; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #4f46e5; }

/* ---------- Client Form ---------- */
.client-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}
.client-input {
  width: 100%;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #f1f5f9;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.client-input:focus { border-color: var(--color-accent); }
.client-input::placeholder { color: #475569; }

/* ---------- Result Block ---------- */
.result-block {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 16px;
}
.result-block h3 {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.result-text {
  color: #e2e8f0;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.result-image {
  max-width: 100%;
  border-radius: 8px;
  display: block;
}

/* ---------- Progress Bar ---------- */
.progress-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #0f172a;
  font-size: 13px;
  color: #94a3b8;
  border-left: 3px solid #334155;
}
.progress-node.running { border-color: #fbbf24; color: #fbbf24; }
.progress-node.done    { border-color: #10b981; color: #10b981; }
.progress-node.error   { border-color: #ef4444; color: #ef4444; }

/* ---------- Animations ---------- */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}
@keyframes port-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0.4); }
  50%       { box-shadow: 0 0 0 4px rgba(99,102,241,0); transform: scale(1.3); }
}
@keyframes slide-in {
  from { transform: translateX(24px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spin { animation: spin 0.8s linear infinite; display: inline-block; }

/* ---------- Client Shell ---------- */
:root {
  --client-shell-topbar-height: 72px;
  --client-shell-sidebar-width: 92px;
  --client-shell-bottom-nav-height: 78px;
  --mobile-safe-top: env(safe-area-inset-top, 0px);
  --mobile-safe-right: env(safe-area-inset-right, 0px);
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-safe-left: env(safe-area-inset-left, 0px);
  --client-shell-bg: #f5f7fc;
  --client-shell-surface: rgba(255, 255, 255, 0.9);
  --client-shell-line: rgba(191, 200, 219, 0.7);
  --client-shell-text: #182338;
  --client-shell-muted: #64748b;
  --client-shell-accent: #5b6cff;
  --client-shell-accent-soft: rgba(91, 108, 255, 0.1);
}

html {
  background: #f7f8fc;
}

body.mobile-app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

body.mobile-app-standalone {
  min-height: 100dvh;
}

body.client-shell-page {
  background:
    radial-gradient(circle at top left, rgba(91, 108, 255, 0.08), transparent 24%),
    linear-gradient(180deg, #f9fbff 0%, var(--client-shell-bg) 100%);
  padding-top: calc(var(--client-shell-topbar-height) + var(--mobile-safe-top));
  padding-left: var(--client-shell-sidebar-width);
}

body.client-shell-page > nav {
  display: none;
}

#client-shell-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  height: calc(var(--client-shell-topbar-height) + var(--mobile-safe-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(var(--mobile-safe-top) + 14px) calc(var(--mobile-safe-right) + 24px) 14px calc(var(--mobile-safe-left) + 22px);
  border-bottom: 1px solid var(--client-shell-line);
  background: rgba(248, 250, 255, 0.86);
  backdrop-filter: blur(18px);
}

.client-shell-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.client-shell-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(91, 108, 255, 0.14);
  background: linear-gradient(135deg, #ffffff 0%, #eef2ff 100%);
  box-shadow: 0 8px 18px rgba(91, 108, 255, 0.08);
  color: var(--client-shell-accent);
  font-size: 18px;
  font-weight: 700;
}

.client-shell-brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.client-shell-brand-title {
  color: var(--client-shell-text);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.client-shell-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.client-shell-pill,
.client-shell-icon-btn,
.client-shell-avatar {
  border: 1px solid var(--client-shell-line);
  background: var(--client-shell-surface);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.client-shell-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--client-shell-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.client-shell-pill strong {
  color: var(--client-shell-text);
}

.client-shell-pill-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(91, 108, 255, 0.12);
  color: var(--client-shell-accent, #4f46e5);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.client-shell-pill--link {
  cursor: pointer;
}

.client-shell-pill--link:hover {
  transform: translateY(-1px);
  border-color: rgba(91, 108, 255, 0.34);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.12);
}

.client-shell-icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
}

.client-shell-icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--client-shell-accent);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.client-shell-icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(91, 108, 255, 0.34);
}

.client-shell-avatar {
  min-width: 42px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--client-shell-text);
  font-size: 14px;
  font-weight: 700;
}

.client-shell-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.client-shell-avatar-default {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #4f46e5;
  background: rgba(238, 242, 255, 0.9);
}

.client-shell-avatar-default svg {
  width: 20px;
  height: 20px;
}

#client-shell-sidebar {
  position: fixed;
  left: 0;
  top: calc(var(--client-shell-topbar-height) + var(--mobile-safe-top));
  bottom: 0;
  z-index: 70;
  width: var(--client-shell-sidebar-width);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 12px;
  border-right: 1px solid var(--client-shell-line);
  background: rgba(247, 249, 254, 0.88);
  backdrop-filter: blur(14px);
}

.client-shell-nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border: 1px solid transparent;
  border-radius: 22px;
  color: var(--client-shell-muted);
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.client-shell-nav-link:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(91, 108, 255, 0.14);
  color: var(--client-shell-text);
}

.client-shell-nav-link.is-active {
  background: var(--client-shell-accent-soft);
  border-color: rgba(91, 108, 255, 0.22);
  color: var(--client-shell-accent);
  box-shadow: 0 10px 24px rgba(91, 108, 255, 0.12);
}

.client-shell-nav-icon {
  width: 40px;
  height: 40px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.72);
  font-size: 20px;
}

.client-shell-nav-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.client-shell-nav-text {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

#client-shell-mobile-nav {
  display: none;
}

body.client-shell-page.client-shell-with-app #app {
  height: calc(100vh - var(--client-shell-topbar-height) - 24px);
  margin: 12px;
}

body.client-shell-page.client-shell-with-main main {
  padding-top: 20px;
  padding-bottom: 24px;
}

@media (max-width: 1024px) {
  body.client-shell-page {
    padding-left: 0;
    padding-bottom: var(--client-shell-bottom-nav-height);
  }

  #client-shell-sidebar {
    display: none;
  }

  #client-shell-topbar {
    padding-inline: calc(16px + var(--mobile-safe-left)) calc(16px + var(--mobile-safe-right));
  }

  body.client-shell-page.client-shell-with-app #app {
    height: auto;
    margin: 12px;
  }

  #client-shell-mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 85;
    display: grid;
    gap: 8px;
    padding: 10px calc(12px + var(--mobile-safe-right)) calc(var(--mobile-safe-bottom) + 10px) calc(12px + var(--mobile-safe-left));
    border-top: 1px solid var(--client-shell-line);
    background: rgba(248, 250, 255, 0.92);
    backdrop-filter: blur(18px);
  }

  .client-shell-mobile-link {
    display: flex;
    min-height: 56px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 18px;
    color: var(--client-shell-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
  }

  .client-shell-mobile-link.is-active {
    color: var(--client-shell-accent);
    background: var(--client-shell-accent-soft);
  }
}

@media (max-width: 640px) {
  :root {
    --client-shell-topbar-height: 64px;
  }

  .client-shell-brand-title {
    font-size: 16px;
  }

  .client-shell-pill {
    padding: 8px 12px;
    font-size: 12px;
  }

  .client-shell-toolbar {
    gap: 8px;
  }
}

@media (display-mode: standalone) {
  body.mobile-app-shell {
    min-height: 100dvh;
  }
}

/* =============================================================
 * UI common tokens + components (ui-common.js companion)
 * ============================================================= */
:root {
  --ui-radius-sm: 12px;
  --ui-radius-md: 18px;
  --ui-radius-lg: 24px;
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-6: 24px;
  --ui-space-8: 32px;
  --ui-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --ui-shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
  --ui-shadow-lg: 0 20px 44px rgba(16, 24, 40, 0.12);
  --ui-focus-ring: 0 0 0 3px rgba(107, 92, 255, 0.35);
  --ui-tap-min: 44px;
  --ui-accent: #6b5cff;
  --ui-accent-strong: #5a48f5;
  --ui-text: #1f2333;
  --ui-muted: #6b7280;
  --ui-border: rgba(143, 154, 196, 0.24);
}

/* Global keyboard focus polish — only visible when navigating by keyboard */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--ui-focus-ring);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--ui-tap-min);
  padding: 10px 20px;
  border-radius: var(--ui-radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.1s ease, border-color 0.18s ease, opacity 0.18s ease;
  user-select: none;
}
.btn:disabled,
.btn.is-loading {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: ui-spin 0.7s linear infinite;
}
.btn-primary {
  background: linear-gradient(135deg, var(--ui-accent), var(--ui-accent-strong));
  color: #fff;
  box-shadow: 0 6px 16px rgba(107, 92, 255, 0.28);
}
.btn-primary:hover:not(:disabled):not(.is-loading) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(107, 92, 255, 0.35);
}
.btn-primary:active:not(:disabled):not(.is-loading) { transform: translateY(0); }
.btn-secondary {
  background: rgba(107, 92, 255, 0.08);
  color: var(--ui-accent);
  border-color: rgba(107, 92, 255, 0.28);
}
.btn-secondary:hover:not(:disabled):not(.is-loading) { background: rgba(107, 92, 255, 0.12); }
.btn-ghost { background: transparent; color: var(--ui-text); }
.btn-ghost:hover:not(:disabled):not(.is-loading) { background: rgba(16, 24, 40, 0.05); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 14px; font-size: 13px; }

@keyframes ui-spin { to { transform: rotate(360deg); } }

/* Cards */
.card {
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-sm);
  padding: var(--ui-space-6);
}
.card-glass {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--ui-shadow-md);
  padding: var(--ui-space-6);
}

/* Form input baseline (opt-in via class) */
.form-input {
  width: 100%;
  min-height: var(--ui-tap-min);
  padding: 10px 14px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-md);
  background: #fff;
  color: var(--ui-text);
  font-size: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.form-input:focus { outline: none; border-color: var(--ui-accent); }
.form-input:focus-visible { outline: none; box-shadow: var(--ui-focus-ring); }

/* Skeleton loaders */
@keyframes ui-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  position: relative;
  background: linear-gradient(90deg, #edeef4 0%, #f5f6fa 50%, #edeef4 100%);
  background-size: 800px 100%;
  animation: ui-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--ui-radius-md);
}
.skeleton-card {
  padding: 0;
  overflow: hidden;
  border-radius: var(--ui-radius-md);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--ui-border);
  animation: none;
}
.skeleton-card::after { display: none; }
.skeleton-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: linear-gradient(90deg, #edeef4 0%, #f5f6fa 50%, #edeef4 100%);
  background-size: 800px 100%;
  animation: ui-shimmer 1.4s ease-in-out infinite;
}
.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #edeef4 0%, #f5f6fa 50%, #edeef4 100%);
  background-size: 800px 100%;
  animation: ui-shimmer 1.4s ease-in-out infinite;
  margin: 0 14px;
}
.skeleton-line-title { height: 14px; width: 60%; margin-top: 4px; }
.skeleton-line-body  { height: 11px; width: 88%; margin-bottom: 14px; }
.skeleton-row {
  background: #fff;
  border: 1px solid var(--ui-border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: none;
}
.skeleton-row .skeleton-line { margin: 0; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px;
  color: var(--ui-muted);
  gap: var(--ui-space-2);
}
.empty-state-icon {
  font-size: 44px;
  opacity: 0.75;
  line-height: 1;
}
.empty-state-title {
  color: var(--ui-text);
  font-size: 16px;
  font-weight: 700;
}
.empty-state-desc {
  font-size: 13px;
  line-height: 1.6;
  max-width: 380px;
}
.empty-state--error .empty-state-icon { color: #b45309; opacity: 0.9; }
.empty-state--error .empty-state-title { color: #b45309; }

/* Password visibility toggle */
.password-field {
  position: relative;
  display: block;
}
.password-field > input { width: 100%; padding-right: 44px; }
.password-field > .password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  color: var(--ui-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.password-field > .password-toggle:hover { color: var(--ui-accent); background: rgba(107, 92, 255, 0.08); }
.password-field > .password-toggle:focus-visible { outline: none; box-shadow: var(--ui-focus-ring); }
.password-field > .password-toggle svg { width: 18px; height: 18px; pointer-events: none; }
.password-field > .password-toggle .pw-eye-off { display: none; }
.password-field > .password-toggle[aria-pressed="true"] .pw-eye-on { display: none; }
.password-field > .password-toggle[aria-pressed="true"] .pw-eye-off { display: block; }

/* Toast polish (coexists with any pre-existing #toast-container) */
#toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
#toast-container .toast {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: 12px;
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.18);
  transition: opacity 0.24s ease, transform 0.24s ease;
  max-width: min(360px, 90vw);
}
#toast-container .toast-success { background: #059669; }
#toast-container .toast-error   { background: #dc2626; }
#toast-container .toast-warn    { background: #b45309; }
#toast-container .toast-info    { background: #1f2937; }

/* Responsive hero title helper */
.ui-h1-fluid {
  font-size: clamp(28px, 4vw + 8px, 52px);
  font-weight: 700;
  line-height: 1.1;
}

/* Mobile horizontal overflow guard */
@media (max-width: 640px) {
  html, body { max-width: 100%; }
  main { overflow-x: hidden; }
}

/* Touch target boost on small touch screens */
@media (max-width: 640px) and (hover: none) {
  .btn-sm { min-height: 40px; }
}

/* ==========================================================================
   Pager — 移动端友好的一体化 pill 分页（UI.renderPager 输出结构）
   桌面端默认隐藏（由调用方决定是否 mount，或用 @media 控制）
   ========================================================================== */
.pager {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  width: 100%;
  flex: 1 1 auto; /* fills parent whether parent is block or flex */
}

.pager-pill {
  display: inline-flex;
  align-items: stretch;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(198, 210, 225, 0.7);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  -webkit-tap-highlight-color: transparent;
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.16s ease, color 0.16s ease, transform 0.1s ease;
}

.pager-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pager-btn:hover {
  background: rgba(79, 70, 229, 0.08);
  color: #4f46e5;
}

.pager-btn:active:not([disabled]) {
  transform: scale(0.94);
  background: rgba(79, 70, 229, 0.14);
}

.pager-btn[disabled] {
  cursor: not-allowed;
  color: #cbd5e1;
  background: transparent;
}

.pager-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(107, 92, 255, 0.35);
}

.pager-current {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  min-width: 72px;
  padding: 0 14px;
  font-variant-numeric: tabular-nums;
  color: #1f2937;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.pager-current span {
  font-size: 20px;
  color: #4f46e5;
}

.pager-current em {
  font-style: normal;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 700;
}

.pager-input {
  font: inherit;
  font-size: 20px;
  color: #4f46e5;
  font-weight: 800;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  width: 2.4ch;
  min-width: 32px;
  max-width: 68px;
  text-align: center;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  outline: none;
  cursor: text;
  -moz-appearance: textfield;
  appearance: textfield;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.pager-input::-webkit-outer-spin-button,
.pager-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pager-input:hover {
  border-color: rgba(99, 102, 241, 0.25);
  background: rgba(238, 242, 255, 0.6);
}

.pager-input:focus,
.pager-input:focus-visible {
  border-color: rgba(79, 70, 229, 0.55);
  background: rgba(238, 242, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(107, 92, 255, 0.2);
}

.pager-meta {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

@media (max-width: 480px) {
  .pager { gap: 6px; margin-top: 16px; }
  .pager-btn { width: 46px; height: 46px; }
  .pager-current { min-width: 76px; padding: 0 16px; }
  .pager-current span { font-size: 22px; }
  .pager-input { font-size: 22px; min-width: 36px; }
  .pager-meta { font-size: 13px; }
}

/* ==========================================================================
   Pager — 桌面端数字化分页（参考 Ant Design）
   ≤480px 显示 .pager-pill；>480px 显示 .pager-list。
   ========================================================================== */
.pager-list { display: none; }

@media (min-width: 481px) {
  /* Desktop footer layout: meta 左下角，pager-list 右下角，同行对齐 */
  .pager {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    flex-wrap: wrap;
  }
  .pager-pill { display: none; }
  .pager-list {
    order: 1;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .pager-meta {
    order: 0;
    margin: 0;
  }
  .pager-list .pager-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(203, 213, 225, 0.8);
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  }
  .pager-list .pager-btn svg { width: 14px; height: 14px; stroke-width: 2.4; }
  .pager-list .pager-btn:hover:not([disabled]) {
    border-color: rgba(99, 102, 241, 0.55);
    color: #4f46e5;
    background: #fff;
  }
  .pager-list .pager-btn[disabled] {
    color: #cbd5e1;
    background: #f8fafc;
    border-color: rgba(226, 232, 240, 0.9);
  }
  .pager-num,
  .pager-ellipsis {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid rgba(203, 213, 225, 0.8);
    background: #fff;
    color: #475569;
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  }
  .pager-num:hover,
  .pager-ellipsis:hover {
    border-color: rgba(99, 102, 241, 0.55);
    color: #4f46e5;
  }
  .pager-num:active:not(.is-current),
  .pager-ellipsis:active {
    transform: scale(0.96);
  }
  .pager-num.is-current {
    border-color: #6366f1;
    color: #4f46e5;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.35) inset;
    cursor: default;
  }
  .pager-num:focus-visible,
  .pager-ellipsis:focus-visible,
  .pager-list .pager-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(107, 92, 255, 0.3);
  }
  .pager-ellipsis {
    border-color: transparent;
    background: transparent;
    color: #94a3b8;
    font-weight: 600;
    padding: 0 4px;
    min-width: 32px;
  }
  .pager-ellipsis-dots,
  .pager-ellipsis-hint {
    display: inline-block;
    transition: opacity 0.15s ease;
  }
  .pager-ellipsis-hint {
    position: absolute;
    inset: 0;
    line-height: 36px;
    color: #4f46e5;
    font-weight: 800;
    opacity: 0;
  }
  .pager-ellipsis:hover .pager-ellipsis-dots,
  .pager-ellipsis-wrap:hover .pager-ellipsis .pager-ellipsis-dots { opacity: 0; }
  .pager-ellipsis:hover .pager-ellipsis-hint,
  .pager-ellipsis-wrap:hover .pager-ellipsis .pager-ellipsis-hint { opacity: 1; }

  /* Hover popover: lists all hidden pages, click to jump */
  .pager-ellipsis-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
  }
  .pager-ellipsis-popover {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    min-width: 72px;
    max-height: 220px;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #fff;
    border: 1px solid rgba(203, 213, 225, 0.85);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
    z-index: 30;
    scrollbar-width: thin;
  }
  /* Bridge the 4px gap so cursor can travel into the popover without the hover dropping */
  .pager-ellipsis-wrap::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 8px;
    pointer-events: none;
  }
  .pager-ellipsis-wrap:hover::before,
  .pager-ellipsis-wrap:focus-within::before {
    pointer-events: auto;
  }
  .pager-ellipsis-wrap:hover .pager-ellipsis-popover,
  .pager-ellipsis-wrap:focus-within .pager-ellipsis-popover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
  }
  .pager-popover-num {
    min-width: 60px;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.12s ease, color 0.12s ease;
  }
  .pager-popover-num:hover,
  .pager-popover-num:focus-visible {
    outline: none;
    background: rgba(99, 102, 241, 0.1);
    color: #4f46e5;
  }
  .pager-ellipsis-popover::-webkit-scrollbar { width: 6px; }
  .pager-ellipsis-popover::-webkit-scrollbar-thumb {
    background: rgba(203, 213, 225, 0.8);
    border-radius: 999px;
  }
}
