:root {
  --primary: #6b4ce6;
  --primary-hover: #5633df;
  --bg-dark: #f0f2f5;
  --surface: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.08);
  --text-main: #1a1a1a;
  --text-muted: #646b73;
  --danger: #ff4757;
  --success: #2ed573;
  --warning: #ffa502;
  
  --input-bg: rgba(0, 0, 0, 0.04);
  --input-focus: rgba(0, 0, 0, 0.08);
  --card-bg: rgba(0, 0, 0, 0.02);
  --card-hover: rgba(0, 0, 0, 0.04);
  --hover-overlay: rgba(0, 0, 0, 0.05);
  
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 24px;
}

[data-theme="dark"] {
  --primary: #7a5ce6;
  --primary-hover: #8f75f5;
  --bg-dark: #121212;
  --surface: #1e1e1e;
  --glass-bg: rgba(30, 30, 30, 0.65);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-main: #e4e4e4;
  --text-muted: #8b9298;
  
  --input-bg: rgba(255, 255, 255, 0.08);
  --input-focus: rgba(255, 255, 255, 0.12);
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-hover: rgba(255, 255, 255, 0.06);
  --hover-overlay: rgba(255, 255, 255, 0.05);
  
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
  height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

#background-blobs {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at top right, var(--bg-dark), var(--bg-dark));
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: float 20s infinite alternate;
}

.blob-1 {
  width: 500px; height: 500px;
  background: var(--primary);
  top: -200px; left: -100px;
}

.blob-2 {
  width: 400px; height: 400px;
  background: #392b7c;
  bottom: -100px; right: 10%;
  animation-delay: -5s;
}

[data-theme="dark"] .blob { opacity: 0.25; }

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(100px, 50px) scale(1.1); }
}

.glass-container {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
}
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--glass-border);
}
.glass-btn {
  background: rgba(107, 76, 230, 0.1);
  border: 1px solid rgba(107, 76, 230, 0.3);
  backdrop-filter: blur(4px);
  color: var(--text-main);
}
.glass-btn:hover {
  background: var(--primary);
  color: white;
}

h1, h2, h3 { font-weight: 600; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2rem;
}
.logo-container.small { margin-bottom: 3rem; transform: scale(0.8); }

.css-puzzle-logo {
  position: relative;
  width: 140px; height: 140px;
  background: var(--primary);
  border: 4px solid var(--bg-dark);
  border-radius: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transform: rotate(-5deg);
  transition: transform 0.3s;
}
.css-puzzle-logo:hover {
  transform: rotate(0deg) scale(1.05);
}
.css-puzzle-logo::before, .css-puzzle-logo::after {
  content: '';
  position: absolute;
  width: 40px; height: 40px;
  background: var(--primary);
  border: 4px solid var(--bg-dark);
  border-radius: 50%;
}
.css-puzzle-logo::before { top: -24px; left: 50px; border-bottom: none; }
.css-puzzle-logo::after { right: -24px; top: 50px; border-left: none; }

.css-puzzle-logo span.hole-1, .css-puzzle-logo span.hole-2 {
  position: absolute;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-dark);
  border: 4px solid var(--bg-dark);
  z-index: 2;
}
.css-puzzle-logo span.hole-1 { bottom: -20px; left: 50px; border-top: none; }
.css-puzzle-logo span.hole-2 { left: -20px; top: 50px; border-right: none; }

.logo-text {
  font-family: 'Press Start 2P', cursive, sans-serif;
  color: white;
  font-size: 18px;
  z-index: 10;
  letter-spacing: 1px;
}

.view-screen { display: none; height: 100vh; width: 100vw; }
.view-screen.active { display: flex; }

#auth-screen { justify-content: center; align-items: center; }
.auth-box { width: 100%; max-width: 420px; padding: 3rem 2.5rem; border-radius: var(--radius-lg); text-align: center; animation: slideUp 0.5s forwards; }
.auth-box h2 { font-size: 1.5rem; margin-bottom: 0.5rem; color: var(--text-main); }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 2rem; }

.form-group { text-align: left; margin-bottom: 1.5rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: 500; }
.form-group input[type="text"], .form-group select, .form-group textarea {
  width: 100%; padding: 12px 16px;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem; font-family: inherit; transition: 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); background: var(--input-focus);
}
.form-group textarea { resize: vertical; min-height: 100px; }

.radio-group { display: flex; gap: 1rem; }
.radio-btn {
  flex: 1; padding: 12px 0; background: var(--input-bg);
  border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  text-align: center; cursor: pointer; transition: 0.2s;
  font-size: 0.9rem; font-weight: 500; color: var(--text-main);
}
.radio-btn:hover { background: var(--hover-overlay); }
.radio-btn input { display: none; }
.radio-btn.active {
  background: rgba(107, 76, 230, 0.1); border-color: var(--primary); color: var(--primary);
}

.primary-btn {
  width: 100%; padding: 14px; background: var(--primary); color: white; border: none;
  border-radius: var(--radius-md); font-weight: 600; font-size: 1rem; cursor: pointer; transition: 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.primary-btn:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 15px rgba(107, 76, 230, 0.3); }
.primary-btn:active { transform: translateY(0); }
.secondary-btn {
  padding: 10px 16px; background: var(--input-bg); color: var(--text-main); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); font-weight: 500; font-size: 0.9rem; cursor: pointer; transition: 0.2s;
}
.secondary-btn:hover { background: var(--hover-overlay); }

#app-screen { display: flex; }

.sidebar { width: 260px; padding: 2rem 1.5rem; display: flex; flex-direction: column; }
.user-profile {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  background: var(--card-bg); border-radius: var(--radius-md); margin-bottom: 2rem;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #b024d9);
  display: flex; justify-content: center; align-items: center;
  font-weight: bold; font-size: 1.1rem; color: white;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 0.95rem; }
.user-role { font-size: 0.75rem; color: var(--primary); font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;}

.nav-links { flex: 1; }
.nav-links li { margin-bottom: 0.5rem; }
.nav-links a {
  display: block; padding: 12px 16px; border-radius: var(--radius-sm);
  color: var(--text-muted); transition: 0.2s; font-weight: 500; font-size: 0.95rem;
}
.nav-links a:hover { background: var(--hover-overlay); color: var(--text-main); }
.nav-links li.active a { background: rgba(107, 76, 230, 0.1); color: var(--primary); border-left: 3px solid var(--primary); }
.danger-text { color: var(--danger) !important; }
.danger-text:hover { background: rgba(255, 71, 87, 0.1) !important; }

.main-content { flex: 1; padding: 2rem 3rem; position: relative; overflow-y: auto; }
.top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2.5rem; }
.top-header h1 { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.5px; }

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--input-bg); border: 1px solid var(--glass-border);
  color: var(--text-main); cursor: pointer; padding: 8px 12px;
  border-radius: var(--radius-sm); font-size: 1rem; transition: 0.2s; margin-left: 10px;
}
.theme-toggle-btn:hover { background: var(--hover-overlay); }
.header-actions { display: flex; gap: 1rem; align-items: center; }

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; height: calc(100% - 100px); min-height: 500px; }
.board-column {
  background: var(--glass-bg); border-radius: var(--radius-md);
  border: 1px solid var(--glass-border); padding: 1rem; display: flex; flex-direction: column; height: 100%;
}
.column-header { display: flex; align-items: center; margin-bottom: 1rem; gap: 8px; }
.column-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-main); flex: 1; }
.task-count { background: var(--input-bg); padding: 2px 8px; border-radius: 12px; font-size: 0.8rem; font-weight: 600; }
.status-indicator { width: 10px; height: 10px; border-radius: 50%; }
.dot-red { background: var(--danger); box-shadow: 0 0 8px rgba(255, 71, 87, 0.4); }
.dot-yellow { background: var(--warning); box-shadow: 0 0 8px rgba(255, 165, 2, 0.4); }
.dot-green { background: var(--success); box-shadow: 0 0 8px rgba(46, 213, 115, 0.4); }

.task-list { flex: 1; overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 12px; }
.task-list::-webkit-scrollbar { width: 4px; }
.task-list::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 4px; }

.task-card {
  background: var(--card-bg); border: 1px solid var(--glass-border);
  padding: 1rem; border-radius: var(--radius-sm); cursor: grab; transition: 0.2s; position: relative;
}
.task-card:active { cursor: grabbing; transform: scale(0.98); }
.task-card:hover { background: var(--card-hover); border-color: var(--primary); box-shadow: var(--shadow-sm); }
.task-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.task-desc { 
  font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; line-height: 1.4; 
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; 
  line-clamp: 2; /* fix standard property */
  overflow: hidden; 
}
.task-meta { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--glass-border); padding-top: 10px; }
.assignee-badge { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text-main); background: var(--input-bg); padding: 4px 8px; border-radius: 12px; }
.notice-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; transition: 0.2s; font-size: 0.85rem; padding: 4px; border-radius: 4px; }
.notice-btn:hover { color: var(--primary); background: rgba(107, 76, 230, 0.1); }
.notice-btn.has-notes { color: var(--warning); }

.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(5px);
  display: flex; justify-content: center; align-items: center;
  z-index: 100; opacity: 0; pointer-events: none; transition: 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-content {
  width: 100%; max-width: 450px; padding: 2rem; border-radius: var(--radius-lg);
  transform: translateY(20px); transition: 0.3s; background: var(--surface); color: var(--text-main);
  border: 1px solid var(--glass-border); box-shadow: var(--shadow-lg);
}
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.close-btn { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; transition: 0.2s; }
.close-btn:hover { color: var(--text-main); }
.mt-15 { margin-top: 15px; }

.status-dropdown { background: var(--surface); color: var(--text-main); border: 1px solid var(--glass-border); padding: 4px; border-radius: 4px; font-size: 0.75rem; outline: none; }
.notices-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.notice-item { background: var(--input-bg); padding: 10px; border-radius: 6px; font-size: 0.85rem; border-left: 2px solid var(--primary); }
.notice-author { font-weight: 600; color: var(--primary); font-size: 0.75rem; margin-bottom: 4px; }

@keyframes slideUp { 0% { transform: translateY(30px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

/* Team View Styles */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}
.team-card {
  padding: 1.5rem;
  border-radius: var(--radius-md);
  transition: transform 0.2s;
}
.team-card:hover { transform: translateY(-5px); }
.team-card-header { display: flex; align-items: center; gap: 15px; margin-bottom: 1.5rem; }
.team-stats { display: flex; gap: 20px; margin-bottom: 1.5rem; }
.stat-item { display: flex; flex-direction: column; }
.stat-val { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.stat-lbl { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }

.progress-bar {
  height: 6px; width: 100%; background: var(--input-bg);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--primary);
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Toast Styles */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px; z-index: 1000;
}
.toast-item {
  padding: 12px 20px; border-radius: var(--radius-sm);
  color: white; font-size: 0.9rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s forwards;
}
.toast-item.success { background: var(--success); }
.toast-item.error { background: var(--danger); }
.toast-item.fade-out { opacity: 0; transform: translateX(20px); transition: 0.5s; }

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

@media (max-width: 768px) {
  #app-screen.active { flex-direction: column; }
  
  /* 1. Ultra-Compact Sidebar Level (50px tall) */
  .sidebar { 
    width: 100%; height: 55px; padding: 0 10px; 
    border-right: none; border-bottom: 1px solid var(--glass-border); 
    display: flex !important; flex-direction: row !important; 
    align-items: center !important; justify-content: space-between !important;
    background: var(--glass-bg); flex-wrap: nowrap !important;
  }
  
  /* Shrink Logo with literal DOM size reduction */
  .logo-container.small { width: 45px; height: 45px; margin: 0; display: flex; justify-content: center; align-items: center; }
  .css-puzzle-logo { zoom: 0.35; margin: 0; }
  
  /* Compact Nav Links */
  .nav-links { 
    display: flex; flex-direction: row; gap: 4px;
    width: auto; padding: 0; border: none; margin: 0; flex: 1; justify-content: center;
  }
  .nav-links li { margin: 0; }
  .nav-links a { padding: 6px 10px; font-size: 0.75rem; border-radius: var(--radius-md); border: none !important; background: transparent; }
  .nav-links li.active a { background: rgba(107, 76, 230, 0.1); color: var(--primary); font-weight: 700; border: none !important; box-shadow: none !important; }
  
  /* Tiny User Profile */
  .user-profile { padding: 0; margin: 0; background: transparent; display: flex; gap: 5px; align-items: center; }
  .user-name, .user-role { display: none; } /* Hide all text here, just avatar */
  .avatar { width: 30px; height: 30px; font-size: 0.8rem; margin: 0; border: 2px solid white; box-shadow: var(--shadow-sm); }
  
  /* --- PERFORMANCE OPTIMIZATIONS FOR MOBILE --- */
  /* Heavy filters and animations crash mobile FPS. We disable them for 60fps speed. */
  .blob { animation: none !important; filter: blur(30px) !important; opacity: 0.1 !important; }
  .glass-container, .glass-panel { 
    backdrop-filter: none !important; 
    -webkit-backdrop-filter: none !important; 
    background: var(--surface) !important; 
  }

  /* Content Area */
  .main-content { 
    padding: 15px; 
    display: flex; flex-direction: column; 
    height: calc(100vh - 55px) !important; 
    overflow: hidden; 
  }
  .top-header { margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
  .top-header > div:first-child { width: 100%; display: flex; justify-content: space-between; align-items: center; }
  .top-header h1 { font-size: 1.15rem; margin: 0; line-height: 1; }
  .theme-toggle-btn { margin: 0; font-size: 0.7rem; padding: 4px 8px; background: var(--surface); box-shadow: var(--shadow-sm); border-radius: 12px; }
  
  .header-actions { display: flex; flex-direction: row; width: 100%; gap: 6px; }
  .header-actions button { flex: 1; padding: 8px; font-size: 0.75rem; margin: 0; border-radius: var(--radius-sm); }
  
  /* 3. Flawless Horizontal Kanban Stage */
  /* Hardware acceleration added to prevent disappearing stages */
  .board { 
    display: flex; 
    flex-direction: row !important; 
    flex-wrap: nowrap !important;
    flex: 1; 
    height: auto !important; min-height: 0 !important;
    overflow-x: auto !important; overflow-y: hidden !important; 
    scroll-snap-type: x mandatory; 
    padding-bottom: 10px; gap: 12px !important; 
    -webkit-overflow-scrolling: touch;
    scroll-padding-left: 5px;
    align-items: stretch !important;
    will-change: scroll-position;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  .board::-webkit-scrollbar { height: 4px; display: block; }
  .board::-webkit-scrollbar-track { background: var(--input-bg); border-radius: 2px; }
  .board::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 2px; }
  
  .board-column { 
    flex: 0 0 88% !important; 
    max-width: 320px !important; 
    height: 100% !important; 
    scroll-snap-align: center; 
    background: var(--surface) !important; 
    box-shadow: var(--shadow-sm) !important; 
    display: flex !important;
    flex-direction: column !important;
    padding: 10px !important;
    transform: translateZ(0); /* iOS fix for disappearing elements */
    -webkit-transform: translateZ(0);
    will-change: transform;
  }
  .column-header { margin-bottom: 10px; }
  .task-list { overflow-y: auto !important; flex: 1 !important; padding-right: 4px; padding-bottom: 5px; gap: 8px; }
  
  .task-card { padding: 12px; }
  .task-title { font-size: 0.9rem; }
  .task-desc { font-size: 0.75rem; margin-bottom: 8px; }
  
  .team-grid { grid-template-columns: 1fr; padding-bottom: 20px;}
  .auth-box { padding: 1.5rem; margin: 10px; width: calc(100% - 20px); }
  .modal-content { width: calc(100% - 20px); padding: 1.25rem; margin: 10px; }
}
