@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Brand */
  --accent: #4B7BF5;
  --accent-hover: #3A6AE4;
  --accent-light: rgba(75, 123, 245, 0.1);
  --accent-medium: rgba(75, 123, 245, 0.18);

  /* Backgrounds */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F7F8FC;
  --bg-sidebar: #F2F4F8;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(75, 123, 245, 0.08);
  --bg-overlay: rgba(0, 0, 0, 0.5);

  /* Text */
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --text-on-accent: #FFFFFF;

  /* Border */
  --border: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.2);

  /* Priority colors */
  --priority-high: #EF4444;
  --priority-medium: #F59E0B;
  --priority-low: #10B981;

  /* Status */
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-panel: -4px 0 24px rgba(0,0,0,0.08);

  /* Radius */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transition */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 120ms;
  --dur-normal: 200ms;
  --dur-slow: 300ms;

  /* Layout */
  --sidebar-width: 240px;
  --detail-width: min(560px, 48vw);
  --header-height: 56px;
}

/* Dark mode */
[data-theme="dark"] {
  --bg-primary: #111827;
  --bg-secondary: #1F2937;
  --bg-sidebar: #161D2B;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(75, 123, 245, 0.12);
  --text-primary: #F9FAFB;
  --text-secondary: #9CA3AF;
  --text-tertiary: #6B7280;
  --border: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.2);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-panel: -4px 0 24px rgba(0,0,0,0.4);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  color-scheme: light dark;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

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

input, textarea {
  font-family: inherit;
  outline: none;
  border: none;
}

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

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ============================================
   APP LAYOUT
   ============================================ */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width var(--dur-slow) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
  z-index: 20;
}

.sidebar.collapsed {
  width: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-section {
  padding: 8px 0 4px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 4px 16px 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  user-select: none;
  position: relative;
}

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

.sidebar-item.active {
  background: var(--bg-active);
  color: var(--accent);
}

.sidebar-item .list-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sidebar-item .item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item .item-count {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  min-width: 16px;
  text-align: right;
}

.sidebar-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 16px);
  margin: 4px 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.sidebar-add-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.sidebar-footer {
  padding: 8px 8px 12px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.user-card:hover { background: var(--bg-hover); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-email {
  font-size: 11px;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
  min-width: 0;
}

.main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.main-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.4px;
  flex: 1;
}

.main-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================
   TASK LIST AREA
   ============================================ */
.task-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0 80px;
}

.task-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-tertiary);
  padding: 40px;
}

.task-list-empty svg {
  opacity: 0.3;
}

.task-list-empty p {
  font-size: 14px;
  text-align: center;
}

/* ============================================
   TASK ITEM
   ============================================ */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background var(--dur-fast);
  position: relative;
  border-radius: 0;
}

.task-item:hover {
  background: var(--bg-hover);
}

.task-item.selected {
  background: var(--bg-active);
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.task-check-btn {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}

.task-check-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: scale(1.1);
}

.task-check-btn.checked {
  border-color: var(--accent);
  background: var(--accent);
  animation: checkPop var(--dur-normal) var(--ease-out);
}

.task-check-btn.checked::after {
  content: "";
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

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

.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 14px;
  font-weight: 450;
  color: var(--text-primary);
  line-height: 1.4;
  transition: color var(--dur-fast);
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.task-due {
  font-size: 11.5px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 3px;
}

.task-due.overdue { color: var(--danger); }

.task-priority-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.task-sub-count {
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-secondary);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.task-note-preview {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Sub-tasks */
.subtask-list {
  padding-left: 30px;
  padding-bottom: 4px;
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 20px 6px 0;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: background var(--dur-fast);
}

.subtask-item:hover { background: var(--bg-hover); }

.subtask-check-btn {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}

.subtask-check-btn:hover { border-color: var(--accent); }

.subtask-check-btn.checked {
  border-color: var(--accent);
  background: var(--accent);
}

.subtask-check-btn.checked::after {
  content: "";
  width: 4px;
  height: 7px;
  border: 1.5px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.subtask-title {
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
}

.subtask-item.completed .subtask-title {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

/* Add task input */
.add-task-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  position: sticky;
  bottom: 0;
}

.add-task-input {
  flex: 1;
  background: none;
  font-size: 14px;
  color: var(--text-primary);
  padding: 4px 0;
}

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

/* ============================================
   DETAIL PANEL
   ============================================ */
.detail-panel {
  width: var(--detail-width);
  border-left: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transform: translateX(0);
  transition: width var(--dur-slow) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
}

.detail-panel.closed {
  width: 0;
  border-left: none;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
}

.detail-close-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  flex-shrink: 0;
}

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

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-title-input {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  width: 100%;
  background: none;
  resize: none;
  letter-spacing: -0.3px;
}

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

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Note area - the wide memo */
.note-editor-wrap {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 280px;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.note-editor-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.note-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-wrap: wrap;
}

.note-toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.note-toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-medium);
  margin: 0 4px;
}

.note-toolbar-btn {
  height: 26px;
  min-width: 26px;
  padding: 0 5px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.note-toolbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.note-toolbar-btn.active {
  background: var(--accent-light);
  color: var(--accent);
}

.note-textarea {
  flex: 1;
  width: 100%;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.7;
  padding: 16px;
  resize: none;
  min-height: 240px;
  font-family: inherit;
}

.note-textarea::placeholder { color: var(--text-tertiary); }

/* ============================================
   MARKDOWN PREVIEW STYLES
   ============================================ */
.markdown-body {
  flex: 1;
  padding: 16px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.7;
  overflow-y: auto;
  min-height: 240px;
  background: var(--bg-primary);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 18px;
  margin-bottom: 8px;
  line-height: 1.35;
  letter-spacing: -0.3px;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.markdown-body h1 { font-size: 20px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.markdown-body h2 { font-size: 17px; }
.markdown-body h3 { font-size: 15px; }

.markdown-body p {
  margin-bottom: 12px;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body strong {
  font-weight: 700;
  color: var(--text-primary);
}

.markdown-body em {
  font-style: italic;
}

.markdown-body del {
  text-decoration: line-through;
  opacity: 0.6;
}

.markdown-body ul,
.markdown-body ol {
  margin-bottom: 12px;
  padding-left: 22px;
}

.markdown-body li {
  margin-bottom: 4px;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 6px 12px;
  margin: 12px 0;
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 2px 5px;
  border-radius: var(--radius-xs);
  color: var(--accent);
}

.markdown-body pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 12px 0;
  overflow-x: auto;
}

.markdown-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 13px;
}

.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

/* Interactive Checkbox in Markdown */
.markdown-checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 6px 0;
  cursor: pointer;
  user-select: none;
}

.markdown-checkbox-box {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--dur-fast);
}

.markdown-checkbox-box.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.markdown-checkbox-box.checked::after {
  content: "";
  width: 4px;
  height: 8px;
  border: 1.5px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

/* Custom Language Selector Popover */
.lang-selector-wrap {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast);
}

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

.lang-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  min-width: 120px;
  z-index: 60;
  animation: dropdownIn var(--dur-fast) var(--ease-out);
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.lang-option:hover {
  background: var(--bg-hover);
}

.lang-option.selected {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-light);
}

.note-toolbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.note-textarea {
  flex: 1;
  width: 100%;
  background: none;
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.7;
  padding: 12px;
  resize: none;
  min-height: 180px;
  font-family: inherit;
}

.note-textarea::placeholder { color: var(--text-tertiary); }

/* Sub-tasks in detail */
.detail-subtasks {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-subtask-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.detail-subtask-row:hover { background: var(--bg-hover); }

.detail-subtask-title {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  background: none;
  cursor: text;
}

.detail-subtask-row.completed .detail-subtask-title {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.add-subtask-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.add-subtask-row:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* Priority selector */
.priority-selector {
  display: flex;
  gap: 6px;
}

.priority-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--dur-fast);
}

.priority-btn.active-high {
  color: var(--priority-high);
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.3);
}

.priority-btn.active-medium {
  color: var(--priority-medium);
  background: rgba(245,158,11,0.08);
  border-color: rgba(245,158,11,0.3);
}

.priority-btn.active-low {
  color: var(--priority-low);
  background: rgba(16,185,129,0.08);
  border-color: rgba(16,185,129,0.3);
}

/* Due date */
.due-date-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--dur-fast);
}

.due-date-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur-fast);
  user-select: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(75,123,245,0.35);
  transform: translateY(-1px);
}

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

.btn-ghost {
  color: var(--text-secondary);
  background: transparent;
}

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

.btn-danger {
  background: transparent;
  color: var(--danger);
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--dur-fast), color var(--dur-fast);
}

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

/* ============================================
   MODALS & OVERLAYS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn var(--dur-normal) var(--ease-out);
}

.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--dur-slow) var(--ease-out);
}

.modal-lg {
  max-width: 560px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  letter-spacing: -0.3px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

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

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

.form-error {
  font-size: 12px;
  color: var(--danger);
}

/* ============================================
   AUTH PAGES
   ============================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 50%, #EFF6FF 100%);
  padding: 20px;
  overflow: auto;
}

[data-theme="dark"] .auth-page {
  background: linear-gradient(135deg, #111827 0%, #1a1035 50%, #111827 100%);
}

.auth-card {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 16px;
  font-weight: 700;
}

.auth-logo-name {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.4px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.auth-link {
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}

.auth-link:hover { text-decoration: underline; }

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

/* ============================================
   BADGES & CHIPS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-accent {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-neutral {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

/* ============================================
   DROPDOWN MENUS
   ============================================ */
.dropdown {
  position: absolute;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  min-width: 160px;
  z-index: 50;
  animation: dropdownIn var(--dur-fast) var(--ease-out);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn var(--dur-normal) var(--ease-out);
  pointer-events: all;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   COLOR PICKER
   ============================================ */
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
  border: 2px solid transparent;
}

.color-swatch:hover { transform: scale(1.2); }
.color-swatch.selected {
  border-color: white;
  box-shadow: 0 0 0 2px currentColor;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--dur-slow) var(--ease-out);
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
    --detail-width: 100%;
  }

  .app-layout {
    position: relative;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-out);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .detail-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(100%);
    transition: transform var(--dur-slow) var(--ease-out);
    width: 100% !important;
  }

  .detail-panel.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-panel);
  }

  .bottom-nav {
    display: flex;
  }

  .main-content {
    padding-bottom: 60px;
  }

  .task-item { padding: 10px 16px; }
  .main-header { padding: 0 16px; }
}

/* Bottom nav (mobile only) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  z-index: 25;
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 16px;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--dur-fast);
  border-radius: var(--radius-sm);
}

.bottom-nav-item.active { color: var(--accent); }

/* FAB */
.fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(75,123,245,0.4);
  transition: transform var(--dur-fast), box-shadow var(--dur-fast);
  z-index: 20;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(75,123,245,0.5);
}

.fab:active { transform: scale(0.97); }

@media (min-width: 769px) {
  .fab { display: none; }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}

/* Mobile-only: hidden on desktop, flex on mobile */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: flex;
  }
}
