/* ─── FONTS ──────────────────────────────────────────────────────────────── */
/* Font: DM Sans Variable — self-hosted (SIL Open Font License) */
@font-face {
  font-family: 'DM Sans';
  src: url('/src/fonts/DMSans.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('/src/fonts/DMSans-Italic.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* ─── BASE: Blue Light (default) ───────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg-a: #f0f4f8;
  --bg-b: #fafcfe;
  --text: #1a1d23;
  --muted: #6b7280;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --panel-inset: #f1f5f9;
  --border: rgba(100, 116, 139, 0.22);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.10), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.08);
  --accent: #2563eb;
  --accent-2: #0891b2;
  --accent-glow: rgba(37, 99, 235, 0.10);
  --danger: #dc2626;
  --done: #9ca3af;
  --radius: 16px;
  --radius-sm: 10px;
  --blur: blur(28px) saturate(160%);
  font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
}

/* ─── DARK: Blue Dark ───────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-a: #0f1117;
  --bg-b: #1a1d24;
  --text: #e8eaf0;
  --muted: #8b95a8;
  --panel: #1e2433;
  --panel-strong: #262b38;
  --panel-inset: #12161f;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.40), 0 1px 3px rgba(0, 0, 0, 0.24);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.56), 0 4px 16px rgba(0, 0, 0, 0.32);
  --accent: #3b82f6;
  --accent-2: #22d3ee;
  --accent-glow: rgba(59, 130, 246, 0.14);
  --danger: #f87171;
  --done: #6b7280;
}

/* ─── COFFEE light ───────────────────────────────────────────────────────── */
:root[data-theme="coffee-light"] {
  color-scheme: light;
  --bg-a: #f2ebe3;
  --bg-b: #faf6f1;
  --text: #2a1f14;
  --muted: #7a5c3e;
  --panel: #fffaf4;
  --panel-strong: #fffaf4;
  --panel-inset: #ece7e0;
  --border: rgba(120, 85, 50, 0.22);
  --shadow: 0 2px 12px rgba(60, 35, 10, 0.12), 0 1px 3px rgba(60, 35, 10, 0.07);
  --shadow-lg: 0 24px 64px rgba(60, 35, 10, 0.18);
  --accent: #6b3a1f;
  --accent-2: #9c5a2a;
  --accent-glow: rgba(107, 58, 31, 0.10);
  --danger: #b91c1c;
  --done: #9c8270;
}

/* ─── COFFEE dark ────────────────────────────────────────────────────────── */
:root[data-theme="coffee-dark"] {
  color-scheme: dark;
  --bg-a: #180f08;
  --bg-b: #201408;
  --text: #eddfc8;
  --muted: #9c7a58;
  --panel: #2c1a0e;
  --panel-strong: #342010;
  --panel-inset: #160e08;
  --border: rgba(160, 110, 60, 0.20);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.44), 0 1px 3px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.60);
  --accent: #c49a6c;
  --accent-2: #a0724a;
  --accent-glow: rgba(196, 154, 108, 0.14);
  --danger: #f87171;
  --done: #7a5c3c;
}

/* ─── MUSIC light ────────────────────────────────────────────────────────── */
:root[data-theme="music-light"] {
  color-scheme: light;
  --bg-a: #f0ebf8;
  --bg-b: #faf8fe;
  --text: #1a0f2e;
  --muted: #7c5ba0;
  --panel: #faf8ff;
  --panel-strong: #faf8ff;
  --panel-inset: #eae5f6;
  --border: rgba(124, 91, 160, 0.24);
  --shadow: 0 2px 12px rgba(60, 20, 100, 0.12), 0 1px 3px rgba(60, 20, 100, 0.07);
  --shadow-lg: 0 24px 64px rgba(60, 20, 100, 0.18);
  --accent: #7c3aed;
  --accent-2: #db2777;
  --accent-glow: rgba(124, 58, 237, 0.10);
  --danger: #dc2626;
  --done: #9d86b8;
}

/* ─── MUSIC dark ─────────────────────────────────────────────────────────── */
:root[data-theme="music-dark"] {
  color-scheme: dark;
  --bg-a: #0e0818;
  --bg-b: #160d24;
  --text: #ede8f8;
  --muted: #9b7cc8;
  --panel: #1c1535;
  --panel-strong: #241c42;
  --panel-inset: #0e0a18;
  --border: rgba(160, 100, 240, 0.20);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.44), 0 1px 3px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.58);
  --accent: #a855f7;
  --accent-2: #ec4899;
  --accent-glow: rgba(168, 85, 247, 0.14);
  --danger: #f87171;
  --done: #6b5285;
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  font-size: 138%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 15% 0%, var(--accent-glow), transparent 45%),
    linear-gradient(160deg, var(--bg-a), var(--bg-b));
}

body.menu-open { overflow: hidden; }

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

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 500px;
  gap: 14px;
  height: calc(100vh - 56px);
  padding: 14px;
  max-width: 1780px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.glass {
  border: 1px solid var(--border);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.sidebar, .details {
  background: var(--panel-inset);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.sidebar, .main, .details {
  min-height: 0;
  border-radius: var(--radius);
}

.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 14px;
  height: 100%;
  min-height: 0;
}

.sidebar-scroll {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

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

.settings-button {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text);
  text-align: left;
  background: var(--panel-strong);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.settings-button:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.mobile-menu-button, .mobile-overlay, .mobile-header { display: none; }

.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px;
  min-width: 0;
  max-width: 1000px;
  height: 100%;
  min-height: 0;
  background: var(--panel-inset, var(--bg-a));
}

.details {
  overflow: auto;
  padding: 16px;
  min-width: 0;
  height: 100%;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
}

.brand-name {
  font-size: 2.1rem;
  line-height: 1.1;
}

.sidebar-close.icon-button {
  display: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.brand span, .view-header p, .muted-row, .task-meta, .timestamps, .no-details p {
  color: var(--muted);
}

.search,
.add-task input,
.field input, .field select, .field textarea,
.step-row input,
.account-form input, .account-form select,
.admin-user-row input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search:focus, .add-task input:focus,
.field input:focus, .field select:focus, .field textarea:focus,
.step-row input:focus, .account-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search { height: 40px; margin-bottom: 16px; padding: 0 12px; }
.nav-section { margin: 16px 0; }

.section-title {
  margin: 0 2px 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.with-action, .group-title, .view-header, .details-header, .settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nav-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease;
}

.nav-row:hover { background: var(--accent-glow); }

.nav-row.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.task-row:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
}

.task-row.selected {
  border-color: var(--accent);
  box-shadow: 0 4px 16px var(--accent-glow), 0 1px 4px rgba(0,0,0,0.06);
}

.row-icon { color: var(--accent); font-weight: 700; display: flex; align-items: center; justify-content: center; width: 18px; }
.row-icon svg { display: block; width: 16px; height: 16px; flex-shrink: 0; }
.count { color: var(--muted); font-size: 1rem; }

.icon-button, .mini-button, .check-button, .star-button, .drag-handle {
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
  line-height: 1;
  padding: 0;
}

.icon-button:hover, .mini-button:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.icon-button:active, .mini-button:active { transform: scale(0.94); }
.icon-button { width: 36px; height: 36px; font-size: 1.25rem; }
.mini-button { width: 32px; height: 36px; font-size: 1.1rem; }

.drag-handle {
  width: 32px; height: 36px;
  color: var(--muted);
  touch-action: none;
  cursor: grab;
}

.drag-handle:active { cursor: grabbing; }
.danger { color: var(--danger); }

.group-title {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  margin-top: 4px;
}

.group-title .group-row { grid-template-columns: 22px 1fr; }
.group-lists { margin-left: 12px; }

.list-drop-zone { min-height: 12px; border-radius: var(--radius-sm); }
.group-lists.collapsed { display: none; }

.list-nav-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-sm);
}

.list-nav-wrap.dragging { opacity: 0.4; }

.list-nav-wrap.drag-over, .list-drop-zone.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.view-header { margin-bottom: 16px; flex-shrink: 0; }

.view-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3.5vw, 3.2rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.view-header p { margin: 6px 0 0; }

.view-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  flex-shrink: 0;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 1rem;
}

.toggle.large {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: var(--panel-strong);
  transition: border-color 140ms ease;
}

.toggle.large:hover { border-color: var(--accent); }

.ghost-button, .file-button, .add-task button {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  color: var(--text);
  background: var(--panel-strong);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.ghost-button:hover, .file-button:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.ghost-button.full { width: 100%; }

.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.add-task {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.add-task input { height: 50px; padding: 0 14px; }

.add-task button {
  min-width: 110px;
  color: white;
  border-color: transparent;
  background: var(--accent);
  font-weight: 600;
}

.add-task button:hover { opacity: 0.88; }

.task-list { overflow: auto; padding-right: 4px; flex: 1; min-height: 0; }

.task-row {
  display: grid;
  grid-template-columns: 32px 1fr auto 36px;
  align-items: center;
  gap: 10px;
  min-height: 70px;
  margin-bottom: 7px;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 10px 12px;
  background: var(--panel-strong);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

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

.check-button {
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 1.05rem;
  color: white;
  background: var(--accent);
  transition: transform 80ms ease, opacity 140ms ease;
}

.check-button:hover { opacity: 0.85; }
.check-button:active { transform: scale(0.9); }
.check-button.unchecked {
  background: var(--panel-inset, #e8edf3);
  border-color: rgba(100,116,139,0.40);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.10), inset 0 1px 2px rgba(0,0,0,0.06);
}
.check-button.small { width: 28px; height: 28px; font-size: 0.95rem; }

.star-button {
  width: 38px; height: 38px;
  font-size: 1.25rem;
  color: var(--border-star, rgba(160, 170, 185, 0.5));
  transition: color 140ms ease, transform 80ms ease;
}

.star-button:hover { color: #f59e0b; transform: scale(1.1); }
.star-button.active { color: #f59e0b; }

.task-controls { display: flex; gap: 3px; }
.task-main { min-width: 0; }

.task-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.88rem;
}

.task-meta span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--panel);
}

.empty, .no-details {
  display: grid;
  min-height: 200px;
  place-items: center;
  align-content: center;
  text-align: center;
}

.details-header { margin-bottom: 14px; }
.details-header h2 { margin: 0; }
.field, .steps { display: grid; gap: 6px; margin-bottom: 12px; }
.due-field { margin-top: 20px; }

.field span, .field-title {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.field input, .field select { height: 48px; padding: 0 11px; }
.field textarea { resize: vertical; padding: 10px 11px; }

.step-row {
  display: grid;
  grid-template-columns: 32px 1fr 36px;
  align-items: center;
  gap: 7px;
}

.step-row input { height: 44px; padding: 0 10px; }

.timestamps { display: grid; gap: 3px; margin-top: 14px; font-size: 0.88rem; }

/* ─── SETTINGS MODAL ─────────────────────────────────────────────────────── */
.settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.settings-overlay.visible { display: block; }

.settings-panel {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 210;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 20px;
  padding: 24px;
  /* transform-origin stays at center since we override transform below */
}

.settings-panel.open {
  display: grid;
  gap: 14px;
  transform: translate(-50%, -50%);
}

.settings-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.settings-modal-header strong { font-size: 1.1rem; }

.settings-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.settings-panel select {
  width: 100%;
  height: 42px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
  cursor: pointer;
}

.settings-panel select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Theme picker */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 8px;
}

.theme-chip {
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--panel-strong);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 140ms ease, background 140ms ease;
  text-align: center;
  line-height: 1.2;
}

.theme-chip:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.theme-chip.active {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 700;
}

.theme-chip .swatch {
  width: 34px;
  height: 18px;
  border-radius: 5px;
  display: block;
  border: 1px solid rgba(0,0,0,0.08);
}

/* ─── ACCOUNT ────────────────────────────────────────────────────────────── */
.account-section, .admin-section {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.account-section h3, .admin-section h3 { margin: 0; }
.account-form, .account-actions, .admin-users { display: grid; gap: 9px; }
.account-form label { display: grid; gap: 6px; color: var(--muted); }

.account-form input, .account-form select, .admin-user-row input {
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
}

.account-message { margin: 0; color: var(--muted); overflow-wrap: anywhere; }

.recovery-codes { display: grid; gap: 7px; }

.recovery-codes code {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  white-space: pre-wrap;
  background: var(--panel-strong);
  font-size: 0.9rem;
}

.admin-user-row {
  display: grid;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--panel);
}

.sort-select {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  color: var(--text);
  background: var(--panel-strong);
  cursor: pointer;
}

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

.task-group-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  margin-bottom: 7px;
  border: 1px solid var(--accent);
  border-radius: 13px;
  padding: 8px 12px;
  color: var(--accent);
  text-align: left;
  background: var(--accent-glow);
  cursor: pointer;
  transition: background 120ms ease, opacity 120ms ease;
}

.task-group-header:hover { opacity: 0.85; }
.task-group-body.collapsed { display: none; }
.empty.compact { min-height: 80px; }

.backup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.backup-actions .ghost-button, .backup-actions .file-button {
  display: grid;
  min-height: 42px;
  place-items: center;
  text-align: center;
}

/* Notification banner */
.notif-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--panel-strong);
  font-size: 0.92rem;
}

.notif-banner button {
  margin-left: auto;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 5px 12px;
  color: var(--accent);
  background: var(--accent-glow);
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── MEDIUM ─────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .shell {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  }

  .details {
    grid-column: 1 / -1;
    min-height: 320px;
  }
}

/* ─── MOBILE ─────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  html { font-size: 108%; }
  body.menu-open { overflow: hidden; }

  .mobile-header {
    display: flex;
    align-items: center;
    position: sticky;
    top: 10px;
    z-index: 35;
    margin: 10px 10px 0 10px;
    padding: 0 10px 0 0;
    border-radius: 13px;
    border: 1px solid var(--border);
    background: var(--panel);
    gap: 0;
    min-width: 0;
  }

  .mobile-menu-button {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    flex-shrink: 0;
    cursor: pointer;
    background: none;
    border: none;
    border-radius: 13px;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
  }

  .mobile-brand-icon {
    width: 26px;
    height: 26px;
    object-fit: contain;
    flex-shrink: 0;
  }

  .mobile-brand-name {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
  }

  .mobile-overlay.visible {
    position: fixed;
    inset: 0;
    z-index: 38;
    display: block;
    background: rgba(0,0,0,0.42);
  }

  .shell {
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 10px;
    min-height: auto;
    width: 100%;
    overflow-x: hidden;
  }

  .main {
    border-radius: 13px;
    overflow: visible;
    padding: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .details {
    border-radius: 13px;
    overflow: visible;
    padding: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .sidebar {
    position: fixed;
    top: 10px;
    bottom: 10px;
    left: 10px;
    z-index: 40;
    width: min(84vw, 340px);
    max-width: calc(100vw - 20px);
    border-radius: 16px;
    padding: 14px;
    transform: translateX(calc(-100% - 24px));
    transition: transform 220ms ease;
  }

  .sidebar.open { transform: translateX(0); }
  .brand { margin-bottom: 11px; }
  .brand-name { font-size: 2.4rem; }
  .sidebar-close.icon-button { display: grid; }
  .nav-section { margin: 12px 0; }

  .view-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .view-header h1 { font-size: clamp(1.7rem, 8vw, 2.4rem); }

  .view-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .add-task { grid-template-columns: 1fr; }
  .task-list { overflow: visible; padding-right: 0; }

  .task-row {
    grid-template-columns: 32px minmax(0, 1fr) 38px;
    gap: 8px;
    min-height: 62px;
  }

  .task-controls { display: none; }
  .task-main strong { white-space: normal; word-break: break-word; }

  .settings-panel {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    border-radius: 16px;
    padding: 18px;
  }

  .theme-picker { grid-template-columns: repeat(3, 1fr); }

  .backup-actions { grid-template-columns: 1fr; }

  .settings-panel label,
  .settings-panel select,
  .settings-panel button,
  .file-button { width: 100%; }
}

@media (max-width: 420px) {
  .theme-picker { grid-template-columns: repeat(2, 1fr); }
  .task-row { padding: 9px 10px; }
  .task-meta { gap: 4px; }
  .view-header h1 { font-size: clamp(1.5rem, 10vw, 2rem); }
}

/* ─── SETTINGS TABS ──────────────────────────────────────────────────────── */
.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.settings-tab {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
  white-space: nowrap;
  text-align: center;
}

.settings-tab:hover {
  background: var(--accent-glow);
  color: var(--text);
  border-color: var(--accent);
}

.settings-tab.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.settings-tab-body {
  display: grid;
  gap: 14px;
}

@media (max-width: 520px) {
  .settings-tab {
    padding: 7px 6px;
  }
}

/* ─── SETTINGS FONT FIX (inherit body scale) ─────────────────────────────── */
/* Settings panel inherits html font-size via rem, no override needed */
.settings-panel { font-size: inherit; }
.settings-tab { font-size: inherit; }
.theme-chip { font-size: 0.9rem; }
.account-form label { font-size: inherit; }
.account-message { font-size: inherit; }
.notif-banner { font-size: inherit; }

/* ─── MOBILE: close button fix ───────────────────────────────────────────── */
@media (max-width: 760px) {
  /* X button in settings should be compact, right-aligned */
  .settings-modal-header .icon-button {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    margin-left: auto;
  }

  /* Mobile view header: title + count inline, sort below */
  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .view-header-top {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .view-header h1 {
    flex: 1;
    min-width: 0;
  }

  .view-header-count {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 0.95rem;
    white-space: nowrap;
  }

  .view-actions {
    width: 100%;
    justify-content: flex-start;
  }

  /* sort select compact on mobile */
  .sort-select {
    width: auto;
    flex-shrink: 0;
  }
}

/* ─── VIEW HEADER TOP (desktop) ─────────────────────────────────────────── */
.view-header-top {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  min-width: 0;
}

.view-header-count {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 500;
  padding-left: 8px;
  border-left: 2px solid var(--border);
}

.sort-select {
  margin-left: 8px;
}

/* desktop: header is still side-by-side row */
@media (min-width: 761px) {
  .view-header {
    flex-direction: row;
    align-items: center;
  }

  /* sort select compact on desktop */
  .sort-select {
    width: auto;
  }
}

/* ─── APP ICON (brand) ───────────────────────────────────────────────────── */
.brand-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ─── ICON PICKER (admin settings) ──────────────────────────────────────── */
.admin-icon-section {
  margin-bottom: 4px;
}

.icon-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.icon-chip {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  min-width: 68px;
  max-width: 68px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: var(--panel-strong);
  cursor: pointer;
  padding: 4px;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 80ms ease;
  flex-shrink: 0;
  align-self: flex-start;
}

.icon-chip:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.icon-chip.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.icon-chip img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
}

.icon-chip-default {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
  font-size: 1.4rem;
}

/* ─── INLINE DIALOG (replaces browser prompt/confirm) ────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dialog-box {
  width: min(380px, calc(100vw - 32px));
  padding: 24px;
  border-radius: 16px;
  display: grid;
  gap: 16px;
}

.dialog-box p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}

.dialog-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
  font: inherit;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

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

.dialog-actions {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
}

/* ─── OVERSCROLL FIX ──────────────────────────────────────────────────────── */
.settings-panel {
  overscroll-behavior: contain;
}

/* ─── TASK DRAG & DROP ───────────────────────────────────────────────────── */
.task-drop-target {
  background: var(--accent-glow) !important;
  border-color: var(--accent) !important;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
