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

:root {
  /* Accent */
  --accent: #007AFF;
  --accent-hover: #0066d6;
  --accent-light: rgba(0, 122, 255, 0.12);
  --accent-glow: rgba(0, 122, 255, 0.4);

  /* Semantic */
  --danger: #FF3B30;
  --danger-light: rgba(255, 59, 48, 0.12);
  --success: #34C759;
  --success-light: rgba(52, 199, 89, 0.12);
  --warning: #FF9500;
  --warning-light: rgba(255, 149, 0, 0.12);

  /* Radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 24px;
  --r-pill: 999px;

  /* Spacing */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Transitions */
  --t-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --t-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --t-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);

  /* Glass */
  --blur: 40px;
  --saturate: 180%;
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --bg: #f2f2f7;
  --bg-gradient: linear-gradient(135deg, #667eea22 0%, #764ba222 50%, #f093fb11 100%);
  --surface: rgba(255, 255, 255, 0.55);
  --surface-solid: #ffffff;
  --surface-hover: rgba(255, 255, 255, 0.75);
  --surface-elevated: rgba(255, 255, 255, 0.72);
  --surface-input: rgba(255, 255, 255, 0.5);
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --text: #1c1c1e;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --overlay: rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-glow: 0 0 30px rgba(0, 122, 255, 0.15);
  --mesh-dot: rgba(0,0,0,0.04);
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
  --bg: #000000;
  --bg-gradient: linear-gradient(135deg, #667eea15 0%, #764ba215 50%, #f093fb08 100%);
  --surface: rgba(28, 28, 30, 0.65);
  --surface-solid: #1c1c1e;
  --surface-hover: rgba(44, 44, 46, 0.75);
  --surface-elevated: rgba(44, 44, 46, 0.8);
  --surface-input: rgba(44, 44, 46, 0.6);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #f2f2f7;
  --text-secondary: #98989d;
  --text-tertiary: #636366;
  --overlay: rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(0, 122, 255, 0.25);
  --mesh-dot: rgba(255,255,255,0.03);
}

html {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  position: relative;
  transition: background var(--t-normal), color var(--t-normal);
}

/* ===== ANIMATED MESH BACKGROUND ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 1px 1px, var(--mesh-dot) 1px, transparent 0);
  background-size: 24px 24px;
  z-index: -1;
  transition: background var(--t-normal);
  pointer-events: none;
}

/* Noise grain overlay — behind content to avoid Safari/WebKit
   pointer-events:none bug on fixed pseudo-elements (z-index -1
   keeps it visible through semi-transparent glass surfaces) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.4;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}
[data-theme="dark"] body::after { opacity: 0.2; }

/* Animated gradient orbs */
.orb-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
/* Orbs are generated by JS to fill full page height */

[data-theme="dark"] .orb { filter: brightness(0.5); }

@keyframes orbDriftA {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(60px, 40px) scale(1.15); }
  50% { transform: translate(-30px, 80px) scale(0.95); }
  75% { transform: translate(40px, -20px) scale(1.08); }
}
@keyframes orbDriftB {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(50px, -60px) scale(1.1); }
  50% { transform: translate(80px, 20px) scale(0.9); }
  75% { transform: translate(-30px, -40px) scale(1.05); }
}
@keyframes orbDriftC {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-50px, -40px) scale(1.12); }
  66% { transform: translate(40px, -60px) scale(0.92); }
}
@keyframes orbDriftD {
  0%, 100% { transform: translate(0, 0) scale(1); }
  30% { transform: translate(-70px, 30px) scale(1.08); }
  60% { transform: translate(20px, -50px) scale(0.95); }
}
@keyframes orbDriftE {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40% { transform: translate(60px, -30px) scale(1.1); }
  70% { transform: translate(-40px, 50px) scale(0.93); }
}
@keyframes orbDriftF {
  0%, 100% { transform: translate(0, 0) scale(1); }
  35% { transform: translate(-40px, 60px) scale(1.06); }
  65% { transform: translate(50px, 30px) scale(0.97); }
}

/* ===== GLASS MIXIN ===== */
.glass {
  background: var(--surface);
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  border: 1px solid var(--border);
  transition: background var(--t-normal), border-color var(--t-normal), box-shadow var(--t-normal);
}
.glass-elevated {
  background: var(--surface-elevated);
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: background var(--t-normal), border-color var(--t-normal), box-shadow var(--t-normal);
}

/* ===== TYPOGRAPHY ===== */
.heading-xl { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.heading-lg { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; }
.heading-md { font-size: 1.17rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.heading-sm { font-size: 0.95rem; font-weight: 600; line-height: 1.4; }
.body-text { font-size: 0.935rem; font-weight: 400; line-height: 1.55; color: var(--text-secondary); }
.caption { font-size: 0.8rem; font-weight: 500; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== LAYOUT ===== */
.page { width: 100%; max-width: 480px; margin: 0 auto; padding: 0 16px; padding-bottom: calc(80px + var(--safe-bottom)); }
@media (min-width: 768px) {
  .page { max-width: 800px; padding: 0 32px; }
}
@media (min-width: 1200px) {
  .page { max-width: 1100px; padding: 0 48px; }
}

.section { margin-bottom: 48px; }
.section-label { margin-bottom: 16px; }

/* ===== ENTRANCE ANIMATIONS ===== */
.animate-in {
  opacity: 0;
  transform: translateY(24px);
  animation: slideIn var(--t-slow) forwards;
}
@keyframes slideIn {
  to { opacity: 1; transform: translateY(0); }
}
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }
.stagger-9 { animation-delay: 0.45s; }
.stagger-10 { animation-delay: 0.5s; }

/* ===== TOP NAV BAR ===== */
.navbar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 100;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background var(--t-normal), border-color var(--t-normal);
}
@media (min-width: 768px) {
  .navbar { padding: calc(14px + var(--safe-top)) 32px 14px; }
}
.navbar-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.navbar-actions { display: flex; gap: 6px; align-items: center; }

/* ===== ICON BUTTON ===== */
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
  overflow: hidden;
}
.icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: scale(1.06);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  width: 56px;
  height: 30px;
  border-radius: var(--r-pill);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  transition: all var(--t-normal);
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(0,122,255,0.3);
  transition: transform var(--t-spring);
}
[data-theme="dark"] .theme-toggle::after {
  transform: translateX(26px);
}
.theme-toggle-icons {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  pointer-events: none;
}
.theme-toggle-icons svg {
  width: 14px;
  height: 14px;
  transition: opacity var(--t-normal);
}
[data-theme="light"] .theme-toggle-icons .icon-moon { opacity: 0.35; }
[data-theme="light"] .theme-toggle-icons .icon-sun { opacity: 1; color: #fff; }
[data-theme="dark"] .theme-toggle-icons .icon-sun { opacity: 0.35; }
[data-theme="dark"] .theme-toggle-icons .icon-moon { opacity: 1; color: #fff; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--r-pill);
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--ripple-x, 50%) var(--ripple-y, 50%), rgba(255,255,255,0.3) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
}
.btn:active::after { opacity: 1; transition: opacity 0s; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,122,255,0.3);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,122,255,0.35); }
.btn-primary:active { transform: translateY(0) scale(0.97); }

.btn-secondary {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--accent);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--accent); transform: translateY(-1px); }
.btn-secondary:active { transform: translateY(0) scale(0.97); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 2px 12px rgba(255,59,48,0.3);
}
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(255,59,48,0.35); }
.btn-danger:active { transform: translateY(0) scale(0.97); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 16px;
}
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-ghost:active { transform: scale(0.97); }

.btn-sm { font-size: 0.8rem; padding: 7px 14px; }
.btn-lg { font-size: 1rem; padding: 14px 28px; border-radius: var(--r-xl); }

.btn-icon {
  padding: 10px;
  border-radius: var(--r-pill);
}
.btn-icon svg { width: 18px; height: 18px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== INPUTS ===== */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input {
  font-family: inherit;
  font-size: 1rem;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-input);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text);
  outline: none;
  transition: all var(--t-fast);
  width: 100%;
}
.input::placeholder { color: var(--text-tertiary); }
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-sm);
  background: var(--surface-hover);
}

.textarea { resize: vertical; min-height: 100px; line-height: 1.5; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* ===== SEARCH BAR ===== */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}
.search-bar .search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
  width: 18px;
  height: 18px;
  transition: color var(--t-fast);
}
.search-bar .input {
  padding-left: 42px;
  padding-right: 42px;
  border-radius: var(--r-pill);
}
.search-bar .input:focus ~ .search-icon,
.search-bar .input:focus + .search-icon { color: var(--accent); }
.search-clear {
  position: absolute;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  opacity: 0;
  transform: scale(0.8);
}
.search-clear.visible { opacity: 1; transform: scale(1); }
.search-clear:hover { background: var(--surface-hover); color: var(--text); }
.search-clear svg { width: 14px; height: 14px; }

/* ===== CHIPS / FILTER PILLS ===== */
.chip-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 2px 16px;
  margin-left: -16px;
  margin-right: -16px;
  scroll-snap-type: x mandatory;
}
.chip-bar::-webkit-scrollbar { display: none; }
@media (min-width: 768px) {
  .chip-bar { padding: 2px 32px; margin-left: -32px; margin-right: -32px; }
}
@media (min-width: 1200px) {
  .chip-bar { padding: 2px 48px; margin-left: -48px; margin-right: -48px; }
}

.chip {
  flex-shrink: 0;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  scroll-snap-align: start;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.chip:active { transform: scale(0.95); }
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(0,122,255,0.25);
}

/* ===== STATS ===== */
.stats-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 16px;
  margin-left: -16px;
  margin-right: -16px;
}
.stats-row::-webkit-scrollbar { display: none; }
@media (min-width: 768px) {
  .stats-row { padding: 2px 32px; margin-left: -32px; margin-right: -32px; }
}
@media (min-width: 1200px) {
  .stats-row { padding: 2px 48px; margin-left: -48px; margin-right: -48px; }
}

.stat-card {
  flex: 1;
  min-width: 90px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  text-align: center;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 2px;
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== CARDS ===== */
.card {
  border-radius: var(--r-xl);
  padding: 20px;
  transition: all var(--t-normal);
}
.card:hover { box-shadow: var(--shadow-lg); }

.card-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  transition: all var(--t-fast);
  cursor: pointer;
}
.card-row:hover { background: var(--surface-hover); }
.card-row:active { transform: scale(0.985); }

.card-row + .card-row { border-top: 1px solid var(--border); }

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.2rem;
}
.card-content { flex: 1; min-width: 0; }
.card-title { font-size: 0.95rem; font-weight: 600; }
.card-subtitle { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.card-meta { font-size: 0.8rem; color: var(--text-tertiary); font-weight: 500; flex-shrink: 0; }
.card-arrow { color: var(--text-tertiary); flex-shrink: 0; transition: transform var(--t-fast); }
.card-row:hover .card-arrow { transform: translateX(3px); color: var(--accent); }

/* ===== COVER GRID (Gamelibrary) ===== */
.cover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
@media (min-width: 768px) {
  .cover-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
}

.cover-card {
  position: relative;
  aspect-ratio: 2/3;
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--t-normal);
}
.cover-card:hover { transform: translateY(-4px) scale(1.02); box-shadow: var(--shadow-lg); }
.cover-card:active { transform: scale(0.97); }
.cover-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-card .cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.cover-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 10px 10px;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
  color: #fff;
}
.cover-rating-bar ~ .cover-overlay {
  padding-bottom: 26px;
}
.cover-title { font-size: 0.78rem; font-weight: 600; line-height: 1.2; }
.cover-meta { font-size: 0.68rem; opacity: 0.75; margin-top: 2px; }
.cover-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.cover-rating {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 3px;
}
.rating-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}
.rating-dot.filled { background: #FFD60A; }

/* ===== LIST ITEMS (Wishlist) ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  transition: all var(--t-fast);
  cursor: pointer;
}
.list-item:hover { background: var(--surface-hover); }
.list-item:active { transform: scale(0.985); }
.list-item + .list-item { border-top: 1px solid var(--border); }

.checkbox {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--t-fast);
  cursor: pointer;
}
.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  animation: checkPop 0.3s var(--t-spring);
}
.checkbox.checked svg { color: #fff; }
.checkbox:not(.checked) svg { display: none; }

@keyframes checkPop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-size: 0.95rem; font-weight: 500; }
.list-item-title.checked-text { text-decoration: line-through; color: var(--text-tertiary); }
.list-item-note { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

.priority-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}
.priority-high { background: var(--danger-light); color: var(--danger); }
.priority-medium { background: var(--warning-light); color: var(--warning); }
.priority-low { background: var(--success-light); color: var(--success); }

/* ===== TABS ===== */
.tab-bar {
  display: flex;
  border-radius: var(--r-lg);
  padding: 3px;
  gap: 2px;
}
.tab {
  flex: 1;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--r-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,122,255,0.2);
}

/* ===== TOGGLE ===== */
.toggle-wrap { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.toggle-label-text { font-size: 0.95rem; font-weight: 500; }
.toggle-description { font-size: 0.8rem; color: var(--text-secondary); margin-top: 1px; }
.toggle {
  width: 51px;
  height: 31px;
  border-radius: var(--r-pill);
  background: var(--text-tertiary);
  border: none;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform var(--t-spring);
}
.toggle.active { background: var(--accent); }
.toggle.active::after { transform: translateX(20px); }

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--accent-light);
  color: var(--accent);
}
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ===== TABLE (Admin) ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  scrollbar-width: none;
}
.table-wrap::-webkit-scrollbar { display: none; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-hover); }
.table .user-cell { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
}
.toast {
  background: var(--surface-elevated);
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 12px 20px;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn 0.5s var(--t-spring) forwards;
  white-space: nowrap;
}
.toast.toast-out { animation: toastOut 0.3s ease forwards; }
.toast-icon { flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success); }
.toast-danger .toast-icon { color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-20px) scale(0.9); }
}

/* ===== BOTTOM SHEET ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 201;
  background: var(--surface-elevated);
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  max-height: 85dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0.4s;
  padding-bottom: var(--safe-bottom);
  visibility: hidden;
}
.sheet.open { transform: translateY(0); visibility: visible; transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s; }

.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--text-tertiary);
  opacity: 0.4;
  margin: 8px auto 0;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
}
.sheet-title { font-size: 1.1rem; font-weight: 600; }
.sheet-body { padding: 0 20px 20px; }

@media (min-width: 768px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: 50%;
    transform: translate(-50%, 50%) scale(0.95);
    opacity: 0;
    max-width: 480px;
    width: 100%;
    border-radius: var(--r-2xl);
    border: 1px solid var(--border);
    max-height: 80vh;
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity var(--t-normal), visibility 0s 0.4s;
  }
  .sheet.open { transform: translate(-50%, 50%) scale(1); opacity: 1; visibility: visible; transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1), opacity var(--t-normal), visibility 0s; }
  .sheet-handle { display: none; }
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface-elevated);
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.9) translateY(10px);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }

.modal-body { padding: 24px; text-align: center; }
.modal-icon { font-size: 2.5rem; margin-bottom: 12px; }
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
.modal-text { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.5; }
.modal-actions {
  display: flex;
  border-top: 1px solid var(--border);
}
.modal-actions .modal-btn {
  flex: 1;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 15px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--accent);
  transition: background var(--t-fast);
}
.modal-actions .modal-btn:hover { background: var(--surface-hover); }
.modal-actions .modal-btn:active { background: var(--surface); }
.modal-actions .modal-btn + .modal-btn { border-left: 1px solid var(--border); }
.modal-actions .modal-btn-danger { color: var(--danger); }
.modal-actions .modal-btn-bold { font-weight: 600; }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  box-shadow: 0 4px 20px rgba(0,122,255,0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: all var(--t-spring);
}
.fab:hover { transform: scale(1.1); box-shadow: 0 6px 28px rgba(0,122,255,0.45); }
.fab:active { transform: scale(0.9); }
.fab svg { width: 24px; height: 24px; }

/* ===== LOGIN CARD ===== */
.login-container {
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 24px;
  border-radius: var(--r-2xl);
  text-align: center;
}
.login-logo {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
  background: linear-gradient(135deg, var(--accent), #AF52DE);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-subtitle { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 28px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .btn { width: 100%; margin-top: 6px; }
.login-error {
  font-size: 0.82rem;
  color: var(--danger);
  padding: 8px 14px;
  border-radius: var(--r-md);
  background: var(--danger-light);
  display: none;
}
.login-error.visible { display: block; }

/* ===== TREE (Notiblox) ===== */
.tree { padding: 4px 0; }
.tree-node { padding-left: 20px; }
.tree-node:first-child { padding-left: 0; }
.tree-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
}
.tree-item:hover { background: var(--surface-hover); }
.tree-toggle {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.tree-toggle:hover { background: var(--surface-hover); }
.tree-toggle svg { width: 12px; height: 12px; transition: transform var(--t-fast); }
.tree-toggle.expanded svg { transform: rotate(90deg); }
.tree-item-label { font-size: 0.9rem; font-weight: 500; flex: 1; }
.tree-item-count {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

/* ===== PROGRESS / SLIDER ===== */
.progress-bar {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--accent);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== AVATAR GROUP ===== */
.avatar-group { display: flex; }
.avatar-group .user-avatar { margin-left: -8px; border: 2px solid var(--bg); }
.avatar-group .user-avatar:first-child { margin-left: 0; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.6; }
.empty-state-text { font-size: 0.95rem; color: var(--text-secondary); }
.empty-state-action { margin-top: 16px; }

/* ===== SKELETON LOADING ===== */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== FILE UPLOAD / DROP ===== */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-xl);
  padding: 32px;
  text-align: center;
  transition: all var(--t-fast);
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.drop-zone-icon { font-size: 2rem; margin-bottom: 8px; color: var(--text-tertiary); }
.drop-zone-text { font-size: 0.88rem; color: var(--text-secondary); }
.drop-zone-hint { font-size: 0.78rem; color: var(--text-tertiary); margin-top: 4px; }

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* ===== COLOR DOTS ===== */
.color-dots { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--t-fast);
  border: 2px solid transparent;
}
.color-dot:hover { transform: scale(1.15); }
.color-dot.selected { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor; }

/* ===== PIE CHART (Zeitscheibe placeholder) ===== */
.pie-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 20px 0;
}
.pie-chart {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  position: relative;
  transform: rotate(-90deg);
}
.pie-legend { display: flex; flex-direction: column; gap: 8px; }
.pie-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.pie-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ===== RESPONSIVE HELPERS ===== */
.desktop-only { display: none; }
@media (min-width: 768px) {
  .desktop-only { display: flex; }
  .mobile-only { display: none; }
}

/* ===== SCROLLBAR (Desktop) ===== */
@media (min-width: 768px) {
  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--text-tertiary); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
}

/* ===== FOCUS VISIBLE ===== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
input:focus:not(:focus-visible) {
  outline: none;
}

/* ===== GAP HELPERS ===== */
.gap-sm { gap: 8px; }
.gap-md { gap: 14px; }
.gap-lg { gap: 20px; }
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.w-full { width: 100%; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 14px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 14px; }
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
