body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #0c0c0c 0%, #1a1a1a 50%, #0f0f0f 100%);
  color: white;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
}

html, body { height: 100%; }

/* Appbar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background-color: #0e3a62;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.appbar-left { display: flex; flex-direction: column; }
.brand { font-size: 26px; font-weight: 800; color: #9fd5ff; text-shadow: 0 0 30px rgba(74, 158, 255, 0.3); }
.tagline { font-size: 12px; opacity: 0.75; }

.appbar-right { display: flex; align-items: center; gap: 10px; }
.appbar-right .burger { width: 36px; height: 36px; border-radius: 8px; }
.appbar-right .menu { position: relative; display: inline; }
.dropdown { position: absolute; right: 0; top: 42px; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: linear-gradient(145deg, #2a2a2a, #1a1a1a); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; box-shadow: 0 8px 25px rgba(0,0,0,0.4); min-width: 180px; }
.dropdown.hidden { display: none; }
.dropdown button { text-align: left; }
.dropdown .danger { color: #ff6b7a; }
.sync-status { opacity: 0.8; font-size: 0.9em; }

/* Autosave toggle */
.autosave-btn { border: 1px solid rgba(255,255,255,0.2); }
.autosave-on { background: linear-gradient(145deg, #26c281, #00b894); border-color: rgba(38,194,129,0.4); }
.autosave-off { background: linear-gradient(145deg, #3a3a3a, #2a2a2a); color: rgba(255,255,255,0.7); border-color: rgba(255,255,255,0.15); }

/* Auth modal tweaks */
.auth-input {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  color: white;
  font-size: 14px;
  outline: none;
}

/* Footer */
.footer {
  margin-top: auto;
  padding: 20px;
  text-align: center;
  color: rgba(255,255,255,0.7);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.main-header {
  text-align: center;
  margin-bottom: 40px;
}

.main-title {
  font-size: 3rem;
  font-weight: 700;
  background: linear-gradient(135deg, #4a9eff, #00d4ff, #4a9eff);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 3s ease-in-out infinite;
  margin: 0;
  text-shadow: 0 0 30px rgba(74, 158, 255, 0.3);
}

.main-subtitle {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 10px;
  font-weight: 300;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

ul::before, li::before {
    background-color: white; 
}

button {
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 2;
    font-family: inherit;
    font-weight: 500;
}

button:hover {
    background: linear-gradient(145deg, #4a4a4a, #3a3a3a);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Task-specific button styles */
.btn-toggle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: linear-gradient(145deg, #4a9eff, #357abd);
    border: 1px solid rgba(74, 158, 255, 0.3);
}

.btn-toggle:hover {
    background: linear-gradient(145deg, #5badff, #4a9eff);
    box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.btn-toggle:disabled {
    background: linear-gradient(145deg, #333, #222);
    color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-toggle:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Remove task button */
li button:nth-child(2) {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    padding: 0;
    background: linear-gradient(145deg, #ff4757, #d63031);
    border: 1px solid rgba(255, 71, 87, 0.3);
    font-size: 14px;
}

li button:nth-child(2):hover {
    background: linear-gradient(145deg, #ff6b7a, #ff4757);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
}

/* Description button */
li button:nth-child(5) {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    padding: 0;
    background: linear-gradient(145deg, #ffa726, #f57c00);
    border: 1px solid rgba(255, 167, 38, 0.3);
    font-size: 14px;
}

li button:nth-child(5):hover {
    background: linear-gradient(145deg, #ffb74d, #ffa726);
    box-shadow: 0 4px 12px rgba(255, 167, 38, 0.3);
}

/* Add subtask button */
li button:nth-child(6) {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    padding: 0;
    background: linear-gradient(145deg, #26c281, #00b894);
    border: 1px solid rgba(38, 194, 129, 0.3);
    font-size: 16px;
    font-weight: bold;
}

li button:nth-child(6):hover {
    background: linear-gradient(145deg, #55efc4, #26c281);
    box-shadow: 0 4px 12px rgba(38, 194, 129, 0.3);
}

/* Floating Add Task Button */
.floating-add-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a9eff, #00d4ff);
    color: white;
    border: none;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 
        0 8px 25px rgba(74, 158, 255, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-add-btn:hover {
    transform: scale(1.1) translateY(-3px);
    box-shadow: 
        0 12px 35px rgba(74, 158, 255, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    background: linear-gradient(135deg, #5badff, #26c6da);
}

.floating-add-btn:active {
    transform: scale(1.05) translateY(-1px);
    box-shadow: 
        0 6px 20px rgba(74, 158, 255, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Pulse animation for floating button */
.floating-add-btn::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a9eff, #00d4ff);
    z-index: -1;
    opacity: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0;
        transform: scale(1);
    }
    50% {
        opacity: 0.3;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(1.4);
    }
}

input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

input[type="checkbox"]:hover {
    border-color: rgba(74, 158, 255, 0.6);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #4a9eff, #357abd);
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.3);
}

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

.task { margin-left: 10px; }
.hidden { display: none; }
.btn-toggle {
  position: relative;
}
ul {
    list-style: none;
    padding-left: 0;
    position: relative;
}

@keyframes fade-in-tree-line {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.tree-line-vertical {
    position: absolute;
    top: -10px;
    left: 4px;
    width: 2px;
    background-color: rgba(255, 255, 255, 0.3);
    z-index: 0;
    pointer-events: none;
}

li {
    position: relative;
    padding-left: 15px;
}

.tree-line-horizontal {
    position: absolute;
    top: 20px;
    left: -15px;
    width: 30px;
    height: 2px;
    background-color: rgba(255, 255, 255, 0.3);
    z-index: 0;
    pointer-events: none;
}

#descriptionModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.3s ease-out;
}

#descriptionModal.show {
  display: flex;
}

.modal-content {
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: white;
  max-width: 600px;
  width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: scale(0.9);
  animation: modalSlideIn 0.3s ease-out forwards;
}

#conflictModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  z-index: 2000; /* above description modal */
  display: none;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.2s ease-out;
}

#conflictModal.show {
  display: flex;
}

#conflictModal .modal-content {
  max-width: 640px;
  width: 92vw;
}

.conflict-title {
  margin: 0;
  color: #ff4d4f;
  text-align: center;
  letter-spacing: 0.3px;
}

.conflict-text {
  margin: 0;
  color: #ffd3d3;
  text-align: center;
  line-height: 1.5;
}

.conflict-text strong {
  color: #ff4d4f;
}

#descriptionText {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  color: white;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
  min-height: 200px;
  max-height: 400px;
  width: 100%;
  box-sizing: border-box;
  transition: all 0.2s ease;
  outline: none;
}

#descriptionText:focus {
  border-color: #4a9eff;
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
}

#descriptionText::placeholder {
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  margin-top: 10px;
}

.modal-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.modal-btn:before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.modal-btn:hover:before {
  left: 100%;
}

.modal-btn-save {
  background: linear-gradient(145deg, #4a9eff, #357abd);
  color: white;
  box-shadow: 0 4px 15px rgba(74, 158, 255, 0.3);
}

.modal-btn-save:hover {
  background: linear-gradient(145deg, #5badff, #4a9eff);
  box-shadow: 0 6px 20px rgba(74, 158, 255, 0.4);
  transform: translateY(-2px);
}

.modal-btn-save:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(74, 158, 255, 0.3);
}

.modal-btn-close {
  background: linear-gradient(145deg, #6c757d, #5a6268);
  color: white;
  box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.modal-btn-close:hover {
  background: linear-gradient(145deg, #7d8691, #6c757d);
  box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
  transform: translateY(-2px);
}

.modal-btn-close:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(108, 117, 125, 0.3);
}

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

@keyframes modalSlideIn {
  from { 
    transform: scale(0.8) translateY(-20px);
    opacity: 0;
  }
  to { 
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.hidden { display: none; }

/* Modern container for the entire app */
.app-container {
  min-width: 600px;
  padding: 0 20px;
  flex: 1 0 auto;
}

#taskList {
  margin-bottom: 100px; /* Space for floating button */
}

.task-description ul {
  list-style: disc;
  padding-left: 20px;
  margin: 10px 0;
  border: none;
  background: none;
}

.task-description ul::before {
  display: none;
}

.task-description li {
  padding: 2px 0;
  border: none;
  background: none;
  border-radius: 0;
  margin: 0;
  box-shadow: none;
  position: static;
}

.task-description li::before {
  display: none;
}

.task-description ul ul {
  margin: 5px 0;
  padding-left: 20px;
  list-style: circle;
}

.task-description ul ul ul {
  list-style: square;
}

.task-description ul ul ul ul {
  list-style: disc;
}

.description-image {
  max-width: 300px;
  max-height: 300px;
  display: inline;
}

.description-image:hover {
  transform: scale(1.05);
}

.modal-img {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: pointer;
}

.modal-img > img {
  max-width: 90%;
  max-height: 90%;
  box-shadow: 0 0 20px rgba(255,255,255,0.5);
}

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

#taskList {
  opacity: 0;
  animation: fadeIn 0.5s ease-out forwards;
}

/* FAB container and attached menu */
.fab-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1100;
  display: flex;
  align-items: center;
}

.fab-menu {
  position: absolute;
  right: 0;
  bottom: 64px;
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.fab-menu.show { display: flex; }

.fab-menu button { 
  width: 180px; 
  text-align: left; 
}

.fab-menu button.danger {
  color: #ff4757;
}

.fab-menu button.danger:hover {
  background: rgba(255, 71, 87, 0.1);
}

@media (hover: hover) and (pointer: fine) {
  .fab-container:hover .fab-menu { display: flex; }
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: rgba(42, 42, 42, 0.8);
  border-left: 3px solid rgba(255, 255, 255, 0.3);
  padding: 8px 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateX(-10px);
  animation: toastIn 0.2s ease forwards;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 100px);
  backdrop-filter: blur(4px);
}

.toast.success {
  border-left-color: rgba(38, 194, 129, 0.8);
}

.toast.error {
  border-left-color: rgba(255, 71, 87, 0.8);
}

.toast.removing {
  animation: toastOut 0.2s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(-10px);
  }
}

/* Modal base and confirm modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.3s ease-out;
}

.modal.show {
  display: flex;
}

.confirm-modal {
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: white;
  max-width: 400px;
  width: 90vw;
  transform: scale(0.9);
  animation: modalSlideIn 0.3s ease-out forwards;
}

.confirm-modal h2 {
  margin: 0 0 16px 0;
  font-size: 20px;
  color: #ff4757;
}

.confirm-modal p {
  margin: 0 0 24px 0;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
}

.modal-btn-danger {
  background: linear-gradient(145deg, #ff4757, #d63031);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 71, 87, 0.3);
}

.modal-btn-danger:hover {
  background: linear-gradient(145deg, #ff6b7a, #ff4757);
  box-shadow: 0 6px 20px rgba(255, 71, 87, 0.4);
  transform: translateY(-2px);
}

.modal-btn-danger:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(255, 71, 87, 0.3);
}

@keyframes fadeInTask {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.subtask, .main-task {
  opacity: 0;
  animation: fadeInTask 0.4s ease-out forwards;
}

@keyframes fadeInDescription {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeOutDescription {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-5px); }
}

.task-description.hidden {
  animation: fadeOutDescription 0.3s ease-out forwards;
}

@keyframes fadeOutSubtasks {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-5px); }
}

.subtasks.hidden {
  animation: fadeOutSubtasks 0.3s ease-out forwards;
}

.insertion-line {
  position: fixed;
  left: 0;
  right: 0;
  height: 2px;
  background: white;
  z-index: 1000;
  pointer-events: none;
}

li.main-task, li.subtask {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  border-radius: 8px;
  margin: 4px 0;
  padding: 6px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  backdrop-filter: blur(10px);
  will-change: transform, box-shadow;
  z-index: 2;
}

li.main-task {
  background: linear-gradient(145deg, #2d2d2d, #1d1d1d);
  border-color: rgba(255, 255, 255, 0.15);
  margin: 6px 0;
}

li.subtask {
  background: linear-gradient(145deg, #252525, #151515);
  margin: 3px 0 3px 20px;
}

li.main-task:hover, li.subtask:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  border-color: rgba(74, 158, 255, 0.3);
}

li.dragging {
  opacity: 0.8;
  transform: scale(1.05) rotate(2deg);
  box-shadow: 
    0 0 0 2px rgba(74, 158, 255, 0.8),
    0 15px 35px rgba(0, 0, 0, 0.5);
  z-index: 3;
}

/* Task content layout */
li.main-task > *:not(.task-description):not(.subtasks), 
li.subtask > *:not(.task-description):not(.subtasks) {
  display: inline-block;
  vertical-align: middle;
}

li.main-task span[contenteditable], li.subtask span[contenteditable] {
  background: transparent;
  border: none;
  outline: none;
  padding: 6px 8px;
  border-radius: 4px;
  transition: background 0.2s ease;
  font-size: 16px;
  line-height: 1.4;
  color: inherit;
}

li.main-task span[contenteditable]:focus, li.subtask span[contenteditable]:focus {
  background: rgba(74, 158, 255, 0.1);
  box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.3);
}

.task-description {
  opacity: 0;
  animation: fadeInDescription 0.3s ease-out forwards;
  margin: 8px 0 4px 0;
  padding: 6px;
  border-left: 3px solid #4a9eff;
  border-radius: 6px;
  font-size: 14px;
  background: rgba(74, 158, 255, 0.05);
  backdrop-filter: blur(5px);
  max-width: 100%;
  overflow-wrap: break-word;
  position: relative;
  z-index: 3;
}

.task-description a {
  color: #4a9eff;
  text-decoration: none;
  transition: color 0.2s ease;
}

.task-description a:hover {
  color: #5badff;
  text-decoration: underline;
}