:root {
  /* Canvas — light desktop SaaS */
  --bg-canvas: #f7f7f8;
  --bg-deep: #f7f7f8;
  --bg-mid: #f0f0f2;
  --bg-gradient: #f7f7f8;
  --bg-mx: 50%;
  --bg-my: 35%;
  --bg-trail-x: 50%;
  --bg-trail-y: 35%;
  --bg-grid-x: 0px;
  --bg-grid-y: 0px;

  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f4f4f5;
  --header-bg: rgba(247, 247, 248, 0.86);
  --overlay-scrim: rgba(17, 17, 19, 0.4);
  --hover-fill: rgba(0, 0, 0, 0.04);
  --hover-border: rgba(0, 0, 0, 0.16);

  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.06);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);

  --primary: #5b6cff;
  --primary-hover: #4a5aef;
  --primary-soft: rgba(91, 108, 255, 0.1);
  --accent: #5b6cff;
  --accent-glow: transparent;
  --gradient-btn: #5b6cff;

  --text-title: #111113;
  --text-body: #3f3f46;
  --text-muted: #71717a;
  --text-on-dark: #111113;
  --text-on-primary: #ffffff;

  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;

  --auth-banner-info-bg: rgba(91, 108, 255, 0.12);
  --auth-banner-info-border: rgba(91, 108, 255, 0.35);
  --auth-banner-info-text: #4338ca;
  --auth-banner-warn-bg: rgba(217, 119, 6, 0.1);
  --auth-banner-warn-border: rgba(217, 119, 6, 0.35);
  --auth-banner-warn-text: #b45309;

  /* Minutes thematic sections (keep in sync with exporters THEME_PALETTE) */
  --mm-theme-orange-fg: #d97706;
  --mm-theme-orange-bg: #fffbeb;
  --mm-theme-orange-border: #fcd34d;
  --mm-theme-blue-fg: #2563eb;
  --mm-theme-blue-bg: #eff6ff;
  --mm-theme-blue-border: #93c5fd;
  --mm-theme-teal-fg: #0d9488;
  --mm-theme-teal-bg: #f0fdfa;
  --mm-theme-teal-border: #5eead4;
  --mm-theme-olive-fg: #65a30d;
  --mm-theme-olive-bg: #f7fee7;
  --mm-theme-olive-border: #bef264;

  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);

  /* Pointer spotlight: white glow + blue-violet grid (light) */
  --spotlight-core: rgba(255, 255, 255, 0.55);
  --spotlight-mid: rgba(255, 255, 255, 0.28);
  --spotlight-trail: rgba(255, 255, 255, 0.16);
  --spotlight-grid: rgba(91, 108, 255, 0.62);
  --spotlight-size: 373px;
  --spotlight-opacity: 1;
  --spotlight-muted-opacity: 0.22;
  --grid-cell: 24px;

  --skeleton-a: #ebebef;
  --skeleton-b: #f4f4f5;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 12px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", "Yu Gothic",
    "Malgun Gothic", sans-serif;
  --transition: 160ms ease;
  --max-width: 1180px;

  /* Motion (read by motion.js; keep in sync for reduced-motion overrides) */
  --motion-enter-y: 32px;
  --motion-enter-duration: 0.5s;
  --motion-stagger: 0.08s;
  --motion-home-stagger: 0.1s;
  --motion-card-lift: -5px;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-enter-y: 0px;
    --motion-enter-duration: 0.01s;
    --motion-stagger: 0s;
    --motion-home-stagger: 0s;
    --motion-card-lift: 0px;
  }
}

html[data-theme="dark"] {
  --bg-canvas: #0f1115;
  --bg-deep: #0f1115;
  --bg-mid: #16181d;
  --bg-gradient: #0f1115;

  --surface: #18181b;
  --surface-raised: #1c1c21;
  --surface-muted: #222228;
  --header-bg: rgba(15, 17, 21, 0.88);
  --overlay-scrim: rgba(0, 0, 0, 0.55);
  --hover-fill: rgba(255, 255, 255, 0.06);
  --hover-border: rgba(255, 255, 255, 0.16);

  --card-bg: #18181b;
  --card-border: rgba(255, 255, 255, 0.08);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.25);

  --primary: #6b7aff;
  --primary-hover: #7c8aff;
  --primary-soft: rgba(107, 122, 255, 0.18);
  --accent: #6b7aff;
  --gradient-btn: #6b7aff;

  --text-title: #f4f4f5;
  --text-body: #d4d4d8;
  --text-muted: #a1a1aa;
  --text-on-dark: #f4f4f5;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --spotlight-core: rgba(107, 122, 255, 0.26);
  --spotlight-mid: rgba(124, 92, 255, 0.14);
  --spotlight-trail: rgba(124, 92, 255, 0.16);
  --spotlight-grid: rgba(255, 255, 255, 0.45);
  --spotlight-opacity: 1;
  --spotlight-muted-opacity: 0.18;

  --skeleton-a: #27272a;
  --skeleton-b: #3f3f46;

  --auth-banner-info-bg: rgba(107, 122, 255, 0.18);
  --auth-banner-info-border: rgba(107, 122, 255, 0.45);
  --auth-banner-info-text: #a5b4fc;
  --auth-banner-warn-bg: rgba(251, 191, 36, 0.12);
  --auth-banner-warn-border: rgba(251, 191, 36, 0.35);
  --auth-banner-warn-text: #fbbf24;

  --mm-theme-orange-fg: #fbbf24;
  --mm-theme-orange-bg: rgba(217, 119, 6, 0.14);
  --mm-theme-orange-border: rgba(251, 191, 36, 0.35);
  --mm-theme-blue-fg: #93c5fd;
  --mm-theme-blue-bg: rgba(37, 99, 235, 0.16);
  --mm-theme-blue-border: rgba(147, 197, 253, 0.35);
  --mm-theme-teal-fg: #5eead4;
  --mm-theme-teal-bg: rgba(13, 148, 136, 0.16);
  --mm-theme-teal-border: rgba(94, 234, 212, 0.35);
  --mm-theme-olive-fg: #bef264;
  --mm-theme-olive-bg: rgba(101, 163, 13, 0.16);
  --mm-theme-olive-border: rgba(190, 242, 100, 0.35);

  color-scheme: dark;
}

html {
  font-size: clamp(100%, 0.2vw + 0.96rem, 106%);
  color-scheme: light;
}

@property --grid-drift-x {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}

@property --grid-drift-y {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  color: var(--text-body);
  line-height: 1.55;
  min-height: 100vh;
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Thin grid lines — masked to spotlight / trail blobs */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--spotlight-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--spotlight-grid) 1px, transparent 1px);
  background-size: var(--grid-cell) var(--grid-cell);
  background-position:
    calc(var(--bg-grid-x) + var(--grid-drift-x)) calc(var(--bg-grid-y) + var(--grid-drift-y)),
    calc(var(--bg-grid-x) + var(--grid-drift-x)) calc(var(--bg-grid-y) + var(--grid-drift-y));
  transform-origin: var(--bg-mx) var(--bg-my);
  -webkit-mask-image:
    radial-gradient(
      calc(var(--spotlight-size) * 0.55) circle at var(--bg-mx) var(--bg-my),
      #000 0%,
      transparent 70%
    ),
    radial-gradient(
      calc(var(--spotlight-size) * 0.7) circle at var(--bg-trail-x) var(--bg-trail-y),
      rgba(0, 0, 0, 0.55) 0%,
      transparent 72%
    );
  mask-image:
    radial-gradient(
      calc(var(--spotlight-size) * 0.55) circle at var(--bg-mx) var(--bg-my),
      #000 0%,
      transparent 70%
    ),
    radial-gradient(
      calc(var(--spotlight-size) * 0.7) circle at var(--bg-trail-x) var(--bg-trail-y),
      rgba(0, 0, 0, 0.55) 0%,
      transparent 72%
    );
  -webkit-mask-composite: source-over;
  mask-composite: add;
  opacity: 0;
  transition: opacity 0.35s ease;
}

/* Drift + expand from cursor/spotlight center */
body.bg-spotlight-active::before {
  animation:
    spotlight-grid-drift 16s linear infinite,
    spotlight-grid-expand 4s ease-out infinite;
}

@keyframes spotlight-grid-drift {
  0% {
    --grid-drift-x: 0px;
    --grid-drift-y: 0px;
  }
  25% {
    --grid-drift-x: 8px;
    --grid-drift-y: -6px;
  }
  50% {
    --grid-drift-x: 16px;
    --grid-drift-y: 4px;
  }
  75% {
    --grid-drift-x: 8px;
    --grid-drift-y: 12px;
  }
  100% {
    --grid-drift-x: 24px;
    --grid-drift-y: 24px;
  }
}

@keyframes spotlight-grid-expand {
  0% {
    transform: scale(1);
  }
  70% {
    transform: scale(1.15);
  }
  100% {
    transform: scale(1);
  }
}

/* Primary glow + softer trail remnant */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(
      var(--spotlight-size) circle at var(--bg-mx) var(--bg-my),
      var(--spotlight-core) 0%,
      var(--spotlight-mid) 32%,
      transparent 62%
    ),
    radial-gradient(
      calc(var(--spotlight-size) * 1.15) circle at var(--bg-trail-x) var(--bg-trail-y),
      var(--spotlight-trail) 0%,
      transparent 58%
    );
  opacity: 0;
  transition: opacity 0.35s ease;
}

body.bg-spotlight-active::before,
body.bg-spotlight-active::after {
  opacity: var(--spotlight-opacity);
}

body.bg-spotlight-active.bg-spotlight-muted::before,
body.bg-spotlight-active.bg-spotlight-muted::after {
  opacity: var(--spotlight-muted-opacity);
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after {
    display: none;
  }

  body.bg-spotlight-active::before {
    animation: none;
  }
}

.hidden {
  display: none !important;
}

.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    box-shadow var(--transition),
    opacity var(--transition);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn-primary {
  background: var(--primary);
  color: var(--text-on-primary);
  border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-title);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-muted);
  border-color: var(--hover-border);
}

.btn-danger {
  background: var(--surface);
  color: var(--error);
  border-color: rgba(220, 38, 38, 0.35);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(220, 38, 38, 0.06);
}

.btn-ghost {
  background: transparent;
  color: var(--text-body);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--hover-fill);
  color: var(--text-title);
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
  font-weight: 400;
}

.status-toast {
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-top: 1rem;
}

.status-toast.loading {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid rgba(91, 108, 255, 0.2);
}

.status-toast.error {
  background: rgba(220, 38, 38, 0.06);
  color: var(--error);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.status-toast.warning {
  background: rgba(217, 119, 6, 0.08);
  color: #b45309;
  border: 1px solid rgba(217, 119, 6, 0.22);
}

.status-toast.success {
  background: rgba(22, 163, 74, 0.08);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.22);
}

html[data-theme="dark"] .status-toast.warning {
  color: #fbbf24;
}

html[data-theme="dark"] .status-toast.success {
  color: #4ade80;
}

select,
textarea,
input[type="file"],
input[type="text"],
input[type="search"] {
  font: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  color: var(--text-body);
  transition: border-color var(--transition), box-shadow var(--transition);
}

select:focus,
textarea:focus,
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
