:root {
  --bg: #f6f4fb;
  --bg-elevated: #fffdf8;
  --surface: #fffcf6;
  --ink: #1a1523;
  --muted: #6d6576;
  --line: #ddd4c6;
  --grid: rgba(27, 24, 20, 0.045);
  --accent: #5b21b6;
  --accent-hover: #4c1d95;
  --accent-soft: #ede9fe;
  --cyan: #0891b2;
  --success: #166534;
  --success-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warning: #b45309;
  --warning-soft: #ffedd5;
  --inactive: #6b7280;
  --inactive-soft: #f3f4f6;
  --shadow: 0 10px 30px rgba(27, 24, 20, 0.08);
  --ring: 0 0 0 3px rgba(91, 33, 182, 0.28);
  --radius: 16px;
  --sidebar-w: 248px;
  --header-h: 68px;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #110e16;
  --bg-elevated: #1a1622;
  --surface: #1f1a28;
  --ink: #f4efe6;
  --muted: #b0a89c;
  --line: #3a3344;
  --grid: rgba(244, 239, 230, 0.04);
  --accent: #c4b5fd;
  --accent-hover: #ddd6fe;
  --accent-soft: #2e2150;
  --cyan: #67e8f9;
  --success: #4ade80;
  --success-soft: #14532d;
  --danger: #fca5a5;
  --danger-soft: #7f1d1d;
  --warning: #fdba74;
  --warning-soft: #7c2d12;
  --inactive: #9ca3af;
  --inactive-soft: #27272a;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  --ring: 0 0 0 3px rgba(196, 181, 253, 0.35);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(circle at top left, rgba(91, 33, 182, 0.08), transparent 28rem);
  line-height: 1.55;
}

[hidden],
.hidden { display: none !important; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 80;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
}

.skip-link:focus { top: 12px; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  padding: 18px 14px;
  background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  border-right: 1px solid var(--line);
  overflow: auto;
}

.main-column { flex: 1; min-width: 0; }

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
}

.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-text { font-weight: 750; letter-spacing: -0.03em; font-size: 0.92rem; }
.brand-tag { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-label {
  margin: 14px 10px 6px;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 750;
}

.nav-link {
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 650;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--ink);
  background: var(--accent-soft);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-view-title { margin: 0; font-weight: 750; letter-spacing: -0.03em; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.header-menu { display: none; }

.session-chip,
.bug-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 750;
}

.session-chip { background: var(--accent-soft); color: var(--accent); }
.bug-pill { background: var(--danger-soft); color: var(--danger); }

.theme-toggle,
.btn {
  appearance: none;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border-color: var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
}

.main-content { max-width: 1120px; margin: 0 auto; padding: 24px 20px 56px; }

.hero-banner,
.module-card {
  position: relative;
  margin-bottom: 22px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.eyebrow,
.module-index {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-title,
.module-card h2,
.modal-container h3 {
  margin: 0 0 10px;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.hero-title { font-size: clamp(1.7rem, 4vw, 2.6rem); }
.hero-subtitle, .module-lede, .modal-body, .muted { color: var(--muted); }
.hero-subtitle { max-width: 68ch; }

code { font-family: var(--mono); font-size: 0.86em; }

.module-header { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.module-header h2 { font-size: 1.35rem; }
.module-lede { margin: 0; }

.stat-grid,
.split-grid,
.form-grid,
.upload-layout,
.products-grid,
.play-grid {
  display: grid;
  gap: 16px;
}

.stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.split-grid { grid-template-columns: 1.4fr 0.8fr; }
.form-grid, .upload-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.products-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.play-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.stat-card, .play-card, .product-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elevated);
}

.stat-card p { margin: 0 0 6px; color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.stat-card strong { font-size: 1.7rem; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label, .form-group legend { font-size: 0.86rem; font-weight: 700; }

input[type="text"],
input[type="password"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--ink);
  font: inherit;
}

textarea { min-height: 88px; resize: vertical; }
select[multiple] { min-height: 96px; }

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.dropzone:focus-visible,
.nav-link:focus-visible,
.skip-link:focus {
  outline: none;
  box-shadow: var(--ring);
}

.radio-group { border: 0; padding: 0; margin: 0; }
.radio-group legend { margin-bottom: 8px; }

.radio-option,
.checkbox-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 16px;
  font-weight: 550;
  cursor: pointer;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
}

.btn { min-height: 42px; padding: 0 16px; border-radius: 10px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn-primary { background: var(--accent); color: #fffdf8; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
.tab.is-active { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }

.feedback { min-height: 1.4em; margin: 16px 0 0; font-weight: 700; }
.feedback.success { color: var(--success); }
.feedback.danger { color: var(--danger); }
.feedback.warning { color: var(--warning); }

.table-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.table-search-group { flex: 1; min-width: 180px; }
.table-live-status { margin: 0 0 8px; color: var(--muted); font-size: 0.88rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }

.users-table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.users-table th, .users-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.users-table tbody tr:last-child td { border-bottom: 0; }
.users-table tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.sort-indicator::after { content: "↕"; color: var(--muted); font-weight: 500; }
.sort-btn[aria-sort="ascending"] .sort-indicator::after { content: "↑"; color: var(--accent); }
.sort-btn[aria-sort="descending"] .sort-indicator::after { content: "↓"; color: var(--accent); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-active { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--inactive-soft); color: var(--inactive); }
.table-empty { margin: 16px 0 0; color: var(--muted); }

.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.pagination-meta { margin: 0; color: var(--muted); font-size: 0.9rem; }
.pagination-pages { display: flex; flex-wrap: wrap; gap: 6px; }

.page-btn {
  min-width: 38px;
  min-height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--ink);
}
.page-btn.is-current { border-color: var(--accent); background: var(--accent-soft); font-weight: 750; }

.async-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }

.spinner-panel, .async-result, .delayed-box {
  margin-top: 8px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.spinner-panel { display: flex; align-items: center; gap: 12px; background: var(--bg-elevated); }
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.async-result { background: var(--success-soft); }
.async-result pre, #api-response-body { margin: 10px 0 0; overflow-x: auto; font-family: var(--mono); font-size: 0.82rem; }
.delayed-box { background: var(--accent-soft); }

.skeleton {
  height: 72px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--line), var(--bg-elevated), var(--line));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.progress-wrap, progress { width: 100%; margin-top: 12px; }
.accordion { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.accordion-trigger {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.accordion-panel { padding: 12px 14px; }

.dropzone {
  display: grid;
  place-items: center;
  min-height: 150px;
  padding: 20px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  background: var(--bg-elevated);
  text-align: center;
  cursor: pointer;
}
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-label { margin: 0 0 4px; font-weight: 750; }
.dropzone-hint, .upload-details { margin: 0; color: var(--muted); }
.upload-details { margin-top: 14px; font-weight: 650; }
.preview { max-width: 180px; margin-top: 10px; border-radius: 10px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 17, 15, 0.55);
}

.modal-container {
  width: min(100%, 480px);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 70;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-weight: 650;
}

.toast.is-success { background: var(--success); color: #fff; }
.toast.is-error { background: var(--danger); color: #fff; }
.toast.is-warning { background: var(--warning); color: #fff; }
.toast.is-info { background: var(--cyan); color: #082f36; }

.activity-feed { list-style: none; padding: 0; margin: 12px 0 0; }
.activity-feed li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }

.hover-wrap { position: relative; display: inline-block; }
.hover-menu, .context-menu {
  position: absolute;
  z-index: 5;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.context-menu { position: fixed; }

.dnd-row { display: flex; gap: 12px; }
.dnd-box {
  min-width: 110px;
  min-height: 64px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--bg-elevated);
}
.dnd-box.drop.is-over { border-color: var(--accent); background: var(--accent-soft); }

.reorder-list { list-style: none; padding: 0; margin: 0; }
.reorder-list li {
  margin-bottom: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elevated);
  cursor: grab;
}

.demo-iframe { width: 100%; height: 160px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.infinite-scroll { height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.infinite-item { padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }

.product-card h3 { margin: 0 0 6px; font-size: 1rem; }
.product-card p { margin: 0 0 8px; color: var(--muted); font-size: 0.86rem; }
.product-actions { display: flex; gap: 6px; }

.app-shell.sidebar-open .sidebar { transform: none; }

@media (max-width: 980px) {
  .stat-grid, .split-grid, .form-grid, .upload-layout { grid-template-columns: 1fr; }
  .header-menu { display: inline-flex; }
  .sidebar {
    position: fixed;
    z-index: 50;
    transform: translateX(-110%);
    transition: transform 0.2s ease;
  }
  .app-shell.sidebar-open .sidebar { transform: none; }
}

@media (max-width: 700px) {
  .header-inner { padding: 0 12px; }
  .brand-text { display: none; }
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.auth-shell {
  width: min(100%, 460px);
}

.auth-brand { margin-bottom: 18px; }

.auth-card {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0 0 12px;
  letter-spacing: -0.035em;
  font-size: 1.8rem;
}

.auth-theme { position: fixed; top: 16px; right: 16px; z-index: 5; }

.demo-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin: 0 0 18px;
  background: var(--accent-soft);
  border-radius: 12px;
  font-size: 0.92rem;
}

.auth-banner {
  padding: 10px 12px;
  margin: 0 0 14px;
  border-radius: 10px;
  background: var(--success-soft);
  color: var(--success);
  font-weight: 700;
}

.auth-footer-copy { margin: 18px 0 0; text-align: center; color: var(--muted); }
.text-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.btn-block { width: 100%; margin-top: 12px; }
.auth-split { margin-top: 8px; }

.home-hero { margin-bottom: 22px; }
.catalog-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 10px; }
.catalog-toolbar input { max-width: 320px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.chip.is-active { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.catalog-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 180px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.catalog-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.catalog-card h3 { margin: 0; font-size: 1.05rem; letter-spacing: -0.03em; }
.catalog-card p { margin: 0; color: var(--muted); flex: 1; }
.catalog-go { font-weight: 750; color: var(--accent); }

.level-pill {
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.level-pill.beginner { background: var(--success-soft); color: var(--success); }
.level-pill.intermediate { background: var(--accent-soft); color: var(--accent); }
.level-pill.advanced { background: var(--warning-soft); color: var(--warning); }

.knowledge-bank {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elevated);
}

.knowledge-bank > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 750;
  list-style: none;
}

.knowledge-bank > summary::-webkit-details-marker { display: none; }
.knowledge-hint { margin-left: auto; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.knowledge-body { padding: 0 16px 16px; }
.knowledge-body h3 { margin: 0 0 8px; }
.knowledge-body p, .knowledge-body li { color: var(--muted); }
.knowledge-body ol { margin: 0 0 12px; padding-left: 1.2rem; }
.knowledge-label { margin: 12px 0 6px; font-weight: 750; color: var(--ink) !important; }

.otp-row, .star-row, .tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.otp-input {
  width: 42px;
  min-height: 46px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 750;
}
.tag-list { list-style: none; padding: 0; }
.tag-list li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
}
.tag-list button { border: 0; background: transparent; cursor: pointer; color: inherit; font-size: 1rem; }
.star-btn {
  border: 0;
  background: transparent;
  color: var(--line);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}
.star-btn.is-on { color: #eab308; }
