/* ============================================
   EduTools — Design System & Styles
   Modern Glassmorphism Dark Theme
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Noto+Sans+Thai:wght@300;400;500;600;700;800;900&display=swap');

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
  /* Colors */
  --bg-primary: #06080f;
  --bg-secondary: #0d1117;
  --bg-tertiary: #161b22;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-glass: rgba(13, 17, 23, 0.8);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-tertiary: #6e7681;
  --text-link: #58a6ff;

  /* Accent Colors */
  --purple: #940533;
  --purple-glow: rgba(148, 5, 51, 0.4);
  --blue: #C0012A;
  --blue-glow: rgba(192, 1, 42, 0.4);
  --cyan: #F5061D;
  --cyan-glow: rgba(245, 6, 29, 0.4);
  --green: #FF8800;
  --green-glow: rgba(255, 136, 0, 0.4);
  --amber: #FFB300;
  --amber-glow: rgba(255, 179, 0, 0.4);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.4);
  --pink: #ec4899;
  --pink-glow: rgba(236, 72, 153, 0.4);
  --indigo: #6366f1;
  --teal: #14b8a6;
  --orange: #f97316;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #940533, #C0012A, #F5061D);
  --gradient-purple: linear-gradient(135deg, #940533, #C0012A);
  --gradient-blue: linear-gradient(135deg, #C0012A, #F5061D);
  --gradient-cyan: linear-gradient(135deg, #F5061D, #FF8800);
  --gradient-green: linear-gradient(135deg, #FF8800, #FFB300);
  --gradient-amber: linear-gradient(135deg, #FFB300, #F5061D);
  --gradient-red: linear-gradient(135deg, #dc2626, #ef4444);
  --gradient-pink: linear-gradient(135deg, #db2777, #ec4899);
  --gradient-hero: linear-gradient(135deg, rgba(148, 5, 51, 0.15), rgba(192, 1, 42, 0.1), rgba(245, 6, 29, 0.05));

  /* Typography */
  --font-primary: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --fs-xs: 0.6875rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.3125rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 2rem;
  --fs-4xl: 2.5rem;
  --fs-5xl: 3.25rem;
  --fs-6xl: 4rem;

  /* Spacing */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;
  --sp-24: 6rem;

  /* Border Radius */
  --r-sm: 0.375rem;
  --r-md: 0.5rem;
  --r-lg: 0.75rem;
  --r-xl: 1rem;
  --r-2xl: 1.25rem;
  --r-3xl: 1.5rem;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
  --shadow-glow-purple: 0 0 40px rgba(148, 5, 51, 0.15);
  --shadow-glow-blue: 0 0 40px rgba(192, 1, 42, 0.15);
  --shadow-glow-cyan: 0 0 40px rgba(245, 6, 29, 0.15);

  /* Transitions */
  --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --header-h: 4rem;
  --max-w: 1280px;
  --max-w-lg: 960px;
  --max-w-sm: 640px;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-primary);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: inherit;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

ul, ol {
  list-style: none;
}

/* ============================================
   Animated Background
   ============================================ */
.bg-mesh {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
}

.bg-mesh::before,
.bg-mesh::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}

.bg-mesh::before {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--mesh-1, rgba(148, 5, 51, 0.2)), transparent 70%);
  top: -200px;
  left: -100px;
}

.bg-mesh::after {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--mesh-2, rgba(245, 6, 29, 0.15)), transparent 70%);
  bottom: -150px;
  right: -100px;
  animation-delay: -10s;
}

.bg-mesh-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.3;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--mesh-3, rgba(192, 1, 42, 0.2)), transparent 70%);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: float 25s ease-in-out infinite;
  animation-delay: -5s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ============================================
   Header / Navbar
   ============================================ */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  z-index: 1000;
  background: rgba(6, 8, 15, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--t-base), box-shadow var(--t-base);
}

.app-header.scrolled {
  background: rgba(6, 8, 15, 0.95);
  box-shadow: var(--shadow-lg);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--sp-6);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  transition: opacity var(--t-fast);
}

.app-logo:hover { opacity: 0.85; }

.app-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--shadow-glow-purple);
}

.app-logo-text {
  font-size: var(--fs-xl);
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.btn-back {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: all var(--t-base);
}

.btn-back:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.btn-back.visible {
  display: flex;
}

.btn-back svg {
  width: 16px;
  height: 16px;
}

.theme-select {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: all var(--t-base);
  cursor: pointer;
  outline: none;
  /* Basic custom arrow */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  background-size: 14px;
  padding-right: var(--sp-8);
  appearance: none;
  -webkit-appearance: none;
}

.theme-select:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

/* Ensure options have dark background so they are visible */
.theme-select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ============================================
   Main Content Area
   ============================================ */
.app-main {
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ============================================
   Hero Section
   ============================================ */
.hero {
  padding: var(--sp-16) var(--sp-6) var(--sp-12);
  text-align: center;
  position: relative;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--sp-6);
  animation: fadeInUp 0.6s ease;
}

.hero-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hero-title {
  font-size: var(--fs-5xl);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-6);
  animation: fadeInUp 0.6s ease 0.1s both;
}

.hero-title-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: var(--fs-lg);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto var(--sp-8);
  line-height: 1.7;
  animation: fadeInUp 0.6s ease 0.2s both;
}

/* ============================================
   Search Bar
   ============================================ */
.search-container {
  max-width: 540px;
  margin: 0 auto var(--sp-12);
  animation: fadeInUp 0.6s ease 0.3s both;
}

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar svg {
  position: absolute;
  left: var(--sp-4);
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-12);
  border-radius: var(--r-xl);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--fs-base);
  transition: all var(--t-base);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

.search-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1), var(--shadow-glow-purple);
  background: var(--bg-card-hover);
}

/* ============================================
   Category Sections
   ============================================ */
.categories-container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--sp-6) var(--sp-16);
}

.category-section {
  margin-bottom: var(--sp-12);
}

.category-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border-color);
}

.category-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.category-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.category-count {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  margin-left: auto;
}

/* ============================================
   Tool Cards Grid
   ============================================ */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
}

.tool-card {
  position: relative;
  padding: var(--sp-6);
  border-radius: var(--r-xl);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--t-base);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--card-accent, var(--gradient-primary));
  opacity: 0;
  transition: opacity var(--t-base);
}

.tool-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.tool-card:hover::before {
  opacity: 1;
}

.tool-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: var(--icon-bg, rgba(139, 92, 246, 0.1));
  color: var(--icon-color, var(--purple));
  flex-shrink: 0;
  transition: transform var(--t-spring);
}

.tool-card:hover .tool-card-icon {
  transform: scale(1.1) rotate(-3deg);
}

.tool-card-title {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tool-card-desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  flex-grow: 1;
}

.tool-card-arrow {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  transition: all var(--t-base);
  margin-top: var(--sp-2);
}

.tool-card:hover .tool-card-arrow {
  color: var(--icon-color, var(--purple));
  gap: var(--sp-3);
}

/* Category accent colors */
.cat-manage .tool-card { --card-accent: var(--gradient-purple); --icon-bg: rgba(148, 5, 51, 0.1); --icon-color: var(--purple); }
.cat-convert .tool-card { --card-accent: var(--gradient-blue); --icon-bg: rgba(192, 1, 42, 0.1); --icon-color: var(--blue); }
.cat-secure .tool-card { --card-accent: var(--gradient-green); --icon-bg: rgba(255, 136, 0, 0.1); --icon-color: var(--green); }
.cat-customize .tool-card { --card-accent: var(--gradient-amber); --icon-bg: rgba(255, 179, 0, 0.1); --icon-color: var(--amber); }
.cat-utility .tool-card { --card-accent: var(--gradient-cyan); --icon-bg: rgba(245, 6, 29, 0.1); --icon-color: var(--cyan); }

/* ============================================
   Tool Page Layout
   ============================================ */
.tool-page {
  display: none;
  max-width: var(--max-w-lg);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-6) var(--sp-16);
  animation: fadeInUp 0.4s ease;
}

.tool-page.active {
  display: block;
}

.tool-page-header {
  text-align: center;
  margin-bottom: var(--sp-8);
}

.tool-page-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto var(--sp-4);
}

.tool-page-title {
  font-size: var(--fs-3xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-3);
}

.tool-page-desc {
  font-size: var(--fs-base);
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ============================================
   Upload Zone
   ============================================ */
.upload-zone {
  position: relative;
  border: 2px dashed var(--border-color);
  border-radius: var(--r-2xl);
  padding: var(--sp-12) var(--sp-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--t-base);
  background: var(--bg-card);
  overflow: hidden;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--t-base);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--purple);
  background: var(--bg-card-hover);
}

.upload-zone.dragover::before {
  opacity: 0.05;
}

.upload-zone-content {
  position: relative;
  z-index: 1;
}

.upload-zone-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--sp-4);
  border-radius: var(--r-xl);
  background: rgba(139, 92, 246, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--purple);
  font-size: 1.5rem;
  transition: transform var(--t-spring);
}

.upload-zone:hover .upload-zone-icon {
  transform: translateY(-4px);
}

.upload-zone-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.upload-zone-text {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: var(--sp-4);
}

.upload-zone-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-full);
  background: var(--gradient-primary);
  color: white;
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: all var(--t-base);
  box-shadow: var(--shadow-glow-purple);
}

.upload-zone-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ============================================
   File List
   ============================================ */
.file-list {
  margin-top: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.file-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: all var(--t-base);
  cursor: grab;
  animation: fadeInUp 0.3s ease;
}

.file-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.file-item.dragging {
  opacity: 0.5;
  transform: scale(0.98);
}

.file-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: rgba(239, 68, 68, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.file-item-info {
  flex-grow: 1;
  min-width: 0;
}

.file-item-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-size {
  font-size: var(--fs-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}

.file-item-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

.file-item-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  transition: all var(--t-fast);
}

.file-item-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.file-item-btn.delete:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

/* Drag handle */
.drag-handle {
  width: 20px;
  height: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
  cursor: grab;
  opacity: 0.4;
  transition: opacity var(--t-fast);
}

.drag-handle:hover { opacity: 0.8; }

.drag-handle span {
  width: 12px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
}

/* ============================================
   Page Thumbnails Grid (for split/rotate)
   ============================================ */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-6);
}

.page-thumb {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 2px solid var(--border-color);
  cursor: pointer;
  transition: all var(--t-base);
  aspect-ratio: 210/297;
  background: white;
}

.page-thumb:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.page-thumb.selected {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.page-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.page-thumb-number {
  position: absolute;
  bottom: var(--sp-2);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: white;
}

.page-thumb-check {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  opacity: 0;
  transform: scale(0.5);
  transition: all var(--t-spring);
}

.page-thumb.selected .page-thumb-check {
  opacity: 1;
  transform: scale(1);
}

/* Rotation indicator on page thumb */
.page-thumb .rotation-badge {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: rgba(59, 130, 246, 0.8);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: white;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: all var(--t-base);
  cursor: pointer;
  border: none;
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-glow-purple);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-success {
  background: var(--gradient-green);
  color: white;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
  transform: translateY(-1px);
}

.btn-lg {
  padding: var(--sp-4) var(--sp-8);
  font-size: var(--fs-base);
  border-radius: var(--r-xl);
}

.btn-sm {
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-xs);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--r-lg);
}

.btn svg {
  width: 18px;
  height: 18px;
}

/* Action bar */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  margin-top: var(--sp-8);
  flex-wrap: wrap;
}

/* ============================================
   Form Controls
   ============================================ */
.form-group {
  margin-bottom: var(--sp-5);
}

.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--fs-sm);
  transition: all var(--t-base);
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4);
}

/* Range slider */
.form-range {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--purple);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
  transition: transform var(--t-fast);
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Checkbox custom */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  font-size: var(--fs-sm);
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: var(--r-sm);
  border: 2px solid var(--border-color);
  background: var(--bg-card);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
  position: relative;
}

.form-check input[type="checkbox"]:checked {
  background: var(--purple);
  border-color: var(--purple);
}

.form-check input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  color: white;
  font-weight: 700;
}

/* Color picker */
.form-color {
  width: 48px;
  height: 48px;
  border-radius: var(--r-lg);
  border: 2px solid var(--border-color);
  padding: 2px;
  cursor: pointer;
  background: var(--bg-card);
}

/* ============================================
   Options Panel
   ============================================ */
.options-panel {
  padding: var(--sp-6);
  border-radius: var(--r-xl);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  margin-top: var(--sp-6);
}

.options-title {
  font-size: var(--fs-md);
  font-weight: 700;
  margin-bottom: var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.options-title svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

/* ============================================
   Signature Canvas
   ============================================ */
.signature-area {
  margin-top: var(--sp-6);
}

.signature-canvas-wrapper {
  position: relative;
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: white;
}

.signature-canvas {
  width: 100%;
  height: 200px;
  cursor: crosshair;
  touch-action: none;
}

.signature-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}

/* ============================================
   Progress Bar
   ============================================ */
.progress-container {
  margin-top: var(--sp-6);
  display: none;
}

.progress-container.active {
  display: block;
}

.progress-bar-wrapper {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  overflow: hidden;
  margin-bottom: var(--sp-3);
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--gradient-primary);
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  text-align: center;
}

/* ============================================
   Download / Result Section
   ============================================ */
.result-section {
  display: none;
  text-align: center;
  margin-top: var(--sp-8);
  padding: var(--sp-8);
  border-radius: var(--r-2xl);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  animation: fadeInUp 0.4s ease;
}

.result-section.active {
  display: block;
}

.result-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--sp-4);
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  font-size: 2rem;
}

.result-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.result-desc {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: var(--sp-6);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: calc(var(--header-h) + var(--sp-4));
  right: var(--sp-4);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  min-width: 280px;
  max-width: 420px;
  animation: slideInRight 0.3s ease;
  font-size: var(--fs-sm);
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--amber); }
.toast.info { border-left: 3px solid var(--blue); }

.toast-icon {
  flex-shrink: 0;
  font-size: 1.2rem;
}

.toast-msg {
  flex-grow: 1;
}

.toast-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--t-fast);
}

.toast-close:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  opacity: 0;
  visibility: hidden;
  transition: all var(--t-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-radius: var(--r-2xl);
  border: 1px solid var(--border-color);
  padding: var(--sp-8);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--t-base);
  box-shadow: var(--shadow-xl);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
}

.modal-title {
  font-size: var(--fs-xl);
  font-weight: 700;
}

/* ============================================
   Loading Spinner
   ============================================ */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--sp-4) auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 15, 0.85);
  backdrop-filter: blur(8px);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  opacity: 0;
  visibility: hidden;
  transition: all var(--t-base);
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-text {
  font-size: var(--fs-base);
  color: var(--text-secondary);
}

/* ============================================
   URL Shortener Specific
   ============================================ */
.url-input-group {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

.url-input-group .form-input {
  flex-grow: 1;
}

.short-url-result {
  display: none;
  margin-top: var(--sp-6);
  padding: var(--sp-5);
  border-radius: var(--r-xl);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.short-url-result.active {
  display: block;
  animation: fadeInUp 0.3s ease;
}

.short-url-display {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--bg-tertiary);
  margin-bottom: var(--sp-4);
}

.short-url-link {
  flex-grow: 1;
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--cyan);
  word-break: break-all;
}

/* ============================================
   QR Code Specific
   ============================================ */
.qr-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
  margin-top: var(--sp-6);
}

.qr-canvas-wrapper {
  padding: var(--sp-6);
  background: white;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  display: inline-block;
}

.qr-canvas-wrapper canvas,
.qr-canvas-wrapper img {
  display: block;
}

/* ============================================
   Watermark Preview
   ============================================ */
.watermark-preview {
  margin-top: var(--sp-6);
  position: relative;
  background: white;
  border-radius: var(--r-xl);
  overflow: hidden;
  aspect-ratio: 210/297;
  max-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
}

/* ============================================
   Password Input Toggle
   ============================================ */
.password-group {
  position: relative;
}

.password-group .toggle-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  transition: color var(--t-fast);
}

.password-group .toggle-pw:hover {
  color: var(--text-primary);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--sp-12);
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--sp-4);
  opacity: 0.5;
}

/* ============================================
   Footer
   ============================================ */
.app-footer {
  border-top: 1px solid var(--border-color);
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

.footer-text {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
}

.footer-text a {
  color: var(--text-secondary);
  transition: color var(--t-fast);
}

.footer-text a:hover {
  color: var(--purple);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Staggered card animations */
.tool-card:nth-child(1) { animation: fadeInUp 0.4s ease 0.0s both; }
.tool-card:nth-child(2) { animation: fadeInUp 0.4s ease 0.05s both; }
.tool-card:nth-child(3) { animation: fadeInUp 0.4s ease 0.1s both; }
.tool-card:nth-child(4) { animation: fadeInUp 0.4s ease 0.15s both; }
.tool-card:nth-child(5) { animation: fadeInUp 0.4s ease 0.2s both; }
.tool-card:nth-child(6) { animation: fadeInUp 0.4s ease 0.25s both; }
.tool-card:nth-child(7) { animation: fadeInUp 0.4s ease 0.3s both; }
.tool-card:nth-child(8) { animation: fadeInUp 0.4s ease 0.35s both; }

/* ============================================
   Tabs
   ============================================ */
.tabs {
  display: flex;
  gap: var(--sp-1);
  padding: var(--sp-1);
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-color);
  margin-bottom: var(--sp-5);
}

.tab-btn {
  flex: 1;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--t-base);
  text-align: center;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--purple);
  color: white;
  box-shadow: var(--shadow-sm);
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
  .tool-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  }

  .hero-title {
    font-size: var(--fs-4xl);
  }
}

@media (max-width: 768px) {
  :root {
    --header-h: 3.5rem;
  }

  .hero {
    padding: var(--sp-10) var(--sp-4) var(--sp-8);
  }

  .hero-title {
    font-size: var(--fs-3xl);
  }

  .hero-subtitle {
    font-size: var(--fs-base);
  }

  .categories-container {
    padding: 0 var(--sp-4) var(--sp-12);
  }

  .tool-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--sp-3);
  }

  .tool-card {
    padding: var(--sp-4);
  }

  .tool-card-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .tool-page {
    padding: var(--sp-6) var(--sp-4) var(--sp-12);
  }

  .tool-page-title {
    font-size: var(--fs-2xl);
  }

  .upload-zone {
    padding: var(--sp-8) var(--sp-4);
  }

  .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--sp-3);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .action-bar {
    flex-direction: column;
  }

  .action-bar .btn {
    width: 100%;
  }

  .url-input-group {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: var(--fs-2xl);
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }

  .tool-card {
    flex-direction: row;
    align-items: center;
  }

  .tool-card-desc {
    display: none;
  }

  .tool-card-arrow {
    margin-top: 0;
    margin-left: auto;
  }

  .header-inner {
    padding: 0 var(--sp-4);
  }

  .app-logo-text {
    font-size: var(--fs-lg);
  }

  .toast {
    min-width: auto;
    max-width: calc(100vw - 2rem);
  }
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-muted { color: var(--text-secondary); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }

/* Select all / deselect */
.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  margin-top: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.selection-bar .count {
  font-weight: 600;
  color: var(--text-primary);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ============================================
   Print styles
   ============================================ */
@media print {
  .app-header,
  .bg-mesh,
  .toast-container {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
}

/* ============================================
   Themes
   ============================================ */

/* 1. Cyber / Futuristic */
[data-theme="cyber"] {
  --bg-primary: #050510;
  --bg-secondary: #0a0a1a;
  --purple: #ff00e6;
  --purple-glow: rgba(255, 0, 230, 0.4);
  --blue: #00f3ff;
  --blue-glow: rgba(0, 243, 255, 0.4);
  --cyan: #a8ff00;
  --cyan-glow: rgba(168, 255, 0, 0.4);
  --green: #b026ff;
  --green-glow: rgba(176, 38, 255, 0.4);
  --amber: #fcee0a;
  --amber-glow: rgba(252, 238, 10, 0.4);
  --gradient-primary: linear-gradient(135deg, #ff00e6, #00f3ff, #b026ff);
  --gradient-purple: linear-gradient(135deg, #ff00e6, #00f3ff);
  --gradient-blue: linear-gradient(135deg, #00f3ff, #a8ff00);
  --gradient-cyan: linear-gradient(135deg, #a8ff00, #fcee0a);
  --gradient-green: linear-gradient(135deg, #fcee0a, #b026ff);
  --gradient-amber: linear-gradient(135deg, #b026ff, #ff00e6);
  --gradient-hero: linear-gradient(135deg, rgba(255,0,230,0.15), rgba(0,243,255,0.1), rgba(168,255,0,0.05));
  --shadow-glow-purple: 0 0 40px rgba(255,0,230, 0.2);
  --shadow-glow-blue: 0 0 40px rgba(0,243,255, 0.2);
  --shadow-glow-cyan: 0 0 40px rgba(168,255,0, 0.2);
  --mesh-1: rgba(255, 0, 230, 0.2);
  --mesh-2: rgba(0, 243, 255, 0.15);
  --mesh-3: rgba(176, 38, 255, 0.2);
}

/* 2. Earthy & Eco */
[data-theme="earthy"] {
  --bg-primary: #121611;
  --bg-secondary: #1a2118;
  --purple: #4caf50;
  --purple-glow: rgba(76, 175, 80, 0.4);
  --blue: #8a9a5b;
  --blue-glow: rgba(138, 154, 91, 0.4);
  --cyan: #e2725b;
  --cyan-glow: rgba(226, 114, 91, 0.4);
  --green: #c2b280;
  --green-glow: rgba(194, 178, 128, 0.4);
  --amber: #81b622;
  --amber-glow: rgba(129, 182, 34, 0.4);
  --gradient-primary: linear-gradient(135deg, #4caf50, #8a9a5b, #e2725b);
  --gradient-purple: linear-gradient(135deg, #4caf50, #8a9a5b);
  --gradient-blue: linear-gradient(135deg, #8a9a5b, #c2b280);
  --gradient-cyan: linear-gradient(135deg, #c2b280, #e2725b);
  --gradient-green: linear-gradient(135deg, #e2725b, #81b622);
  --gradient-amber: linear-gradient(135deg, #81b622, #4caf50);
  --gradient-hero: linear-gradient(135deg, rgba(76, 175, 80, 0.15), rgba(138, 154, 91, 0.1), rgba(226, 114, 91, 0.05));
  --shadow-glow-purple: 0 0 40px rgba(76, 175, 80, 0.15);
  --shadow-glow-blue: 0 0 40px rgba(138, 154, 91, 0.15);
  --shadow-glow-cyan: 0 0 40px rgba(226, 114, 91, 0.15);
  --mesh-1: rgba(76, 175, 80, 0.2);
  --mesh-2: rgba(138, 154, 91, 0.15);
  --mesh-3: rgba(226, 114, 91, 0.2);
}

/* 3. Bold & Vibrant */
[data-theme="vibrant"] {
  --bg-primary: #0a0014;
  --bg-secondary: #16002c;
  --purple: #ff0055;
  --purple-glow: rgba(255, 0, 85, 0.4);
  --blue: #0044ff;
  --blue-glow: rgba(0, 68, 255, 0.4);
  --cyan: #00ffcc;
  --cyan-glow: rgba(0, 255, 204, 0.4);
  --green: #ffdd00;
  --green-glow: rgba(255, 221, 0, 0.4);
  --amber: #ff6600;
  --amber-glow: rgba(255, 102, 0, 0.4);
  --gradient-primary: linear-gradient(135deg, #ff0055, #0044ff, #00ffcc);
  --gradient-purple: linear-gradient(135deg, #ff0055, #0044ff);
  --gradient-blue: linear-gradient(135deg, #0044ff, #00ffcc);
  --gradient-cyan: linear-gradient(135deg, #00ffcc, #ffdd00);
  --gradient-green: linear-gradient(135deg, #ffdd00, #ff6600);
  --gradient-amber: linear-gradient(135deg, #ff6600, #ff0055);
  --gradient-hero: linear-gradient(135deg, rgba(255,0,85,0.15), rgba(0,68,255,0.1), rgba(0,255,204,0.05));
  --shadow-glow-purple: 0 0 40px rgba(255,0,85, 0.2);
  --shadow-glow-blue: 0 0 40px rgba(0,68,255, 0.2);
  --shadow-glow-cyan: 0 0 40px rgba(0,255,204, 0.2);
  --mesh-1: rgba(255, 0, 85, 0.2);
  --mesh-2: rgba(0, 68, 255, 0.15);
  --mesh-3: rgba(0, 255, 204, 0.2);
}

/* 4. Dark Mode First */
[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #141414;
  --bg-card: rgba(255, 255, 255, 0.03);
  --purple: #ffffff;
  --purple-glow: rgba(255, 255, 255, 0.2);
  --blue: #a3a3a3;
  --blue-glow: rgba(163, 163, 163, 0.2);
  --cyan: #737373;
  --cyan-glow: rgba(115, 115, 115, 0.2);
  --green: #525252;
  --green-glow: rgba(82, 82, 82, 0.2);
  --amber: #d4d4d4;
  --amber-glow: rgba(212, 212, 212, 0.2);
  --gradient-primary: linear-gradient(135deg, #ffffff, #a3a3a3, #737373);
  --gradient-purple: linear-gradient(135deg, #ffffff, #a3a3a3);
  --gradient-blue: linear-gradient(135deg, #a3a3a3, #737373);
  --gradient-cyan: linear-gradient(135deg, #737373, #525252);
  --gradient-green: linear-gradient(135deg, #525252, #d4d4d4);
  --gradient-amber: linear-gradient(135deg, #d4d4d4, #ffffff);
  --gradient-hero: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(163,163,163,0.05), rgba(115,115,115,0.03));
  --shadow-glow-purple: 0 0 40px rgba(255,255,255, 0.1);
  --shadow-glow-blue: 0 0 40px rgba(163,163,163, 0.1);
  --shadow-glow-cyan: 0 0 40px rgba(115,115,115, 0.1);
  --mesh-1: rgba(255, 255, 255, 0.05);
  --mesh-2: rgba(163, 163, 163, 0.04);
  --mesh-3: rgba(115, 115, 115, 0.03);
}

/* 5. Soft Neutral + Accent */
[data-theme="neutral"] {
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e9ecef;
  --bg-card: rgba(0, 0, 0, 0.03);
  --bg-card-hover: rgba(0, 0, 0, 0.06);
  --bg-glass: rgba(255, 255, 255, 0.8);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --text-primary: #212529;
  --text-secondary: #495057;
  --text-tertiary: #6c757d;
  --purple: #d4a373;
  --purple-glow: rgba(212, 163, 115, 0.4);
  --blue: #ccd5ae;
  --blue-glow: rgba(204, 213, 174, 0.4);
  --cyan: #e9edc9;
  --cyan-glow: rgba(233, 237, 201, 0.4);
  --green: #fefae0;
  --green-glow: rgba(254, 250, 224, 0.4);
  --amber: #faedcd;
  --amber-glow: rgba(250, 237, 205, 0.4);
  --gradient-primary: linear-gradient(135deg, #d4a373, #ccd5ae);
  --gradient-purple: linear-gradient(135deg, #d4a373, #faedcd);
  --gradient-blue: linear-gradient(135deg, #ccd5ae, #e9edc9);
  --gradient-cyan: linear-gradient(135deg, #e9edc9, #fefae0);
  --gradient-green: linear-gradient(135deg, #fefae0, #faedcd);
  --gradient-amber: linear-gradient(135deg, #faedcd, #d4a373);
  --gradient-hero: linear-gradient(135deg, rgba(212,163,115,0.15), rgba(204,213,174,0.1), rgba(233,237,201,0.05));
  --shadow-glow-purple: 0 0 40px rgba(212,163,115, 0.2);
  --shadow-glow-blue: 0 0 40px rgba(204,213,174, 0.2);
  --shadow-glow-cyan: 0 0 40px rgba(233,237,201, 0.2);
  --mesh-1: rgba(212, 163, 115, 0.2);
  --mesh-2: rgba(204, 213, 174, 0.15);
  --mesh-3: rgba(233, 237, 201, 0.2);
}
[data-theme="neutral"] .app-header { background: rgba(255,255,255,0.85); }
[data-theme="neutral"] .app-header.scrolled { background: rgba(255,255,255,0.95); }
[data-theme="neutral"] .search-input { background: #fff; color: #000; }
[data-theme="neutral"] .tool-card { background: #fff; box-shadow: 0 4px 6px rgba(0,0,0,0.02); }
[data-theme="neutral"] .app-logo-text { -webkit-text-fill-color: var(--text-primary); background: none; }

/* 6. Jewel Tone */
[data-theme="jewel"] {
  --bg-primary: #0a0f18;
  --bg-secondary: #101622;
  --purple: #0f52ba;
  --purple-glow: rgba(15, 82, 186, 0.4);
  --blue: #50c878;
  --blue-glow: rgba(80, 200, 120, 0.4);
  --cyan: #9966cc;
  --cyan-glow: rgba(153, 102, 204, 0.4);
  --green: #e0115f;
  --green-glow: rgba(224, 17, 95, 0.4);
  --amber: #ffb81c;
  --amber-glow: rgba(255, 184, 28, 0.4);
  --gradient-primary: linear-gradient(135deg, #0f52ba, #9966cc, #e0115f);
  --gradient-purple: linear-gradient(135deg, #0f52ba, #9966cc);
  --gradient-blue: linear-gradient(135deg, #50c878, #0f52ba);
  --gradient-cyan: linear-gradient(135deg, #9966cc, #e0115f);
  --gradient-green: linear-gradient(135deg, #e0115f, #ffb81c);
  --gradient-amber: linear-gradient(135deg, #ffb81c, #50c878);
  --gradient-hero: linear-gradient(135deg, rgba(15,82,186,0.15), rgba(153,102,204,0.1), rgba(224,17,95,0.05));
  --shadow-glow-purple: 0 0 40px rgba(15,82,186, 0.2);
  --shadow-glow-blue: 0 0 40px rgba(80,200,120, 0.2);
  --shadow-glow-cyan: 0 0 40px rgba(153,102,204, 0.2);
  --mesh-1: rgba(15, 82, 186, 0.2);
  --mesh-2: rgba(153, 102, 204, 0.15);
  --mesh-3: rgba(224, 17, 95, 0.2);
}

/* 7. Gradient System */
[data-theme="gradient"] {
  --bg-primary: #1a0b2e;
  --bg-secondary: #251242;
  --purple: #ff7eb3;
  --purple-glow: rgba(255, 126, 179, 0.4);
  --blue: #ff758c;
  --blue-glow: rgba(255, 117, 140, 0.4);
  --cyan: #845ec2;
  --cyan-glow: rgba(132, 94, 194, 0.4);
  --green: #d65db1;
  --green-glow: rgba(214, 93, 177, 0.4);
  --amber: #ff9671;
  --amber-glow: rgba(255, 150, 113, 0.4);
  --gradient-primary: linear-gradient(135deg, #ff7eb3, #ff758c, #845ec2);
  --gradient-purple: linear-gradient(135deg, #ff7eb3, #ff758c);
  --gradient-blue: linear-gradient(135deg, #ff758c, #d65db1);
  --gradient-cyan: linear-gradient(135deg, #845ec2, #ff9671);
  --gradient-green: linear-gradient(135deg, #d65db1, #ff7eb3);
  --gradient-amber: linear-gradient(135deg, #ff9671, #845ec2);
  --gradient-hero: linear-gradient(135deg, rgba(255,126,179,0.15), rgba(255,117,140,0.1), rgba(132,94,194,0.05));
  --shadow-glow-purple: 0 0 40px rgba(255,126,179, 0.2);
  --shadow-glow-blue: 0 0 40px rgba(255,117,140, 0.2);
  --shadow-glow-cyan: 0 0 40px rgba(132,94,194, 0.2);
  --mesh-1: rgba(255, 126, 179, 0.2);
  --mesh-2: rgba(255, 117, 140, 0.15);
  --mesh-3: rgba(132, 94, 194, 0.2);
}

