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

  :root {
    --bg: #f5f4f0;
    --surface: #ffffff;
    --surface2: #f1efe9;
    --surface3: #e8e6e0;
    --border: rgba(0,0,0,0.1);
    --border2: rgba(0,0,0,0.18);
    --text1: #1a1a18;
    --text2: #5a5955;
    --text3: #9a9890;
    --radius: 8px;
    --radius-lg: 12px;
    --purple: #534AB7;
    --purple-bg: #EEEDFE;
    --purple-mid: #AFA9EC;
    --teal: #1D9E75;
    --teal-bg: #E1F5EE;
    --coral: #D85A30;
    --amber: #BA7517;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #1c1c1a;
      --surface: #252522;
      --surface2: #2e2e2b;
      --surface3: #3a3a36;
      --border: rgba(255,255,255,0.1);
      --border2: rgba(255,255,255,0.18);
      --text1: #f0efea;
      --text2: #a8a69e;
      --text3: #6a6860;
      --purple-bg: #26215C;
      --teal-bg: #04342C;
    }
  }

  html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text1); font-size: 14px; }

  .app { display: flex; height: 100vh; overflow: hidden; }

  /* ── Sidebar ── */
  .sidebar {
    width: 270px; min-width: 270px;
    background: var(--surface);
    border-right: 0.5px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
  }

  .sidebar-top {
    padding: 16px 14px 12px;
    border-bottom: 0.5px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    height: 57px; box-sizing: border-box;
  }

  .app-name {
    font-size: 15px; font-weight: 500; color: var(--text1);
    display: flex; align-items: center; gap: 8px;
  }
  .app-name i { color: var(--purple); font-size: 18px; }

  .section-label {
    font-size: 10px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--text3); padding: 12px 14px 6px;
    display: flex; align-items: center; justify-content: space-between;
  }
  .section-label button {
    background: none; border: none; cursor: pointer;
    color: var(--text3); font-size: 14px; padding: 1px 3px;
    border-radius: 4px; display: flex; align-items: center;
  }
  .section-label button:hover { background: var(--surface2); color: var(--text2); }

  /* ── Calendar ── */
  .cal-wrap { padding: 0 14px 12px; }
  .cal-nav-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
  .cal-month { font-size: 12px; font-weight: 500; color: var(--text1); }
  .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
  .cal-dn { text-align: center; font-size: 9px; color: var(--text3); padding: 2px 0 4px; font-weight: 500; }
  .cal-day {
    text-align: center; font-size: 11px; padding: 3px 0;
    border-radius: 5px; cursor: pointer; color: var(--text2);
    position: relative; line-height: 1.6;
  }
  .cal-day:hover { background: var(--surface2); }
  .cal-day.today { background: var(--purple); color: #fff; font-weight: 500; }
  .cal-day.other { color: var(--text3); opacity: 0.4; cursor: default; }
  .cal-day.has-dot::after {
    content: ''; position: absolute; bottom: 1px; left: 50%;
    transform: translateX(-50%); width: 3px; height: 3px;
    border-radius: 50%; background: var(--teal);
  }
  .cal-day.today.has-dot::after { background: rgba(255,255,255,0.7); }

  .sidebar-divider { height: 0.5px; background: var(--border); flex-shrink: 0; }

  /* ── Sidebar scroll area ── */
  .sidebar-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
  .sidebar-scroll::-webkit-scrollbar { width: 3px; }
  .sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

  /* ── Project Tree ── */
  /* Two stacked trees ("My Tasks" + "DL Projects") can outgrow the fixed area
     above the sidebar's own scroll region, so this one scrolls on its own. */
  .tree { padding: 6px 6px 4px; flex: 0 1 auto; min-height: 0; max-height: 42vh; overflow-y: auto; }
  .tree::-webkit-scrollbar { width: 3px; }
  .tree::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
  .tree-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 5px 8px; border-radius: 6px; cursor: pointer;
    font-size: 12.5px; color: var(--text2); user-select: none;
  }
  .tree-item:hover { background: var(--surface2); }
  .tree-item.active { background: var(--surface2); color: var(--text1); font-weight: 500; }
  .tree-item-left { display: flex; align-items: center; gap: 7px; min-width: 0; }
  .tree-toggle { font-size: 10px; color: var(--text3); width: 12px; flex-shrink: 0; text-align: center; }
  .tree-toggle-empty { cursor: default; }
  .tree-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .tree-count { font-size: 10px; color: var(--text3); background: var(--surface2); border-radius: 10px; padding: 1px 6px; }
  .tree-item.active .tree-count { background: var(--surface3); }
  .tree-sub { margin-left: 28px; padding-left: 8px; font-size: 12px; border-left: 1px solid var(--border); }
  .tree-sub2 { margin-left: 42px; padding-left: 8px; font-size: 11.5px; border-left: 1px solid var(--border); }
  .tree-indent { margin-left: 14px; }
  .tree-toggle { cursor: pointer; }
  .tree-toggle:hover { color: var(--text2); }
  .tree-toolbar { display: flex; align-items: center; gap: 2px; padding: 2px 10px 6px; }
  .tt-btn {
    background: none; border: none; cursor: pointer; color: var(--text3);
    width: 26px; height: 26px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
  }
  .tt-btn:hover { background: var(--surface2); color: var(--text1); }
  .tree.hidden { display: none; }
  .tree-item.tree-sub { margin-top: 2px; }

  /* ── Users section ── */
  /* ── High-priority list ── */
  .hp-list { padding: 4px 6px 10px; }
  .hp-item {
    display: flex; align-items: flex-start; gap: 7px;
    padding: 6px 8px; border-radius: 6px; cursor: pointer;
    font-size: 12.5px; color: var(--text2); user-select: none;
  }
  .hp-item:hover { background: var(--surface2); }
  .hp-pip { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; background: #E24B4A; }
  .hp-body { flex: 1; min-width: 0; }
  .hp-title { font-size: 12px; color: var(--text1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hp-meta { font-size: 10.5px; color: var(--text3); margin-top: 1px; }
  .hp-av {
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 8px; font-weight: 600; flex-shrink: 0; margin-top: 2px;
  }

  /* ── User filter bar (board header) ── */
  .user-filter-bar {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 20px 0; background: var(--surface);
    border-bottom: 0.5px solid var(--border);
    overflow-x: auto;
  }
  .user-filter-bar::-webkit-scrollbar { display: none; }
  .uftab {
    display: flex; align-items: center; gap: 5px;
    padding: 4px 10px 4px 5px; border-radius: 20px;
    cursor: pointer; border: 0.5px solid transparent;
    color: var(--text2); background: none; font-family: inherit;
    font-size: 11px; white-space: nowrap; flex-shrink: 0;
  }
  .uftab:hover { background: var(--surface2); }
  .uftab.active {
    background: var(--purple-bg); color: var(--purple);
    border-color: var(--purple-mid); font-weight: 500;
  }
  .uftab .av-sm {
    width: 18px; height: 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 8px; font-weight: 500;
  }
  .uftab-all { padding: 4px 10px; }

  /* ── Board ── */
  .board { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
  .board-body { flex: 1; display: flex; flex-direction: row; overflow: hidden; min-height: 0; }

  .board-header {
    background: var(--surface);
    border-bottom: 0.5px solid var(--border);
    padding: 16px 20px 12px;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    height: 57px; box-sizing: border-box;
  }
  .board-title { font-size: 20px; font-weight: 500; color: var(--text1); white-space: nowrap; }
  .board-title .crumb-link { cursor: pointer; color: var(--text3); }
  .board-title .crumb-link:hover { color: var(--purple); }
  .board-title .crumb-current { color: var(--text1); }
  .board-title .crumb-sep { color: var(--border2); }

  .board-views { display: flex; gap: 6px; flex-shrink: 0; }
  .current-user { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
  .current-user .cu-av {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 500; flex-shrink: 0;
  }
  .current-user .cu-name { font-size: 20px; color: var(--text1); font-weight: 500; white-space: nowrap; }
  .current-user .cu-role { font-size: 11px; color: var(--text3); }
  .current-user .cu-email { font-size: 11px; color: var(--text3); }
  .view-btn {
    background: none; border: 0.5px solid var(--border);
    border-radius: 6px; padding: 4px 8px; cursor: pointer;
    color: var(--text3); font-size: 14px; display: flex; align-items: center;
  }
  .view-btn:hover { color: var(--text2); background: var(--surface2); }
  .view-btn.active { color: var(--purple); border-color: var(--purple-mid); background: var(--purple-bg); }

  /* ── Login ── */
  .login-screen {
    position: fixed; inset: 0; z-index: 100; background: var(--bg);
    display: flex; align-items: center; justify-content: center; padding: 24px;
  }
  .login-screen.hidden { display: none; }
  .login-card {
    width: 360px; max-width: 100%;
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: var(--radius-lg); padding: 32px 30px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.10);
  }
  .login-brand { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 600; color: var(--text1); margin-bottom: 26px; }
  .login-brand i { color: var(--purple); font-size: 20px; }
  .login-h { font-size: 19px; font-weight: 600; color: var(--text1); margin-bottom: 4px; }
  .login-sub { font-size: 13px; color: var(--text3); margin-bottom: 22px; }
  .login-field { margin-bottom: 14px; }
  .login-field label { display: block; font-size: 11px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
  .login-field input {
    width: 100%; background: var(--surface2); border: 0.5px solid var(--border);
    border-radius: var(--radius); padding: 10px 12px; font-size: 13px; color: var(--text1);
    font-family: inherit; outline: none; box-sizing: border-box;
  }
  .login-field input:focus { border-color: var(--purple); }
  .login-field.err input { border-color: #E24B4A; }
  .login-btn {
    width: 100%; background: var(--purple); color: #fff; border: none;
    border-radius: var(--radius); padding: 11px; font-size: 13px; font-weight: 500;
    cursor: pointer; font-family: inherit; margin-top: 4px;
  }
  .login-btn:hover { opacity: 0.92; }
  .login-divider { display: flex; align-items: center; gap: 10px; margin: 20px 0 14px; color: var(--text3); font-size: 11px; }
  .login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
  .login-accounts { display: flex; gap: 6px; justify-content: center; }
  .login-acc {
    display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer;
    padding: 8px 4px; border-radius: var(--radius); border: 0.5px solid transparent; width: 66px;
  }
  .login-acc:hover { background: var(--surface2); }
  .login-acc.selected { border-color: var(--purple-mid); background: var(--purple-bg); }
  .login-acc .la-av { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; }
  .login-acc .la-name { font-size: 10px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58px; }
  .current-user { cursor: pointer; border-radius: var(--radius); padding: 4px 6px; }
  .current-user:hover { background: var(--surface2); }

  /* ── Columns ── */
  .columns-wrap { flex: 1; overflow: auto; padding: 14px 20px; }
  .columns { display: flex; flex-direction: column; width: 100%; min-width: 0; }
  .col { width: 260px; display: flex; flex-direction: column; }

  /* ── Swimlanes (group-by-project, continuous across columns) ── */
  .lane-status-row, .lane-cells { display: grid; grid-template-columns: repeat(3, 1fr); column-gap: 12px; }
  .lane-status-row {
    position: sticky; top: -14px; z-index: 3; background: var(--bg);
    padding: 4px 8px 10px; margin-top: -4px;
  }
  .lane-status-cell { display: flex; align-items: center; gap: 7px; padding: 0 2px; }
  .lane { display: flex; flex-direction: column; border-radius: var(--radius-lg); padding: 4px 8px 8px; margin-bottom: 8px; }
  .lane-head {
    display: flex; align-items: center; gap: 7px;
    padding: 12px 2px 8px; font-size: 12px; font-weight: 500; color: var(--text2);
    position: sticky; left: 0;
  }
  .lane-head-drillable { cursor: pointer; border-radius: 6px; }
  .lane-head-drillable:hover { background: var(--surface2); }
  .lane-level-tag {
    font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text3); background: var(--surface3); border-radius: 4px; padding: 1px 5px;
  }
  .lane-stage-dates { font-size: 11px; color: var(--text3); display: flex; align-items: center; gap: 4px; }
  .lane-stage-dates i { font-size: 12px; }
  /* stretch (not start): a status column with fewer/no cards must still fill
     the lane row's full height, or its drop zone shrinks to just its own
     content and you have to land the drag precisely on a thin strip instead
     of anywhere in that column. */
  .lane-cells { align-items: stretch; padding-bottom: 4px; }
  .lane-cell { display: flex; flex-direction: column; gap: 6px; min-height: 46px; border-radius: var(--radius); padding: 2px; }
  .lane-cell.drag-over { background: var(--surface2); }
  /* flex (not block): now that .lane-cell stretches to the row's full height
     (see .lane-cells above), the placeholder should fill whatever's left of
     that height too and center "Drop here" in the middle of it, not just
     sit as a small box up top. */
  .lane-cell.drag-over .drop-placeholder { display: flex; }
  .col-header { display: flex; align-items: center; gap: 7px; padding: 6px 2px 10px; }
  .col-status-dot { width: 8px; height: 8px; border-radius: 50%; }
  .col-title { font-size: 13px; font-weight: 500; color: var(--text1); }
  .col-count { font-size: 11px; background: var(--surface3); color: var(--text2); border-radius: 10px; padding: 1px 7px; margin-left: auto; }
  /* User modal: Telegram link + admin-only roll-up toggle */
  .mu-hint { font-size: 10.5px; color: var(--text3); margin: -4px 0 12px; line-height: 1.45; }
  /* Whether the bot has actually reached this chat — hidden until there's an
     ID to say anything about, so an empty field stays quiet. */
  .mu-status {
    display: none; font-size: 11px; font-weight: 500;
    margin: -4px 0 6px; line-height: 1.45;
  }
  .mu-status.shown { display: block; }
  .mu-status.ok { color: var(--teal); }
  .mu-status.warn { color: var(--amber); }
  .mu-check {
    display: flex; align-items: center; gap: 7px;
    font-size: 12.5px; color: var(--text1); cursor: pointer; margin-bottom: 4px;
  }
  .mu-check input[type="checkbox"] {
    width: auto; margin: 0; flex-shrink: 0; accent-color: var(--purple); cursor: pointer;
  }

  /* Personal-project checkbox hint in the project modal */
  .mp-personal-hint { font-size: 10.5px; color: var(--text3); margin-bottom: 12px; line-height: 1.4; }
  /* Marks a personal project in the sidebar tree — see isMyPersonal() */
  .tree-personal { font-size: 11px; color: var(--text3); flex-shrink: 0; }

  /* Explains where the current completion date puts the task — see refreshCompletedVisibility() */
  .mt-completed-hint { font-size: 10.5px; color: var(--text3); margin-bottom: 10px; line-height: 1.4; }

  /* ── History modal (tasks archived off the board — see isArchivedDone()) ── */
  .hist-sub { font-size: 11.5px; color: var(--text3); margin: -4px 0 12px; line-height: 1.5; }
  .hist-list { max-height: 46vh; overflow-y: auto; margin: 12px -4px 4px; padding: 0 4px; }
  .hist-list::-webkit-scrollbar { width: 3px; }
  .hist-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
  .hist-month {
    font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--text3); padding: 10px 4px 5px;
  }
  .hist-row {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 8px; border-radius: 6px; cursor: pointer;
  }
  .hist-row:hover { background: var(--surface2); }
  .hist-main { flex: 1; min-width: 0; }
  .hist-title { font-size: 12.5px; color: var(--text1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hist-meta { font-size: 10.5px; color: var(--text3); margin-top: 2px; }
  .hist-empty { font-size: 12px; color: var(--text3); text-align: center; padding: 24px 0; }

  /* "+N hidden" / "hide old" chip in the Done column header — see isStaleDone() */
  .col-done-toggle {
    font-size: 10.5px; line-height: 1; white-space: nowrap;
    background: none; border: 0.5px solid var(--border2); color: var(--text3);
    border-radius: 10px; padding: 3px 7px; cursor: pointer; font-family: inherit;
  }
  .col-done-toggle:hover { color: var(--purple); border-color: var(--purple); }
  .col-done-toggle.is-on { color: var(--purple); border-color: var(--purple); background: var(--purple-bg); }
  .col-add-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text3); font-size: 16px; padding: 2px;
    border-radius: 4px; display: flex; align-items: center;
  }
  .col-add-btn:hover { background: var(--surface2); color: var(--text2); }
  .col-group-head {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 2px 4px; font-size: 11px; font-weight: 500; color: var(--text2);
  }
  .col-group-head:first-child { padding-top: 2px; }
  .col-group-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
  .col-group-count { font-size: 10px; color: var(--text3); }
  .col-body {
    flex: 1; overflow-y: auto; display: flex;
    flex-direction: column; gap: 6px; padding-right: 2px;
  }
  .col-body::-webkit-scrollbar { width: 3px; }
  .col-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

  /* ── Task card ── */
  .task-card {
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: var(--radius); padding: 10px 12px;
    cursor: grab; transition: border-color 0.12s;
  }
  .task-card:hover { border-color: var(--border2); }
  .task-card:active { cursor: grabbing; }
  /* Nothing on the card said it could be dragged: `cursor: grab` only shows up
     under a mouse pointer, and on a touch screen there is no pointer at all —
     the long-press that starts a drag there was invisible. This grip is the
     affordance. It's decoration, not a handle: `pointer-events: none` keeps the
     drag working from anywhere on the card, and keeps the tap that opens the
     task from landing on an icon instead. */
  .card-grip {
    font-size: 13px; color: var(--text3); opacity: 0; margin-left: -3px;
    transition: opacity 0.12s; pointer-events: none; flex-shrink: 0;
  }
  .task-card:hover .card-grip { opacity: 0.55; }
  .task-card.dragging .card-grip { opacity: 0.55; }
  /* Touch: no hover to reveal it, so it stays visible — faintly, since it's a
     hint and not a control. */
  @media (hover: none) {
    .card-grip { opacity: 0.4; }
  }
  /* Subtle per-status tint, same technique as the high-priority one below —
     status is already implied by column position, so this stays gentle
     (lighter alpha) and yields to .high, which is the more urgent signal. */
  .task-card.status-todo { border-color: rgba(136,135,128,0.3); background: rgba(136,135,128,0.035); }
  .task-card.status-todo:hover { border-color: rgba(136,135,128,0.5); }
  .task-card.status-inprogress { border-color: rgba(83,74,183,0.3); background: rgba(83,74,183,0.035); }
  .task-card.status-inprogress:hover { border-color: rgba(83,74,183,0.5); }
  .task-card.status-done { border-color: rgba(29,158,117,0.3); background: rgba(29,158,117,0.035); }
  .task-card.status-done:hover { border-color: rgba(29,158,117,0.5); }
  .task-card.high { border-color: rgba(226,75,74,0.45); background: rgba(226,75,74,0.045); }
  .task-card.high:hover { border-color: rgba(226,75,74,0.7); }
  .task-card.dragging { opacity: 0.45; }
  /* Where a dragged card would land. Without this the cell only highlights as
     a whole, which says the drop is allowed but not the one thing reordering
     is about — which slot. Drawn as a line in the gap above the card it would
     go in front of, or under the last card when dropping at the bottom. */
  .task-card.drop-before::before {
    content: ''; display: block; height: 3px; border-radius: 2px;
    background: var(--purple); margin: -4px 0 5px;
  }
  .lane-cell.drop-at-end::after {
    content: ''; display: block; height: 3px; border-radius: 2px;
    background: var(--purple); margin: 1px 0 0;
  }
  .drag-ghost {
    position: fixed; z-index: 300; pointer-events: none;
    opacity: 0.95; box-shadow: 0 14px 32px rgba(0,0,0,0.22);
    transform-origin: top left; cursor: grabbing;
  }
  .card-top { display: flex; align-items: center; gap: 5px; margin-bottom: 7px; }
  .priority-pip { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
  .priority-sym { font-size: 12px; font-weight: 700; line-height: 1; letter-spacing: -1.5px; flex-shrink: 0; font-family: -apple-system, 'Segoe UI', sans-serif; }
  .proj-tag {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 10px; font-weight: 500; padding: 2px 7px;
    border-radius: 4px; line-height: 1.5;
  }
  .card-title { font-size: 12.5px; color: var(--text1); line-height: 1.45; margin-bottom: 10px; }
  /* The task's number, the handle people quote at the bot. Dimmed and tabular
     so a column of them lines up and never competes with the title itself. */
  .card-num {
    color: var(--text3); font-weight: 600;
    font-variant-numeric: tabular-nums; user-select: all;
  }
  .card-footer { display: flex; align-items: center; justify-content: space-between; }
  .card-date { font-size: 10px; color: var(--text3); display: flex; align-items: center; gap: 3px; }
  .card-date i { font-size: 11px; }
  .card-time { font-size: 10px; color: var(--purple); display: flex; align-items: center; gap: 3px; font-weight: 500; }
  .card-time i { font-size: 11px; }
  .card-subtask-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
  /* Clickable: toggles `done` without opening the task — see wireCardSubtaskToggles() */
  .card-subtask-item {
    display: flex; align-items: flex-start; gap: 5px;
    font-size: 11px; color: var(--text2); line-height: 1.35;
    cursor: pointer; border-radius: 4px; margin: 0 -3px; padding: 1px 3px;
  }
  .card-subtask-item:hover { background: var(--surface2); }
  .card-subtask-item:hover i { color: var(--purple); }
  .card-subtask-item.pending { opacity: 0.5; pointer-events: none; }
  .card-subtask-item i { font-size: 13px; color: var(--text3); flex-shrink: 0; margin-top: 1px; }
  .card-subtask-item.done { color: var(--text3); text-decoration: line-through; }
  .card-subtask-item.done i { color: var(--purple); }
  .card-av {
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 500; cursor: pointer;
    transition: transform 0.1s;
  }
  .card-av:hover { transform: scale(1.15); }

  /* ── Drop zone ── */
  .drop-placeholder {
    border: 1.5px dashed var(--border2); border-radius: var(--radius);
    padding: 14px; text-align: center; font-size: 11px;
    color: var(--text3); display: none;
    flex: 1; align-items: center; justify-content: center; min-height: 46px;
  }
  .col-body.drag-over .drop-placeholder { display: block; }
  .col-body.drag-over { background: var(--surface2); border-radius: var(--radius); }

  /* ── Add-task row ── */
  .add-task-row {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 4px; color: var(--text3); font-size: 11.5px;
    cursor: pointer; border-radius: 6px; margin-top: 4px;
  }
  .add-task-row:hover { background: var(--surface2); color: var(--text2); }
  .add-task-row i { font-size: 14px; }

  /* ── Custom date picker ── */
  .datepicker-wrap { position: relative; margin-bottom: 10px; }
  .datepicker-input {
    display: flex; align-items: center; gap: 7px;
    padding: 8px 11px; background: var(--surface2);
    border: 0.5px solid var(--border); border-radius: var(--radius);
    font-size: 13px; color: var(--text1); cursor: pointer;
    user-select: none;
  }
  .datepicker-input:hover { border-color: var(--border2); }
  .datepicker-input:focus { outline: none; border-color: var(--purple); }
  .datepicker-popup {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 200;
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: 12px; padding: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    width: 240px; display: none;
  }
  .datepicker-popup.open { display: block; }
  .dp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
  .dp-month { font-size: 13px; font-weight: 600; color: var(--text1); }
  .dp-nav {
    width: 26px; height: 26px; border-radius: 6px;
    border: none; background: none; cursor: pointer;
    color: var(--text2); display: flex; align-items: center; justify-content: center;
    font-size: 13px;
  }
  .dp-nav:hover { background: var(--surface2); color: var(--text1); }
  .dp-weekdays { display: grid; grid-template-columns: repeat(7,1fr); margin-bottom: 4px; }
  .dp-weekdays span { text-align: center; font-size: 10px; color: var(--text3); font-weight: 500; padding: 2px 0; }
  .dp-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }
  .dp-day {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    font-size: 12px; border-radius: 6px; cursor: pointer; color: var(--text1);
  }
  .dp-day:hover { background: var(--surface2); }
  .dp-day.other-month { color: var(--text3); opacity: 0.4; }
  .dp-day.today { font-weight: 600; color: var(--purple); }
  .dp-day.selected { background: var(--purple); color: #fff; font-weight: 500; }
  .dp-day.selected:hover { background: var(--purple); }

  /* ── Time tracking ── */
  .time-track-section { border-top: 0.5px solid var(--border); padding-top: 12px; margin-bottom: 4px; }
  .tt-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
  .tt-label { font-size: 12px; color: var(--text2); font-weight: 500; }
  .tt-total { font-size: 13px; color: var(--purple); font-weight: 600; }
  .tt-entries { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; max-height: 120px; overflow-y: auto; }
  .tt-entry { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); padding: 5px 8px; background: var(--surface2); border-radius: 6px; }
  .tt-entry .tt-h { font-weight: 600; color: var(--text1); flex-shrink: 0; }
  .tt-entry .tt-note { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tt-entry .tt-date { font-size: 10.5px; color: var(--text3); flex-shrink: 0; }
  .tt-entry .tt-del { border: none; background: none; cursor: pointer; color: var(--text3); flex-shrink: 0; display: flex; }
  .tt-entry .tt-del:hover { color: #E24B4A; }
  .tt-add-row { display: flex; gap: 6px; }
  /* ── Day detail modal ── */
  .day-modal-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; margin-bottom: 14px; padding-right: 2px; }
  .day-modal-list::-webkit-scrollbar { width: 4px; }
  .day-modal-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
  /* The day modal reuses the board card, but nothing is draggable in there —
     so the grip must not appear and promise something that doesn't work. */
  .day-modal-list .task-card { cursor: pointer; }
  .day-modal-list .card-grip { display: none; }
  .day-modal-empty { font-size: 12.5px; color: var(--text3); padding: 24px 0; text-align: center; }

  /* ── Timetable modal ── */
  .tw-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
  .tw-controls select { margin-bottom: 0; flex: 1; }
  .tw-month-nav { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
  .tw-month-label { font-size: 13px; font-weight: 500; color: var(--text1); min-width: 108px; text-align: center; }
  .tw-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
  .tw-dn { text-align: center; font-size: 9.5px; color: var(--text3); padding: 0 0 4px; font-weight: 500; }
  /* Tall enough to name the projects a day went into, not just total it.
     A square cell had no room, which is why the breakdown used to live only
     in the panel below. */
  .tw-cell {
    min-height: 88px; display: flex; flex-direction: column; align-items: stretch;
    gap: 3px; border-radius: 7px; cursor: pointer; background: var(--surface2);
    font-size: 12px; color: var(--text2); padding: 5px 6px; overflow: hidden;
  }
  .tw-cell:hover { background: var(--border); }
  .tw-cell.pad { visibility: hidden; cursor: default; }
  .tw-cell.today .tw-cell-num { color: var(--purple); font-weight: 700; }
  .tw-cell.has-hours { background: rgba(83,74,183,0.1); }
  /* A working day already past that didn't reach a full day. Ordered after
     .has-hours so a part-filled day reads as short, not as done. */
  .tw-cell.short { background: rgba(186,117,23,0.13); }
  .tw-cell.short .tw-cell-hours { color: var(--amber); }
  .tw-cell.short .tw-cell-num { color: var(--amber); }
  .tw-cell.has-hours .tw-cell-hours { color: var(--purple); font-weight: 600; }
  /* An outline rather than an inset shadow: the cells sit on fractional
     coordinates (7 columns of 1fr), and a 1.5px inset stroke landed across a
     pixel boundary there, so parts of the ring were antialiased away. A whole
     2px outline snaps cleanly, and — unlike a shadow — is painted over the
     cell's own `overflow: hidden`. */
  .tw-cell.selected { outline: 2px solid var(--purple); outline-offset: -2px; }
  .tw-cell-head { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
  .tw-cell-num { font-weight: 600; line-height: 1; }
  .tw-cell-hours { font-size: 9.5px; color: var(--text3); line-height: 1; }
  .tw-cell-projects { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .tw-cell-proj {
    display: flex; align-items: baseline; justify-content: space-between; gap: 4px;
    font-size: 9.5px; line-height: 1.25; color: var(--text2);
    background: var(--surface); border-radius: 3px; padding: 1px 3px;
  }
  /* The name yields to the hours: a truncated project is still recognisable,
     a truncated number is a wrong number. */
  .tw-cell-proj-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .tw-cell-proj-h { color: var(--purple); font-weight: 600; flex-shrink: 0; }
  .tw-detail { min-height: 52px; margin-bottom: 12px; padding: 8px 10px; border-radius: 8px; background: var(--surface2); }
  .tw-detail-date { font-size: 11.5px; font-weight: 500; color: var(--text1); margin-bottom: 6px; }
  .tw-detail-empty { font-size: 11.5px; color: var(--text3); }
  .tw-detail-placeholder { font-size: 11.5px; color: var(--text3); display: flex; align-items: center; height: 36px; }
  .tw-day-tasks { display: flex; flex-wrap: wrap; gap: 5px; }
  .tw-task-chip {
    font-size: 10.5px; color: var(--text2); background: var(--surface);
    border: 0.5px solid var(--border); border-radius: 4px; padding: 2px 6px;
  }
  .tw-legend { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text3); margin-bottom: 10px; }
  .tw-legend-swatch { width: 11px; height: 11px; border-radius: 3px; background: rgba(186,117,23,0.13); flex-shrink: 0; }
  .tw-totals {
    display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text2);
    border-top: 0.5px solid var(--border); padding-top: 10px;
  }
  .tw-totals b { color: var(--text1); }

  .subtask-section { border-top: 0.5px solid var(--border); padding-top: 12px; margin-bottom: 12px; }
  .st-entries { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; max-height: 140px; overflow-y: auto; }
  .st-entry { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text1); padding: 5px 8px; border-radius: 6px; }
  .st-entry:hover { background: var(--surface2); }
  /* width:auto overrides the generic ".modal input { width:100% }" rule below —
     without it the checkbox stretches to fill the row, shoving the title and
     delete button off past the right edge (invisible, not just misaligned). */
  /* margin:0 strips the browser's default checkbox margin (asymmetric top/
     bottom), which otherwise throws off align-items:center and leaves the
     checkbox sitting visibly higher than the title/delete-button next to it. */
  .st-entry input[type="checkbox"] { width: auto; margin: 0; flex-shrink: 0; accent-color: var(--purple); cursor: pointer; }
  .st-entry .st-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .st-entry.done .st-title { color: var(--text3); text-decoration: line-through; }
  .st-entry .tt-del { border: none; background: none; cursor: pointer; color: var(--text3); flex-shrink: 0; display: flex; }
  .st-entry .tt-del:hover { color: #E24B4A; }
  .tt-empty { font-size: 11.5px; color: var(--text3); padding: 2px 0 4px; }
  /* ── Modals ── */
  .modal-bg {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.35); z-index: 100;
    align-items: center; justify-content: center;
    /* A tall modal (the task one especially) must stay reachable on a short
       screen — the page itself can't scroll, .app is height:100vh/overflow:hidden. */
    overflow-y: auto; padding: 24px 0;
  }
  .modal-bg.open { display: flex; }
  .modal {
    background: var(--surface); border: 0.5px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px 22px;
    width: 360px; max-width: 95vw;
    /* margin:auto centres it *and* keeps the top reachable when it overflows,
       which align-items:center alone does not. */
    margin: auto;
  }
  .modal h3 { font-size: 14px; font-weight: 500; margin-bottom: 14px; color: var(--text1); }
  /* One label style for every field in a modal — these used to be four copies
     of the same inline style, with the other fields carrying no label at all. */
  .field-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; }
  .field-row { display: flex; gap: 8px; }
  .field-row .field-col { flex: 1; min-width: 0; }
  /* The hint sits directly under this one, so it keeps a tighter gap. */
  #mt-completed-row input { margin-bottom: 4px; }
  .modal input, .modal select, .modal textarea {
    width: 100%; background: var(--surface2);
    border: 0.5px solid var(--border); border-radius: var(--radius);
    padding: 7px 10px; font-size: 13px; color: var(--text1);
    margin-bottom: 10px; font-family: inherit; outline: none;
    display: block;
  }
  .modal textarea { resize: vertical; min-height: 60px; }
  .modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--purple); }
  .modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
  .btn {
    border: 0.5px solid var(--border); background: var(--surface);
    color: var(--text2); border-radius: var(--radius); padding: 6px 14px;
    font-size: 12px; cursor: pointer; font-family: inherit;
  }
  .btn:hover { background: var(--surface2); }
  .btn.primary { background: var(--purple); color: #fff; border-color: var(--purple); }
  .btn.primary:hover { opacity: 0.9; }
  .btn.danger { background: #FCEBEB; color: #A32D2D; border-color: #F09595; }
  .btn.danger:hover { background: #F7C1C1; }

  /* ── User modal avatars ── */
  .av-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
  .av-option {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 10px; border-radius: 20px; cursor: pointer;
    border: 0.5px solid var(--border); font-size: 11px; color: var(--text2);
    background: var(--surface2);
  }
  .av-option:hover { border-color: var(--border2); }
  .av-option.selected { border-color: var(--purple-mid); background: var(--purple-bg); color: var(--purple); font-weight: 500; }
  .av-option .av-sm2 {
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 500;
  }

  /* ── User management modal ── */
  .user-mgmt-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
  #modal-pmgmt-bg .user-mgmt-list { max-height: 60vh; overflow-y: auto; padding-right: 2px; }
  #modal-pmgmt-bg .user-mgmt-list::-webkit-scrollbar { width: 4px; }
  #modal-pmgmt-bg .user-mgmt-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
  .user-mgmt-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius);
    background: var(--surface2); border: 0.5px solid var(--border);
  }
  .user-mgmt-info { flex: 1; min-width: 0; }
  .user-mgmt-name { font-size: 13px; color: var(--text1); font-weight: 500; }
  .user-mgmt-meta { font-size: 11px; color: var(--text3); margin-top: 1px; }
  .user-mgmt-actions { display: flex; gap: 4px; }
  .icon-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text3); font-size: 15px; padding: 3px;
    border-radius: 4px; display: flex; align-items: center;
  }
  .icon-btn:hover { background: var(--surface3); color: var(--text2); }

  .columns-wrap::-webkit-scrollbar { height: 4px; }
  .columns-wrap::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

  /* ── Admin: team management page ── */
  .admin-page {
    display: none; position: fixed; inset: 0; z-index: 50;
    background: var(--bg); flex-direction: column;
  }
  .admin-page.open { display: flex; }
  .admin-page .board-header { gap: 10px; }
  #admin-search {
    width: 220px; background: var(--surface2); border: 0.5px solid var(--border);
    border-radius: var(--radius); padding: 7px 10px; font-size: 12.5px;
    color: var(--text1); font-family: inherit; outline: none;
  }
  #admin-search:focus { border-color: var(--purple); }
  .admin-body { flex: 1; overflow-y: auto; padding: 24px 20px; }
  .admin-body .user-mgmt-list { max-width: 640px; margin: 0 auto; }
  .role-badge {
    display: inline-block; font-size: 9px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; border-radius: 4px; padding: 1px 5px;
    margin-left: 6px; vertical-align: 1px;
  }
  .role-badge.admin { background: var(--purple-bg); color: var(--purple); }
  .role-badge.inactive { background: var(--surface3); color: var(--text3); }

  /* ── Project collaborators picker ── */
  .collab-picker {
    display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px;
    max-height: 132px; overflow-y: auto;
  }
  .collab-picker:empty::before {
    content: 'No other members to add'; font-size: 11.5px; color: var(--text3);
  }
  .collab-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 10px 4px 4px; border-radius: 16px; cursor: pointer;
    border: 0.5px solid var(--border); background: var(--surface2);
    font-size: 11.5px; color: var(--text2); user-select: none;
  }
  .collab-chip:hover { border-color: var(--border2); }
  .collab-chip.selected { border-color: var(--purple-mid); background: var(--purple-bg); color: var(--purple); font-weight: 500; }
  .collab-chip .collab-av {
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 500; flex-shrink: 0;
  }
