/* ==========================================================================
   Continuum Forge — Premium Sci-Fi Theme (Alpha 1.5)
   ========================================================================== */

/* --- Design tokens --- */
:root {
  --bg: #0a0e17;
  --bg-elevated: #111827;
  --bg-card: #151d2e;
  --panel: rgba(21, 29, 46, 0.85);
  --panel-2: rgba(17, 24, 39, 0.92);
  --border: rgba(100, 130, 180, 0.22);
  --border-bright: rgba(34, 211, 238, 0.35);
  --text: #eef4ff;
  --text-muted: #94a3b8;
  --accent: #22d3ee;
  --accent-2: #818cf8;
  --accent-dim: #0891b2;
  --accent-violet: #a78bfa;
  --accent-glow: rgba(34, 211, 238, 0.18);
  --accent-glow-strong: rgba(34, 211, 238, 0.32);
  --violet-glow: rgba(129, 140, 248, 0.15);
  --danger: #f87171;
  --success: #34d399;
  --warning: #fbbf24;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Fira Code", "Consolas", monospace;
  --sidebar-width: 248px;
  --sidebar-collapsed-width: 68px;
  --topbar-height: 52px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 24px rgba(34, 211, 238, 0.12);
  --transition: 0.18s ease;
}

html.sidebar-collapsed {
  --sidebar-width: var(--sidebar-collapsed-width);
}

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body.has-sidebar {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(34, 211, 238, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(129, 140, 248, 0.06), transparent),
    radial-gradient(ellipse 50% 30% at 0% 80%, rgba(8, 145, 178, 0.05), transparent),
    linear-gradient(180deg, #0a0e17 0%, #0d1220 50%, #0a0e17 100%);
}

body.has-sidebar::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(100, 130, 180, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 130, 180, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, black 20%, transparent 75%);
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: #67e8f9; text-decoration: none; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Glass panels & cards --- */
.glass-panel,
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  border-color: rgba(100, 130, 180, 0.32);
}

/* --- App shell --- */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.97) 0%, rgba(10, 14, 23, 0.98) 100%);
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.22s ease;
  z-index: 200;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.15rem 0.85rem 0.65rem;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(100, 130, 180, 0.12);
  margin-bottom: 0.35rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.98rem;
  min-width: 0;
  letter-spacing: -0.01em;
}
.sidebar-brand:hover { color: var(--accent); text-decoration: none; }
.sidebar-brand-icon {
  color: var(--accent);
  flex-shrink: 0;
  font-size: 1.2rem;
  text-shadow: 0 0 12px var(--accent-glow-strong);
}
.sidebar-brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

html.sidebar-collapsed .sidebar-brand-text,
html.sidebar-collapsed .sidebar-alpha,
html.sidebar-collapsed .sidebar-toggle-label,
html.sidebar-collapsed .sidebar-label,
html.sidebar-collapsed .sidebar-section-label,
html.sidebar-collapsed .sidebar-context,
html.sidebar-collapsed .sidebar-user-info,
html.sidebar-collapsed .badge-soon {
  display: none;
}

html.sidebar-collapsed .sidebar-header { justify-content: center; padding: 0.85rem 0.25rem; }
html.sidebar-collapsed .sidebar-brand { justify-content: center; }
html.sidebar-collapsed .sidebar-link { justify-content: center; padding: 0.6rem; }
html.sidebar-collapsed .sidebar-toggle { justify-content: center; }
html.sidebar-collapsed .profile-card { justify-content: center; padding: 0.5rem; }
html.sidebar-collapsed .sidebar-user-avatar { margin: 0; }

.brand-tag {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border-bright);
  color: var(--accent);
  border-radius: var(--radius-pill);
  background: var(--accent-glow);
  box-shadow: 0 0 12px var(--accent-glow);
}
.sidebar-alpha { flex-shrink: 0; }

.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0.75rem 0.55rem;
  padding: 0.5rem 0.7rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  width: calc(100% - 1.5rem);
  transition: all var(--transition);
}
.sidebar-toggle:hover {
  border-color: var(--border-bright);
  color: var(--accent);
  background: var(--accent-glow);
  box-shadow: var(--shadow-glow);
}
html.sidebar-collapsed .sidebar-toggle-icon { transform: scaleX(-1); }

.sidebar-nav { flex: 1; padding: 0 0.55rem; }
.sidebar-section-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0.85rem 0.55rem 0.4rem;
  padding: 0;
  opacity: 0.85;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  margin-bottom: 0.2rem;
  border: 1px solid transparent;
  transition: all var(--transition);
}
.sidebar-link:hover {
  background: var(--accent-glow);
  color: var(--accent);
  text-decoration: none;
  border-color: rgba(34, 211, 238, 0.15);
}
.sidebar-link.active {
  background: linear-gradient(90deg, var(--accent-glow) 0%, var(--violet-glow) 100%);
  color: var(--accent);
  border-color: var(--border-bright);
  box-shadow: 0 0 16px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-weight: 500;
}
.sidebar-link-sub { padding-left: 1.1rem; font-size: 0.84rem; opacity: 0.92; }
.sidebar-link-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.sidebar-icon { flex-shrink: 0; width: 1.3rem; text-align: center; font-size: 0.95rem; }
.sidebar-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge-soon {
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.12rem 0.4rem;
  border: 1px solid rgba(129, 140, 248, 0.35);
  color: var(--accent-2);
  background: var(--violet-glow);
  border-radius: var(--radius-pill);
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar-context {
  margin: 0.55rem 0.75rem;
  padding: 0.75rem 0.85rem;
  background: rgba(21, 29, 46, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent-dim);
}
.sidebar-context-text { margin: 0; font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: rgba(0, 0, 0, 0.15);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.7rem;
  margin-bottom: 0.55rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sidebar-user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent-dim), var(--accent-2));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--accent-glow);
}
.sidebar-user-info { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.sidebar-user-name { font-size: 0.88rem; color: var(--text); font-weight: 600; }
.sidebar-link-logout { margin-bottom: 0; }

/* --- Top bar --- */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--topbar-height);
  padding: 0 1.35rem;
  background: rgba(17, 24, 39, 0.88);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-toggle-mobile {
  display: none;
  margin: 0;
  width: auto;
  padding: 0.45rem 0.6rem;
}

.app-topbar-title {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.app-topbar-user {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0.65rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.user-label { font-size: 0.82rem; color: var(--text-muted); }

.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.65rem 1.5rem 2rem;
}

/* --- Auth / Login --- */
.main-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(34, 211, 238, 0.12), transparent),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(129, 140, 248, 0.1), transparent),
    var(--bg);
  position: relative;
}

.main-auth::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(100, 130, 180, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 130, 180, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.auth-shell { width: 100%; max-width: 420px; position: relative; z-index: 1; }
.auth-card {
  width: 100%;
  box-shadow: var(--shadow-md), 0 0 48px rgba(34, 211, 238, 0.08);
  border-color: var(--border-bright);
}
.auth-header { text-align: center; margin-bottom: 1.65rem; }
.auth-brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.auth-brand-icon {
  font-size: 1.5rem;
  color: var(--accent);
  text-shadow: 0 0 16px var(--accent-glow-strong);
}
.auth-header h1 {
  margin: 0;
  font-size: 1.65rem;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle { color: var(--text-muted); margin: 0; font-size: 0.9rem; }

/* --- Page headers --- */
.page-header { margin-bottom: 1.65rem; }
.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 0.35rem;
  font-weight: 600;
}
.page-subtitle { color: var(--text-muted); margin: 0; font-size: 0.95rem; }
.page-subtitle strong { color: var(--text); }
.page-note {
  color: var(--text-muted);
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
  padding: 0.35rem 0.65rem;
  background: var(--violet-glow);
  border-radius: var(--radius-pill);
  display: inline-block;
  border: 1px solid rgba(129, 140, 248, 0.2);
}
.flex-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.header-actions { display: flex; gap: 0.55rem; flex-wrap: wrap; }

.dashboard-hero { padding-bottom: 0.25rem; }
.panel-desc { color: var(--text-muted); font-size: 0.88rem; margin: -0.35rem 0 0.5rem; }

/* --- Dashboard stats --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.65rem;
}

.stat-card {
  text-align: center;
  padding: 1.65rem 1.15rem;
  position: relative;
  overflow: hidden;
  border-top: 2px solid transparent;
  background: linear-gradient(180deg, rgba(21, 29, 46, 0.9) 0%, rgba(15, 20, 32, 0.85) 100%);
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.85;
}
.stat-card:hover {
  border-color: var(--border-bright);
  box-shadow: var(--shadow-glow), var(--shadow-md);
  transform: translateY(-2px);
}
.stat-value {
  display: block;
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent) 0%, #67e8f9 50%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}
.stat-label {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

/* --- Quick actions --- */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}
.action-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.95rem 1.1rem;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.08) 0%, rgba(17, 24, 39, 0.6) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  text-align: center;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all var(--transition);
}
.action-link:hover {
  border-color: var(--border-bright);
  background: linear-gradient(180deg, var(--accent-glow) 0%, rgba(129, 140, 248, 0.1) 100%);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
  text-decoration: none;
  color: #67e8f9;
}
.action-icon { opacity: 0.85; font-size: 0.95rem; }

/* --- Lists --- */
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.list-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: all var(--transition);
}
.list-card:hover {
  border-color: var(--border-bright);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
  text-decoration: none;
}
.list-card h3 { margin: 0 0 0.5rem; color: var(--text); font-weight: 600; }
.card-desc, .card-meta { color: var(--text-muted); font-size: 0.88rem; margin: 0.25rem 0; }
.card-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.meta { font-size: 0.78rem; color: var(--text-muted); }

/* --- Badges --- */
.badge {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.22rem 0.55rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-weight: 500;
}
.badge-role {
  border-color: rgba(34, 211, 238, 0.4);
  color: var(--accent);
  background: var(--accent-glow);
}
.badge-audience { border-color: rgba(129, 140, 248, 0.45); color: #c4b5fd; background: var(--violet-glow); }
.badge-draft { border-color: rgba(148, 163, 184, 0.4); color: #cbd5e1; background: rgba(148, 163, 184, 0.08); }
.badge-canon { border-color: rgba(52, 211, 153, 0.45); color: var(--success); background: rgba(52, 211, 153, 0.1); }
.badge-experimental { border-color: rgba(251, 191, 36, 0.45); color: var(--warning); background: rgba(251, 191, 36, 0.08); }
.badge-retired { border-color: rgba(168, 162, 158, 0.35); color: #a8a29e; }
.badge-reviewed { border-color: rgba(129, 140, 248, 0.45); color: #c4b5fd; background: var(--violet-glow); }
.badge-approved { border-color: rgba(52, 211, 153, 0.45); color: var(--success); background: rgba(52, 211, 153, 0.1); }
.badge-rejected { border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; background: rgba(248, 113, 113, 0.08); }
.badge-mode { border-color: var(--border-bright); color: var(--accent); text-transform: none; letter-spacing: normal; background: var(--accent-glow); }
.badge-missing { border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; background: rgba(248, 113, 113, 0.08); }
.badge-weak { border-color: rgba(251, 191, 36, 0.45); color: var(--warning); background: rgba(251, 191, 36, 0.08); }
.badge-populated { border-color: rgba(52, 211, 153, 0.45); color: var(--success); background: rgba(52, 211, 153, 0.1); }
.badge-sm { font-size: 0.58rem; padding: 0.15rem 0.4rem; }

/* --- Forms --- */
.form { display: flex; flex-direction: column; gap: 1.1rem; }
.form-card { max-width: 800px; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.form-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.5rem; align-items: center; }

input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
  background: rgba(10, 14, 23, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  font-family: inherit;
  font-size: 0.94rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:hover, select:hover, textarea:hover {
  border-color: rgba(100, 130, 180, 0.35);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-glow);
}
textarea { resize: vertical; min-height: 88px; line-height: 1.6; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-dim) 0%, #06b6d4 50%, var(--accent-2) 100%);
  color: #fff;
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #06b6d4 0%, var(--accent) 50%, #a5b4fc 100%);
  box-shadow: 0 6px 24px rgba(34, 211, 238, 0.35);
  transform: translateY(-1px);
  text-decoration: none;
  color: #fff;
}
.btn-secondary {
  background: rgba(34, 211, 238, 0.08);
  color: var(--accent);
  border-color: var(--border-bright);
}
.btn-secondary:hover {
  background: var(--accent-glow);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
  text-decoration: none;
  color: #67e8f9;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(100, 130, 180, 0.4);
  background: rgba(255, 255, 255, 0.05);
  text-decoration: none;
}
.btn-forge {
  display: block;
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  border-color: var(--border);
  margin-bottom: 0.45rem;
  text-align: left;
  padding: 0.55rem 0.75rem;
  font-weight: 500;
}
.btn-forge:hover {
  border-color: var(--border-bright);
  color: var(--accent);
  background: var(--accent-glow);
  box-shadow: inset 0 0 12px var(--accent-glow);
  text-decoration: none;
  transform: translateX(2px);
}
.btn-sm { padding: 0.38rem 0.7rem; font-size: 0.78rem; }
.btn-block { width: 100%; }

/* --- Detail --- */
.detail-grid { margin-bottom: 1.5rem; display: grid; gap: 1rem; }
.detail-list { margin: 0; }
.detail-list dt {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.85rem;
  font-weight: 600;
}
.detail-list dt:first-child { margin-top: 0; }
.detail-list dd { margin: 0.2rem 0 0; }
.detail-list-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1.5rem; }
.pre-wrap { white-space: pre-wrap; }

.section-title { font-size: 1.05rem; margin: 1.5rem 0 1rem; color: var(--text-muted); font-weight: 600; }
.subsection-title { font-size: 0.95rem; margin: 1.25rem 0 0.75rem; color: var(--accent); font-weight: 600; }

/* --- Character workspace --- */
.character-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
  border-left: 3px solid var(--accent);
  box-shadow: var(--shadow-md), 0 0 32px rgba(34, 211, 238, 0.06);
}
.character-header h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text) 20%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.character-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.65rem; margin-bottom: 0.5rem; }
.character-meta-item { font-size: 0.88rem; color: var(--text-muted); }
.character-meta-item strong { color: var(--text); }
.character-universe { margin: 0; font-size: 0.88rem; color: var(--text-muted); }

.character-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.15rem;
  align-items: start;
}
@media (max-width: 960px) {
  .character-layout { grid-template-columns: 1fr; }
}

.character-sections { display: flex; flex-direction: column; gap: 0.85rem; }
.character-section {
  border-left: 2px solid rgba(34, 211, 238, 0.15);
}
.character-section h2 {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.field-content { margin: 0; color: var(--text); line-height: 1.7; }

.character-traits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
}
.character-traits-grid .card { margin-bottom: 0; }

.character-sidebar { display: flex; flex-direction: column; gap: 1rem; }
.sidebar-section { margin-bottom: 0; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.tag-chip {
  font-size: 0.78rem;
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--violet-glow);
  border: 1px solid rgba(129, 140, 248, 0.3);
  color: #c4b5fd;
}

/* --- AI Forge Panel --- */
.forge-panel { position: sticky; top: calc(var(--topbar-height) + 1rem); }
.panel-forge {
  border-color: rgba(34, 211, 238, 0.35);
  background: linear-gradient(165deg, rgba(34, 211, 238, 0.08) 0%, rgba(129, 140, 248, 0.06) 50%, rgba(21, 29, 46, 0.9) 100%);
  box-shadow: var(--shadow-glow), var(--shadow-md);
}
.panel-forge-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}
.panel-forge-icon {
  color: var(--accent);
  font-size: 1.1rem;
  text-shadow: 0 0 12px var(--accent-glow-strong);
}
.panel-forge h2 {
  margin: 0;
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.forge-notice {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 0.65rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  border: 1px solid rgba(100, 130, 180, 0.15);
}
.forge-actions { margin-top: 0.85rem; }
.forge-links { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.35rem; }
.forge-group {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(100, 130, 180, 0.14);
}
.forge-group:first-of-type { margin-top: 0.65rem; padding-top: 0; border-top: none; }
.forge-group-title {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.forge-group-help {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}
.forge-group-guide { margin-bottom: 0.25rem; }

/* --- AI Action Badges --- */
.ai-action-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1.35;
  white-space: nowrap;
}
.ai-action-badge-calls-local-ai {
  color: #67e8f9;
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.35);
}
.ai-action-badge-prompt-only {
  color: #c4b5fd;
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.32);
}
.ai-action-badge-draft-only {
  color: #2dd4bf;
  background: rgba(45, 212, 191, 0.1);
  border-color: rgba(45, 212, 191, 0.3);
}
.ai-action-badge-review-first {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.28);
}
.ai-action-badge-applies-after-confirm {
  color: #86efac;
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.28);
}
.ai-action-badge-future {
  color: var(--text-muted);
  background: rgba(100, 130, 180, 0.08);
  border-color: rgba(100, 130, 180, 0.22);
}
.ai-action-note { margin: 0.35rem 0 0; }
.ai-workflow-guide-notice { margin-bottom: 1rem; border-color: rgba(56, 189, 248, 0.28); }
.ai-workflow-guide-notice p { margin: 0; font-size: 0.88rem; line-height: 1.55; }
.ai-workflow-doc { max-height: none; }

/* --- AI Drafts --- */
.drafts-panel h2 { margin: 0; font-size: 0.95rem; color: var(--accent); font-weight: 600; }
.draft-compact-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.draft-compact-item {
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(100, 130, 180, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.draft-compact-item:last-child { border-bottom: none; }
.draft-compact-title { font-size: 0.88rem; font-weight: 600; color: var(--text); text-decoration: none; }
.draft-compact-title:hover { color: var(--accent); }
.draft-compact-meta { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.draft-compact-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; align-items: center; }

.draft-list { display: flex; flex-direction: column; gap: 0.85rem; }
.draft-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0;
  transition: all var(--transition);
}
.draft-row:hover {
  border-color: var(--border-bright);
  box-shadow: var(--shadow-glow);
}
.draft-row h3 { margin: 0 0 0.35rem; font-size: 1.02rem; font-weight: 600; }
.draft-row-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 0.35rem; }
.draft-preview { margin: 0; font-size: 0.84rem; color: var(--text-muted); line-height: 1.5; }
.draft-row-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

.draft-status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius);
}
.status-bar-label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
.inline-form { display: inline; margin: 0; }

.response-block {
  background: rgba(10, 14, 23, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  line-height: 1.7;
  font-size: 0.94rem;
}
.draft-meta { padding: 0.75rem 1rem; background: rgba(0, 0, 0, 0.15); }
.draft-meta p { margin: 0; }

/* --- Apply Draft to Field --- */
.apply-success-banner {
  margin-bottom: 1rem;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}
.apply-success-banner p { margin: 0; font-size: 0.9rem; }

/* --- Convert Draft to Character --- */
.convert-notice { margin-bottom: 1rem; border-color: rgba(251, 191, 36, 0.28); }
.convert-draft-panel { margin-bottom: 1rem; border-color: rgba(56, 189, 248, 0.28); }
.convert-draft-panel h2 { margin-top: 0; }
.convert-character-grid { align-items: start; }
.convert-reference-panel h2 { margin-top: 0; }
.convert-reference-textarea { min-height: 420px; font-size: 0.82rem; }
.extract-intelligence-panel { margin-bottom: 1rem; border-color: rgba(167, 139, 250, 0.28); }
.extract-intelligence-panel h2 { margin-top: 0; }
.extract-intelligence-grid { align-items: start; }
.extract-intelligence-main { display: flex; flex-direction: column; gap: 1rem; }
.intelligence-extract-hint { font-size: 0.85rem; margin: 0.5rem 0; }
.field-hint { font-size: 0.82rem; margin: 0.25rem 0 0.5rem; }

/* --- AI Response Cleanup --- */
.ai-cleanup-panel { margin-bottom: 1rem; border-color: rgba(45, 212, 191, 0.28); }
.ai-cleanup-panel h2 { margin-top: 0; }
.ai-cleanup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.ai-cleanup-notice { color: var(--accent-warn, #fbbf24); font-size: 0.88rem; margin: 0.5rem 0; }
.ai-cleanup-subhead { font-size: 0.95rem; margin: 0.75rem 0 0.35rem; }
.ai-cleaned-preview { border-color: rgba(45, 212, 191, 0.25); }
.ai-raw-response-details { margin-top: 0.75rem; }
.ai-raw-response-details summary { cursor: pointer; color: var(--text-muted); font-size: 0.88rem; }
.parsed-fields-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.extracted-fields-list { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0; }
.extracted-field-card h3 { margin-top: 0; }
.extracted-field-textarea { width: 100%; min-height: 120px; }
.compact-actions { margin-top: 0.75rem; }

/* --- Universe Bible --- */
.universe-bible-notice { margin-bottom: 1rem; }
.universe-bible-form { display: flex; flex-direction: column; gap: 0.85rem; }
.bible-section { padding: 0; overflow: hidden; }
.bible-section-summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  user-select: none;
}
.bible-section-summary::-webkit-details-marker { display: none; }
.bible-section-summary h2 { margin: 0; font-size: 1rem; color: var(--accent); }
.bible-section-body { padding: 0 1.15rem 1.15rem; border-top: 1px solid rgba(100, 130, 180, 0.12); }

/* Universe Form AI Assist */
.universe-form-helper-card {
  margin-bottom: 1rem;
  border-color: rgba(56, 189, 248, 0.28);
}
.universe-form-helper-card h2 { margin-top: 0; font-size: 1rem; color: var(--accent); }
.universe-form-helper-card p { margin: 0.35rem 0 0; font-size: 0.9rem; line-height: 1.55; }
.universe-save-first-note {
  margin-top: 0.65rem !important;
  color: var(--accent-warn, #fbbf24);
  font-size: 0.85rem !important;
}
.field-assist-helper-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  margin-top: 0.4rem;
}
.field-assist-mini-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.08);
  color: var(--accent-teal, #2dd4bf);
  text-decoration: none;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s;
}
a.field-assist-mini-btn:hover {
  background: rgba(45, 212, 191, 0.16);
  border-color: rgba(45, 212, 191, 0.55);
  color: var(--accent-teal, #2dd4bf);
}
.field-assist-disabled-pill {
  cursor: not-allowed;
  opacity: 0.55;
  border-color: rgba(100, 130, 180, 0.25);
  background: rgba(100, 130, 180, 0.06);
  color: var(--text-muted);
}
.field-assist-helper-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.universe-form-sticky-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin-top: 0.5rem;
  padding: 0.85rem 0 0.25rem;
  background: linear-gradient(to top, var(--bg) 75%, transparent);
}
.universe-form-sticky-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(100, 130, 180, 0.2);
  border-radius: var(--radius);
  background: rgba(12, 18, 32, 0.92);
  backdrop-filter: blur(8px);
}
.universe-form-sticky-inner .form-actions { margin: 0; }
.universe-form-sticky-note { margin: 0; font-size: 0.82rem; }

/* --- Long form UX --- */
.long-form-shell {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 5rem;
}

.long-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-section-essential,
.form-section-details,
.bible-section {
  scroll-margin-top: calc(var(--topbar-height, 3.5rem) + 1rem);
}

.form-section-essential {
  padding: 1rem 1.15rem;
}

.form-section-essential h2 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  color: var(--accent);
}

.form-section-details {
  padding: 0;
  overflow: hidden;
}

.form-section-summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  user-select: none;
}

.form-section-summary::-webkit-details-marker { display: none; }

.form-section-summary h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--accent);
}

.form-section-details-body {
  padding: 0 1.15rem 1.15rem;
  border-top: 1px solid rgba(100, 130, 180, 0.12);
}

.form-quick-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid rgba(100, 130, 180, 0.18);
  background: rgba(12, 18, 32, 0.55);
}

.form-quick-jump-link {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(100, 130, 180, 0.22);
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.form-quick-jump-link:hover {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.08);
}

.compact-ai-assist-note {
  padding: 0.75rem 1rem;
}

.compact-ai-assist-note p { margin: 0.35rem 0 0; }

.field-helper-muted {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.field-assist-compact {
  margin-top: 0.35rem;
}

.field-assist-compact .field-assist-helper-text { display: none; }

.sticky-form-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
}

@media (max-width: 768px) {
  .universe-form-sticky-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .universe-form-sticky-inner .form-actions {
    width: 100%;
  }
  .universe-form-sticky-inner .form-actions .btn {
    flex: 1;
  }
  .long-form-shell { padding-bottom: 6rem; }
}

.universe-short-pitch { font-size: 1.05rem; color: var(--text-muted); margin: 0.35rem 0; max-width: 720px; }
.universe-badge-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.65rem; }
.bible-completion-card { margin-bottom: 1rem; }
.bible-completion-card h2 { margin-top: 0; font-size: 0.95rem; }
.bible-completion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.65rem;
}
.bible-completion-item {
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid rgba(100, 130, 180, 0.18);
  background: rgba(0, 0, 0, 0.12);
}
.bible-completion-label { display: block; font-size: 0.82rem; font-weight: 600; }
.bible-completion-meta { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; text-transform: capitalize; }
.bible-status-complete { border-color: rgba(34, 197, 94, 0.35); }
.bible-status-partial { border-color: rgba(251, 191, 36, 0.35); }
.bible-status-empty { border-color: rgba(100, 130, 180, 0.15); opacity: 0.85; }
.bible-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.bible-overview-card { padding: 0; overflow: hidden; }
.bible-overview-card summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1rem;
}
.bible-overview-card summary::-webkit-details-marker { display: none; }
.bible-overview-card h2 { margin: 0; font-size: 0.9rem; color: var(--accent); }
.bible-overview-body { padding: 0 1rem 1rem; font-size: 0.88rem; line-height: 1.55; color: var(--text-muted); }
.universe-assist-links-card { margin-bottom: 1rem; }
.universe-assist-links-card h2 { margin-top: 0; font-size: 0.95rem; }
.universe-assist-link-row { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.65rem; }
.universe-assist-target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
  margin: 0.75rem 0 1rem;
}
.universe-assist-target-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
}
.universe-assist-target-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.universe-assist-target-kind {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.ai-wait-note { margin-top: 0.5rem; color: var(--text-muted); font-size: 0.82rem; }

/* --- Local AI thinking / loading --- */
.ai-thinking-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(6px);
}
.ai-thinking-overlay[hidden] { display: none; }
body.ai-request-pending .app-main {
  pointer-events: none;
  user-select: none;
}
.ai-thinking-panel {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  max-width: 480px;
  width: 100%;
  padding: 1.35rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.96), rgba(8, 14, 28, 0.98));
  box-shadow: 0 0 40px rgba(56, 189, 248, 0.15), var(--shadow-glow);
}
.ai-thinking-panel strong {
  display: block;
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.ai-thinking-panel p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.ai-thinking-orb {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(125, 211, 252, 0.9), rgba(56, 189, 248, 0.25) 55%, transparent 70%);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.45);
  animation: ai-orb-pulse 1.8s ease-in-out infinite;
}
@keyframes ai-orb-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; box-shadow: 0 0 24px rgba(56, 189, 248, 0.45); }
  50% { transform: scale(1.08); opacity: 1; box-shadow: 0 0 36px rgba(56, 189, 248, 0.65); }
}
.ai-thinking-dots {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.85rem;
}
.ai-thinking-dots span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  animation: ai-dot-bounce 1.2s ease-in-out infinite;
}
.ai-thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-5px); opacity: 1; }
}
.ai-thinking-panel-inline {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin: 1rem 0;
  padding: 1rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(56, 189, 248, 0.28);
  background: rgba(56, 189, 248, 0.06);
}
.ai-thinking-panel-inline[hidden] { display: none; }
.ai-thinking-panel-inline .ai-thinking-orb {
  width: 2rem;
  height: 2rem;
}

/* --- Background AI job wait page --- */
.ai-job-wait-page .ai-job-status-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.ai-job-spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.25);
  border-top-color: var(--accent, #38bdf8);
  animation: ai-job-spin 0.9s linear infinite;
  flex-shrink: 0;
}
.ai-job-spinner[hidden] { display: none; }
@keyframes ai-job-spin {
  to { transform: rotate(360deg); }
}
.ai-job-error-card {
  border-color: rgba(248, 113, 113, 0.35);
}
.field-assist-bg-card {
  margin-bottom: 1rem;
  border-color: rgba(56, 189, 248, 0.28);
}
.field-assist-bg-card h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
}
.field-assist-legacy-sync {
  margin-top: 0.5rem;
}
.field-assist-legacy-sync-body {
  margin-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.ai-response-panel {
  border-color: rgba(34, 197, 94, 0.35);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.08), var(--shadow-glow);
  margin-bottom: 1rem;
}
.ai-response-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.ai-response-header h2 { margin: 0; }
.ai-response-received-badge {
  font-size: 0.72rem;
}

.ai-response-actions-panel {
  margin-top: 1rem;
  margin-bottom: 1.25rem;
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.1), var(--shadow-glow);
  background: linear-gradient(
    145deg,
    rgba(15, 23, 42, 0.92) 0%,
    rgba(30, 41, 59, 0.78) 100%
  );
}
.ai-response-actions-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}
.ai-response-actions-title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.ai-response-actions-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.ai-action-badge {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.ai-action-badge-draft {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}
.ai-action-badge-review {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.1);
}
.ai-action-badge-confirm {
  color: #fcd34d;
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}
.ai-action-badge-new {
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.1);
}
.ai-future-inline-note {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid rgba(56, 189, 248, 0.45);
  background: rgba(0, 0, 0, 0.18);
  line-height: 1.45;
}
.ai-response-actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.ai-response-actions-grid .ai-action-btn {
  min-width: 10.5rem;
}

/* --- Generate AI workflow full-width response layout --- */
.generate-ai-workflow-page.ai-workflow-has-response .field-assist-grid {
  display: none;
}

.generate-character-workflow-shell,
.convert-character-workflow-shell {
  width: 100%;
  max-width: 52rem;
  margin: 0 auto;
}

.generate-character-workflow-shell .card,
.convert-character-workflow-shell .card,
.generate-character-workflow-shell .form-actions,
.convert-character-workflow-shell .form-actions {
  width: 100%;
  box-sizing: border-box;
}

.surprise-me-hero {
  border-color: rgba(167, 139, 250, 0.4);
  background: linear-gradient(145deg, rgba(30, 27, 75, 0.55), rgba(15, 23, 42, 0.85));
  margin-bottom: 0.85rem;
}

.surprise-me-hero-title {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
}

.surprise-me-hero-btn {
  margin-top: 0.65rem;
}

.ai-retry-notice {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.08);
}

.ai-retry-notice p { margin: 0; font-size: 0.88rem; }

.convert-missing-fields {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.06);
  margin-bottom: 0.75rem;
}

.convert-missing-fields p {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.convert-missing-fields p:last-child { margin-bottom: 0; }

.generate-primary-actions {
  border-color: rgba(56, 189, 248, 0.28);
  margin-bottom: 0.75rem;
}

.generate-primary-actions-title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
}

.generate-primary-actions-row {
  margin-bottom: 0.35rem;
}

.ai-response-panel-wide .inner-warning {
  margin: 0.75rem 0;
  padding: 0.65rem 0.85rem;
  box-shadow: none;
}

.convert-character-form-panel {
  margin-bottom: 1rem;
}

.convert-reference-panel summary.convert-reference-summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
}

.convert-reference-textarea {
  margin-top: 0.75rem;
  width: 100%;
}

.generate-ai-results-stack {
  width: 100%;
  max-width: 52rem;
  margin: 1.25rem auto 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ai-response-panel-wide {
  width: 100%;
}

.ai-response-readable {
  max-width: 100%;
  max-height: none;
  overflow: visible;
  line-height: 1.6;
  font-size: 0.92rem;
}

.generation-settings-collapsed {
  margin-bottom: 1rem;
}

.generation-settings-collapsed summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.25rem 0;
}

.generation-settings-fields {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-workflow-compact-context {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.35rem 1.25rem;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.ai-workflow-compact-context p { margin: 0; }

.generation-prompt-collapsed .prompt-textarea {
  max-height: 9rem;
}

.form-actions-compact {
  margin-top: 0.5rem;
}

.fill-bible-guidance { margin-bottom: 0.5rem; }

.fill-field-count-warning,
.fill-field-count-warning-static {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.06);
  margin-bottom: 0.75rem;
}

.fill-field-count-warning-static.fill-warning-strong-static {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.06);
}

.fill-field-count-warning p,
.fill-field-count-warning-static p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.ai-reasoning-warning {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
  margin-bottom: 0.75rem;
}

.ai-reasoning-warning p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.long-form-shell-new-character {
  padding-bottom: 6.5rem;
}

.apply-draft-panel {
  margin-bottom: 1rem;
  border-color: rgba(56, 189, 248, 0.28);
}
.apply-draft-target { margin: 0 0 0.5rem; }
.apply-draft-warning {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: #fbbf24;
  line-height: 1.45;
}
.apply-draft-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.apply-draft-card {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}
.apply-draft-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.apply-draft-proposed { border-color: rgba(56, 189, 248, 0.3); }
.apply-draft-value {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-height: 220px;
  overflow-y: auto;
}
.apply-draft-form { margin-top: 0.5rem; }
.apply-mode-fieldset { border: none; padding: 0; margin: 0 0 0.85rem; }
.apply-mode-legend {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}
.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  cursor: pointer;
  line-height: 1.45;
}
.radio-label input[type="radio"] { margin-top: 0.2rem; accent-color: var(--accent); }
.form-static-value { margin: 0.35rem 0 0; }

/* --- Fill Missing Fields --- */
.fill-missing-card { border-style: dashed; border-color: rgba(129, 140, 248, 0.25); }
.fill-missing-form { display: flex; flex-direction: column; gap: 1rem; }
.fill-field-table { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.75rem; }
.fill-field-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) auto auto 1fr;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
}
.fill-field-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.88rem;
}
.fill-field-check input { accent-color: var(--accent); }
.fill-field-count { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.fill-field-preview { font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Generate Whole Character --- */
.generate-character-card { margin-bottom: 1rem; border-style: dashed; border-color: rgba(129, 140, 248, 0.25); }
.generate-character-form .inner-panel { margin-top: 1rem; padding: 1rem; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 0.75rem; }

.empty-state.compact p { margin: 0; }
.muted.compact { font-size: 0.85rem; margin: 0; }

/* --- Images --- */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.85rem; margin-bottom: 1rem; }
.image-card { margin: 0; }
.image-link { display: block; text-decoration: none; }
.image-link:hover img {
  border-color: var(--border-bright);
  box-shadow: 0 0 20px var(--accent-glow-strong);
  transform: scale(1.02);
}
.image-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all var(--transition);
  cursor: pointer;
}
.image-card figcaption { font-size: 0.78rem; margin-top: 0.45rem; color: var(--text-muted); }
.image-card figcaption strong { color: var(--text); display: block; font-size: 0.84rem; }
.image-card figcaption p { margin: 0.25rem 0 0; }
.image-meta { font-size: 0.72rem; color: var(--text-muted); margin: 0.35rem 0 0.25rem; display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
.image-download-link { font-size: 0.78rem; font-weight: 500; }
.media-quality-note { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 0.75rem; line-height: 1.45; }

.form-compact { gap: 0.75rem; }
.empty-state.compact { padding: 1.25rem; text-align: left; }
.empty-state.compact p { margin: 0; font-size: 0.88rem; }

/* --- Table --- */
.filter-bar {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filter-bar .form-group { flex: 1; min-width: 160px; margin: 0; }

.table-wrap { overflow-x: auto; padding: 0; border-radius: var(--radius-lg); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 0.85rem 1.1rem; text-align: left; border-bottom: 1px solid rgba(100, 130, 180, 0.12); }
.data-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: rgba(17, 24, 39, 0.8);
  font-weight: 600;
}
.data-table tr:hover td { background: var(--accent-glow); }
.data-table a { font-weight: 500; }

/* --- Prompt console --- */
.prompt-console .page-header h1 {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.prompt-notice {
  background: linear-gradient(90deg, var(--accent-glow) 0%, var(--violet-glow) 100%);
  border-color: var(--border-bright);
  margin-bottom: 1rem;
  border-left: 3px solid var(--accent);
}
.prompt-notice p { margin: 0; font-size: 0.88rem; color: var(--text-muted); }

.prompt-textarea,
.prompt-console textarea.prompt-textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.65;
  background: rgba(10, 14, 23, 0.7);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  color: var(--text);
  padding: 1.15rem;
  resize: vertical;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.25);
}

/* --- Misc --- */
.empty-state {
  text-align: center;
  padding: 2.25rem;
  color: var(--text-muted);
}
.empty-state p { margin-bottom: 1rem; }
.back-link { margin-top: 1.5rem; font-size: 0.88rem; }
.muted { color: var(--text-muted); }
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.88rem;
}
.alert-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

h2 { margin: 0 0 0.75rem; font-size: 1.12rem; font-weight: 600; }

/* --- AI Chat --- */
.ai-chat-page .ai-config-card { margin-bottom: 1rem; }
.ai-config-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1.25rem;
  margin: 0;
  font-size: 0.88rem;
}
.ai-config-list dt { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.05em; }
.ai-config-list dd { margin: 0; color: var(--text); }
.ai-config-list code {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.25);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}
.ai-config-note { margin: 0.85rem 0 0; font-size: 0.85rem; color: var(--text-muted); line-height: 1.55; }
.ai-chat-grid { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .ai-chat-grid { grid-template-columns: 1fr; } }

.ai-error-panel {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
  margin-bottom: 1rem;
}
.ai-error-panel h2 { color: #fca5a5; }

.ai-unavailable-panel {
  border-color: rgba(251, 191, 36, 0.45);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(15, 23, 42, 0.35));
  margin-bottom: 1rem;
}
.ai-unavailable-panel h2 {
  color: #fcd34d;
  margin-bottom: 0.65rem;
}
.ai-unavailable-message {
  margin: 0 0 0.85rem;
  line-height: 1.65;
  color: var(--text);
}
.ai-support-contact {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.ai-support-contact a {
  color: #fcd34d;
  text-decoration: none;
}
.ai-support-contact a:hover { text-decoration: underline; }
.ai-error-detail {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.ai-error-detail summary {
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
}
.ai-error-detail code {
  display: block;
  margin-top: 0.45rem;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  color: #cbd5e1;
  word-break: break-word;
}
.compact-list-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}
.compact-list-card { padding: 0.85rem 1rem; }
.compact-list-card h3 { font-size: 1rem; margin: 0; }
.compact-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.world-detail-grid { margin-bottom: 1rem; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.forge-chat-btn { margin-bottom: 0.85rem; }
.forge-section-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0.5rem 0 0.45rem;
}

/* --- Media Library --- */
.media-filter-bar { align-items: flex-end; }
.media-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.media-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  margin-bottom: 0;
  transition: all var(--transition);
}
.media-card:hover {
  border-color: var(--border-bright);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}
.media-thumb-link { display: block; background: rgba(0, 0, 0, 0.25); }
.media-thumb {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  transition: all var(--transition);
}
.media-thumb-link:hover .media-thumb {
  box-shadow: inset 0 0 24px var(--accent-glow);
}
.media-card-body { padding: 1rem 1.15rem 1.15rem; }
.media-card-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
}
.media-card-context {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.media-card-meta { margin: 0 0 0.45rem; font-size: 0.75rem; color: var(--text-muted); }
.media-card-badges { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.45rem; }
.media-card-desc { margin: 0 0 0.55rem; font-size: 0.82rem; color: var(--text-muted); line-height: 1.45; }
.media-card-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* --- Docs & Framework Placeholder --- */
.doc-content { padding: 1.25rem 1.5rem; overflow-x: auto; }
.doc-markdown {
  margin: 0;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.framework-placeholder { border-style: dashed; }
.framework-placeholder-text {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Character Intelligence --- */
.intelligence-card { border-color: rgba(56, 189, 248, 0.22); }
.intelligence-card-header { align-items: center; margin-bottom: 0.75rem; }
.intelligence-card-header h2 { margin: 0; }
.intelligence-detail-summary { margin-bottom: 0.85rem; }
.intelligence-drive-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.65rem;
}
.drive-chip-list { list-style: none; padding: 0; margin: 0.35rem 0 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.drive-chip-list.compact { margin-top: 0.25rem; }
.drive-chip {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}
.drive-chip-high { border-color: rgba(56, 189, 248, 0.35); color: var(--accent); }
.drive-chip-low { border-color: rgba(148, 163, 184, 0.35); color: var(--text-muted); }
.intelligence-snippet { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--text-muted); line-height: 1.45; }
.intelligence-card-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.intelligence-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.intelligence-viz-note { margin: 0 0 1rem; }
.drive-score-grid { display: flex; flex-direction: column; gap: 0.65rem; }
.drive-score-row { display: flex; flex-direction: column; gap: 0.25rem; }
.drive-score-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.drive-score-value { color: var(--accent); font-weight: 600; }
.drive-score-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.drive-score-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dim, #0ea5e9), var(--accent));
  box-shadow: 0 0 12px var(--accent-glow);
  transition: width var(--transition);
}
.intelligence-section { margin-bottom: 1rem; }
.intelligence-form .form-section { margin-bottom: 1rem; }
.drive-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
}
.drive-form-group input[type="number"] { max-width: 100%; }
.form-help { font-size: 0.78rem; color: var(--text-muted); margin: -0.25rem 0 0.45rem; line-height: 1.4; }
.intelligence-context-details { margin-top: 0.75rem; }
.intelligence-context-details summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.intelligence-context-preview {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
}

/* --- Field AI Assistant --- */
.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.field-assist-link {
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-decoration: none;
  padding: 0.15rem 0.45rem;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 999px;
  transition: all var(--transition);
}
.field-assist-link:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.field-assist-page .field-assist-notice { margin-bottom: 1rem; }
.field-assist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.field-current-value {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-height: 200px;
  overflow-y: auto;
}
.field-assist-form { display: flex; flex-direction: column; gap: 1rem; }
.field-assist-actions {
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.field-assist-save-check { margin: 0; font-size: 0.82rem; }
.detail-list.compact dt { font-size: 0.72rem; }
.detail-list.compact dd { font-size: 0.85rem; margin-bottom: 0.45rem; }

/* --- Dev Debug Panel --- */
.debug-panel {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1200;
  max-width: min(22rem, calc(100vw - 2rem));
  font-size: 0.78rem;
}

.debug-panel-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(120, 180, 255, 0.35);
  background: rgba(12, 20, 36, 0.92);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.debug-panel-toggle:hover {
  color: var(--text-primary);
  border-color: rgba(120, 180, 255, 0.55);
}

.debug-panel-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(80, 200, 255, 0.65);
}

.debug-panel-expanded .debug-panel-toggle { display: none; }

.debug-panel-body {
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(18rem, 40vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid rgba(120, 180, 255, 0.28);
  background: rgba(10, 16, 28, 0.94);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px);
}

.debug-panel-body[hidden] { display: none; }

.debug-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid rgba(120, 180, 255, 0.15);
}

.debug-panel-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.debug-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.debug-clear-form { margin: 0; }

.debug-clear-button,
.debug-panel-collapse {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
}

.debug-panel-note {
  margin: 0;
  padding: 0.35rem 0.65rem 0;
}

.debug-panel-events {
  overflow-y: auto;
  padding: 0.45rem 0.65rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.debug-event {
  line-height: 1.35;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.debug-event-empty { background: transparent; border: none; padding: 0.2rem 0; }

.debug-event-time {
  color: var(--accent-cyan);
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
}

.debug-event-type {
  color: var(--accent-gold, #d4b86a);
  font-weight: 600;
  text-transform: lowercase;
}

.debug-event-message { color: var(--text-primary); }

.debug-event-data {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
}

.debug-event-client .debug-event-type { color: #8ec8ff; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }
  html.sidebar-collapsed .app-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width) + var(--sidebar-collapsed-width)));
  }
  .sidebar-toggle-mobile { display: flex; }
  .app-topbar-user { display: none; }
  .main-content { padding: 1.1rem; }
  .page-header h1 { font-size: 1.55rem; }
  .stat-value { font-size: 2rem; }
}

@media (min-width: 769px) {
  .sidebar-toggle-mobile { display: none; }
}

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

/* --- Archive / lifecycle --- */
.archived-banner {
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.08);
  margin-bottom: 1rem;
}

.lifecycle-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.lifecycle-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.lifecycle-delete-btn {
  color: var(--danger, #f87171);
}

.lifecycle-reason-input {
  max-width: 12rem;
  font-size: 0.85rem;
}

.archive-item-card {
  margin-bottom: 0.75rem;
}

.archive-item-head {
  align-items: flex-start;
  gap: 1rem;
}

.archive-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
}

.table-actions {
  white-space: nowrap;
}

.table-actions form {
  display: inline;
}
