/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Keyboard focus rings ── */
/* Only shown during keyboard navigation, not mouse clicks */
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Light Theme ── */
:root {
  --bg:                #ede8df;
  --surface:           #ffffff;
  --surface-2:         #f7f4ef;
  --surface-3:         #efe9e0;
  --border:            #d8d0c4;
  --border-soft:       #E8E2D8;
  --text:              #18140e;
  --text-2:            #4a4338;
  --muted:             #7a7064;
  --accent:            #6D28D9;
  --accent-hover:      #5B21B6;
  --accent-grad:       linear-gradient(135deg, #6D28D9, #9333EA);
  --accent-light:      #F3EEFF;
  --accent-soft:       #F3EEFF;
  --accent-border:     #C4B5FD;
  --shadow-sm:         0 1px 4px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.07);
  --shadow:            0 4px 14px rgba(0,0,0,0.12);
  --shadow-lg:         0 8px 32px rgba(0,0,0,0.18);
  --shadow-card:       0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.06), 0 8px 20px rgba(0,0,0,0.03);
  --shadow-card-hover: 0 2px 4px rgba(0,0,0,0.05), 0 8px 24px rgba(0,0,0,0.10), 0 16px 32px rgba(0,0,0,0.04);
  --ease:              cubic-bezier(0.4, 0, 0.2, 1);
  --radius:            14px;
  --col-bg:            #e4ddd3;
  --star-color:        #F59E0B;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --bg:                #1d1b18;
  --surface:           #272420;
  --surface-2:         #2f2c28;
  --surface-3:         #373430;
  --border:            #3d3a35;
  --border-soft:       #332F2B;
  --text:              #f0ebe2;
  --text-2:            #b0a89c;
  --muted:             #9a948c;
  --accent:            #7C3AED;
  --accent-hover:      #8B5CF6;
  --accent-grad:       linear-gradient(135deg, #7C3AED, #9333EA);
  --accent-light:      #1E1A2E;
  --accent-soft:       #1E1A2E;
  --accent-border:     #4C2889;
  --shadow-sm:         0 1px 4px rgba(0,0,0,0.45);
  --shadow:            0 4px 14px rgba(0,0,0,0.55);
  --shadow-lg:         0 8px 32px rgba(0,0,0,0.75);
  --shadow-card:       0 1px 2px rgba(0,0,0,0.30), 0 4px 12px rgba(0,0,0,0.40), 0 8px 20px rgba(0,0,0,0.20);
  --shadow-card-hover: 0 2px 4px rgba(0,0,0,0.40), 0 8px 24px rgba(0,0,0,0.55), 0 16px 32px rgba(0,0,0,0.30);
  --col-bg:            #211f1c;
  --star-color:        #FBBF24;
}

body {
  font-family: var(--font-family, 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  background:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(255,255,255,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 80% 80%, rgba(109,40,217,0.04) 0%, transparent 70%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
}

.hidden { display: none !important; }

/* ══════════════════════════════
   HEADER
══════════════════════════════ */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 52px;
  background: rgba(254, 252, 249, 0.78);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(221,214,203,0.7);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 2px 12px rgba(0,0,0,0.07);
  transition: background 0.25s, border-color 0.25s;
}

.header-left { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.header-logo-icon {
  width: 30px; height: 30px;
  background: var(--accent-grad);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 3px 10px rgba(109,40,217,0.35);
}
.header-divider {
  width: 1px; height: 20px;
  background: var(--border); flex-shrink: 0;
}
.logo { font-size: 15px; }
.header h1 { font-size: 15px; font-weight: 800; letter-spacing: -0.4px; color: var(--text); }

/* ── TaskNest Wordmark ── */
.logo-wordmark {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.logo-wordmark-row {
  display: flex;
  align-items: baseline;
  line-height: 1;
}
.logo-task {
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-nest {
  font-weight: 300;
  letter-spacing: -0.5px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-underline {
  height: 2px;
  background: var(--accent-grad);
  border-radius: 1px;
}

/* header wordmark size */
.header .logo-wordmark .logo-task,
.header .logo-wordmark .logo-nest { font-size: 22px; }

/* login logo icon */
.login-logo-icon {
  width: 68px;
  height: 68px;
  background: var(--accent-grad);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 6px 24px rgba(168,85,247,0.35);
}

/* login title wordmark */
.login-title .logo-task,
.login-title .logo-nest { font-size: 32px; }
.login-title { margin-bottom: 6px; }

/* View Tabs */
.view-nav {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.view-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.view-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.header-right { display: flex; align-items: center; gap: 7px; flex-shrink: 0; margin-left: auto; }

.dev-badge {
  background: #7C3AED;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.2px;
}

.icon-btn {
  background: rgba(246,242,235,0.7);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px; height: 32px;
  font-size: 15px;
  color: var(--text-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease-out, transform 0.15s ease-out;
  white-space: nowrap;
  padding: 0;
}
.icon-btn:hover { background: var(--surface-3); transform: translateY(-1px); }

/* ── Profile menu ─────────────────────────────────────────── */
.profile-menu-wrap { position: relative; }

.profile-avatar-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--accent-grad);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  padding: 0;
  transition: box-shadow 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.profile-avatar-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(109,40,217,0.35); }
.profile-avatar-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-avatar-btn img[src=""], .profile-avatar-btn img:not([src]) { display: none; }
#profileAvatarInitial {
  font-size: 14px; font-weight: 700; color: #fff;
  line-height: 1; pointer-events: none;
}
.profile-avatar-btn.has-photo #profileAvatarInitial { display: none; }

.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  z-index: 999;
  overflow: hidden;
  animation: dropdownIn 0.18s var(--ease) both;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.profile-top {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 14px 12px;
}

.profile-photo-label {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden; flex-shrink: 0;
  border: 2px solid var(--border);
  transition: opacity 0.15s;
  position: relative;
}
.profile-photo-label:hover { opacity: 0.85; }
.profile-photo-label input[type="file"] { display: none; }
.profile-photo-label img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-photo-label img[src=""], .profile-photo-label img:not([src]) { display: none; }
#dropdownAvatarInitial {
  font-size: 20px; font-weight: 700; color: #fff; pointer-events: none;
}
.profile-photo-label.has-photo #dropdownAvatarInitial { display: none; }

.profile-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.profile-name {
  font-size: 15px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profile-edit-name-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  font-size: 11px; color: var(--muted); text-align: left;
  font-family: inherit;
  transition: color 0.15s;
}
.profile-edit-name-btn:hover { color: var(--accent); }

.profile-greeting {
  margin: 0 10px 10px;
  padding: 10px 12px;
  font-size: 12px; line-height: 1.5; color: var(--text-2);
  background: var(--surface-2);
  border-radius: 8px;
}
.profile-greeting strong { color: var(--text); }

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

.profile-menu-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; background: none; border: none;
  padding: 9px 14px; font-size: 13px; color: var(--text-2);
  cursor: pointer; text-align: left; font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.profile-menu-item:hover { background: var(--surface-2); color: var(--text); }
.sign-out-item { color: var(--muted); }
.sign-out-item:hover { background: rgba(239,68,68,0.08); color: #ef4444; }

[data-theme="dark"] .profile-dropdown { box-shadow: 0 8px 32px rgba(0,0,0,0.45); }
[data-theme="dark"] .profile-avatar-btn { border-color: var(--border); }

.btn-add {
  background: var(--accent-grad);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 15px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: -0.1px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 2px 10px rgba(109,40,217,0.32);
  transition: all 0.18s var(--ease);
  white-space: nowrap;
}
.btn-add:hover {
  transform: scale(1.02) translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 6px 20px rgba(109,40,217,0.45);
}

/* ══════════════════════════════
   STATUS LINE
══════════════════════════════ */
.status-line {
  background: rgba(255,255,255,0.38);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(221,214,203,0.5);
  padding: 5px 20px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-shrink: 0;
}
.status-item {
  font-size: 11.5px; font-weight: 500;
  color: var(--muted);
  display: flex; align-items: center; gap: 5px;
}
.status-item strong { color: var(--text-2); font-weight: 700; }
.status-item.warn strong { color: #B45309; }
.status-item.status-urgent { color: #dc2626; font-weight: 600; }
.status-item.status-urgent strong { color: #b91c1c; }
[data-theme="dark"] .status-item.status-urgent { color: #f87171; }
[data-theme="dark"] .status-item.status-urgent strong { color: #fca5a5; }
.status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--border); flex-shrink: 0;
}

/* ══════════════════════════════
   BOARD VIEW
══════════════════════════════ */
.board-view {
  height: calc(100vh - 84px);
  overflow: hidden;
  position: relative;
  padding: 0;
  cursor: default;
  /* The board handles its own one-finger pan + two-finger pinch on touch
     devices, so tell the browser not to hijack those gestures (no page
     scroll / double-tap zoom while dragging the board). */
  touch-action: none;
}
/* …but let text fields inside the board keep normal touch behaviour, so
   tapping to place the caret / select text still works on phones. */
.board-view input,
.board-view textarea {
  touch-action: auto;
  -webkit-user-select: text;
  user-select: text;
}
/* Stop the long-press "picked it up" gesture from also triggering the phone's
   text-selection / image callout on the board. */
.board-view { -webkit-touch-callout: none; }
/* An item that's been picked up by a long-press on touch — lifts a little. */
.touch-lifted {
  transform: scale(1.04);
  box-shadow: 0 12px 30px rgba(0,0,0,0.30) !important;
  opacity: 0.97;
  z-index: 9999 !important;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
@media (prefers-reduced-motion: reduce) {
  .touch-lifted { transition: none; }
}
/* The moveable canvas layer — transformed by JS */
.board-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}
/* The columns wrapper sits inside the canvas and is a positioning context */
.board-columns {
  position: absolute;
  top: 0; left: 0;
  width: 4000px;
  height: 4000px;
}

/* Canvas zoom controls — floating pill in the bottom-right */
.canvas-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 4px 6px;
  box-shadow: var(--shadow);
  z-index: 50;
  user-select: none;
}
.canvas-ctrl-btn {
  background: none; border: none;
  color: var(--text-2);
  font-size: 15px; font-weight: 700;
  width: 30px; height: 30px;
  border-radius: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.14s, color 0.14s;
  line-height: 1;
}
.canvas-ctrl-btn:hover { background: var(--surface-3); color: var(--text); }
.canvas-ctrl-zoom-label {
  font-size: 11px; font-weight: 700;
  width: 44px; cursor: default;
  color: var(--muted); letter-spacing: 0.02em;
}
.canvas-ctrl-zoom-label:hover { background: none; color: var(--muted); }
.canvas-ctrl-divider {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 3px;
  flex-shrink: 0;
}

/* Column — absolutely placed on the infinite canvas */
.board-column {
  position: absolute;
  width: 310px;
  background: var(--col-bg);
  background: color-mix(in srgb, var(--col-tint, transparent) 18%, var(--col-bg));
  border-radius: var(--radius);
  border-top: 3px solid var(--col-accent, transparent);
  display: flex;
  flex-direction: column;
  transition: background 0.4s, border-color 0.4s;
  box-shadow: var(--shadow-card);
}

.column-header {
  padding: 14px 14px 8px;
  flex-shrink: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.32), transparent);
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: grab;
}
.column-header:active { cursor: grabbing; }
.column-title-row { display: flex; align-items: center; gap: 9px; margin-bottom: 3px; }
.day-pill {
  width: 28px; height: 28px; border-radius: 8px;
  font-size: 13px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.day-pill-btn {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.day-pill-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.55);
}
.column-title { font-size: 17px; font-weight: 800; color: var(--text); letter-spacing: -0.4px; }
.column-subtitle { font-size: 11px; color: var(--muted); line-height: 1.4; padding-left: 2px; }

.column-body {
  padding: 4px 10px 6px;
  display: flex; flex-direction: column; gap: 10px;
}

.column-add-class-btn {
  margin: 4px 10px 10px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 9px;
  padding: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.column-add-class-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* Column header actions (rename / delete) */
/* col-drag-handle removed — column drags from any blank header area */

.board-column.col-dragging {
  opacity: 0.75;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.column-header-actions { display: flex; gap: 3px; margin-left: auto; }
.column-header-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 2px 5px;
  border-radius: 5px; opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  line-height: 1;
}
.board-column:hover .column-header-btn { opacity: 1; }
.column-header-btn:hover { background: var(--surface-3); color: var(--text); }
.column-header-btn.danger:hover { background: #FEE2E2; color: #EF4444; }
[data-theme="dark"] .column-header-btn.danger:hover { background: #3b1515; color: #f87171; }

/* Column color swatch — visible on column hover */
.customize-col-color-btn {
  display: inline-flex;
  width: 18px; height: 18px;
  border-radius: 50%; padding: 0;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1.5px var(--border);
  cursor: pointer; opacity: 0;
  transition: opacity 0.15s, transform 0.12s, box-shadow 0.12s;
}
.board-column:hover .customize-col-color-btn { opacity: 1; }
.customize-col-color-btn:hover { transform: scale(1.25); box-shadow: 0 0 0 2px var(--accent); }

/* Column tint color picker popup */
.col-tint-popup {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 160px;
}
.col-tint-popup-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.col-tint-input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: none;
}
.col-tint-reset-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: center;
}
.col-tint-reset-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent);
}

/* Add-column placeholder — floats near the rightmost column */
.column-add-col {
  position: absolute;
  width: 200px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; padding: 24px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-height: 140px;
}
.column-add-col:hover {
  border-color: var(--border);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.column-add-col-icon { font-size: 26px; color: var(--muted); line-height: 1; }
.column-add-col-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.column-add-col:hover .column-add-col-icon,
.column-add-col:hover .column-add-col-label { color: var(--text); }

/* Inline new-column form */
.new-column-form {
  width: 280px;
  background: var(--surface); border: 1.5px solid var(--accent);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow);
}
.new-column-form-title { font-size: 13px; font-weight: 800; color: var(--text); }
.new-column-form-row { display: flex; gap: 7px; align-items: center; }
.new-column-form-row input[type="text"] {
  flex: 1; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--surface-2); color: var(--text);
}
.new-column-form-row input[type="text"]:focus { outline: none; border-color: var(--accent); }
.new-column-form-actions { display: flex; gap: 7px; }

/* ── Subject Group — the real card ── */
.subject-group {
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid rgba(221,214,203,0.6);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease), background 0.25s;
}
.subject-group:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-1px);
}

.subject-color-bar { height: 4px; background: var(--subject-color, #6D28D9); flex-shrink: 0; border-radius: 14px 14px 0 0; }

.subject-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 13px 9px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
}
.subject-group-header:active { cursor: grabbing; }
.subject-group-label { font-size: 10.5px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--subject-color, var(--text)); flex: 1; }
.subject-group-count {
  font-size: 10px; color: var(--subject-color, #6366F1); font-weight: 800;
  white-space: nowrap; padding: 2px 8px; border-radius: 20px;
  border: 1.5px solid var(--subject-color, #6366F1);
  background: transparent;
}

/* ── Kanban Card — flat task row inside class card ── */
.kanban-card {
  display: flex; flex-direction: column;
  border-bottom: 1px solid var(--border);
  border-left: 2.5px solid transparent;
  background: transparent;
  transition: background 0.15s ease-out, border-left-color 0.15s ease-out;
}
.kanban-card:last-child { border-bottom: none; }
.kanban-card:hover {
  background: var(--surface-2);
  border-left-color: var(--subject-color, var(--border));
}
.kanban-card.done { opacity: 0.45; }
.kanban-card.done .card-title { text-decoration: line-through; color: var(--muted); }

.card-main-row {
  padding: 9px 13px 9px 10.5px;
  display: flex; align-items: flex-start; gap: 10px;
}

.card-checkbox {
  width: 15px; height: 15px; border-radius: 4px;
  border: 2px solid var(--subject-color, #ccc);
  appearance: none; -webkit-appearance: none;
  cursor: pointer; flex-shrink: 0; margin-top: 2px;
  transition: background 0.15s; position: relative;
}
.card-checkbox:checked { background: var(--subject-color, #ccc); border-color: var(--subject-color, #ccc); }
.card-checkbox:checked::after {
  content: '✓'; position: absolute;
  top: -2px; left: 1px;
  color: #fff; font-size: 10px; font-weight: 800;
}

.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 13px; font-weight: 500; color: var(--text); line-height: 1.45; }
.card-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 4px; }

.card-due {
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
  background: #EFF6FF; color: #3B82F6; border: 1px solid #BFDBFE;
  cursor: pointer; transition: opacity 0.12s;
}
.card-due:hover { opacity: 0.75; text-decoration: underline dotted; }
.card-due.overdue { background: #FEE2E2; color: #DC2626; border-color: #FECACA; }
.card-due.soon    { background: #FEF3C7; color: #D97706; border-color: #FDE68A; }
[data-theme="dark"] .card-due         { background: #172554; color: #60a5fa; border-color: #1e40af; }
[data-theme="dark"] .card-due.overdue { background: #3b1515; color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] .card-due.soon    { background: #2d2008; color: #fbbf24; border-color: #78350f; }

.card-mini-stars { font-size: 10px; color: var(--star-color); letter-spacing: -1px; }
.card-estimate   { font-size: 10px; color: var(--muted); }

.card-notes { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.card-delete {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; padding: 0;
  flex-shrink: 0; opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.kanban-card:hover .card-delete { opacity: 1; }
.card-delete:hover { color: #EF4444; }

/* Subtask checklist */
.card-subtask-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 1px 3px; flex-shrink: 0;
  display: flex; align-items: center; gap: 3px;
  opacity: 0; transition: opacity 0.15s, color 0.15s;
  border-radius: 5px;
}
.kanban-card:hover .card-subtask-btn { opacity: 1; }
.card-subtask-btn.has-subs { opacity: 1; color: var(--accent); }
.card-subtask-btn:hover { background: var(--surface-3); }
.subtask-count { font-size: 10px; font-weight: 700; }

.subtask-panel {
  padding: 2px 13px 10px 38px;
  display: flex; flex-direction: column; gap: 1px;
}
.subtask-item {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 2px; border-radius: 5px; cursor: pointer;
  transition: background 0.1s;
}
.subtask-item:hover { background: var(--surface-3); }
.subtask-item.done .subtask-text { text-decoration: line-through; color: var(--muted); }
.subtask-check {
  width: 12px; height: 12px; border-radius: 3px;
  border: 1.5px solid var(--border);
  appearance: none; -webkit-appearance: none;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.12s; position: relative;
}
.subtask-check:checked { background: var(--accent); border-color: var(--accent); }
.subtask-check:checked::after {
  content: '✓'; position: absolute;
  top: -3px; left: 0px;
  color: #fff; font-size: 9px; font-weight: 800;
}
.subtask-text { font-size: 12px; color: var(--text-2); flex: 1; line-height: 1.4; }
.subtask-del {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 10px; padding: 0 2px;
  opacity: 0; transition: opacity 0.12s; flex-shrink: 0;
}
.subtask-item:hover .subtask-del { opacity: 1; }
.subtask-del:hover { color: #EF4444; }

.subtask-add-row { padding: 4px 2px 0; }
.subtask-add-input {
  width: 100%; border: none;
  border-bottom: 1px dashed var(--border);
  background: transparent;
  font-size: 12px; color: var(--text); padding: 3px 0;
  outline: none; font-family: inherit;
}
.subtask-add-input::placeholder { color: var(--muted); }
.subtask-add-input:focus { border-bottom-color: var(--accent); }

.group-empty {
  font-size: 12px; color: var(--muted); padding: 14px 13px;
  text-align: center; font-style: italic; letter-spacing: 0.1px;
}

/* Inline quick-add */
.inline-add-trigger {
  padding: 9px 13px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-top: 1px solid var(--border);
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.inline-add-trigger:hover { background: var(--surface-2); color: var(--accent); }

.inline-add-form {
  padding: 9px 13px 11px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; flex-direction: column; gap: 6px;
}
.inline-add-name {
  width: 100%; padding: 7px 9px;
  border: 1.5px solid var(--accent); border-radius: 7px;
  font-size: 13px; font-weight: 500;
  background: var(--surface); color: var(--text);
  font-family: inherit;
}
.inline-add-name:focus { outline: none; }
.inline-add-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-add-date {
  padding: 5px 10px;
  border: 1.5px solid var(--border); border-radius: 6px;
  font-size: 12px; font-weight: 500;
  background: var(--surface); color: var(--text);
  font-family: inherit; cursor: pointer;
}
.inline-add-date:focus { outline: none; border-color: var(--accent); }
.inline-add-date::-webkit-calendar-picker-indicator {
  cursor: pointer; opacity: 0.7;
}
[data-theme="dark"] .inline-add-date::-webkit-calendar-picker-indicator {
  filter: invert(1); opacity: 0.8;
}
.inline-add-est {
  padding: 5px 8px;
  border: 1.5px solid var(--border); border-radius: 6px;
  font-size: 12px; font-weight: 500;
  background: var(--surface); color: var(--text);
  font-family: inherit; cursor: pointer;
}
.inline-add-est:focus { outline: none; border-color: var(--accent); }
.inline-add-hint { font-size: 11px; color: var(--muted); }

.card-due-empty { color: var(--muted); font-style: italic; font-size: 11px; }
.card-due-input {
  font-size: 11px; font-family: inherit;
  border: 1.5px solid var(--accent); border-radius: 5px;
  padding: 1px 4px;
  background: var(--surface); color: var(--text);
  cursor: pointer;
}

.inline-add-extras {
  display: flex; flex-direction: column; gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 7px;
  margin-top: 2px;
}
.inline-add-stars-row {
  display: flex; align-items: center; gap: 6px;
}
.inline-add-stars-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.inline-star-btns { display: flex; gap: 1px; }
.inline-star {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--border);
  padding: 0 1px; line-height: 1;
  transition: color 0.1s, transform 0.1s;
}
.inline-star.active, .inline-star.hover { color: var(--star-color, #f59e0b); }
.inline-star:hover { transform: scale(1.2); }
.inline-star-hint { font-size: 11px; color: var(--muted); min-width: 52px; }
.inline-add-notes {
  width: 100%; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 12px; background: var(--surface); color: var(--text);
  font-family: inherit;
}
.inline-add-notes:focus { outline: none; border-color: var(--accent); }
.inline-add-actions {
  display: flex; gap: 6px; justify-content: flex-end;
}
.inline-save-btn {
  padding: 5px 14px; font-size: 12px; font-weight: 600;
  background: var(--accent); color: #fff;
  border: none; border-radius: 7px; cursor: pointer;
  font-family: inherit;
  transition: opacity 0.12s;
}
.inline-save-btn:hover { opacity: 0.88; }
.inline-cancel-btn {
  padding: 5px 10px; font-size: 12px;
  background: none; color: var(--muted);
  border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}
.inline-cancel-btn:hover { background: var(--surface-2); }

/* ══════════════════════════════
   CALENDAR VIEW
══════════════════════════════ */
.calendar-view {
  height: calc(100vh - 84px); overflow-y: auto; padding: 20px;
  display: flex; align-items: flex-start; gap: 16px;
}
.cal-panel {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.cal-sidebar {
  width: 200px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  position: sticky; top: 0;
  max-height: calc(100vh - 30px); overflow-y: auto;
}
.cal-sidebar::-webkit-scrollbar { width: 4px; }
.cal-sidebar::-webkit-scrollbar-track { background: transparent; }
.cal-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.cal-sidebar-inner { padding: 14px; }
.cal-sidebar-heading {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--muted); margin-bottom: 10px;
}
.cal-top {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
}
.cal-nav { display: flex; align-items: center; gap: 9px; }
.cal-arrow {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; width: 28px; height: 28px; cursor: pointer;
  font-size: 13px; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.cal-arrow:hover { background: var(--surface-3); }
#calTitle { font-size: 15px; font-weight: 800; color: var(--text); min-width: 150px; }
.view-toggle { display: flex; gap: 4px; margin-left: auto; }
.toggle-btn {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--muted); transition: all 0.15s;
}
.toggle-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cal-legend { display: flex; flex-direction: column; gap: 0; }
.legend-section-toggle {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; background: none; border: none;
  border-top: 1px solid var(--border);
  padding: 8px 0 4px; margin: 0; cursor: pointer;
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted);
}
.cal-legend > .legend-section-toggle:first-child { border-top: none; padding-top: 0; }
.legend-section-toggle:hover { color: var(--text-2); }
.legend-toggle-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; text-align: left; }
.legend-toggle-right { display: flex; align-items: center; gap: 5px; flex-shrink: 0; margin-left: 6px; }
.legend-count { font-size: 9px; font-weight: 700; background: var(--surface-3); color: var(--muted); padding: 1px 5px; border-radius: 10px; line-height: 1.4; }
.legend-chevron { width: 6px; height: 6px; flex-shrink: 0; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 0.2s; }
.legend-section-toggle.is-collapsed .legend-chevron { transform: rotate(-45deg); }
.legend-items-group { display: flex; flex-direction: column; gap: 5px; padding-bottom: 4px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.legend-dot-work { background: transparent; border: 2px dashed currentColor; box-sizing: border-box; }

.calendar-grid { padding: 14px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 5px; }
.cal-weekday { text-align: center; font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; padding: 3px 0; }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day {
  min-height: 96px; border-radius: 8px; border: 1px solid var(--border);
  padding: 7px; cursor: pointer; background: var(--surface-2);
  transition: background 0.15s, border-color 0.15s;
}
.cal-day:hover { background: var(--surface-3); border-color: var(--muted); }
.cal-day.today { border-color: var(--accent); background: var(--accent-light); }
.cal-day.other-month { opacity: 0.22; pointer-events: none; }
.cal-day.selected { background: var(--accent-light); border-color: var(--accent); }
.day-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: var(--text-2);
  margin-bottom: 5px;
}
.cal-day.today .day-num {
  background: var(--accent); color: #fff;
}
.day-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.day-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.week-grid { display: flex; flex-direction: column; gap: 5px; }
.week-day-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 13px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface-2);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.week-day-row:hover { background: var(--surface-3); border-color: var(--muted); }
.week-day-row.today { border-color: var(--accent); background: var(--accent-light); }
.week-day-label { min-width: 80px; flex-shrink: 0; }
.week-day-name { font-size: 13px; font-weight: 700; color: var(--text); }
.week-day-date { font-size: 11px; color: var(--muted); margin-top: 2px; }
.week-day-row.today .week-day-name { color: var(--accent); }
.week-tasks { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; align-items: center; }
.week-task-chip { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; color: #fff; white-space: nowrap; max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.week-empty { font-size: 12px; color: var(--muted); }

.day-detail {
  margin: 0 14px 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.day-detail-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; font-size: 13px; font-weight: 800; color: var(--text);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.day-detail-header button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 13px; }
.day-detail-add-event-btn {
  margin-left: auto;
  margin-right: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #8B5CF6 !important;
  border: 1.5px solid #8B5CF6 !important;
  border-radius: 20px;
  background: transparent !important;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.day-detail-add-event-btn:hover {
  background: #8B5CF6 !important;
  color: #fff !important;
}
#dayDetailTasks { display: flex; flex-direction: column; gap: 0; }

.detail-card {
  display: flex; align-items: stretch; gap: 0;
  border-bottom: 1px solid var(--border); background: var(--surface);
  transition: background 0.12s;
}
.detail-card:last-child { border-bottom: none; }
.detail-card:hover { background: var(--surface-2); }
.detail-color-bar { width: 4px; flex-shrink: 0; border-radius: 0; }
.detail-card-body { flex: 1; padding: 11px 14px; min-width: 0; }
.detail-card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.detail-card-title.done-title { text-decoration: line-through; color: var(--muted); }
.detail-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.detail-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.detail-badge.event-badge { color: #fff; border-color: transparent; }
.detail-stars { font-size: 11px; color: var(--star-color); letter-spacing: -1px; }
.detail-card-notes { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.4; font-style: italic; }
.detail-card-subs { font-size: 11px; color: var(--muted); margin-top: 4px; }
.detail-event-actions {
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  padding: 8px 10px 8px 4px; opacity: 0;
  transition: opacity 0.15s;
}
.detail-card:hover .detail-event-actions { opacity: 1; }
/* Study-plan card: slightly muted vs "due today" card */
.detail-card-study { opacity: 0.88; }
.detail-card-study .detail-card-title { color: var(--text-2); }
.detail-card-done { background: rgba(22, 163, 74, 0.06); }
[data-theme="dark"] .detail-card-done { background: rgba(22, 163, 74, 0.10); }
/* Section labels that separate "Due today" from "Study plan" in day detail */
.detail-section-label {
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 8px 14px 4px;
  border-bottom: 1px solid var(--border);
}
.detail-event-btn {
  background: none; border: none; cursor: pointer; font-size: 13px;
  padding: 3px 5px; border-radius: 5px; color: var(--muted);
  transition: background 0.12s, color 0.12s; line-height: 1;
}
.detail-event-btn:hover { background: var(--surface-3); color: var(--text); }
.detail-event-btn.danger:hover { background: #FEE2E2; color: #EF4444; }
[data-theme="dark"] .detail-event-btn.danger:hover { background: #3b1515; color: #f87171; }
.event-series-note {
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border-left: 3px solid #8B5CF6;
  border-radius: 6px;
  padding: 7px 10px;
  margin: 0 0 12px;
  line-height: 1.4;
}
.detail-done-check {
  width: 14px; height: 14px; border-radius: 4px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; margin: auto 12px auto 0;
}
.detail-empty { padding: 14px 16px; font-size: 13px; color: var(--muted); }

/* ══════════════════════════════
   PLAN VIEW
══════════════════════════════ */
.plan-view { height: calc(100vh - 84px); overflow-y: auto; padding: 20px; }
.plan-panel {
  max-width: 780px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.plan-top {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.plan-title-area h2 { font-size: 16px; font-weight: 800; color: var(--text); }
.plan-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.plan-sub-tabs { display: flex; gap: 4px; }
.plan-content { padding: 16px; display: flex; flex-direction: column; gap: 10px; }

/* Priority cards */
.priority-card {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 13px 15px;
  transition: box-shadow 0.15s, background 0.25s;
}
.priority-card:hover { box-shadow: var(--shadow); }

.priority-rank {
  font-size: 12px; font-weight: 800; color: var(--muted);
  min-width: 22px; text-align: right; padding-top: 2px; flex-shrink: 0;
}

.priority-badge {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; flex-shrink: 0; min-width: 52px;
}
.priority-emoji { font-size: 18px; line-height: 1; }
.priority-label {
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 6px; border-radius: 20px; color: #fff; white-space: nowrap;
}
.priority-label.priority-critical { background: #DC2626; }
.priority-label.priority-high     { background: #EA580C; }
.priority-label.priority-medium   { background: #CA8A04; }
.priority-label.priority-low      { background: #16A34A; }

.priority-body { flex: 1; min-width: 0; }
.priority-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; line-height: 1.4; }
.priority-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.priority-subject {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; color: #fff; white-space: nowrap;
}
.priority-due { font-size: 11px; color: var(--muted); }
.priority-due.overdue { color: #DC2626; font-weight: 700; }
.priority-due.soon    { color: #D97706; font-weight: 700; }
.priority-details { display: flex; align-items: center; gap: 10px; margin-top: 5px; flex-wrap: wrap; }
.priority-time  { font-size: 11px; color: var(--muted); }
.priority-stars { font-size: 12px; color: var(--star-color); letter-spacing: -1px; }

.priority-score {
  font-size: 20px; font-weight: 900; flex-shrink: 0;
  color: var(--muted); min-width: 40px; text-align: right; padding-top: 2px;
}

/* Plan empty state */
.plan-empty {
  text-align: center; color: var(--muted); font-size: 14px;
  padding: 48px 20px; line-height: 1.7;
}

/* Daily Schedule */
.schedule-header-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.schedule-settings-btn {
  background: none; border: 1px solid var(--border);
  border-radius: 7px; padding: 4px 10px;
  font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer;
  transition: background 0.15s;
}
.schedule-settings-btn:hover { background: var(--surface-2); color: var(--text); }

.schedule-day {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); overflow: hidden;
}
.schedule-day-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-3);
}
.schedule-day-header.is-today { background: var(--accent-light); border-color: var(--accent-border); }
.schedule-day-name { font-size: 13px; font-weight: 800; color: var(--text); }
.schedule-day-date { font-size: 11px; color: var(--muted); }
.schedule-day-header.is-today .schedule-day-name { color: var(--accent); }
.schedule-time-badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 8px; color: var(--muted);
}
.schedule-day-tasks { padding: 8px 14px; display: flex; flex-direction: column; gap: 6px; }
.schedule-task {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; border-left: 3px solid var(--subject-color, #ccc);
}
.schedule-task-name { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.schedule-task-meta { display: flex; align-items: center; gap: 6px; }
.schedule-task-subject {
  font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 20px; color: #fff;
}
.schedule-task-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
/* Multi-day tasks: a task too big for one day gets split into pieces. */
.schedule-task.is-multiday { border-left-style: dashed; }
.schedule-task-part {
  display: inline-block; margin-left: 7px; font-size: 10px; font-weight: 700;
  padding: 1px 7px; border-radius: 20px; vertical-align: middle;
  background: var(--subject-color, #888); color: #fff; opacity: 0.9;
}
.schedule-task-full { font-size: 11px; color: var(--muted); white-space: nowrap; font-style: italic; }
/* Events in the schedule get a slightly different look — more opaque/colorful */
.schedule-event {
  background: color-mix(in srgb, var(--subject-color, #ccc) 8%, var(--surface));
}
/* Divider between events and homework tasks */
.schedule-study-window {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 4px 2px;
  border-top: 1px dashed var(--border);
  margin-top: 2px;
}
.schedule-free { font-size: 12px; color: var(--muted); padding: 8px 10px; font-style: italic; }
.schedule-rest-day { font-size: 12px; color: var(--muted); padding: 8px 14px; font-style: italic; }

/* ── Stats (Dev Mode) ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; text-align: center;
}
.stat-value { font-size: 28px; font-weight: 900; color: var(--text); line-height: 1; }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }

.stats-section-title { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }

.stat-bar-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.stat-bar-row:last-child { border-bottom: none; }
.stat-bar-label { font-size: 12px; font-weight: 600; color: var(--text); min-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-bar-track { flex: 1; height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.stat-bar-fill.good { background: #22C55E; }
.stat-bar-fill.warn { background: #F59E0B; }
.stat-bar-fill.over { background: #EF4444; }
.stat-bar-value { font-size: 11px; color: var(--muted); font-weight: 600; min-width: 36px; text-align: right; }

.stats-no-data { font-size: 13px; color: var(--muted); padding: 12px 0; font-style: italic; }

/* ══════════════════════════════
   MODALS
══════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 480px;
  max-width: calc(100vw - 32px); max-height: calc(100vh - 60px);
  overflow-y: auto; padding: 24px;
  border: 1px solid var(--border);
  transition: background 0.25s, border-color 0.25s;
}
.modal-wide { width: 560px; }
.modal-sm   { width: 400px; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-header h3 { font-size: 17px; font-weight: 800; color: var(--text); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 17px; }
.modal-close:hover { color: var(--text); }
.modal-hint { font-size: 13px; color: var(--muted); margin-bottom: 16px; line-height: 1.5; }

/* Task Form */
.task-form { display: flex; flex-direction: column; gap: 13px; margin-top: 14px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.task-form label { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.task-form input:not([type="color"]),
.task-form select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--surface-2); color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.task-form input:not([type="color"]):focus,
.task-form select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }

.form-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 4px; }
.btn-cancel {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 16px;
  font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer;
  transition: background 0.15s;
}
.btn-cancel:hover { background: var(--surface-3); }
.btn-save {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 8px 18px;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: background 0.15s;
}
.btn-save:hover { background: var(--accent-hover); }

/* Star Rating */
.star-row { display: flex; align-items: center; gap: 3px; padding: 5px 0; }
.star-btn {
  background: none; border: none; cursor: pointer;
  font-size: 22px; color: var(--border); line-height: 1;
  transition: color 0.1s, transform 0.1s; padding: 0 1px;
}
.star-btn.active, .star-btn.hover { color: var(--star-color); }
.star-btn:hover { transform: scale(1.15); }
.star-hint { font-size: 11px; color: var(--muted); margin-left: 6px; }

/* Reflection */
.reflection-name {
  font-size: 14px; font-weight: 700; color: var(--accent);
  margin-bottom: 14px; line-height: 1.4;
}

/* Manage Classes */
.classes-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 20px; }
.class-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface-2);
  transition: background 0.15s;
}
.class-row:hover { background: var(--surface-3); }
.class-color-dot { width: 15px; height: 15px; border-radius: 50%; flex-shrink: 0; }
.class-name { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); }
.class-priority-stars { font-size: 12px; color: var(--star-color); letter-spacing: -1px; flex-shrink: 0; }
.class-day-badge { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 20px; color: #fff; letter-spacing: 0.3px; }
.class-day-badge.a { background: #6366F1; }
.class-day-badge.b { background: #059669; }
.class-task-count { font-size: 11px; color: var(--muted); white-space: nowrap; }
.class-actions { display: flex; gap: 4px; flex-shrink: 0; }
.btn-icon {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon.danger:hover { background: #FEE2E2; border-color: #EF4444; color: #EF4444; }
[data-theme="dark"] .btn-icon.danger:hover { background: #3b1515; border-color: #7f1d1d; color: #f87171; }

.class-edit-row {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 9px;
  border: 1px solid var(--accent); background: var(--accent-light);
  flex-wrap: wrap;
}
.class-edit-row input[type="text"],
.class-edit-row select {
  flex: 1; min-width: 80px;
  padding: 6px 9px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 13px;
  background: var(--surface); color: var(--text);
}
.class-edit-row input[type="text"]:focus,
.class-edit-row select:focus { outline: none; border-color: var(--accent); }
.class-edit-stars { display: flex; gap: 2px; align-items: center; flex-shrink: 0; }
.class-edit-star {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--border); line-height: 1;
  transition: color 0.1s; padding: 0;
}
.class-edit-star.active { color: var(--star-color); }

/* Manage Classes & Columns modal sections */
.manage-section { margin-bottom: 4px; }
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.columns-manage-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.column-manage-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 2px;
}
.col-edit-name {
  flex: 1; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; background: var(--surface-2); color: var(--text);
}
.col-edit-name:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.col-save-btn { padding: 5px 12px !important; font-size: 12px !important; }

.add-column-inline { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.add-column-inline input[type="text"] {
  flex: 1; min-width: 120px; padding: 7px 11px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--surface-2); color: var(--text);
}
.add-column-inline input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }

.add-class-form { padding-top: 16px; }
.add-class-form h4 { font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 9px; }
.add-class-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.add-class-row input[type="text"] {
  flex: 1; min-width: 120px; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--surface-2); color: var(--text);
}
.add-class-row input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.add-class-row select {
  padding: 8px 9px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text); cursor: pointer;
}
.color-picker {
  width: 38px; height: 36px; border: 1px solid var(--border);
  border-radius: 8px; padding: 3px; background: var(--surface-2);
  cursor: pointer; flex-shrink: 0;
}
.color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker::-webkit-color-swatch { border-radius: 5px; border: none; }

/* Settings Modal */
.settings-section { margin-bottom: 20px; }
.settings-heading { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.hours-grid { display: flex; flex-direction: column; gap: 6px; }
.hours-row { display: flex; align-items: center; gap: 12px; }
.hours-row label { font-size: 13px; color: var(--text-2); min-width: 90px; font-weight: 600; }
.hours-input {
  width: 80px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; background: var(--surface-2); color: var(--text);
  text-align: center;
}
.hours-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }

/* Toggle Switch */
.toggle-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text); }
.toggle-switch input { display: none; }
.toggle-track { width: 40px; height: 22px; background: var(--border); border-radius: 11px; position: relative; transition: background 0.2s; flex-shrink: 0; }
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb { width: 16px; height: 16px; background: #fff; border-radius: 50%; position: absolute; top: 3px; left: 3px; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }

/* Work Time Window (Settings) */
.settings-optional { font-size: 11px; font-weight: 600; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 2px 7px; border-radius: 20px; margin-left: 6px; vertical-align: middle; letter-spacing: 0.02em; }
.work-hours-grid { display: flex; flex-direction: column; gap: 8px; }
.work-hours-row { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.work-hours-day-label { font-size: 13px; font-weight: 600; color: var(--text-2); min-width: 30px; }
.work-hours-toggle-wrap { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.work-hours-toggle-wrap input { display: none; }
.work-hours-toggle-wrap input:checked + .toggle-track { background: var(--accent); }
.work-hours-toggle-wrap input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
.work-hours-times { display: flex; align-items: center; gap: 7px; }
.work-hours-times.hidden { display: none; }
.work-hours-sep { font-size: 12px; color: var(--muted); }
.work-start-input, .work-end-input {
  padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; background: var(--surface-2); color: var(--text);
  font-family: var(--font-family); cursor: pointer;
}
.work-start-input:focus, .work-end-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Add Event button (calendar header) ── */
.btn-add-event {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-add-event:hover { background: var(--surface-3); color: var(--text); }

/* ── Monthly calendar name chips ── */
.day-chips { display: flex; flex-direction: column; gap: 2px; }
.day-chip {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.5;
}
/* Study-day chip: dashed outline, no fill */
.day-chip-work {
  background: transparent;
  border: 1.5px dashed currentColor;
  line-height: 1.3;
  padding: 0 4px;
}
/* Study-day dot: outline instead of filled */
.day-dot-work {
  background: transparent;
  border: 2px dashed currentColor;
  box-sizing: border-box;
}
/* Completed task chip: strikethrough, faded */
.day-chip-done {
  opacity: 0.55;
  text-decoration: line-through;
}
/* Completed task dot: hollow circle */
.day-dot-done {
  background: transparent;
  border: 2px solid;
  box-sizing: border-box;
}

/* ── Weekly 4-column grid ── */
.weekly-table {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.weekly-header-row,
.weekly-row {
  display: grid;
  grid-template-columns: 90px 1fr 140px 130px;
}
.weekly-header-row {
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}
.weekly-row {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.weekly-row:last-child { border-bottom: none; }
.weekly-row.today { background: var(--accent-light); }
.weekly-th {
  padding: 7px 10px;
  font-size: 10px; font-weight: 800;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px;
  border-right: 1px solid var(--border);
}
.weekly-th:last-child { border-right: none; }
.weekly-day-cell {
  padding: 10px 12px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center;
}
.weekly-day-name { font-size: 13px; font-weight: 700; color: var(--text); }
.weekly-day-date { font-size: 10px; color: var(--muted); margin-top: 2px; }
.weekly-row.today .weekly-day-name { color: var(--accent); }
.weekly-data-cell {
  padding: 8px 10px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
  min-height: 52px;
}
.weekly-data-cell:last-child { border-right: none; }
.weekly-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--text); line-height: 1.3;
}
.weekly-item-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.weekly-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weekly-item-badge {
  font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 20px;
  color: #fff; white-space: nowrap; flex-shrink: 0;
}
.weekly-nothing { font-size: 11px; color: var(--muted); font-style: italic; }
/* Study-day rows in weekly view */
.weekly-item-work { opacity: 0.75; }
.weekly-item-dot-work { background: transparent; border: 2px dashed currentColor; box-sizing: border-box; }
.weekly-item-badge-work { background: transparent; border: 1.5px dashed currentColor; }
.weekly-item-done { opacity: 0.6; }
.weekly-item-done .weekly-item-name { text-decoration: line-through; }
.weekly-item-dot-done { background: transparent; border: 2px solid currentColor; box-sizing: border-box; }

/* ══════════════════════════════
   CUSTOMIZE PANEL
══════════════════════════════ */
.icon-btn.customize-active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent-border);
}

.customize-panel {
  position: fixed;
  right: 16px;
  top: 72px;
  width: 272px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}

.customize-panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.customize-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; padding: 2px 6px;
  border-radius: 5px; line-height: 1; font-family: inherit;
}
.customize-close:hover { background: var(--surface-2); color: var(--text); }

.customize-section {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.customize-section:last-child { border-bottom: none; }

.customize-section-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 9px;
}

/* Tabs */
.customize-tabs {
  display: flex; gap: 3px;
  background: var(--surface-2);
  padding: 3px; border-radius: 8px;
  margin-bottom: 10px;
}
.customize-tab {
  flex: 1; padding: 5px 6px;
  font-size: 11px; font-weight: 600;
  border: none; border-radius: 6px;
  background: transparent; color: var(--muted);
  cursor: pointer; font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.customize-tab.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
}

.customize-tab-body { display: flex; flex-direction: column; gap: 8px; }

/* Color */
.customize-color-row { display: flex; align-items: center; gap: 10px; }
.customize-color-input {
  width: 46px; height: 34px;
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; padding: 2px; background: none;
}
.customize-hint { font-size: 12px; color: var(--muted); }

/* Gradients */
.customize-gradient-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.gradient-swatch {
  height: 38px; border-radius: 8px; cursor: pointer;
  border: 2.5px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.gradient-swatch:hover { transform: scale(1.07); }
.gradient-swatch.active { border-color: var(--text); }

/* Image */
.customize-img-url {
  width: 100%; padding: 7px 10px; font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
.customize-img-url:focus { outline: none; border-color: var(--accent); }
.customize-or { font-size: 11px; color: var(--muted); text-align: center; }
.customize-upload-label {
  display: block; text-align: center;
  padding: 8px 10px;
  border: 1.5px dashed var(--border); border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.customize-upload-label:hover { background: var(--surface-2); color: var(--accent); border-color: var(--accent); }
.customize-upload-label input { display: none; }

.customize-reset {
  margin-top: 6px; font-size: 11px; font-weight: 600;
  color: var(--muted); background: none; border: none;
  cursor: pointer; padding: 0; font-family: inherit;
  text-align: left;
}
.customize-reset:hover { color: var(--text); text-decoration: underline; }

/* Font */
.customize-font-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.customize-font-pill {
  padding: 9px 6px; text-align: center;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.customize-font-pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.customize-font-pill.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }

/* Title editor */
.customize-title-row { display: flex; gap: 6px; align-items: center; }
.customize-emoji-input {
  width: 44px; text-align: center; font-size: 18px;
  padding: 6px 2px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-family: inherit;
}
.customize-emoji-input:focus { outline: none; border-color: var(--accent); }
.customize-title-input {
  flex: 1; padding: 7px 9px; font-size: 13px; font-weight: 700;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-family: inherit;
}
.customize-title-input:focus { outline: none; border-color: var(--accent); }

/* ══════════════════════════════
   LOGIN SCREEN
══════════════════════════════ */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  /* a column so Midnight's ledge can sit above the cards; the auto margins
     below keep everything centred but still let it scroll if space is tight */
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  overflow-y: auto;
  z-index: 300;
  /* the top third is Midnight's shelf, so the cards start below it */
  padding: 36vh 20px 20px;
  /* The page catches a little of the light coming through Midnight's window.
     Deliberately gentle — it's a wash over the theme's own background, not a
     new colour scheme, so TaskNest still looks like TaskNest in both themes.
     midnight.js stamps data-phase here as her weather changes. */
  background-image: radial-gradient(125% 78% at 50% 0%,
                    var(--sky-wash, transparent) 0%, transparent 62%);
  transition: background-image 0.6s ease;
}
.login-overlay[data-phase="rainy"]   { --sky-wash: rgba( 88,110,142, 0.34); }
.login-overlay[data-phase="sunny"]   { --sky-wash: rgba( 96,168,232, 0.32); }
.login-overlay[data-phase="evening"] { --sky-wash: rgba(214,124, 86, 0.30); }
.login-overlay[data-phase="night"]   { --sky-wash: rgba( 68, 72,132, 0.36); }

/* ══ Midnight's ledge scene (above the sign-in cards) ══════
   Art + roaming brain: midnight.js. The picture itself is purely decorative
   and has pointer-events off, so it can never swallow a tap meant for a
   sign-in button; only the little weather buttons below it are clickable. */
.midnight-scene { width: 100%; max-width: 400px; }
/* the copy inside the Settings panel — still a little framed picture */
#midnightSettingsScene { margin: 0 auto 18px; }

/* ── On the sign-in screen her room IS the page: no frame, no border, the
      ledge running the full width with the cards floating below it. ── */
.login-overlay .midnight-scene {
  position: fixed; inset: 0; max-width: none;
  z-index: 0; pointer-events: none;
  animation: view-fade-in 0.6s ease both;
}
.login-overlay .midnight-stage {
  position: absolute; inset: 0;
  border: none; border-radius: 0; box-shadow: none; overflow: hidden;
}
/* three classes deep on purpose: the boxed `.midnight-stage .midnight-room`
   rule below sets height:auto at equal specificity and would otherwise win on
   source order, leaving a gap at the foot of the page */
.login-overlay .midnight-stage .midnight-room { width: 100%; height: 100%; }
/* the cards sit in front of the room, in the dim part below the shelf */
.login-overlay > .welcome-card, .login-overlay > .login-card { position: relative; z-index: 1; }
.midnight-stage {
  position: relative;
  border-radius: 18px; overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  line-height: 0;
  pointer-events: none;
}
.midnight-stage svg { display: block; image-rendering: pixelated; shape-rendering: crispEdges; }
.midnight-stage .midnight-room { width: 100%; height: auto; }
/* she is 46 cells wide on a 300-cell scene (15.33%), standing on the ledge */
.midnight-stage .midnight-cat {
  position: absolute; width: 15.33%; height: auto;
  bottom: 12.5%; left: 50%; transform: translateX(-50%);
}
/* auto margins centre the card in the space under the shelf, and — unlike
   justify-content:center — degrade safely instead of clipping when it's tall */
.welcome-card, .login-card { margin: auto 0; }

/* ══ Midnight roaming the app (board / calendar / plan) ══════
   Just the cat, walking the empty parts of the page and going around anything
   you're reading or dragging. Her route is worked out in midnight.js.

   pointer-events:none is NOT optional. The board is drag-and-drop — if this
   stage could receive a click or a drag it would break moving task cards
   between columns. Nothing inside here may ever turn it back on. */
.midnight-roam-stage {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 6;                 /* above the page, below menus, modals and drags */
}
.midnight-roam-stage .midnight-cat {
  position: absolute;
  width: var(--mn-cat-w, 60px); height: auto;
  image-rendering: pixelated; shape-rendering: crispEdges;
  /* she fades in rather than blinking into existence on a view switch */
  animation: view-fade-in 0.5s ease both;
}
/* her leg cycle, driven by the same variable as her walking speed */
.midnight-roam-stage .pose-walk .walkA,
.midnight-roam-stage .pose-walk .walkB { animation-duration: var(--mn-cycle, 0.50s); }

/* she's a black cat — on the dark theme she needs a touch of separation */
[data-theme="dark"] .midnight-roam-stage .midnight-cat {
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.28));
}

/* reduced motion: she sits still, and never sets off at all (midnight.js) */
@media (prefers-reduced-motion: reduce) {
  .midnight-roam-stage .midnight-cat { animation: none; }
  .midnight-roam-stage .pose-walk .walkA,
  .midnight-roam-stage .pose-walk .walkB { animation: none; }
}

/* ── pick the weather ── */
.midnight-looks {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 5px; margin-top: 9px;
}
.midnight-look {
  font-family: inherit; font-size: 11px; font-weight: 500; line-height: 1;
  color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 10px; cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.midnight-look:hover { color: var(--text); border-color: var(--accent-border); }
/* fingers need more room than a mouse pointer */
@media (pointer: coarse) { .midnight-look { padding: 10px 13px; font-size: 11.5px; } }
.midnight-look[aria-pressed="true"] {
  color: #fff; background: var(--accent); border-color: var(--accent);
}

/* Her little animations. Walking flips between two drawings; the rest is
   slow breathing, drifting Zzz and stars twinkling out of step. */
/* 0.5s = 4 steps a second, which is the stride that matches her 15%/sec
   walking speed. Speed them up without speeding her up and she moonwalks. */
.pose-walk .walkA { animation: mn-frameA 0.50s steps(1) infinite; }
.pose-walk .walkB { animation: mn-frameB 0.50s steps(1) infinite; }
@keyframes mn-frameA { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
@keyframes mn-frameB { 0%,49% { opacity: 0; } 50%,100% { opacity: 1; } }
.pose-nap    { transform-origin: 50% 100%; animation: mn-breathe 3.4s ease-in-out infinite; }
.pose-lounge { transform-origin: 50% 100%; animation: mn-breathe 4.2s ease-in-out infinite; }
@keyframes mn-breathe { 0%,100% { transform: scaleY(1); } 50% { transform: scaleY(1.035); } }
.pet-z { animation: mn-z 3.4s ease-in-out infinite; }
@keyframes mn-z {
  0%   { opacity: 0; transform: translateY(2px); }
  35%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}
.twinkle-a { animation: mn-tw 3.6s ease-in-out infinite; }
.twinkle-b { animation: mn-tw 4.9s ease-in-out infinite 1.2s; }
.twinkle-c { animation: mn-tw 6.1s ease-in-out infinite 2.4s; }
@keyframes mn-tw { 0%,100% { opacity: 0.45; } 50% { opacity: 1; } }
/* Rain: each sheet slides down by exactly one pattern-repeat (12 grid rows)
   and starts over, so the loop is invisible. Near drops fall faster. */
.rain-a { animation: mn-rain 0.55s linear infinite; }
.rain-b { animation: mn-rain 0.95s linear infinite; }
@keyframes mn-rain { from { transform: translateY(0); } to { transform: translateY(12px); } }

/* Shorter screens: shrink her room, then tuck it away entirely so the
   sign-in buttons always have room. */
/* Landscape phones: there isn't room for both a room and a sign-in card, so
   the room steps aside and the card takes the whole screen back. */
@media (max-height: 520px) {
  .login-overlay .midnight-scene { display: none; }
  .login-overlay { padding: 20px; }
}
/* …and the same when Midnight is switched off in Settings */
.login-overlay.no-midnight .midnight-scene { display: none; }
.login-overlay.no-midnight { padding: 20px; background-image: none; }

/* the Settings panel dims its preview when she's switched off */
.midnight-onoff { margin-bottom: 14px; }
.midnight-off #midnightSettingsScene,
.midnight-off .midnight-looks { opacity: 0.4; }
@media (prefers-reduced-motion: reduce) {
  .midnight-scene, .midnight-scene * { animation: none !important; }
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px;
  text-align: center;
}

.login-logo { font-size: 48px; line-height: 1; }
.login-title {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.3px;
}
.login-subtitle { font-size: 14px; color: var(--muted); line-height: 1.6; max-width: 280px; }

/* ── Welcome screen (the elegant first page) ── */
.welcome-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 52px 40px;
  width: 100%; max-width: 400px;
  display: flex; flex-direction: column; align-items: center;
  gap: 18px;
  text-align: center;
  animation: welcome-in 0.5s ease both;
}
@keyframes welcome-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Welcome card gently drifts up and fades out on "Get Started" */
.welcome-card.leaving {
  animation: welcome-out 0.32s ease forwards;
}
@keyframes welcome-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-14px) scale(0.98); }
}
/* Sign-in card fades in after the welcome card leaves */
.login-card.entering {
  animation: welcome-in 0.42s ease both;
}
@media (prefers-reduced-motion: reduce) {
  .welcome-card, .welcome-card.leaving, .login-card.entering { animation: none; }
}

/* ── Reusable view entrances (login, boards, home) ── */
@keyframes view-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes view-rise-in {
  from { opacity: 0; transform: translateY(16px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.app-entering   { animation: view-fade-in 0.5s ease both; }
.board-entering { animation: view-rise-in 0.4s ease both; }
.home-entering  { animation: view-rise-in 0.38s ease both; }

/* Quick, light fade for switching Board / Calendar / Plan tabs */
@keyframes view-switch-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view-switching { animation: view-switch-in 0.28s ease both; }

@media (prefers-reduced-motion: reduce) {
  .app-entering, .board-entering, .home-entering, .view-switching { animation: none; }
}
.welcome-logo-icon {
  width: 76px; height: 76px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #A855F7, #EC4899);
  box-shadow: 0 8px 22px rgba(168, 85, 247, 0.35);
}
.welcome-title {
  font-family: 'Merriweather', Georgia, serif;
  font-size: 40px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.1;
  margin: 2px 0;
}
.welcome-tagline {
  font-size: 15px; color: var(--muted); line-height: 1.7; max-width: 300px;
  margin-bottom: 4px;
}
.btn-get-started {
  width: 100%; padding: 14px 16px;
  background: linear-gradient(135deg, #A855F7, #EC4899);
  color: #fff; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; letter-spacing: 0.2px;
  box-shadow: 0 6px 18px rgba(168, 85, 247, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn-get-started:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(168, 85, 247, 0.4);
  filter: brightness(1.05);
}
.btn-get-started:active { transform: translateY(0); }

.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--text);
  cursor: pointer; transition: background 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.btn-google:hover { background: var(--surface-2); box-shadow: var(--shadow-sm); }

.login-divider {
  width: 100%; display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--muted);
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.btn-show-email {
  width: 100%; padding: 11px 16px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 10px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.btn-show-email:hover { background: var(--accent-hover); }

.login-form {
  width: 100%; display: flex; flex-direction: column; gap: 9px;
  margin-top: 4px;
}
.login-form input {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; background: var(--surface-2); color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }

.btn-login-submit {
  width: 100%; padding: 11px;
  background: var(--accent); color: #fff; border: none;
  border-radius: 9px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background 0.15s;
}
.btn-login-submit:hover { background: var(--accent-hover); }

.btn-mode-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--accent); font-family: inherit;
  font-weight: 600; padding: 4px 0;
  transition: opacity 0.15s;
}
.btn-mode-toggle:hover { opacity: 0.75; text-decoration: underline; }

.login-error {
  color: #DC2626; background: #FEE2E2; border: 1px solid #FECACA;
  border-radius: 8px; padding: 9px 13px;
  font-size: 13px; font-weight: 500; width: 100%; text-align: left;
  line-height: 1.5;
}
[data-theme="dark"] .login-error { background: #3b1515; border-color: #7f1d1d; color: #f87171; }

.login-privacy {
  font-size: 11px; color: var(--muted); line-height: 1.5;
  max-width: 280px; text-align: center; margin-top: 4px;
}

/* ── Dark mode premium overrides ── */
[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(109,40,217,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 80% 80%, rgba(147,51,234,0.05) 0%, transparent 70%),
    var(--bg);
}
[data-theme="dark"] .header {
  background: rgba(27, 24, 21, 0.82);
  border-bottom-color: rgba(61,58,53,0.7);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 2px 12px rgba(0,0,0,0.40);
}
[data-theme="dark"] .status-line {
  background: rgba(27,24,21,0.55);
  border-bottom-color: rgba(61,58,53,0.5);
}

/* Light custom background — dark glass, dark text */
body[data-bg="light"] .status-line {
  background: rgba(255,255,255,0.78);
  border-bottom-color: rgba(0,0,0,0.10);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
body[data-bg="light"] .status-item { color: rgba(0,0,0,0.60); }
body[data-bg="light"] .status-item strong { color: rgba(0,0,0,0.82); }
body[data-bg="light"] .status-item.warn strong { color: #92400E; }
body[data-bg="light"] .status-dot { background: rgba(0,0,0,0.20); }

/* Dark custom background — dark glass, light text */
body[data-bg="dark"] .status-line {
  background: rgba(0,0,0,0.42);
  border-bottom-color: rgba(255,255,255,0.08);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
body[data-bg="dark"] .status-item { color: rgba(255,255,255,0.72); }
body[data-bg="dark"] .status-item strong { color: rgba(255,255,255,0.92); }
body[data-bg="dark"] .status-item.warn strong { color: #FCD34D; }
body[data-bg="dark"] .status-dot { background: rgba(255,255,255,0.25); }

/* Image background — stronger dark glass, white text */
body[data-bg="image"] .status-line {
  background: rgba(0,0,0,0.50);
  border-bottom-color: rgba(255,255,255,0.08);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
body[data-bg="image"] .status-item { color: rgba(255,255,255,0.80); }
body[data-bg="image"] .status-item strong { color: #fff; }
body[data-bg="image"] .status-item.warn strong { color: #FCD34D; }
body[data-bg="image"] .status-dot { background: rgba(255,255,255,0.30); }
[data-theme="dark"] .column-header {
  background: linear-gradient(to bottom, rgba(255,255,255,0.04), transparent);
}
[data-theme="dark"] .icon-btn {
  background: rgba(39,36,32,0.7);
}
[data-theme="dark"] .subject-group {
  border-color: rgba(61,58,53,0.6);
}

.sign-out-btn { color: var(--muted) !important; }

.btn-forgot {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--muted); font-family: inherit;
  padding: 2px 0; transition: color 0.15s;
}
.btn-forgot:hover { color: var(--text); text-decoration: underline; }

.forgot-msg {
  font-size: 12px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; width: 100%; text-align: left; line-height: 1.5;
}

/* ══════════════════════════════
   MOBILE  (≤ 640 px)
══════════════════════════════ */
@media (max-width: 640px) {

  /* On phones the header wraps to two rows, so its height isn't a fixed 52px.
     Lay the app out as a full-height flex column instead of hard-coding
     `100vh - 84px` — otherwise the page overflows and the status line (the
     "Good morning" bar) scrolls up out of sight after you move around. */
  #mainApp {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .status-line { flex: none; }
  .home-view,
  .board-view,
  .calendar-view,
  .plan-view {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }

  /* Header — two-row layout on mobile */
  .header {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px 0;
    gap: 4px;
    align-items: center;
  }
  .header-left  { order: 1; flex: 1; }
  .header-right { order: 2; margin-left: 0; }
  .header-divider { display: none; }

  /* Nav tabs: own row, scrollable sideways */
  .view-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 4px 0 10px;
  }
  .view-nav::-webkit-scrollbar { display: none; }
  .view-tab { flex-shrink: 0; }

  .icon-btn { padding: 5px 8px; font-size: 11px; }
  #openSettings, #openCustomize { display: none; }

  /* Board — allow horizontal scroll as before, just less padding */
  .board-view { padding: 0; }
  .board-column { width: 270px; }

  /* Calendar — stack panel + sidebar vertically */
  .calendar-view {
    flex-direction: column;
    padding: 10px;
    gap: 10px;
    height: auto;
    min-height: calc(100vh - 110px);
  }

  /* Hide the legend sidebar on mobile — not enough room */
  .cal-sidebar { display: none; }

  .cal-panel { width: 100%; }

  .cal-top {
    padding: 10px 12px;
    gap: 8px;
  }

  #calTitle { font-size: 13px; min-width: 120px; }

  /* Shrink the calendar grid cells */
  .calendar-grid { padding: 8px 6px; }
  .cal-weekdays { gap: 2px; }
  .cal-weekday  { font-size: 9px; letter-spacing: 0; padding: 2px 0; }
  .cal-days     { gap: 2px; }

  .cal-day {
    min-height: 52px;
    padding: 4px 3px;
    border-radius: 6px;
  }

  .day-num {
    width: 18px; height: 18px;
    font-size: 10px;
    margin-bottom: 2px;
  }

  .day-dot  { width: 5px; height: 5px; }
  .day-chip { font-size: 8px; padding: 1px 3px; }

  /* Weekly view on mobile */
  .weekly-header-row,
  .weekly-row { grid-template-columns: 70px 1fr; }
  .weekly-data-cell:nth-child(3),
  .weekly-data-cell:nth-child(4),
  .weekly-th:nth-child(3),
  .weekly-th:nth-child(4) { display: none; }

  /* Day detail panel */
  .day-detail { margin: 0 6px 10px; }

  /* Plan view */
  .plan-view { padding: 10px; }
  .plan-panel { max-width: 100%; }

  /* Modals — full width on mobile */
  .modal, .modal-wide, .modal-sm {
    width: calc(100vw - 24px);
    padding: 18px 16px;
  }

  /* Login card */
  .login-card { padding: 32px 20px; }
}

/* ══════════════════════════════════════════════════════════
   CANVAS TOOLBAR  (left-side vertical pill)
══════════════════════════════════════════════════════════ */
/* ── Tool Sidebar (replaces old toolbar pill) ─────────── */
.tool-sidebar {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  display: flex;
  flex-direction: row;
  align-items: center;
  user-select: none;
}
.tool-sidebar-toggle {
  width: 34px;
  height: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  box-shadow: var(--shadow);
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, border-radius 0.18s;
  font-family: inherit;
}
.tool-sidebar-toggle:hover { background: var(--surface-2); color: var(--accent); }
.tool-sidebar.open .tool-sidebar-toggle {
  border-radius: 10px 0 0 10px;
  border-right-color: transparent;
  box-shadow: none;
}
.tool-sidebar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 12px 12px 0;
  box-shadow: var(--shadow);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  max-width: 0;
  transition: max-width 0.22s ease, padding 0.22s ease;
}
.tool-sidebar.open .tool-sidebar-panel {
  max-width: 120px;
  padding: 5px 5px;
}
.tool-sidebar-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.tool-sidebar-item:hover { background: var(--surface-2); color: var(--text); }
.tool-sidebar-item.active { background: var(--accent-light); color: var(--accent); }
.tool-sidebar-item span { opacity: 0; transition: opacity 0.15s 0.05s; }
.tool-sidebar.open .tool-sidebar-item span { opacity: 1; }

/* ══════════════════════════════════════════════════════════
   STICKY NOTES
══════════════════════════════════════════════════════════ */
.sticky-note {
  position: absolute;
  width: 200px;
  min-height: 140px;
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: box-shadow 0.18s var(--ease);
}
.sticky-note:hover {
  box-shadow: var(--shadow-card-hover);
}
.sticky-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 7px 3px;
  opacity: 0.7;
  transition: opacity 0.15s;
  flex-shrink: 0;
  gap: 4px;
  cursor: grab;
  border-radius: 10px 10px 0 0;
}
.sticky-note-header:active { cursor: grabbing; }
.sticky-note:hover .sticky-note-header {
  opacity: 1;
  background: rgba(0,0,0,0.05);
}
.sticky-note-colors {
  display: flex;
  gap: 4px;
  align-items: center;
  flex: 1;
  justify-content: center;
}
.sticky-note-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  flex-shrink: 0;
}
.sticky-note-color-swatch:hover,
.sticky-note-color-swatch.active {
  transform: scale(1.3);
  border-color: rgba(0,0,0,0.28);
}
.sticky-note-delete {
  background: none;
  border: none;
  color: rgba(0,0,0,0.35);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 5px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.sticky-note-delete:hover {
  background: rgba(239,68,68,0.14);
  color: #EF4444;
}
.sticky-note-textarea {
  flex: none;
  width: 100%;
  min-height: 80px;
  padding: 4px 10px 10px;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  /* Always dark text — sticky note backgrounds are always light pastels */
  color: rgba(0, 0, 0, 0.75);
  line-height: 1.55;
  cursor: text;
  box-sizing: border-box;
  overflow: hidden;   /* grows instead of scrolling */
  height: auto;
}
.sticky-note-textarea::placeholder { color: rgba(0,0,0,0.3); }
/* Note backgrounds are always light pastels — keep all controls dark regardless of theme */

/* ── Fold / collapse toggle ─────────────────────────────── */
.sticky-note-fold {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(0,0,0,0.38);
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.sticky-note-fold:hover {
  background: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.65);
}
.sticky-note-fold svg {
  transition: transform 0.2s;
}
/* When folded: chevron flips up, header stays visible, body hides */
.sticky-note.folded .sticky-note-fold svg {
  transform: rotate(180deg);
}
.sticky-note.folded { min-height: auto; }
.sticky-note.folded .sticky-note-textarea { display: none; }
.sticky-note.folded .sticky-note-header { opacity: 1; }

/* ══════════════════════════════════════════════════════════
   CONNECTION LINES (SVG overlay)
══════════════════════════════════════════════════════════ */
#connectionsSvg {
  position: absolute;
  top: 0;
  left: 0;
  width: 4000px;
  height: 4000px;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}
#connectionsSvg .connection-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2px;
  stroke-opacity: 0.75;
  pointer-events: stroke;
  cursor: pointer;
  transition: stroke-opacity 0.15s, stroke-width 0.15s;
}
#connectionsSvg .connection-line:hover {
  stroke-opacity: 1;
  stroke-width: 3px;
}
#connectionsSvg .connection-line.selected {
  stroke: #DC2626;
  stroke-opacity: 1;
  stroke-width: 3px;
  stroke-dasharray: 6 3;
}
#connectionsSvg .preview-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2px;
  stroke-opacity: 0.4;
  stroke-dasharray: 6 4;
  pointer-events: none;
}
/* Board cursor changes in connect mode */
.board-view.connect-mode-active {
  cursor: crosshair;
}
/* Dashed outline on all connectable elements in connect mode */
.connect-mode-active .board-column,
.connect-mode-active .sticky-note,
.connect-mode-active .canvas-table,
.connect-mode-active .floating-task,
.connect-mode-active .floating-subject {
  cursor: crosshair;
  outline: 1.5px dashed rgba(109,40,217,0.4);
  outline-offset: 3px;
}
/* Solid purple ring on the element being dragged from */
.connect-source-highlight {
  outline: 2.5px solid var(--accent) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 4px rgba(109,40,217,0.12) !important;
}
/* Green ring on a valid drop target while hovering over it */
.connect-drop-highlight {
  outline: 2.5px solid #059669 !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 4px rgba(5,150,105,0.12) !important;
}

/* ══════════════════════════════════════════════════════════
   FLOATING TASKS
══════════════════════════════════════════════════════════ */
.floating-task {
  position: absolute;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: box-shadow 0.18s var(--ease);
}
.floating-task:hover { box-shadow: var(--shadow-card-hover); }
.floating-task-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 5px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.floating-task-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.floating-task-body { padding: 0; }
.floating-task-body .kanban-card { border-radius: 0 0 10px 10px; border-bottom: none; }
.floating-task-unpin {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 5px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.floating-task-unpin:hover { background: var(--surface-3); color: var(--text); }

/* ══════════════════════════════════════════════════════════
   FLOATING SUBJECTS
══════════════════════════════════════════════════════════ */
.floating-subject {
  position: absolute;
  width: 310px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--subject-color, var(--accent));
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: box-shadow 0.18s var(--ease);
}
.floating-subject:hover { box-shadow: var(--shadow-card-hover); }
.floating-subject-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px 7px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.floating-subject-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--subject-color, var(--accent));
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.floating-subject-unpin {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 5px;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.floating-subject-unpin:hover { background: var(--surface-3); color: var(--text); }
.floating-subject-body {
  padding: 4px 0 4px;
  display: flex;
  flex-direction: column;
}
.floating-subject-body .kanban-card:last-child { border-radius: 0 0 10px 10px; }
.floating-subject-empty {
  padding: 10px 13px;
  font-size: 12px;
  color: var(--muted);
}

/* Shared floating drag handle */
.floating-drag-handle {
  color: var(--muted);
  cursor: grab;
  padding: 2px 4px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}
.floating-drag-handle:hover { background: var(--surface-3); color: var(--text); }
.floating-drag-handle:active { cursor: grabbing; }

/* Drop-target highlight when dragging a floating item over a column */
.board-column.drop-target-highlight {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
  background: color-mix(in srgb, var(--accent) 5%, var(--col-bg));
}
/* Ghost appearance while dragging */
.floating-dragging {
  opacity: 0.72;
  box-shadow: var(--shadow-lg) !important;
  z-index: 9999 !important;
}

/* ══════════════════════════════════════════════════════════
   DRAG-OUT HANDLES on task cards and subject headers
══════════════════════════════════════════════════════════ */
/* card-float-handle and subject-float-handle removed — drag-out is now
   a natural gesture: slide the card/class sideways out of the column */

/* ══════════════════════════════════════════════════════════
   MULTI-BOARD HOME SCREEN
══════════════════════════════════════════════════════════ */
.home-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px 64px;
  min-height: calc(100vh - 52px);
  background: var(--bg);
  overflow-y: auto;
}
/* `margin: auto` is the safe way to centre a flex child both ways — with
   `align-items: center` alone a tall list would get clipped off the top. */
.home-content {
  max-width: 860px;
  width: 100%;
  margin: auto;
  text-align: center;
}
.home-greeting-emoji { margin-right: 5px; }
.home-greeting {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  letter-spacing: 0.2px;
}
.home-title {
  font-size: 30px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 7px;
  letter-spacing: -0.6px;
}
.home-subtitle {
  font-size: 14.5px;
  color: var(--muted);
  margin-bottom: 30px;
  line-height: 1.4;
}
/* Flex (not grid) so a half-full last row stays centred instead of
   left-aligning against empty phantom columns. */
.home-boards-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-bottom: 28px;
}

/* Individual board card */
.home-board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: box-shadow 0.18s var(--ease), transform 0.15s var(--ease), border-color 0.15s;
  position: relative;
  user-select: none;
  min-height: 120px;
  /* Fixed-ish width (rather than 1fr) keeps a lone board card the same size
     as a full row, and lets it shrink to fit two-up on a phone. */
  flex: 0 1 168px;
  max-width: 200px;
}
.home-board-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-3px);
  border-color: var(--accent-border);
}
.home-board-card:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}
.home-board-emoji {
  font-size: 44px;
  line-height: 1;
  display: block;
}
.home-board-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  word-break: break-word;
  line-height: 1.3;
}

/* How much is waiting on this board. Starts empty and fills in when the
   counts arrive, so it must not reserve space it might not use — hence
   min-height rather than a fixed line. */
.home-board-stat {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  min-height: 14px;
  line-height: 1.2;
}
.home-board-stat.overdue { color: #DC2626; }
.home-board-stat.soon    { color: #D97706; }
.home-board-stat.clear   { color: #16a34a; }
.home-board-stat.quiet   { color: var(--muted); opacity: 0.7; font-weight: 500; }
[data-theme="dark"] .home-board-stat.overdue { color: #f87171; }
[data-theme="dark"] .home-board-stat.soon    { color: #fbbf24; }
[data-theme="dark"] .home-board-stat.clear   { color: #4ade80; }

/* Optional per-board colour, picked in the ✏️ panel. The plain `background`
   line below is the fallback for browsers without color-mix — they get the
   normal card rather than a broken one. */
.home-board-card.tinted {
  background: var(--surface);
  background: color-mix(in srgb, var(--board-color) 9%, var(--surface));
  border-color: var(--border);
  border-color: color-mix(in srgb, var(--board-color) 30%, var(--border));
}
.home-board-card.tinted:hover {
  border-color: color-mix(in srgb, var(--board-color) 55%, var(--border));
}
/* The emoji sits on a soft disc of the board's colour. */
.home-board-card.tinted .home-board-emoji {
  border-radius: 50%;
  padding: 5px;
  background: color-mix(in srgb, var(--board-color) 16%, transparent);
}

/* Action buttons (appear on hover) */
.home-board-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.home-board-card:hover .home-board-actions { opacity: 1; }
.home-board-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1;
  transition: background 0.12s;
}
.home-board-action-btn:hover { background: var(--surface-2); }

/* New board button */
.btn-new-board {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1.5px dashed var(--accent-border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
  font-family: inherit;
}
.btn-new-board:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.btn-new-board:active { transform: none; }

/* ── Edit Board panel: colour swatches ── */
.board-color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 4px;
}
.board-color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--border) inset;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s var(--ease), box-shadow 0.12s;
}
.board-color-swatch:hover { transform: scale(1.12); }
.board-color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface) inset;
}
/* "No colour" — a plain swatch with a diagonal line through it. */
.board-color-swatch.none {
  background:
    linear-gradient(to top right,
      transparent calc(50% - 1px), var(--muted) calc(50% - 1px),
      var(--muted) calc(50% + 1px), transparent calc(50% + 1px)),
    var(--surface-2);
}
/* Keep the emoji field just wide enough for an icon or two. */
.board-edit-icon { flex: 0 0 74px; }
.board-edit-icon input { text-align: center; font-size: 18px; }

/* Home screen on phones — tighten up so two board cards still fit side by
   side. Flexbox wraps to a new line *before* it shrinks an item, so the card
   width has to come down here or you'd get one lonely card per row.
   NOTE: this block has to live *after* the base rules above, not up in the
   main 640px media query, or the later base rules would win. */
@media (max-width: 640px) {
  .home-view { padding: 32px 20px 48px; }
  .home-title { font-size: 25px; }
  .home-subtitle { font-size: 13.5px; margin-bottom: 24px; }
  .home-boards-grid { gap: 14px; }
  .home-board-card {
    flex-basis: 150px;
    min-height: 112px;
    padding: 18px 12px 15px;
  }
  .home-board-emoji { font-size: 38px; }
}

/* ── Leave Board button + board name in header ────────── */
.leave-board-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  font-family: inherit;
  flex-shrink: 0;
}
.leave-board-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent-border);
}
.leave-board-btn.hidden { display: none; }

.current-board-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  flex-shrink: 1;
}
.current-board-name.hidden { display: none; }

/* ── Empty-board template picker ───────────────────────── */
.board-empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 32px 20px;
  pointer-events: none; /* let canvas pan through the background */
}
.board-empty-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  text-align: center;
  letter-spacing: -0.3px;
}
.board-empty-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  text-align: center;
  max-width: 340px;
  line-height: 1.5;
}
.board-empty-templates {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  pointer-events: all;
}
.board-empty-tpl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 120px;
  padding: 20px 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  font-family: inherit;
}
.board-empty-tpl:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-3px);
}
.board-empty-tpl:active { transform: translateY(-1px); }
.tpl-icon { font-size: 32px; line-height: 1; display: block; }
.tpl-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}
.tpl-desc {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

/* ── Canvas Tables ─────────────────────────────────────── */
.canvas-table {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  z-index: 10;
  min-width: 200px;
  overflow: hidden;
}
.canvas-table-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.canvas-table-drag {
  cursor: grab;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0 2px;
  flex-shrink: 0;
}
.canvas-table-drag:active { cursor: grabbing; }
.canvas-table-label {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.canvas-table-fold,
.canvas-table-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}
.canvas-table-fold:hover,
.canvas-table-delete:hover { background: var(--surface-3); color: var(--text); }
.canvas-table-fold svg { transition: transform 0.2s; }
.canvas-table.folded .canvas-table-fold svg { transform: rotate(180deg); }
.canvas-table-grid {
  display: grid;
  border-top: 0;
}
.canvas-table.folded .canvas-table-grid,
.canvas-table.folded .canvas-table-add-row,
.canvas-table.folded .canvas-table-footer { display: none; }
.canvas-table-cell {
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 4px 7px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  min-width: 80px;
  min-height: 28px;
}
.canvas-table-cell:focus {
  background: var(--accent-light);
  box-shadow: inset 0 0 0 1.5px var(--accent-border);
}
.canvas-table-footer {
  display: flex;
  gap: 4px;
  padding: 4px 6px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.canvas-table-add-row,
.canvas-table-add-col {
  background: none;
  border: 1px dashed var(--border);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 8px;
  font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.canvas-table-add-row:hover,
.canvas-table-add-col:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent-border);
}

/* ── Canvas Images ─────────────────────────────────────── */
.canvas-image {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  z-index: 10;
  overflow: hidden;
  min-width: 120px;
  min-height: 80px;
}
.canvas-image-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transition: opacity 0.15s;
}
.canvas-image:hover .canvas-image-header { opacity: 1; }
.canvas-image-drag {
  cursor: grab;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0 2px;
}
.canvas-image-drag:active { cursor: grabbing; }
.canvas-image-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}
.canvas-image-delete:hover { background: #FEE2E2; color: #DC2626; }
.canvas-image-img {
  display: block;
  max-width: 320px;
  max-height: 240px;
  width: 100%;
  height: auto;
  object-fit: contain;
  background: var(--surface-3);
}

/* ══ Entry page (logged-out visitors) ══════════════════════
   The old welcome card grew into a scrolling page: a top bar, the welcome
   card under Midnight's shelf, then sections that slide up OVER her room
   (they have a solid background) and a footer with the legal links.
   `.landing-mode` is on the overlay whenever this page is showing; app.js
   takes it off for the sign-in card, which keeps the old centred layout. */
.login-overlay.landing-mode { padding: 0; display: block; }
.login-overlay > .landing { position: relative; z-index: 1; width: 100%; }
.landing.leaving { animation: welcome-out 0.32s ease forwards; }

.landing-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px max(20px, calc((100% - 1040px) / 2));
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.landing-bar-logo {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  font-family: 'Merriweather', Georgia, serif; font-size: 18px; font-weight: 700;
}
.landing-bar-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #A855F7, #EC4899);
}
.btn-landing-login {
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  color: var(--accent); background: var(--surface);
  border: 1.5px solid var(--accent-border); border-radius: 999px;
  padding: 9px 18px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-landing-login:hover { background: var(--accent); color: #fff; }

/* Welcome: headline + buttons on the left, the board picture on the right.
   Midnight's big room isn't used here — it stays for the sign-in card. */
.login-overlay.landing-mode .midnight-scene { display: none; }
.login-overlay.landing-mode { background-image: none; }
.landing-hero {
  min-height: calc(100vh - 54px);
  max-width: 1080px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center; gap: clamp(28px, 5vw, 64px);
  padding: 48px 24px 64px;
}
.landing-h1 {
  font-family: 'Merriweather', Georgia, serif;
  font-size: clamp(38px, 5.4vw, 58px); line-height: 1.08; letter-spacing: -1px;
  color: var(--text); margin-bottom: 18px;
}
.landing-h1 em { font-style: italic; color: var(--accent); }
.landing-hero-sub { font-size: 17px; line-height: 1.7; color: var(--muted); max-width: 440px; margin-bottom: 58px; }
.landing-cta-wrap { position: relative; display: inline-block; }
.btn-text-link {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 14px; color: var(--muted);
}
.btn-text-link:hover { color: var(--accent); text-decoration: underline; }
.landing-hero-btn { width: auto; padding: 15px 30px; font-size: 15.5px; }
.landing-hero-login { display: block; margin-top: 14px; padding: 0; }

/* Midnight perched on the button's top edge, tail hanging over */
/* her paws are drawn on row 46 of 50, so the box sits 8% below the button's
   top edge to put her right ON it — lying along the top, not hovering */
.button-cat {
  position: absolute; right: 14px; bottom: calc(100% - 5.6px);
  width: 64px; height: 70px; pointer-events: none; z-index: 1;
}
.button-cat-pose {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated; shape-rendering: crispEdges;
  opacity: 0; transition: opacity 0.25s;
}
.button-cat-pose.on { opacity: 1; }
[data-theme="dark"] .button-cat-pose { filter: drop-shadow(0 0 2px rgba(255,255,255,0.3)); }

/* the little board picture */
.board-preview {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 0 0 16px; overflow: hidden; text-align: left;
  transform: rotate(1.2deg);
}
.bp-chrome {
  display: flex; align-items: center; gap: 6px;
  padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.bp-chrome span { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.bp-chrome b { margin-left: 8px; font-size: 13px; font-weight: 700; color: var(--text); }
.bp-tabs { display: flex; gap: 6px; padding: 12px 14px 4px; }
.bp-tabs span { font-size: 12px; font-weight: 600; color: var(--muted); padding: 5px 11px; border-radius: 999px; }
.bp-tabs .on { background: var(--accent-light); color: var(--accent); }
.bp-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 10px 14px 0; }
.bp-head {
  font-size: 12.5px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 6px; margin-bottom: 9px;
}
.bp-head::before { content: ''; width: 8px; height: 8px; border-radius: 3px; background: var(--c); }
.bp-card {
  background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--c);
  border-radius: 0 9px 9px 0; padding: 9px 10px; margin-bottom: 8px;
  display: flex; flex-wrap: wrap; gap: 5px;
}
.bp-card p { width: 100%; font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.35; }
.bp-due, .bp-check, .bp-part {
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 7px;
}
.bp-soon { color: #B45309; border-color: #FCD34D; }
[data-theme="dark"] .bp-soon { color: #FCD34D; border-color: #92400E; }
.bp-part { color: var(--accent); border-color: var(--accent-border); }
.bp-done { opacity: 0.55; }
.bp-done p { text-decoration: line-through; }
.bp-note {
  font-size: 12px; font-weight: 600; color: #713F12; background: #FEF08A;
  padding: 10px; border-radius: 3px; transform: rotate(-3deg); margin-top: 4px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

@media (max-width: 860px) {
  .landing-hero { grid-template-columns: 1fr; min-height: 0; padding-top: 40px; text-align: center; }
  .landing-hero-sub { margin-left: auto; margin-right: auto; }
  .landing-hero-login { margin-left: auto; margin-right: auto; }
  .board-preview { transform: none; }
}
@media (max-width: 480px) {
  .bp-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bp-col:nth-child(3) { display: none; }
}

/* sections: solid backgrounds, so they cover Midnight's room as you scroll */
.landing-section { background: var(--bg); padding: 72px 20px; }
.landing-section-alt { background: var(--surface-2, var(--surface)); }
.landing-inner { max-width: 1000px; margin: 0 auto; text-align: center; }
.landing-eyebrow {
  font-size: 12.5px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.landing-h2 {
  font-family: 'Merriweather', Georgia, serif;
  font-size: clamp(24px, 4vw, 34px); line-height: 1.25; color: var(--text);
  margin-bottom: 14px;
}
.landing-lead {
  font-size: 16px; line-height: 1.75; color: var(--muted);
  max-width: 640px; margin: 0 auto;
}
.landing-goals, .landing-features {
  display: grid; gap: 18px; margin-top: 40px; text-align: left;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.landing-goal, .landing-feature {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; box-shadow: var(--shadow-sm);
}
.landing-goal h3, .landing-feature h3 { font-size: 16.5px; color: var(--text); margin: 10px 0 6px; }
.landing-goal p, .landing-feature p { font-size: 14px; line-height: 1.6; color: var(--muted); }
.landing-goal-num {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; background: linear-gradient(135deg, #A855F7, #EC4899);
}
.landing-feature-icon { display: block; color: var(--text); line-height: 0; }
.pixel-icon { width: 40px; height: 40px; image-rendering: pixelated; shape-rendering: crispEdges; }

/* the maker's story: a note pinned to the page, not another grey box */
.landing-story {
  max-width: 620px; margin: 30px auto 0; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent); border-radius: 0 14px 14px 0;
  padding: 26px 30px; transform: rotate(-0.6deg);
  box-shadow: var(--shadow-sm);
}
.landing-story p { font-size: 16px; line-height: 1.8; color: var(--text); margin-bottom: 14px; }
.landing-story-sign {
  font-family: 'Merriweather', Georgia, serif; font-style: italic;
  color: var(--muted) !important; margin: 4px 0 0 !important;
}

.landing-midnight-inner {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px; align-items: center; text-align: left;
}
.landing-midnight-inner .landing-lead { margin: 0; }
.landing-midnight-scene { width: 100%; max-width: 440px; justify-self: center; }
/* this copy of her is the boxed picture, not the full-page room, so undo the
   room's "fill the whole screen" rules that also match inside the overlay */
.login-overlay .landing-midnight-scene .midnight-stage {
  position: relative; inset: auto;
  border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
.login-overlay .landing-midnight-scene .midnight-stage .midnight-room { height: auto; }
.login-overlay.no-midnight .landing-midnight { display: none; }
@media (max-width: 760px) {
  .landing-midnight-inner { grid-template-columns: 1fr; text-align: center; gap: 24px; }
}

.landing-cta { padding-bottom: 88px; }
.landing-cta-btn { width: auto; padding: 14px 32px; margin-top: 26px; }

/* footer — the same look is used on the legal pages (legal.css) */
.site-footer {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 32px 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.site-footer-logo { font-family: 'Merriweather', Georgia, serif; font-size: 18px; font-weight: 700; }
.site-footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; }
.site-footer-links a { font-size: 14px; color: var(--muted); text-decoration: none; }
.site-footer-links a:hover { color: var(--accent); text-decoration: underline; }
.site-footer-copy { font-size: 12.5px; color: var(--muted); }
.site-footer-help { font-size: 14px; color: var(--muted); }
.site-footer-help a { color: var(--accent); }
mark.todo { background: #FDE68A; color: #713F12; padding: 1px 5px; border-radius: 4px; font-weight: 700; }

/* the sign-in card's way back to the entry page */
.btn-login-back {
  position: absolute; top: 14px; left: 14px;
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 6px 8px; border-radius: 8px;
}
.btn-login-back:hover { color: var(--accent); background: var(--surface-2, transparent); }

/* ══ Loading skeleton ══════════════════════════════════════
   While body.booting is on, ONLY the skeleton shows — no flash of the entry
   page for someone who's actually signed in. data-boot picks its shape. */
.boot-skeleton { display: none; }
body.booting .boot-skeleton {
  display: block; position: fixed; inset: 0; z-index: 2; background: var(--bg);
}
body.booting .landing,
body.booting .login-card,
body.booting .midnight-scene { visibility: hidden; }
.sk-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px max(20px, calc((100% - 1040px) / 2));
}
.sk-page, .sk-board { display: none; }
body[data-boot="page"]  .sk-page  { display: flex; }
body[data-boot="board"] .sk-board { display: flex; }
.sk-page {
  flex-direction: column; align-items: center; gap: 14px;
  width: calc(100% - 40px); max-width: 400px; margin: 30vh auto 0;
  padding: 44px 36px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--border);
}
.sk-board { gap: 18px; padding: 28px 20px; overflow: hidden; }
.sk-col { flex: 0 0 260px; display: flex; flex-direction: column; gap: 12px; }
.sk {
  display: block; border-radius: 10px;
  background: linear-gradient(90deg, var(--border) 25%,
              color-mix(in srgb, var(--border) 45%, var(--surface)) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.3s ease-in-out infinite;
}
.sk-logo  { width: 120px; height: 24px; }
.sk-pill  { width: 76px; height: 34px; border-radius: 999px; }
.sk-icon  { width: 76px; height: 76px; border-radius: 20px; }
.sk-title { width: 70%; height: 32px; }
.sk-line  { width: 90%; height: 14px; }
.sk-line.short { width: 60%; }
.sk-button { width: 100%; height: 48px; border-radius: 12px; margin-top: 6px; }
.sk-col-head { height: 22px; width: 55%; }
.sk-card  { height: 74px; border-radius: 12px; }
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* screen-reader-only text (e.g. "Loading TaskNest…") */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .sk, .landing.leaving { animation: none; }
}

/* ── Password strength meter (create account only) ── */
.pw-meter { width: 100%; margin-top: -2px; text-align: left; }
.pw-meter-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.pw-meter-bar span { height: 5px; border-radius: 3px; background: var(--border); transition: background 0.2s; }
.pw-meter-text { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.pw-meter[data-level="1"] .pw-meter-bar span:nth-child(-n+1) { background: #EF4444; }
.pw-meter[data-level="2"] .pw-meter-bar span:nth-child(-n+2) { background: #F59E0B; }
.pw-meter[data-level="3"] .pw-meter-bar span { background: #22C55E; }
.pw-meter[data-level="1"] .pw-meter-text { color: #DC2626; }
.pw-meter[data-level="3"] .pw-meter-text { color: #16A34A; }
[data-theme="dark"] .pw-meter[data-level="1"] .pw-meter-text { color: #F87171; }
[data-theme="dark"] .pw-meter[data-level="3"] .pw-meter-text { color: #4ADE80; }

/* ── Suggest a feature ── */
.task-form textarea {
  width: 100%; font-family: inherit; font-size: 14px; line-height: 1.5;
  padding: 10px 12px; border-radius: 10px; resize: vertical;
  background: var(--surface); color: var(--text); border: 1.5px solid var(--border);
}
.task-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.suggest-count { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: 4px; }
.task-form .suggest-intro { margin: 0; }
/* the reply opt-in box. Selectors start with .task-form on purpose: the
   form's own rules make every input full-width and every label tiny
   ALL-CAPS, which squashed this checkbox into an unreadable bar */
.suggest-optin {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.task-form .suggest-email-opt {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text);
  text-transform: none; letter-spacing: normal;
}
.task-form .suggest-email-opt input[type="checkbox"] {
  width: 18px; height: 18px; padding: 0; margin: 1px 0 0; flex: none;
  border: none; box-shadow: none; accent-color: var(--accent);
}
.suggest-optin-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.suggest-email { font-size: 12.5px; font-weight: 500; color: var(--muted); word-break: break-all; }
.suggest-privacy {
  font-size: 12.5px; line-height: 1.5; color: var(--muted);
  margin: 8px 0 0 28px;   /* lines up with the text, not the checkbox */
}
.suggest-privacy a { color: var(--accent); }
.suggest-msg { font-size: 14px; font-weight: 600; color: #DC2626; margin-bottom: 10px; }
.suggest-msg.ok { color: #16A34A; }
[data-theme="dark"] .suggest-msg { color: #F87171; }
[data-theme="dark"] .suggest-msg.ok { color: #4ADE80; }

/* ── Sign-up agreement checkboxes ── */
.signup-checks { display: flex; flex-direction: column; gap: 9px; text-align: left; margin: 2px 0 4px; }
.signup-check { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: var(--text); cursor: pointer; }
.signup-check input { margin-top: 2px; width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.signup-check a, .login-privacy a { color: var(--accent); }

/* ── One-time Privacy/Terms notice (floats at the bottom, never moves the board) ── */
.legal-notice {
  /* centered with auto margins, not transform — the rise-in animation uses transform */
  position: fixed; left: 0; right: 0; bottom: 20px; margin: 0 auto;
  z-index: 400; width: min(560px, calc(100% - 32px));
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--accent-border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 12px 14px 12px 16px;
  animation: view-rise-in 0.35s ease both;
}
.legal-notice-icon { font-size: 22px; flex: none; }
.legal-notice p { flex: 1; font-size: 14px; line-height: 1.45; margin: 0; }
.legal-notice a { color: var(--accent); font-weight: 600; }
.legal-notice-btn {
  flex: none; font-family: inherit; font-size: 13.5px; font-weight: 700;
  color: #fff; background: var(--accent); border: none; border-radius: 9px;
  padding: 8px 14px; cursor: pointer;
}
.legal-notice-btn:hover { background: var(--accent-hover); }
@media (prefers-reduced-motion: reduce) { .legal-notice { animation: none; } }

/* ── Change password panel (Settings → Password) ── */
#pwChangeForm .pw-meter { margin-top: 6px; }
#pwChangeForm .btn-forgot { align-self: flex-start; text-align: left; }
.pw-change-msg {
  font-size: 13px; line-height: 1.5; padding: 9px 12px; border-radius: 8px;
  color: #B91C1C; background: rgba(239,68,68,0.10); border: 1px solid rgba(239,68,68,0.25);
}
.pw-change-msg.ok { color: #15803D; background: rgba(34,197,94,0.10); border-color: rgba(34,197,94,0.30); }
[data-theme="dark"] .pw-change-msg    { color: #FCA5A5; }
[data-theme="dark"] .pw-change-msg.ok { color: #86EFAC; }
