:root {
  --ec-font-sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ec-body-bg: #f4efe7;
  --ec-body-bg-alt: #fffaf4;
  --ec-bg-glow-1: rgba(251, 191, 36, 0.24);
  --ec-bg-glow-2: rgba(244, 114, 182, 0.16);
  --ec-body-pattern:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.82) 0, transparent 20%),
    radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.65) 0, transparent 24%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 52%);
  --ec-surface-1: rgba(255, 250, 244, 0.9);
  --ec-surface-2: rgba(255, 245, 235, 0.94);
  --ec-surface-3: rgba(255, 255, 255, 0.72);
  --ec-border-strong: rgba(223, 163, 106, 0.34);
  --ec-border-soft: rgba(255, 255, 255, 0.58);
  --ec-text-1: #5a4635;
  --ec-text-2: #7f6249;
  --ec-text-muted: #aa8b70;
  --ec-accent-1: #ef8354;
  --ec-accent-2: #f6ad55;
  --ec-accent-soft: rgba(239, 131, 84, 0.2);
  --ec-shadow-sm: 0 12px 24px rgba(113, 72, 34, 0.08);
  --ec-shadow-lg: 0 24px 60px rgba(113, 72, 34, 0.16);
  --ec-radius-card: 28px;
  --ec-radius-chip: 999px;
  --ec-surface-blur: 12px;
}

:root[data-educlass-theme="tech"] {
  --ec-font-sans: "Segoe UI", "Bahnschrift", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ec-body-bg: #06111f;
  --ec-body-bg-alt: #08182a;
  --ec-bg-glow-1: rgba(6, 182, 212, 0.24);
  --ec-bg-glow-2: rgba(99, 102, 241, 0.22);
  --ec-body-pattern:
    radial-gradient(circle at 12% 20%, rgba(34, 211, 238, 0.16) 0, transparent 24%),
    radial-gradient(circle at 86% 14%, rgba(129, 140, 248, 0.16) 0, transparent 26%),
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  --ec-surface-1: rgba(7, 20, 37, 0.82);
  --ec-surface-2: rgba(13, 31, 53, 0.88);
  --ec-surface-3: rgba(10, 24, 43, 0.68);
  --ec-border-strong: rgba(56, 189, 248, 0.3);
  --ec-border-soft: rgba(148, 163, 184, 0.16);
  --ec-text-1: #dff7ff;
  --ec-text-2: #9ad7e6;
  --ec-text-muted: #6ea0b2;
  --ec-accent-1: #33d1ff;
  --ec-accent-2: #7c83ff;
  --ec-accent-soft: rgba(51, 209, 255, 0.18);
  --ec-shadow-sm: 0 18px 42px rgba(3, 8, 20, 0.28);
  --ec-shadow-lg: 0 32px 76px rgba(3, 8, 20, 0.42);
  --ec-radius-card: 26px;
  --ec-surface-blur: 18px;
}

:root[data-educlass-theme="cartoon"] {
  --ec-font-sans: "Comic Sans MS", "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ec-body-bg: #fff2b8;
  --ec-body-bg-alt: #fffdf1;
  --ec-bg-glow-1: rgba(255, 159, 104, 0.42);
  --ec-bg-glow-2: rgba(56, 189, 248, 0.28);
  --ec-body-pattern:
    radial-gradient(circle at 15% 18%, rgba(255, 255, 255, 0.94) 0, transparent 16%),
    radial-gradient(circle at 84% 14%, rgba(255, 255, 255, 0.84) 0, transparent 18%),
    radial-gradient(circle at 18% 74%, rgba(255, 111, 145, 0.18) 0, transparent 15%),
    radial-gradient(circle at 82% 74%, rgba(59, 130, 246, 0.2) 0, transparent 15%),
    radial-gradient(circle, rgba(147, 197, 253, 0.24) 1.8px, transparent 1.8px);
  --ec-surface-1: rgba(255, 255, 255, 0.96);
  --ec-surface-2: rgba(255, 244, 196, 0.98);
  --ec-surface-3: rgba(255, 255, 255, 0.9);
  --ec-border-strong: rgba(96, 165, 250, 0.46);
  --ec-border-soft: rgba(255, 255, 255, 0.82);
  --ec-text-1: #3b334a;
  --ec-text-2: #5f5474;
  --ec-text-muted: #8d84a4;
  --ec-accent-1: #ff9f68;
  --ec-accent-2: #52c7ff;
  --ec-accent-soft: rgba(255, 159, 104, 0.28);
  --ec-shadow-sm: 0 16px 0 rgba(59, 130, 246, 0.1), 0 20px 38px rgba(59, 130, 246, 0.16);
  --ec-shadow-lg: 0 20px 0 rgba(59, 130, 246, 0.14), 0 34px 68px rgba(59, 130, 246, 0.22);
  --ec-radius-card: 34px;
  --ec-surface-blur: 8px;
}

:root[data-educlass-theme="warm"] {
  --ec-font-sans: "Georgia", "PingFang SC", "Microsoft YaHei", serif;
  --ec-body-bg: #f6efe7;
  --ec-body-bg-alt: #fffaf2;
  --ec-bg-glow-1: rgba(251, 191, 36, 0.22);
  --ec-bg-glow-2: rgba(244, 114, 182, 0.16);
  --ec-body-pattern:
    radial-gradient(circle at 15% 16%, rgba(255, 255, 255, 0.84) 0, transparent 18%),
    radial-gradient(circle at 86% 18%, rgba(255, 255, 255, 0.66) 0, transparent 22%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.1), transparent 48%);
  --ec-surface-1: rgba(255, 251, 245, 0.92);
  --ec-surface-2: rgba(255, 246, 236, 0.95);
  --ec-surface-3: rgba(255, 255, 255, 0.76);
  --ec-border-strong: rgba(234, 179, 8, 0.24);
  --ec-border-soft: rgba(255, 255, 255, 0.56);
  --ec-text-1: #5e4a3c;
  --ec-text-2: #846957;
  --ec-text-muted: #af917e;
  --ec-accent-1: #f59e0b;
  --ec-accent-2: #fb7185;
  --ec-accent-soft: rgba(245, 158, 11, 0.16);
  --ec-shadow-sm: 0 12px 24px rgba(120, 84, 50, 0.08);
  --ec-shadow-lg: 0 24px 56px rgba(120, 84, 50, 0.14);
  --ec-radius-card: 30px;
  --ec-surface-blur: 10px;
}

:root[data-educlass-theme="business"] {
  --ec-font-sans: "Bahnschrift", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ec-body-bg: #eef2f6;
  --ec-body-bg-alt: #f8fafc;
  --ec-bg-glow-1: rgba(148, 163, 184, 0.16);
  --ec-bg-glow-2: rgba(16, 185, 129, 0.08);
  --ec-body-pattern:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  --ec-surface-1: rgba(255, 255, 255, 0.96);
  --ec-surface-2: rgba(244, 247, 250, 0.98);
  --ec-surface-3: rgba(255, 255, 255, 0.86);
  --ec-border-strong: rgba(100, 116, 139, 0.2);
  --ec-border-soft: rgba(255, 255, 255, 0.8);
  --ec-text-1: #0f172a;
  --ec-text-2: #334155;
  --ec-text-muted: #64748b;
  --ec-accent-1: #0f766e;
  --ec-accent-2: #1f2937;
  --ec-accent-soft: rgba(15, 118, 110, 0.14);
  --ec-shadow-sm: 0 10px 20px rgba(15, 23, 42, 0.06);
  --ec-shadow-lg: 0 20px 46px rgba(15, 23, 42, 0.1);
  --ec-radius-card: 22px;
  --ec-surface-blur: 4px;
}

html[data-educlass-theme] {
  color-scheme: light;
}

html[data-educlass-theme="tech"] {
  color-scheme: dark;
}

html[data-educlass-theme] body {
  font-family: var(--ec-font-sans);
  background:
    radial-gradient(circle at top left, var(--ec-bg-glow-1) 0, transparent 34%),
    radial-gradient(circle at top right, var(--ec-bg-glow-2) 0, transparent 38%),
    var(--ec-body-pattern),
    linear-gradient(180deg, var(--ec-body-bg-alt), var(--ec-body-bg));
  background-size: auto, auto, 24px 24px, auto;
  color: var(--ec-text-1);
  transition: background 220ms ease, color 220ms ease;
}

html[data-educlass-theme="cartoon"] body {
  background-size: auto, auto, 52px 52px, auto;
}

html[data-educlass-theme] body,
html[data-educlass-theme] #root,
html[data-educlass-theme] main,
html[data-educlass-theme] aside,
html[data-educlass-theme] section {
  position: relative;
}

html[data-educlass-theme] [class*="bg-white"],
html[data-educlass-theme] [class*="bg-slate-50"],
html[data-educlass-theme] [class*="bg-slate-100"] {
  background: var(--ec-surface-1) !important;
}

html[data-educlass-theme] [class*="border-slate-"],
html[data-educlass-theme] [class*="border-black"] {
  border-color: var(--ec-border-strong) !important;
}

html[data-educlass-theme] [class*="bg-indigo-600"],
html[data-educlass-theme] [class*="bg-indigo-500"],
html[data-educlass-theme] [class*="hover:bg-indigo-700"],
html[data-educlass-theme] [class*="hover:bg-indigo-600"] {
  background: linear-gradient(135deg, var(--ec-accent-1), var(--ec-accent-2)) !important;
  color: #ffffff !important;
}

html[data-educlass-theme] [class*="text-indigo-600"],
html[data-educlass-theme] [class*="text-indigo-500"] {
  color: var(--ec-accent-1) !important;
}

html[data-educlass-theme] [class*="bg-indigo-50"],
html[data-educlass-theme] [class*="bg-indigo-100"] {
  background: var(--ec-accent-soft) !important;
  color: var(--ec-accent-1) !important;
}

html[data-educlass-theme] [class*="border-indigo-"],
html[data-educlass-theme] [class*="ring-indigo-"] {
  border-color: var(--ec-accent-soft) !important;
  --tw-ring-color: var(--ec-accent-soft) !important;
}

html[data-educlass-theme] [class*="rounded-2xl"],
html[data-educlass-theme] [class*="rounded-3xl"],
html[data-educlass-theme] dialog,
html[data-educlass-theme] [role="dialog"] {
  border-radius: var(--ec-radius-card) !important;
}

html[data-educlass-theme="cartoon"] button,
html[data-educlass-theme="cartoon"] [role="button"] {
  border-radius: 20px !important;
  font-weight: 900;
}

html[data-educlass-theme="business"] [class*="rounded-2xl"],
html[data-educlass-theme="business"] [class*="rounded-3xl"] {
  border-radius: 22px !important;
}

html[data-educlass-theme] [class*="shadow-"],
html[data-educlass-theme] [role="dialog"],
html[data-educlass-theme] dialog {
  box-shadow: var(--ec-shadow-lg) !important;
}

html[data-educlass-theme="tech"] [class*="bg-white"],
html[data-educlass-theme="tech"] [class*="bg-slate-50"],
html[data-educlass-theme="tech"] [class*="bg-slate-100"],
html[data-educlass-theme="tech"] [role="dialog"] {
  backdrop-filter: blur(var(--ec-surface-blur));
}

html[data-educlass-theme="tech"] [class*="bg-white"],
html[data-educlass-theme="tech"] [class*="bg-slate-50"],
html[data-educlass-theme="tech"] [class*="bg-slate-100"] {
  background:
    linear-gradient(180deg, rgba(10, 24, 43, 0.92), rgba(7, 20, 37, 0.82)),
    var(--ec-surface-1) !important;
  box-shadow:
    inset 0 0 0 1px rgba(51, 209, 255, 0.12),
    var(--ec-shadow-lg) !important;
}

html[data-educlass-theme="cartoon"] [class*="bg-white"],
html[data-educlass-theme="cartoon"] [class*="bg-slate-50"],
html[data-educlass-theme="cartoon"] [class*="bg-slate-100"],
html[data-educlass-theme="cartoon"] [role="dialog"] {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.92) 0, transparent 28%),
    linear-gradient(180deg, rgba(255, 247, 204, 0.96), rgba(255, 255, 255, 0.96)),
    var(--ec-surface-1) !important;
  border-width: 2px !important;
}

html[data-educlass-theme="cartoon"] [class*="shadow-"],
html[data-educlass-theme="cartoon"] [role="dialog"],
html[data-educlass-theme="cartoon"] dialog {
  box-shadow:
    0 12px 0 rgba(96, 165, 250, 0.1),
    var(--ec-shadow-lg) !important;
}

html[data-educlass-theme="cartoon"] .educlass-theme-fab,
html[data-educlass-theme="cartoon"] .educlass-theme-panel,
html[data-educlass-theme="cartoon"] .educlass-theme-card {
  border-width: 2px;
}

html[data-educlass-theme="warm"] [class*="bg-white"],
html[data-educlass-theme="warm"] [class*="bg-slate-50"],
html[data-educlass-theme="warm"] [class*="bg-slate-100"] {
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(255, 244, 233, 0.94)),
    var(--ec-surface-1) !important;
}

html[data-educlass-theme="business"] [class*="bg-white"],
html[data-educlass-theme="business"] [class*="bg-slate-50"],
html[data-educlass-theme="business"] [class*="bg-slate-100"] {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(244, 247, 250, 0.98)),
    var(--ec-surface-1) !important;
}

html[data-educlass-theme="business"] [class*="shadow-"],
html[data-educlass-theme="business"] [role="dialog"],
html[data-educlass-theme="business"] dialog {
  box-shadow:
    0 1px 0 rgba(15, 23, 42, 0.06),
    var(--ec-shadow-lg) !important;
}

.educlass-theme-shell {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.educlass-theme-fab {
  border: 1px solid var(--ec-border-strong);
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--ec-surface-1);
  color: var(--ec-text-1);
  box-shadow: var(--ec-shadow-sm);
  backdrop-filter: blur(var(--ec-surface-blur));
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 700 12px/1 var(--ec-font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.educlass-theme-fab:hover {
  transform: translateY(-2px);
}

.educlass-theme-fab__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ec-accent-1), var(--ec-accent-2));
  box-shadow: 0 0 0 6px var(--ec-accent-soft);
}

.educlass-theme-panel {
  width: min(320px, calc(100vw - 24px));
  padding: 16px;
  border-radius: calc(var(--ec-radius-card) - 4px);
  border: 1px solid var(--ec-border-strong);
  background: var(--ec-surface-2);
  box-shadow: var(--ec-shadow-lg);
  backdrop-filter: blur(calc(var(--ec-surface-blur) + 2px));
  display: none;
}

.educlass-theme-panel.is-open {
  display: block;
}

.educlass-theme-panel__title {
  margin: 0 0 12px;
  color: var(--ec-text-1);
  font: 800 14px/1.2 var(--ec-font-sans);
}

.educlass-theme-panel__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.educlass-theme-card {
  border: 1px solid transparent;
  border-radius: 22px;
  padding: 12px;
  background: var(--ec-surface-3);
  color: var(--ec-text-1);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.educlass-theme-card:hover {
  transform: translateY(-1px);
}

.educlass-theme-card.is-active {
  border-color: var(--ec-accent-1);
  box-shadow: inset 0 0 0 1px var(--ec-accent-soft);
}

.educlass-theme-card__swatch {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.educlass-theme-card__swatch span {
  flex: 1;
  height: 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.educlass-theme-card__name {
  display: block;
  font: 800 13px/1.2 var(--ec-font-sans);
  margin-bottom: 4px;
}

.educlass-theme-card__desc {
  display: block;
  color: var(--ec-text-muted);
  font: 600 11px/1.5 var(--ec-font-sans);
}

@media (max-width: 768px) {
  .educlass-theme-shell {
    right: 12px;
    bottom: 12px;
  }

  .educlass-theme-panel {
    width: min(300px, calc(100vw - 20px));
  }
}
