.app {
  width: 100%;
  min-height: 100vh;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.header {
  text-align: center;
  padding: 30px 20px;
  background: var(--bg-secondary);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.tree-container {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  min-height: 400px;
}

.add-task-row + .tree-container {
  margin-top: -15px;
}

.tree-container::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}

.tree-container::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 6px;
}

.tree-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 6px;
}

.tree-container::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* Custom settings row (checkbox + admin button) */
.custom-settings-row {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-right: 14px;
  margin-top: -16px;
  margin-bottom: -16px;
}

/* Admin action buttons (bright red border) */
.admin-action-btn {
  font-size: calc(0.78rem * var(--scale-topbar, 1));
  padding: 3px 12px;
  border: 2px solid #e53935;
  border-radius: 5px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.admin-action-btn:hover {
  background: #e53935;
  color: #fff;
}

/* Admin-only outline for bars/controls that are hidden from normal users */
.admin-only-outline {
  outline: 2px solid #e53935;
  outline-offset: -2px;
  border-radius: 10px;
}

/* Expand/collapse button for filtering/sorting bars */
.filter-sort-expand-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: calc(0.75rem * var(--scale-panels, 1));
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

.filter-sort-expand-btn:hover:not(:disabled) {
  color: var(--text-primary);
}

.filter-sort-expand-btn--disabled {
  opacity: 0.3;
  cursor: default;
}

/* Custom filtering/sorting checkbox */
.custom-settings-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0 4px 14px;
  font-size: calc(0.85rem * var(--scale-panels, 1));
  color: var(--text-secondary);
  transition: color 0.15s ease;
}

.custom-settings-checkbox:hover {
  color: var(--text-primary);
}

.custom-settings-checkbox input[type="checkbox"] {
  accent-color: var(--accent-primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Add task button */
.add-task-row {
  padding: 20px 0 5px 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.add-task-btn {
  padding: 7px 20px;
  border-radius: 7px;
  border: 1px solid var(--accent-primary);
  background: transparent;
  color: var(--accent-primary);
  font-size: calc(0.95rem * var(--scale-panels, 1));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-task-btn:hover {
  background: var(--accent-primary);
  color: #fff;
}

.add-task-btn:active {
  filter: brightness(0.85);
}

.add-task-btn--shared {
  border-color: #c62828;
  color: #c62828;
}
.add-task-btn--shared:hover {
  background: #c62828;
  color: #fff;
}

.next-init-step-btn {
  padding: 7px 20px;
  border-radius: 7px;
  border: 1px solid #d4a017;
  background: transparent;
  color: #d4a017;
  font-size: calc(0.95rem * var(--scale-panels, 1));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.next-init-step-btn:hover {
  background: #d4a017;
  color: #fff;
}
.next-init-step-btn:active {
  filter: brightness(0.85);
}

/* Selection mode banner */
.selection-mode-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 20px;
  background: linear-gradient(135deg, rgba(255, 255, 0, 0.15), rgba(255, 235, 59, 0.1));
  border: 1px solid rgba(255, 255, 0, 0.4);
  border-radius: 10px;
  animation: selectionBannerPulse 2s ease-in-out infinite;
}

.selection-mode-banner-text {
  color: var(--text-primary);
  font-size: calc(0.95rem * var(--scale-panels, 1));
  font-weight: 500;
}

.selection-mode-cancel-btn {
  padding: 4px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: calc(0.85rem * var(--scale-panels, 1));
  cursor: pointer;
  transition: all 0.2s ease;
}

.selection-mode-cancel-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

@keyframes selectionBannerPulse {
  0%, 100% {
    border-color: rgba(255, 255, 0, 0.4);
    box-shadow: 0 0 6px rgba(255, 255, 0, 0.1);
  }
  50% {
    border-color: rgba(255, 255, 0, 0.7);
    box-shadow: 0 0 12px rgba(255, 255, 0, 0.2);
  }
}

/* ── Edit View dialog ────────────────────────────────────────────────── */

.edit-view-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 11000;
}

.edit-view-dialog {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 28px 32px 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edit-view-title {
  margin: 0;
  font-size: calc(1.2rem * var(--scale-panels, 1));
  color: var(--text-primary);
}

.edit-view-id {
  font-size: calc(0.75rem * var(--scale-panels, 1));
  color: var(--text-muted);
  margin-top: -8px;
  font-family: monospace;
}

.edit-view-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: calc(0.85rem * var(--scale-panels, 1));
  color: var(--text-secondary);
}

.edit-view-input {
  padding: 7px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: calc(0.9rem * var(--scale-panels, 1));
  outline: none;
  transition: border-color 0.15s ease;
}

.edit-view-input:focus {
  border-color: var(--accent-primary);
}

.edit-view-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.edit-view-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: calc(0.85rem * var(--scale-panels, 1));
  color: var(--text-secondary);
  cursor: pointer;
}

.edit-view-checkbox-label input[type="checkbox"] {
  accent-color: var(--accent-primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.edit-view-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.edit-view-cancel-btn {
  padding: 6px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: calc(0.85rem * var(--scale-panels, 1));
  cursor: pointer;
  transition: all 0.15s ease;
}

.edit-view-cancel-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.edit-view-save-btn {
  padding: 6px 16px;
  font-size: calc(0.85rem * var(--scale-panels, 1));
}

/* ── Login screen ─────────────────────────────────────────────────────── */

.login-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-form {
  width: 100%;
  max-width: 380px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px 32px 32px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: -8px 0 0;
}

.login-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.login-input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.login-button {
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease;
  margin-top: 4px;
}

.login-button:hover:not(:disabled) {
  opacity: 0.9;
}

.login-button:active:not(:disabled) {
  transform: scale(0.98);
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--error);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
}

/* ── Top bar (user info + sign out) ──────────────────────────────────── */

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: var(--pad-topbar-bar-v, 0px) var(--pad-topbar-bar-h, 4px);
  margin-bottom: -12px;
  font-family: var(--font-topbar);
  font-weight: var(--weight-topbar, 400);
  font-size: calc(0.78rem * var(--scale-topbar, 1));
}

.app-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}

.app-admin-badge {
  background: var(--error);
  color: #fff;
  font-size: calc(0.7rem * var(--scale-topbar, 1));
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 10px;
  border-radius: 4px;
}

.app-user-info {
  font-size: calc(0.8rem * var(--scale-topbar, 1));
  color: var(--text-muted);
}

.app-logout-btn {
  padding: var(--pad-topbar-btn-v, 3px) var(--pad-topbar-btn-h, 12px);
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: calc(0.78rem * var(--scale-topbar, 1));
  cursor: pointer;
  transition: all 0.2s ease;
}

.app-logout-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.topbar-add-task-btn {
  padding: 5px 16px;
  border-radius: 6px;
  border: none;
  background: linear-gradient(180deg, #2a5a8a 0%, #1a3a5c 100%);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.topbar-add-task-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 45%);
  border-radius: inherit;
  pointer-events: none;
}
.topbar-add-task-btn:hover {
  filter: brightness(1.15);
}
.topbar-add-task-btn:active {
  filter: brightness(0.9);
}
.topbar-add-task-btn--shared {
  background: linear-gradient(180deg, #d32f2f 0%, #9a1c1c 100%);
}

.topbar-next-init-btn {
  padding: 5px 16px;
  border-radius: 6px;
  border: none;
  background: linear-gradient(180deg, #a07a18 0%, #6b5010 100%);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.topbar-next-init-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 45%);
  border-radius: inherit;
  pointer-events: none;
}
.topbar-next-init-btn:hover {
  filter: brightness(1.15);
}
.topbar-next-init-btn:active {
  filter: brightness(0.9);
}

.sync-led {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e53935;
  box-shadow: 0 0 4px 1px rgba(229, 57, 53, 0.5);
  flex-shrink: 0;
}

/* ── Mobile top bar & menu ─────────────────────────────────────────── */

.mobile-topbar {
  display: flex;
  align-items: center;
  height: 44px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0;
  flex-shrink: 0;
  font-family: var(--font-topbar);
  font-weight: var(--weight-topbar, 400);
  font-size: calc(0.9rem * var(--scale-topbar, 1));
}

.mobile-menu-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.4rem;
}
.mobile-menu-btn:hover {
  background: var(--bg-hover);
}

.mobile-add-btn {
  width: 37px;
  height: 37px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #2a5a8a 0%, #1a3a5c 100%);
  border: none;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.4rem;
  border-radius: 6px;
  margin: 4px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.mobile-add-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 45%);
  border-radius: inherit;
  pointer-events: none;
}
.mobile-add-btn:hover {
  filter: brightness(1.15);
}

.mobile-next-init-btn {
  width: 37px;
  height: 37px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #a07a18 0%, #6b5010 100%);
  border: none;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 6px;
  margin: 4px;
  padding: 0;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.mobile-next-init-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 45%);
  border-radius: inherit;
  pointer-events: none;
}
.mobile-next-init-btn:hover {
  filter: brightness(1.15);
}

.mobile-hamburger-icon {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  position: relative;
}
.mobile-hamburger-icon::before,
.mobile-hamburger-icon::after {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  position: absolute;
  left: 0;
}
.mobile-hamburger-icon::before { top: -6px; }
.mobile-hamburger-icon::after { top: 6px; }

.mobile-view-name {
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  padding: 0 8px;
}

.mobile-menu-panel {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  animation: mobileMenuSlide 0.15s ease-out;
}

@keyframes mobileMenuSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mobile-menu-section {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
}
.mobile-menu-section:last-child { border-bottom: none; }

.mobile-menu-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 16px;
  letter-spacing: 0.05em;
  font-family: var(--font-panels);
}

.mobile-menu-entry {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-panels);
  font-size: calc(0.85rem * var(--scale-panels, 1));
  gap: 16px;
}
.mobile-menu-entry:hover {
  background: var(--bg-hover);
}
.mobile-menu-entry--active {
  background: var(--accent-primary);
  color: #fff;
}
.mobile-menu-entry--active:hover {
  background: var(--accent-hover);
}

.mobile-menu-entry-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-menu-badge {
  background: var(--accent-primary);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.mobile-menu-entry--active .mobile-menu-badge {
  background: rgba(255,255,255,0.3);
}

.mobile-menu-toggle {
  cursor: pointer;
  gap: 8px;
}
.mobile-menu-toggle input[type="checkbox"] {
  accent-color: var(--accent-primary);
}

.mobile-menu-expandable {
  padding-left: 24px;
  font-size: calc(0.82rem * var(--scale-panels, 1));
  color: var(--text-secondary);
}

.mobile-menu-expanded-content {
  padding: 4px 8px 8px 8px;
}

.mobile-menu-user-info {
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: default;
}
.mobile-menu-user-info:hover {
  background: transparent;
}

.mobile-menu-signout {
  color: var(--error, #e74c3c);
}

.mobile-menu-admin {
  gap: 8px;
}

/* Badge overrides inside mobile menu: inline instead of absolute-positioned */
.mobile-menu-views .view-notification-badge {
  position: static;
  flex-shrink: 0;
}
.mobile-menu-views .view-badge-group {
  position: static;
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.mobile-menu-views .view-badge-group .view-notification-badge {
  position: static;
}
.mobile-menu-views .mobile-menu-entry {
  position: relative;
}

/* ── Media queries ───────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .app {
    padding: 12px;
    gap: 12px;
  }

  .header h1 {
    font-size: 1.8rem;
  }

  .tree-container {
    padding: 16px;
  }

  .login-form {
    padding: 32px 20px 24px;
  }
}

