/* KnowledgeStream Modern UI — Inter */
:root {
  --bg: #f1f5f9;
  --bg-paint: #f1f5f9;
  --surface: #ffffff;
  --surface-paint: #ffffff;
  --surface-2: #f8fafc;
  --surface-2-paint: #f8fafc;
  --border: #e2e8f0;
  --border-paint: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #6366f1;
  --primary-paint: #6366f1;
  --primary-600: #4f46e5;
  --accent: #f97316;
  --accent-paint: #f97316;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --sidebar: #0f172a;
  --sidebar-paint: #0f172a;
  --on-sidebar: #e2e8f0;
  --on-sidebar-muted: #94a3b8;
  --topbar: #ffffff;
  --topbar-paint: #ffffff;
  --on-topbar: #0f172a;
  --on-topbar-muted: #64748b;
  --panel: #ffffff;
  --panel-paint: #ffffff;
  --on-panel: #0f172a;
  --on-panel-muted: #64748b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --maxw: 1440px;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Inter", system-ui, sans-serif;
  --app-sidebar-w: 248px;
  --topbar-h: 88px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --bg-paint: #0b1220;
  --surface: #111827;
  --surface-paint: #111827;
  --surface-2: #1e293b;
  --surface-2-paint: #1e293b;
  --border: #334155;
  --border-paint: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #818cf8;
  --primary-paint: #818cf8;
  --primary-600: #6366f1;
  --accent: #fb923c;
  --accent-paint: #fb923c;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --topbar: #1e293b;
  --topbar-paint: #1e293b;
  --on-topbar: #f8fafc;
  --on-topbar-muted: #94a3b8;
  --panel: #111827;
  --panel-paint: #111827;
  --on-panel: #f8fafc;
  --on-panel-muted: #94a3b8;
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-paint, var(--bg));
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
code { font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }

/* Icons */
.ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.15em;
}
.ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic-lg { width: 2rem; height: 2rem; }
.ic-xl { width: 3rem; height: 3rem; }

/* Layout shell */
.m-shell {
  min-height: 100vh;
  display: flex;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b));
}
.m-shell.has-app-sidebar { padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
@media (min-width: 1024px) {
  .m-shell.has-app-sidebar { padding-bottom: 0; padding-left: var(--app-sidebar-w); }
  .m-shell.has-app-sidebar .m-tabbar { display: none; }
}

.m-app-sidebar {
  display: none;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--app-sidebar-w);
  z-index: 50;
  background: var(--sidebar-paint, var(--sidebar));
  color: var(--on-sidebar, #e2e8f0);
  border-right: 1px solid color-mix(in srgb, var(--on-sidebar) 12%, transparent);
  flex-direction: column;
}
@media (min-width: 1024px) {
  .m-app-sidebar { display: flex; }
}
.sidebar-brand { padding: 18px 16px 12px; border-bottom: 1px solid color-mix(in srgb, var(--on-sidebar) 10%, transparent); }
.sidebar-brand-link {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit;
}
.sidebar-brand-link:hover { text-decoration: none; }
.sidebar-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-paint, #6366f1), #8b5cf6);
  color: #fff; display: inline-grid; place-items: center;
}
.sidebar-mark .ic { width: 1.25rem; height: 1.25rem; }
.sidebar-brand-text { display: grid; gap: 2px; line-height: 1.2; }
.sidebar-brand-text strong { font-size: 0.95rem; font-weight: 700; color: #fff; }
.sidebar-brand-text span { font-size: 0.72rem; color: var(--on-sidebar-muted, #94a3b8); }
.sidebar-nav { flex: 1; overflow: auto; padding: 12px 10px; display: grid; gap: 4px; align-content: start; }
.sidebar-section-label {
  margin: 14px 8px 6px; font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--on-sidebar-muted, #94a3b8); font-weight: 600;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--on-sidebar-muted, #94a3b8); text-decoration: none; font-weight: 500; font-size: 0.92rem;
  position: relative;
}
.sidebar-link .ic { width: 1.1rem; height: 1.1rem; opacity: 0.9; }
.sidebar-link:hover { background: color-mix(in srgb, #fff 8%, transparent); color: var(--on-sidebar, #e2e8f0); text-decoration: none; }
.sidebar-link.active {
  background: color-mix(in srgb, var(--primary-paint, #6366f1) 22%, transparent);
  color: #fff;
}
.sidebar-link-sub { padding-left: 28px; font-size: 0.86rem; }
.sidebar-badge {
  margin-left: auto; min-width: 1.25rem; height: 1.25rem; padding: 0 6px;
  border-radius: 999px; background: var(--primary-paint, #6366f1); color: #fff;
  font-size: 0.68rem; font-weight: 700; display: inline-grid; place-items: center;
}
.sidebar-tag {
  margin-left: auto; font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  padding: 2px 6px; border-radius: 6px;
  background: color-mix(in srgb, var(--primary-paint, #6366f1) 25%, transparent);
  color: color-mix(in srgb, var(--primary-paint, #6366f1) 85%, #fff);
}
.sidebar-bottom {
  padding: 10px; border-top: 1px solid color-mix(in srgb, var(--on-sidebar) 10%, transparent);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; padding: 10px; border-radius: 12px;
  background: color-mix(in srgb, #000 18%, transparent);
}
.sidebar-user-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit; border-radius: 10px;
  padding: 2px; margin: -2px;
}
.sidebar-user-link:hover { background: color-mix(in srgb, #fff 8%, transparent); text-decoration: none; }
.sidebar-user-link:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary-paint, #6366f1) 70%, #fff); outline-offset: 2px; }
.sidebar-user-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.sidebar-user-meta strong { font-size: 0.86rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta span { font-size: 0.72rem; color: var(--on-sidebar-muted, #94a3b8); text-transform: lowercase; }
.sidebar-avatar { width: 36px; height: 36px; font-size: 0.8rem; }
.sidebar-logout { width: 34px; height: 34px; border-color: transparent; background: transparent; color: var(--on-sidebar-muted); }
.sidebar-copyright {
  margin: 10px 4px 0; font-size: 0.68rem; color: var(--on-sidebar-muted, #64748b); text-align: center;
}
.sso-buttons { display: grid; gap: 8px; }
.sso-buttons .sso-btn { text-align: center; text-decoration: none; }

.m-shell-column { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.m-page-topbar {
  position: sticky; top: 0; z-index: 30;
  min-height: var(--topbar-h);
  background: var(--topbar-paint, var(--topbar));
  color: var(--on-topbar, var(--text));
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px;
}
.m-page-topbar-left { min-width: 0; }
.page-eyebrow {
  margin: 0 0 4px; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-topbar-muted, var(--muted));
}
.page-title {
  margin: 0; font-size: clamp(1.35rem, 2.2vw, 1.85rem); font-weight: 800;
  letter-spacing: -0.03em; line-height: 1.15; color: var(--on-topbar, var(--text));
}
.page-subtitle { margin: 6px 0 0; color: var(--on-topbar-muted, var(--muted)); font-size: 0.92rem; }
.m-page-topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-search {
  position: relative; display: none;
}
@media (min-width: 768px) { .topbar-search { display: block; } }
.topbar-search input {
  width: min(280px, 36vw);
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2-paint, var(--surface-2)); color: var(--text);
}
.topbar-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.topbar-search-icon .ic { width: 1rem; height: 1rem; }
.topbar-bell { position: relative; }
.topbar-bell-dot {
  position: absolute; top: 8px; right: 8px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--danger); border: 2px solid var(--topbar-paint, var(--topbar));
}
.topbar-company { display: none; text-align: right; line-height: 1.25; padding-left: 8px; }
@media (min-width: 768px) { .topbar-company { display: block; } }
.topbar-company strong { display: block; font-size: 0.86rem; color: var(--on-topbar, var(--text)); }
.topbar-company span { font-size: 0.75rem; color: var(--on-topbar-muted, var(--muted)); }

.topbar-company-menu { position: relative; flex-shrink: 1; min-width: 0; max-width: min(220px, 32vw); }
@media (min-width: 768px) { .topbar-company-menu { max-width: min(280px, 36vw); } }
.topbar-company-btn {
  display: flex; align-items: center; gap: 8px; max-width: 100%;
  background: var(--surface-2-paint, var(--surface-2)); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 10px 6px 6px; cursor: pointer;
  color: var(--on-topbar, var(--text)); font: inherit; font-size: 0.84rem;
}
.topbar-company-btn:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.topbar-company-btn .company-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
  font-weight: 600; font-size: 0.84rem;
}
.topbar-company-btn .company-icon { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.topbar-company-btn .company-mark {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  display: inline-grid; place-items: center; font-size: 0.72rem; font-weight: 700;
  background: color-mix(in srgb, var(--primary) 18%, var(--surface-2)); color: var(--primary-paint, var(--primary));
}
.brand-caret { font-size: 0.65rem; color: var(--on-topbar-muted, var(--muted)); flex-shrink: 0; margin-left: 2px; }
.brand-company-drop {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; max-width: min(92vw, 360px);
  max-height: min(70vh, 420px); overflow: auto; z-index: 55;
  background: var(--surface-paint, var(--surface)); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px; box-shadow: var(--shadow);
}
.brand-company-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; color: var(--text); padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font: inherit; font-size: 0.9rem;
}
.brand-company-item:hover, .brand-company-item.active { background: var(--surface-2-paint, var(--surface-2)); }
.brand-company-item.active { font-weight: 600; }
.brand-company-item .company-icon { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.brand-company-item .company-mark {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  display: inline-grid; place-items: center; font-size: 0.72rem; font-weight: 700;
  background: var(--surface-2-paint, var(--surface-2)); border: 1px solid var(--border);
}

.m-topbar { display: none; }
.m-sidenav { display: none; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2-paint, var(--surface-2));
  color: var(--text); cursor: pointer; display: inline-grid; place-items: center;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn .ic { width: 1.15rem; height: 1.15rem; }
.avatar, .avatar-sm { border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.avatar { width: 72px; height: 72px; }
.avatar-sm { width: 28px; height: 28px; }
.avatar-fallback {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--primary-paint, var(--primary)); color: #fff;
  font-size: 0.7rem; font-weight: 800;
}
.company-icon { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; }
.company-icon-lg { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.company-mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--surface-2); display: inline-grid; place-items: center; font-size: 0.75rem; font-weight: 600;
}
.m-main { padding: 20px; min-width: 0; flex: 1; }
.m-container { max-width: var(--maxw); margin: 0 auto; width: 100%; }

/* Mobile tab bar */
.m-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex; background: var(--surface-paint, var(--surface));
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.12);
}
.m-tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); text-decoration: none; font-size: 0.68rem; font-weight: 600;
}
.m-tabbar a .ic { width: 1.35rem; height: 1.35rem; }
.m-tabbar a.active { color: var(--primary); }
.m-tabbar a:hover { text-decoration: none; color: var(--text); }

/* Typography / sections */
.section-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.section-head h1 {
  margin: 0; flex: 1; font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.5vw, 1.9rem); font-weight: 700; letter-spacing: -0.02em;
}
h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 0 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 0 0 0.5rem; }
.dash-hero {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 1.5rem; padding: 1.25rem 0 0.5rem;
}
.dash-hero h1 {
  margin: 0.15rem 0 0.35rem; font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.25rem); font-weight: 700;
}
.dash-eyebrow { margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.dash-hero-company { display: flex; align-items: center; gap: 12px; }

/* Cards & grids */
.card {
  background: var(--surface-paint, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  color: var(--on-surface, var(--text));
}
.card h1, .card h2, .card h3, .card h4 { color: var(--on-surface, var(--text)); }
.card .muted { color: var(--on-surface-muted, var(--muted)); }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.compact-cards .card { padding: 0.75rem; }

/* Tabs (course edit, etc.) */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 0 -1rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}
.tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--on-surface-muted, var(--muted));
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: -1px;
  padding: 0.65rem 0.9rem;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--on-surface, var(--text)); }
.tab.active {
  border-bottom-color: var(--primary, #2563eb);
  color: var(--primary, #2563eb);
}
.tab-panels { padding-top: 1.25rem; }
.course-edit-shell .course-edit-intro {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}
.learn-list { display: flex; flex-direction: column; gap: 10px; }
.learn-list .course-card { display: grid; grid-template-columns: 100px 1fr; }

.course-card { overflow: hidden; padding: 0; display: flex; flex-direction: column; }
.course-thumb {
  aspect-ratio: 16/9; background: var(--surface-2);
  display: grid; place-items: center; color: var(--muted);
}
.course-thumb.has-image { padding: 0; }
.course-thumb img.cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.course-body { padding: 0.9rem 1rem 1rem; flex: 1; display: flex; flex-direction: column; }
.course-body h3 { margin: 0.35rem 0 0.4rem; font-size: 1.05rem; }
.course-card-locked { opacity: 0.85; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 640px) { .stat-grid { grid-template-columns: 1fr; } }
.stat {
  text-align: left; cursor: default; border: 1px solid var(--border);
  background: var(--surface); width: 100%;
}
.stat-clickable { cursor: pointer; }
.stat-clickable:hover, .stat.active {
  border-color: color-mix(in srgb, var(--primary) 50%, var(--border));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent);
}
.stat .n { display: block; font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; }
.stat .l { color: var(--muted); font-size: 0.85rem; font-weight: 500; }

.progress {
  height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 8px 0;
}
.progress > span {
  display: block; height: 100%; border-radius: 999px;
  background: var(--primary-paint, var(--primary));
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.ok { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); border-color: transparent; }
.badge.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); border-color: transparent; }
.badge.scorm12, .badge.scorm2004, .badge.xapi, .badge.mp4, .badge.quiz, .badge.assignment {
  background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); border-color: transparent;
}

/* Dashboard layouts */
.dash-page { display: flex; flex-direction: column; gap: 1.25rem; }
.dash-split {
  display: grid; gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 1100px) {
  .dash-split { grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); align-items: start; }
}
.dash-panel-col { display: grid; gap: 14px; align-content: start; }
.dash-panel-section {
  background: var(--panel-paint, var(--panel));
  color: var(--on-panel, var(--text));
  border: 1px solid var(--border);
}
.dash-panel-section .muted { color: var(--on-panel-muted, var(--muted)); }
.dash-panel-stack { display: grid; gap: 14px; }

.dash-stat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 900px) { .dash-stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.dash-stat {
  position: relative; text-align: left; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-paint, var(--surface));
  padding: 14px 14px 12px; cursor: pointer; width: 100%;
  box-shadow: var(--shadow);
}
.dash-stat:hover, .dash-stat.active { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.dash-stat-icon {
  width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center;
  margin-bottom: 10px;
}
.dash-stat-icon .ic { width: 1.1rem; height: 1.1rem; }
.dash-stat-indigo .dash-stat-icon { background: color-mix(in srgb, #6366f1 18%, transparent); color: #6366f1; }
.dash-stat-amber .dash-stat-icon { background: color-mix(in srgb, #f59e0b 18%, transparent); color: #f59e0b; }
.dash-stat-green .dash-stat-icon { background: color-mix(in srgb, #22c55e 18%, transparent); color: #22c55e; }
.dash-stat-rose .dash-stat-icon { background: color-mix(in srgb, #ec4899 18%, transparent); color: #ec4899; }
.dash-stat-num {
  position: absolute; top: 14px; right: 14px;
  font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1;
}
.dash-stat-label { display: block; font-weight: 700; font-size: 0.95rem; }
.dash-stat-sub { display: block; margin-top: 4px; font-size: 0.78rem; color: var(--muted); }

.dash-learning-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
}
#dashLearning { margin-top: 1.25rem; }
.dash-learning-head h2 { margin: 0; font-size: 1.2rem; }
.dash-select {
  padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-paint, var(--surface)); color: var(--text); font-size: 0.86rem;
}
.filter-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-pill {
  border: 1px solid var(--border); background: var(--surface-paint, var(--surface));
  color: var(--muted); border-radius: 999px; padding: 7px 14px; font-size: 0.84rem; font-weight: 600; cursor: pointer;
}
.filter-pill:hover { color: var(--text); }
.filter-pill.active {
  background: color-mix(in srgb, var(--primary-paint, #6366f1) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--primary-paint, #6366f1) 35%, var(--border));
  color: var(--primary-paint, var(--primary));
}

.learn-container { width: 100%; }
.learn-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.learn-grouped {
  display: flex; flex-direction: column; gap: 2rem;
}
.learn-category-group { margin: 0; }
.learn-category-title {
  margin: 0 0 12px; font-size: 0.95rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.learn-category-group + .learn-category-group {
  padding-top: 0.25rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.learn-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-paint, var(--surface)); overflow: hidden;
  box-shadow: var(--shadow);
}
.learn-card.is-locked {
  opacity: 0.88;
  position: relative;
  cursor: help;
}
.learn-lock-tooltip {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: color-mix(in srgb, var(--surface-paint, var(--surface)) 94%, transparent);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.learn-card.is-locked:hover .learn-lock-tooltip,
.learn-card.is-locked:focus-within .learn-lock-tooltip {
  opacity: 1;
}
.learn-lock-tooltip-title {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.learn-lock-tooltip-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}
.learn-lock-tooltip-list li + li { margin-top: 4px; }
.learn-card-thumb {
  height: 120px; display: grid; place-items: center; position: relative;
}
.learn-card-thumb-icon .ic { width: 2rem; height: 2rem; color: rgba(255,255,255,0.92); }
.learn-card-body { padding: 14px; display: grid; gap: 8px; }
.learn-type-badge {
  display: inline-flex; align-self: flex-start; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 6px;
  background: color-mix(in srgb, var(--primary-paint, #6366f1) 14%, transparent);
  color: var(--primary-paint, var(--primary));
}
.learn-card-body h3 { margin: 0; font-size: 1rem; line-height: 1.35; }
.learn-status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600;
}
.learn-status .ic { width: 0.95rem; height: 0.95rem; }
.learn-status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.learn-status-done { color: var(--success); }
.learn-status-progress { color: var(--warn); }
.learn-status-locked { color: var(--muted); }
.learn-status-new { color: var(--muted); }
.learn-progress {
  height: 6px; border-radius: 999px; background: var(--surface-2-paint, var(--surface-2)); overflow: hidden;
}
.learn-progress > span { display: block; height: 100%; border-radius: 999px; transition: width .2s ease; }
.learn-progress.is-done > span { background: var(--success); }
.learn-progress.is-progress > span { background: var(--warn); }
.learn-progress.is-locked > span, .learn-progress.is-new > span { background: var(--border); }
.learn-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.learn-btn { flex: 1; min-width: 0; justify-content: center; }
.learn-btn-primary { background: var(--primary-paint, var(--primary)); color: #fff; border-color: transparent; }
.learn-btn-ghost { background: transparent; }
.learn-btn-accent { background: color-mix(in srgb, var(--accent-paint, var(--accent)) 18%, var(--surface)); color: var(--accent-paint, var(--accent)); flex: 0; }
.learn-btn-muted { opacity: 0.7; }

.quick-actions {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.quick-action {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px; border-radius: var(--radius); text-decoration: none; color: var(--text);
  border: 1px solid var(--border);
}
.quick-action:hover { text-decoration: none; transform: translateY(-1px); }
.quick-action .ic { width: 1.35rem; height: 1.35rem; margin-top: 2px; }
.quick-action strong { display: block; font-size: 0.95rem; }
.quick-action span { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.quick-action-blue { background: color-mix(in srgb, #3b82f6 10%, var(--surface)); }
.quick-action-amber { background: color-mix(in srgb, #f59e0b 12%, var(--surface)); }
.quick-action-green { background: color-mix(in srgb, #22c55e 10%, var(--surface)); }

.featured-blog { overflow: hidden; border-radius: calc(var(--radius) - 2px); }
.featured-blog-cover { height: 120px; background-size: cover; background-position: center; }
.featured-blog-body { padding: 12px 0 0; display: grid; gap: 8px; }
.featured-blog-body h3 { margin: 0; font-size: 1rem; }
.featured-blog-link {
  display: inline-flex; align-items: center; gap: 4px; font-weight: 600;
  color: var(--primary-paint, var(--primary)); text-decoration: none;
}
.featured-blog-link .ic { width: 0.9rem; height: 0.9rem; }
.dash-cert-item {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent-paint, var(--accent)) 10%, var(--panel-paint, var(--panel)));
  border: 1px solid color-mix(in srgb, var(--accent-paint, var(--accent)) 22%, var(--border));
  margin-bottom: 10px;
}
.dash-cert-icon {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent-paint, var(--accent)) 20%, transparent);
  color: var(--accent-paint, var(--accent));
}
.dash-cert-icon .ic { width: 1rem; height: 1rem; }

.dash-layout { display: flex; flex-direction: column; gap: 1.5rem; }
.dash-split {
  display: grid; gap: 1.5rem;
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .dash-split-right { grid-template-columns: 1.6fr 1fr; }
  .dash-split-left { grid-template-columns: 1fr 1.6fr; }
  .dash-split-left .dash-main { order: 2; }
}
.dash-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 0.75rem; }
.dash-section-head h2 { margin: 0; }
.blog-dash-list, .cert-list { display: flex; flex-direction: column; gap: 10px; }
.note-dash-list, .dash-link-list { display: flex; flex-direction: column; gap: 0; }
.blog-dash-card, .cert-list-item {
  display: block; padding: 0; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
  overflow: hidden;
}
.blog-dash-card:hover { border-color: var(--primary); text-decoration: none; }
.cert-list-item { padding: 12px; }
.dash-link-panel { padding: 0; overflow: hidden; }
.dash-link-item, .note-dash-card {
  display: block; padding: 12px 14px; color: var(--text); text-decoration: none;
  background: transparent; border: 0; border-radius: 0;
  border-bottom: 1px solid var(--border);
}
.dash-link-item:last-child, .note-dash-card:last-child { border-bottom: 0; }
.dash-link-item:hover, .note-dash-card:hover {
  background: var(--surface-2); text-decoration: none;
}
.dash-link-item .muted { display: block; margin-top: 2px; }
.blog-dash-cover {
  --cover-h: 100px;
  --cover-x: 50%;
  --cover-y: 50%;
  --cover-zoom-n: 1;
  position: relative;
  height: var(--cover-h);
  overflow: hidden;
  background: var(--surface-2, var(--surface));
  border-radius: 0;
  margin: 0;
}
.blog-dash-cover-media {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: auto calc(var(--cover-zoom-n) * 100%);
  background-position: var(--cover-x) var(--cover-y);
}
.blog-dash-body { padding: 12px; display: grid; gap: 4px; }
.blog-dash-body strong { font-size: 0.95rem; line-height: 1.3; }
.blog-dash-body .muted { margin: 0; font-size: 0.82rem; line-height: 1.35; }

.blog-cover {
  --cover-h: 180px;
  --cover-x: 50%;
  --cover-y: 50%;
  --cover-zoom-n: 1;
  position: relative;
  width: 100%;
  height: var(--cover-h);
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2, var(--surface));
  margin: 0 0 12px;
}
.blog-cover-media {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: auto calc(var(--cover-zoom-n) * 100%);
  background-position: var(--cover-x) var(--cover-y);
}
.blog-cover.editable .blog-cover-media { cursor: grab; touch-action: none; }
.blog-cover.editable.dragging .blog-cover-media { cursor: grabbing; }
.blog-cover-toolbar {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.blog-cover-toolbar .row { gap: 16px; align-items: end; flex-wrap: wrap; }
.blog-cover-toolbar .field { margin: 0; flex: 1; min-width: 140px; }
.blog-cover-toolbar input[type="range"] { width: 100%; }
.blog-cover-hint { margin: 0; font-size: 0.85rem; }
.blog-excerpt {
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.5;
}
.blog-body {
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.blog-body img { max-width: 100%; height: auto; border-radius: 8px; }
.blog-body table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.blog-body th, .blog-body td { border: 1px solid var(--border); padding: 8px 10px; }
.blog-body blockquote {
  margin: 12px 0; padding: 8px 14px;
  border-left: 3px solid var(--primary);
  background: var(--surface-2);
}
.forum-post {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 8px;
}
.cke { width: 100% !important; }
.dash-link-title { display: block; font-weight: 600; }
.cert-list-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.cert-actions { display: flex; gap: 6px; }
.badge-shelf { display: flex; flex-wrap: wrap; gap: 10px; }
.earned-badge {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 88px; padding: 10px 8px; border-radius: 12px;
  text-align: center; font-size: 0.75rem; font-weight: 600;
  background: color-mix(in srgb, var(--badge-color, var(--primary)) 18%, var(--surface-paint, var(--surface)));
  border: 1px solid color-mix(in srgb, var(--badge-color, var(--primary)) 45%, var(--border));
}
.earned-badge img, .earned-badge-glyph {
  width: 48px; height: 48px; border-radius: 50%;
  background: color-mix(in srgb, var(--badge-color, var(--primary)) 25%, var(--surface-2));
  object-fit: cover; display: grid; place-items: center; color: var(--badge-color, var(--primary)); font-size: 1.25rem;
}

/* Admin hub */
.admin-hub { display: flex; flex-direction: column; gap: 1.75rem; }
.admin-group h2 { margin-bottom: 0.75rem; }
.admin-hub-card {
  display: flex; flex-direction: column; gap: 6px; padding: 1.1rem;
  color: var(--text); text-decoration: none; transition: transform 0.15s ease, border-color 0.15s;
}
.admin-hub-card:hover { border-color: var(--primary); transform: translateY(-2px); text-decoration: none; }
.admin-hub-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 16%, var(--surface-2));
  color: var(--primary); display: grid; place-items: center; margin-bottom: 4px;
}
.admin-hub-icon .ic { width: 1.35rem; height: 1.35rem; }

/* Tables */
.table-wrap {
  overflow: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
.pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; }

/* Forms & buttons */
.field { margin-bottom: 0.85rem; }
.field label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--muted); }
.field input, .field select, .field textarea,
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="url"], input[type="color"],
select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px;
}
input[type="color"] { padding: 4px; height: 42px; cursor: pointer; }
.topbar-search input[type="search"] {
  width: min(280px, 36vw);
  padding: 10px 12px 10px 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2-paint, var(--surface-2));
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--primary-paint, var(--primary)); color: #fff;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn.secondary {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
.btn.ghost { background: transparent; color: var(--text); border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 11px; font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn .ic { width: 1em; height: 1em; }
:root[data-button-style="pill"] .btn { border-radius: 999px; }
:root[data-button-style="square"] .btn { border-radius: 4px; }
:root[data-button-style="soft"] .btn {
  background: color-mix(in srgb, var(--primary) 18%, var(--surface));
  color: var(--primary); border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}
:root[data-button-style="soft"] .btn.secondary { background: var(--surface-2); color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Empty states */
.empty-state {
  text-align: center; padding: 2.5rem 1.5rem; color: var(--muted);
}
.empty-state .ic { margin: 0 auto 0.75rem; color: var(--primary); opacity: 0.85; }

/* Auth */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { justify-content: center; font-size: 1.25rem; }
.auth-card .card { box-shadow: var(--shadow); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 14, 12, 0.55); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px;
  animation: fadeIn 0.15s ease;
}
.modal-panel {
  width: min(560px, 100%); max-height: min(90vh, 800px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}
.modal-panel.wide { width: min(1100px, 100%); }

.q-opt-row {
  display: grid;
  grid-template-columns: 1.6rem auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  margin-bottom: 10px;
}
.q-opt-letter { font-weight: 600; margin-top: 10px; }
.q-opt-row .q-opt-correct { margin-top: 12px; }
.q-opt-row input[type="text"],
.q-opt-row textarea { width: 100%; min-width: 0; }
.q-opt-row .cke { width: 100% !important; }
.q-opt-spacer { width: 1.1rem; height: 1.1rem; margin-top: 12px; }
.q-match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  margin-bottom: 10px;
}
.q-match-cell { min-width: 0; }
.q-match-row input[type="text"],
.q-match-row textarea { width: 100%; min-width: 0; }
.q-match-row .cke { width: 100% !important; }
.q-match-row > .muted { margin-top: 28px; }
.q-text { white-space: normal; word-break: break-word; max-width: 36rem; }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-head h3 { margin: 0; flex: 1; font-size: 1.1rem; }
.modal-body { padding: 16px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--border);
}

/* Toast */
#toast {
  position: fixed; bottom: calc(var(--tabbar-h) + 16px + var(--safe-b)); left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 200; max-width: min(420px, calc(100vw - 24px));
  padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 0.9rem;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); color: #fff; }
@media (min-width: 1100px) {
  .m-shell.has-side ~ #toast, body:has(.m-shell.has-side) #toast {
    bottom: 24px;
  }
}

/* Page loading */
.page-loading {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(2px);
}
.page-loading .spin {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.forum-threads { display: flex; flex-direction: column; gap: 10px; }
.forum-post {
  padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
}
.forum-post.announcement { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.theme-swatches { display: inline-flex; gap: 4px; vertical-align: middle; }
.theme-swatch { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); display: inline-block; }

.row-menu { position: relative; display: inline-flex; justify-content: flex-end; }
.row-menu-toggle {
  min-width: 36px;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 1.15rem;
  line-height: 1;
  letter-spacing: 0.05em;
}
.row-menu-panel {
  display: none;
  position: fixed;
  z-index: 90;
  min-width: 188px;
  padding: 6px;
  background: var(--surface-paint, var(--surface));
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.row-menu.open .row-menu-panel { display: grid; gap: 2px; }
.row-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--on-surface, var(--text));
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.row-menu-item:hover:not(:disabled) { background: var(--surface-2-paint, var(--surface-2)); }
.row-menu-item:disabled { opacity: 0.45; cursor: not-allowed; }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }

.theme-order-list { display: grid; gap: 8px; margin-bottom: 14px; }
.theme-order-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-paint, var(--surface));
}
.theme-preset-grid {
  display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 12px;
}
.theme-preset-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  background: var(--surface-paint, var(--surface));
}
.theme-preset-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }
.theme-preset-preview {
  border-radius: 10px; padding: 14px; margin-bottom: 10px; min-height: 72px;
  border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
}
.theme-preset-bar {
  display: flex; gap: 6px; align-items: center; padding: 8px 10px; border-radius: 8px; margin-bottom: 10px;
}
.theme-preset-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
@media (min-width: 720px) {
  .theme-preset-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .theme-preset-grid { grid-template-columns: repeat(3, 1fr); }
}

.table-wrap.report-viewport {
  overflow: auto;
  background: var(--surface-paint, var(--surface));
}
.table-wrap.report-viewport table {
  width: max-content;
  min-width: 100%;
}
.table-wrap.report-viewport th,
.table-wrap.report-viewport td {
  white-space: nowrap;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-wrap.report-viewport thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-paint, var(--surface));
}

.badge.log-debug { background: var(--surface-2-paint, var(--surface-2)); }
.badge.log-info { background: color-mix(in srgb, var(--primary) 25%, var(--surface)); }
.badge.log-warn { background: color-mix(in srgb, var(--warn, #c9a227) 30%, var(--surface)); }
.badge.log-error { background: color-mix(in srgb, var(--danger) 30%, var(--surface)); }
.log-pre {
  max-height: 420px; overflow: auto;
  padding: 12px; border-radius: 8px;
  background: var(--surface-2-paint, var(--surface-2));
  border: 1px solid var(--border);
  font-size: 0.8rem; white-space: pre-wrap; word-break: break-word;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ks-spin { to { transform: rotate(360deg); } }

.ks-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-top-color: var(--primary);
  animation: ks-spin .7s linear infinite; flex-shrink: 0;
}
.ks-spinner-sm { width: 14px; height: 14px; border-width: 2px; display: inline-block; vertical-align: -2px; }
.upload-status {
  margin-top: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-paint, var(--surface));
}
.upload-status.parsing .ks-spinner { border-top-color: var(--accent, var(--primary)); }
.upload-status-row { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.upload-status-hint { margin: 8px 0 0; font-size: .85rem; }
.upload-progress {
  margin-top: 10px; height: 8px; border-radius: 999px; overflow: hidden;
  background: var(--surface-2-paint, var(--surface-2));
}
.upload-progress > span {
  display: block; height: 100%; width: 0%;
  background: var(--primary-paint, var(--primary)); transition: width .15s ease;
}
.upload-result {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-paint, var(--surface));
}
.upload-result.ok {
  border-color: color-mix(in srgb, var(--success) 55%, var(--border));
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
}
.upload-result.err {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

/* Certificate designer */
.cert-section { margin-top: 8px; }
.cert-designer { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
@media (min-width: 900px) {
  .cert-designer { grid-template-columns: 160px 1fr 200px; }
}
.cert-palette { display: flex; flex-direction: column; gap: 8px; }
.cert-canvas-wrap {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); min-height: 200px; overflow: hidden;
}
.cert-bg { display: block; width: 100%; height: auto; }
.cert-overlay { position: absolute; left: 0; top: 0; pointer-events: none; }
.cert-placeholder { padding: 24px; text-align: center; }
.cert-field {
  position: absolute; pointer-events: auto; cursor: move;
  border: 1px dashed color-mix(in srgb, var(--primary) 60%, transparent);
  padding: 2px 4px; font-weight: 600; user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cert-field.selected {
  border: 2px solid var(--accent, var(--primary));
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.cert-props { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.cert-preview-host { display: flex; justify-content: center; width: 100%; overflow: auto; }
.cert-preview-canvas { max-width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--border); }

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