/* =========================================================
   ClearList — Design System & Responsive Styles
   ========================================================= */

:root {
  color-scheme: light;
  --bg-app: #f5f6fa;
  --bg-sidebar: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f8f9fc;
  --bg-hover: #f0f2f8;
  --bg-active: #eef2ff;

  --text-primary: #141824;
  --text-secondary: #555e73;
  --text-muted: #8a93a8;

  --border: #e5e8f0;
  --border-strong: #d3d8e6;

  --accent: #4f6ef7;
  --accent-hover: #3d5be6;
  --accent-soft: rgba(79, 110, 247, 0.12);

  --danger: #e5484d;
  --danger-soft: rgba(229, 72, 77, 0.12);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.14);

  --p-high: #e5484d;
  --p-medium: #f59e0b;
  --p-low: #3b82f6;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.18);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-w: 268px;
  --detail-w: 380px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-app: #0f1219;
  --bg-sidebar: #141821;
  --bg-surface: #181d28;
  --bg-surface-subtle: #1d2331;
  --bg-hover: #222938;
  --bg-active: rgba(99, 128, 255, 0.16);

  --text-primary: #eef1f8;
  --text-secondary: #a7b0c4;
  --text-muted: #6e7891;

  --border: #262e40;
  --border-strong: #343f57;

  --accent: #6683ff;
  --accent-hover: #7c95ff;
  --accent-soft: rgba(102, 131, 255, 0.18);

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.15);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 5px;
}

.hidden {
  display: none !important;
}

.spacer {
  flex: 1;
}

.muted-text {
  color: var(--text-muted);
  font-size: 12.5px;
}

/* =========================================================
   App Layout Shell
   ========================================================= */

.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* =========================================================
   Sidebar
   ========================================================= */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
  transition: transform 0.22s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #5472ff, #3853db);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 10px rgba(79, 110, 247, 0.35);
}

.brand-icon svg {
  width: 17px;
  height: 17px;
}

.brand-name {
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: -0.02em;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 14px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  color: var(--text-secondary);
  font-weight: 500;
  transition: background 0.14s, color 0.14s;
  position: relative;
}

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

.nav-item.active {
  background: var(--bg-active);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.drag-over {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
}

.icon-inbox { color: #3b82f6; }
.icon-today { color: #f59e0b; }
.icon-upcoming { color: #8b5cf6; }
.icon-all { color: #64748b; }
.icon-completed { color: #10b981; }

.list-emoji {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.list-color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

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

.nav-badge {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0 4px;
}

.nav-badge.empty {
  opacity: 0;
}

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

.nav-edit-btn {
  opacity: 0;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 5px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.nav-item:hover .nav-edit-btn {
  opacity: 1;
}
.nav-edit-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sync-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sync-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.sync-status-dot, .sync-pill-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.sync-status-dot.synced, .sync-pill-dot.synced {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}
.sync-status-dot.syncing, .sync-pill-dot.syncing {
  background: var(--accent);
  animation: pulse 1.2s infinite ease-in-out;
}
.sync-status-dot.warning, .sync-pill-dot.warning {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
}
.sync-status-dot.error, .sync-pill-dot.error {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.sync-card-text {
  flex: 1;
  min-width: 0;
}

.sync-card-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.sync-card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.ghost-btn svg {
  width: 15px;
  height: 15px;
}

/* =========================================================
   Main Content Area
   ========================================================= */

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.view-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.view-heading h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 210px;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  outline: none;
  font-size: 13px;
  transition: border-color 0.15s, width 0.2s, background 0.15s;
}

#search-input:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
  width: 245px;
}

.compact-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.compact-select:hover, .compact-select:focus {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.sync-pill:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.main-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px 28px 60px;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}

/* =========================================================
   Quick-Add Composer
   ========================================================= */

.quick-add-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.quick-add-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.quick-add-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-add-plus {
  color: var(--accent);
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.quick-add-plus svg {
  width: 18px;
  height: 18px;
}

#quick-add-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  padding: 4px 0;
}

#quick-add-input::placeholder {
  color: var(--text-muted);
}

.quick-add-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.quick-meta-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.date-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chip-select, .chip-date, .chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
  outline: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.chip-btn:hover, .chip-select:hover, .chip-date:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.chip-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.chip-btn[data-priority="high"] { color: var(--p-high); border-color: var(--p-high); background: var(--danger-soft); }
.chip-btn[data-priority="medium"] { color: var(--p-medium); border-color: var(--p-medium); background: var(--warning-soft); }
.chip-btn[data-priority="low"] { color: var(--p-low); border-color: var(--p-low); background: var(--accent-soft); }

/* =========================================================
   Task Groups & Task Rows
   ========================================================= */

.completed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
}

.task-group {
  margin-bottom: 22px;
}

.task-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 8px 4px;
}

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

.task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s, box-shadow 0.14s, opacity 0.14s;
  position: relative;
}

.task-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.task-row.selected {
  border-color: var(--accent);
  background: var(--bg-active);
}

.task-row.dragging {
  opacity: 0.45;
  box-shadow: var(--shadow-md);
}

.task-row.drag-target-top {
  box-shadow: 0 -2px 0 0 var(--accent);
}

.task-row.drag-target-bottom {
  box-shadow: 0 2px 0 0 var(--accent);
}

.drag-handle {
  color: var(--text-muted);
  opacity: 0;
  cursor: grab;
  padding: 2px 0;
  margin-left: -4px;
  display: flex;
  align-items: center;
  transition: opacity 0.12s;
}

.task-row:hover .drag-handle {
  opacity: 0.7;
}
.drag-handle:active {
  cursor: grabbing;
}
.drag-handle svg {
  width: 14px;
  height: 14px;
}

/* Custom Circular Checkbox */
.task-check-btn {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: transform 0.14s, background 0.14s, border-color 0.14s;
}

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

.task-check-btn.p-high { border-color: var(--p-high); }
.task-check-btn.p-medium { border-color: var(--p-medium); }
.task-check-btn.p-low { border-color: var(--p-low); }

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

.task-check-btn svg {
  width: 12px;
  height: 12px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.12s, transform 0.14s;
}

.task-check-btn.checked svg {
  opacity: 1;
  transform: scale(1);
}

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

.task-title {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

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

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

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.meta-pill svg {
  width: 12px;
  height: 12px;
}

.meta-pill.overdue {
  color: var(--danger);
  font-weight: 600;
}

.meta-pill.due-today {
  color: var(--warning);
  font-weight: 600;
}

.meta-pill.list-tag {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--text-secondary);
}

.priority-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.priority-dot.high { background: var(--p-high); }
.priority-dot.medium { background: var(--p-medium); }
.priority-dot.low { background: var(--p-low); }

.task-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}

.task-row:hover .task-row-actions {
  opacity: 1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 58px 20px;
  color: var(--text-muted);
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  color: var(--accent);
}

.empty-icon svg {
  width: 26px;
  height: 26px;
}

.empty-state h3 {
  margin: 0 0 6px;
  font-size: 16px;
  color: var(--text-primary);
}

.empty-state p {
  margin: 0;
  font-size: 13.5px;
}

/* =========================================================
   Detail Panel (Right Slide-Over)
   ========================================================= */

.detail-panel {
  width: var(--detail-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 25;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.detail-complete-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-complete-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.detail-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.detail-title-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  resize: none;
  padding: 6px 8px;
  margin: -6px -8px 0;
  outline: none;
}

.detail-title-input:hover, .detail-title-input:focus {
  border-color: var(--border);
  background: var(--bg-surface-subtle);
}

.detail-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.detail-field label, .detail-section label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.input-field {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  outline: none;
  font-size: 13.5px;
  transition: border-color 0.14s, background 0.14s;
}

.input-field:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.quick-date-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.mini-chip {
  border: 1px solid var(--border);
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11.5px;
  cursor: pointer;
}

.mini-chip:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.priority-segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface-subtle);
}

.priority-segmented button {
  border: none;
  background: transparent;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-right: 1px solid var(--border);
}

.priority-segmented button:last-child {
  border-right: none;
}

.priority-segmented button.active[data-p="none"] { background: var(--bg-hover); color: var(--text-primary); font-weight: 600; }
.priority-segmented button.active[data-p="low"] { background: var(--accent-soft); color: var(--p-low); font-weight: 600; }
.priority-segmented button.active[data-p="medium"] { background: var(--warning-soft); color: var(--p-medium); font-weight: 600; }
.priority-segmented button.active[data-p="high"] { background: var(--danger-soft); color: var(--p-high); font-weight: 600; }

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

.detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.subtask-progress-bar {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-hover);
  overflow: hidden;
}

.subtask-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.subtask-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.subtask-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.subtask-item span {
  flex: 1;
  font-size: 13.5px;
  word-break: break-word;
}

.subtask-item.done span {
  text-decoration: line-through;
  color: var(--text-muted);
}

.add-subtask-form {
  display: flex;
  gap: 6px;
}

.add-subtask-form input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  outline: none;
  font-size: 13px;
}

.add-subtask-form input:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.detail-notes-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  resize: vertical;
  min-height: 100px;
  outline: none;
  line-height: 1.55;
}

.detail-notes-input:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
}

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

/* =========================================================
   Buttons
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, opacity 0.14s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface-subtle);
  border-color: var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
}
.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.14s, color 0.14s;
}

.icon-btn.small {
  width: 26px;
  height: 26px;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

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

.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-btn.spinning svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* =========================================================
   Modals & Setup Wizard
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 24, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-sm { max-width: 440px; }
.modal-lg { max-width: 650px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.modal-subtitle {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.modal-body {
  padding: 18px 22px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.alert-banner {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
}

.alert-warn {
  background: var(--warning-soft);
  border: 1px solid var(--warning);
  color: var(--text-primary);
}

.sync-status-panel {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface-subtle);
}

.sync-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.status-badge-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.sync-status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-error-box {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
}

.config-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-block label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.input-action-row {
  display: flex;
  gap: 8px;
}

.field-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.device-link-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}

.device-link-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.wizard-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface-subtle);
  padding: 12px 14px;
}

.wizard-details summary {
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
}

.wizard-steps {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wizard-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.wizard-step p {
  margin: 3px 0 0;
  font-size: 12.8px;
  color: var(--text-secondary);
}

.origin-copy-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 7px 0;
  padding: 7px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.origin-copy-box code {
  background: transparent;
  padding: 0;
  font-size: 12.5px;
  color: var(--text-primary);
  word-break: break-all;
}

.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.backup-actions {
  display: flex;
  gap: 8px;
}

.file-upload-btn {
  cursor: pointer;
}

/* Emoji & Color Pickers */
.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emoji-choice {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface-subtle);
  cursor: pointer;
  font-size: 17px;
  display: grid;
  place-items: center;
}

.emoji-choice.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch.active {
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--text-primary);
}

/* =========================================================
   Toasts
   ========================================================= */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 15px;
  background: #1c2230;
  color: #f4f6fb;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  animation: slideUp 0.18s ease;
}

[data-theme="dark"] .toast {
  background: #283145;
  border: 1px solid var(--border-strong);
}

.toast-action {
  border: none;
  background: transparent;
  color: #8ba4ff;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
}

.toast-action:hover {
  text-decoration: underline;
}

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

/* =========================================================
   Responsive Design (Tablet & Mobile)
   ========================================================= */

.mobile-only {
  display: none;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 24, 0.45);
  z-index: 28;
}

@media (max-width: 1020px) {
  .detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(400px, 100vw);
    box-shadow: var(--shadow-lg);
    z-index: 40;
  }
}

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

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    padding: 12px 16px;
  }

  .main-scroll {
    padding: 16px 14px 70px;
  }

  #search-input, #search-input:focus {
    width: 150px;
  }

  .detail-field-grid {
    grid-template-columns: 1fr;
  }

  .drag-handle {
    opacity: 0.45;
  }

  .task-row-actions {
    opacity: 1;
  }
}

@media (max-width: 560px) {
  .sync-pill #header-sync-label {
    display: none;
  }
}
