  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --bg: #15151c;
    --surface: #1e1e28;
    --raised: #272734;
    --border: #38385a;
    --text: #f0f0fa;
    --text-sub: #9898c8;
    --text-dim: #5a5a80;
    --red: #e07070;
    --red-bg: rgba(224,112,112,0.13);
    --red-border: rgba(224,112,112,0.30);
    --green: #60c484;
    --green-bg: rgba(96,196,132,0.13);
    --green-border: rgba(96,196,132,0.30);
    --yellow: #d4b06a;
    --yellow-bg: rgba(212,176,106,0.13);
    --yellow-border: rgba(212,176,106,0.30);
    --blue: #6aa8e0;
    --blue-bg: rgba(106,168,224,0.13);
    --blue-border: rgba(106,168,224,0.30);
  }
  html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'DM Sans', system-ui, sans-serif; overflow: hidden; }
  ::-webkit-scrollbar { width: 3px; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
  input { font-family: inherit; border: none; outline: none; background: transparent; color: var(--text); }

  #app { display: flex; flex-direction: column; height: 100vh; }

  header { display: flex; align-items: center; justify-content: space-between; padding: 18px 28px 0; flex-shrink: 0; }
  .logo-label { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-sub); margin-bottom: 2px; }
  .logo-name  { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
  nav { display: flex; gap: 3px; background: var(--surface); padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
  .tab-btn { padding: 6px 18px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--text-sub); transition: all 0.15s; text-transform: capitalize; }
  .tab-btn.active { background: var(--raised); color: var(--text); }

  /* Sync status indicator */
  .sync-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); margin-right: 28px; transition: background 0.4s; flex-shrink: 0; }
  .sync-dot.saving  { background: var(--yellow); }
  .sync-dot.saved   { background: var(--green); }
  .sync-dot.error   { background: var(--red); }

  main { flex: 1; display: flex; gap: 16px; padding: 16px 28px 28px; min-height: 0; overflow: hidden; }

  .quadrant-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
  .axis-x { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-sub); text-align: center; padding: 5px 0; flex-shrink: 0; }
  .middle-row { flex: 1; display: flex; min-height: 0; }
  .axis-y { writing-mode: vertical-rl; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-sub); display: flex; align-items: center; justify-content: center; width: 18px; flex-shrink: 0; }
  .axis-y.left  { transform: rotate(180deg); margin-right: 10px; }
  .axis-y.right { margin-left: 10px; }
  .grid { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 8px; min-height: 0; }

  .qpanel { border-radius: 13px; padding: 14px 15px; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
  .qpanel.red    { background: var(--red-bg);    border: 1px solid var(--red-border); }
  .qpanel.green  { background: var(--green-bg);  border: 1px solid var(--green-border); }
  .qpanel.yellow { background: var(--yellow-bg); border: 1px solid var(--yellow-border); }
  .qpanel.blue   { background: var(--blue-bg);   border: 1px solid var(--blue-border); }
  .qpanel-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; flex-shrink: 0; }
  .q-label { font-size: 14px; font-weight: 600; }
  .q-sub   { font-size: 10px; color: var(--text-sub); margin-top: 2px; }
  .red    .q-label { color: var(--red); }
  .green  .q-label { color: var(--green); }
  .yellow .q-label { color: var(--yellow); }
  .blue   .q-label { color: var(--blue); }
  .q-add { width: 22px; height: 22px; border-radius: 6px; font-size: 17px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity 0.15s; }
  .q-add:hover { opacity: 0.7; }
  .red    .q-add { background: rgba(224,112,112,0.18); color: var(--red); }
  .green  .q-add { background: rgba(96,196,132,0.18);  color: var(--green); }
  .yellow .q-add { background: rgba(212,176,106,0.18); color: var(--yellow); }
  .blue   .q-add { background: rgba(106,168,224,0.18); color: var(--blue); }

  .task-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
  .task-item { display: flex; align-items: center; gap: 8px; background: rgba(21,21,30,0.6); border-radius: 7px; padding: 8px 10px; cursor: grab; transition: opacity 0.2s; user-select: none; }
  .task-item:active { cursor: grabbing; }
  .task-item.dragging { opacity: 0.25; }
  .task-item.completing { opacity: 0; transform: translateX(8px); transition: opacity 0.22s, transform 0.22s; }
  .task-item.drag-insert-before { box-shadow: 0 -2px 0 0 var(--text-sub); }
  .task-list.drag-over { outline: 2px dashed var(--border); outline-offset: 3px; border-radius: 8px; background: rgba(255,255,255,0.02); }
  .qpanel.red.drag-over    .task-list { outline-color: var(--red); }
  .qpanel.green.drag-over  .task-list { outline-color: var(--green); }
  .qpanel.yellow.drag-over .task-list { outline-color: var(--yellow); }
  .qpanel.blue.drag-over   .task-list { outline-color: var(--blue); }
  .task-check { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; }
  .task-check:hover { opacity: 0.6; }
  .red    .task-check { border: 1.5px solid rgba(224,112,112,0.6); }
  .green  .task-check { border: 1.5px solid rgba(96,196,132,0.6); }
  .yellow .task-check { border: 1.5px solid rgba(212,176,106,0.6); }
  .blue   .task-check { border: 1.5px solid rgba(106,168,224,0.6); }
  .task-text { font-size: 14px; line-height: 1.3; flex: 1; }
  .task-empty { font-size: 12px; color: var(--text-dim); padding: 2px 0; }

  .add-row { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 7px; padding: 8px 10px; }
  .red    .add-row { border: 1px solid rgba(224,112,112,0.35); }
  .green  .add-row { border: 1px solid rgba(96,196,132,0.35); }
  .yellow .add-row { border: 1px solid rgba(212,176,106,0.35); }
  .blue   .add-row { border: 1px solid rgba(106,168,224,0.35); }
  .add-ghost { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; opacity: 0.3; }
  .red    .add-ghost { border: 1.5px solid var(--red); }
  .green  .add-ghost { border: 1.5px solid var(--green); }
  .yellow .add-ghost { border: 1.5px solid var(--yellow); }
  .blue   .add-ghost { border: 1.5px solid var(--blue); }
  .add-input { font-size: 14px; flex: 1; }
  .add-input::placeholder { color: var(--text-dim); }

  .done-stack { width: 230px; flex-shrink: 0; background: var(--surface); border-radius: 14px; border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
  .done-top { padding: 15px 18px 13px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
  .done-lbl { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-sub); margin-bottom: 4px; }
  .done-row { display: flex; align-items: baseline; justify-content: space-between; }
  .done-count { font-size: 28px; font-weight: 600; letter-spacing: -0.04em; }
  .done-archive-btn { font-size: 11px; color: var(--text-dim); }
  .done-archive-btn:hover { color: var(--green); }
  .done-list { flex: 1; overflow-y: auto; padding: 13px 18px; display: flex; flex-direction: column; gap: 11px; }
  .done-item { cursor: context-menu; }
  .done-item-text { font-size: 13px; color: var(--text-sub); text-decoration: line-through; line-height: 1.4; }
  .done-meta { display: flex; align-items: center; gap: 5px; margin-top: 3px; }
  .done-dot  { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
  .done-time { font-size: 11px; color: var(--text-dim); }
  .done-empty { font-size: 13px; color: var(--text-dim); }

  #ctx-menu { position: fixed; z-index: 999; background: var(--raised); border: 1px solid var(--border); border-radius: 10px; padding: 5px; min-width: 175px; box-shadow: 0 10px 36px rgba(0,0,0,0.55); display: none; }
  #ctx-menu.visible { display: block; }
  .ctx-label { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); padding: 6px 10px 4px; }
  .ctx-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 6px; font-size: 13px; color: var(--text-sub); cursor: pointer; transition: background 0.1s; }
  .ctx-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
  .ctx-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

  /* Heatmap */
  .heatmap-wrap { flex: 1; display: flex; flex-direction: column; overflow-y: auto; gap: 32px; padding: 4px 0 20px; }
  .heatmap-section { flex-shrink: 0; }
  .heatmap-section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
  .heatmap-section-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .heatmap-title { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
  .heatmap-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
  .heatmap-body { overflow-x: auto; overflow-y: hidden; flex-shrink: 0; padding-bottom: 6px; }
  .heatmap-body::-webkit-scrollbar { height: 2px; }
  .heatmap-months { display: flex; margin-bottom: 6px; padding-left: 30px; }
  .heatmap-grid-wrap { display: flex; gap: 6px; }
  .heatmap-day-labels { display: flex; flex-direction: column; justify-content: space-between; padding: 1px 0; width: 24px; flex-shrink: 0; }
  .heatmap-day-label { font-size: 9px; color: var(--text-dim); height: 12px; line-height: 12px; }
  .heatmap-cols { display: flex; gap: 3px; }
  .heatmap-col  { display: flex; flex-direction: column; gap: 3px; }
  .heatmap-cell { width: 12px; height: 12px; border-radius: 2px; cursor: pointer; transition: transform 0.12s, box-shadow 0.12s; position: relative; flex-shrink: 0; }
  .heatmap-cell:hover { transform: scale(1.5); box-shadow: 0 2px 10px rgba(0,0,0,0.5); z-index: 2; }
  .heatmap-legend { display: flex; align-items: center; gap: 6px; margin-top: 18px; }
  .heatmap-legend-label { font-size: 11px; color: var(--text-dim); }
  .heatmap-legend-cells { display: flex; gap: 3px; }
  .legend-cell { width: 12px; height: 12px; border-radius: 2px; }

  /* Day popup */
  #day-popup { position: fixed; z-index: 998; background: var(--raised); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px 14px; min-width: 220px; max-width: 290px; box-shadow: 0 12px 40px rgba(0,0,0,0.6); display: none; }
  #day-popup.visible { display: block; }
  .popup-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 4px; }
  .popup-date { font-size: 13px; font-weight: 600; color: var(--text); }
  .popup-close { font-size: 18px; color: var(--text-dim); line-height: 1; margin-top: -1px; }
  .popup-close:hover { color: var(--text-sub); }
  .popup-count { font-size: 11px; color: var(--text-dim); margin-bottom: 12px; }
  .popup-task { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
  .popup-dot  { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
  .popup-task-text { font-size: 13px; color: var(--text-sub); }
  .popup-empty { font-size: 13px; color: var(--text-dim); }

  /* Loading screen */
  #loading { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; z-index: 9999; transition: opacity 0.3s; }
  #loading.gone { opacity: 0; pointer-events: none; }
  .loading-logo { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
  .loading-sub  { font-size: 12px; color: var(--text-dim); }
  .loading-error { font-size: 13px; color: var(--red); max-width: 340px; text-align: center; line-height: 1.5; }

  .placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 13px; }

  /* ── Calendar ────────────────────────────────────────────────────────────── */
  .cal-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
  .cal-toolbar { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; padding: 0 0 12px; }
  .cal-nav-group { display: flex; align-items: center; gap: 8px; }
  .cal-view-group { display: flex; align-items: center; gap: 6px; }
  .cal-nav-btn { width: 28px; height: 28px; border-radius: 7px; background: var(--surface); border: 1px solid var(--border); font-size: 18px; color: var(--text-sub); display: flex; align-items: center; justify-content: center; transition: all 0.15s; line-height: 1; }
  .cal-nav-btn:hover { color: var(--text); background: var(--raised); }
  .cal-today-btn { padding: 5px 12px; border-radius: 7px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 500; color: var(--text-sub); transition: all 0.15s; }
  .cal-today-btn:hover { color: var(--text); }
  .cal-heading { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
  .cal-view-toggle { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
  .cal-view-btn { padding: 4px 12px; border-radius: 6px; font-size: 12px; font-weight: 500; color: var(--text-sub); transition: all 0.15s; }
  .cal-view-btn.active { background: var(--raised); color: var(--text); }
  .cal-add-btn { padding: 6px 14px; border-radius: 7px; background: var(--green); color: var(--bg); font-size: 13px; font-weight: 600; transition: opacity 0.15s; }
  .cal-add-btn:hover { opacity: 0.85; }

  /* Week view */
  #cal-content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .cal-week-container { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-radius: 13px; border: 1px solid var(--border); overflow: hidden; }
  /* Single scroll zone — scrolls both axes; header + gutter stick */
  .cal-week-scroll { flex: 1; overflow: auto; }
  .cal-week-inner { display: flex; flex-direction: column; min-width: calc(54px + 7 * 100px); }
  /* Sticky header+allday block */
  .cal-week-sticky { position: sticky; top: 0; z-index: 10; }
  .cal-week-header { display: flex; flex-shrink: 0; border-bottom: 1px solid var(--border); background: var(--raised); }
  .cal-gutter-head { width: 54px; flex-shrink: 0; border-right: 1px solid var(--border); position: sticky; left: 0; z-index: 12; background: var(--raised); }
  .cal-day-head { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 0; border-right: 1px solid var(--border); min-width: 100px; }
  .cal-day-head:last-child { border-right: none; }
  .cal-day-name { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 5px; }
  .cal-day-num { font-size: 18px; font-weight: 600; letter-spacing: -0.03em; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-sub); }
  .cal-today-head .cal-day-num { background: var(--green); color: var(--bg); }
  .cal-week-grid { display: flex; position: relative; }
  .cal-time-gutter { width: 54px; flex-shrink: 0; position: sticky; left: 0; z-index: 8; background: var(--surface); border-right: 1px solid var(--border); }
  .cal-time-label { position: absolute; right: 8px; font-size: 10px; color: var(--text-dim); transform: translateY(-50%); line-height: 1; user-select: none; pointer-events: none; }
  .cal-day-col { flex: 1; position: relative; border-right: 1px solid var(--border); cursor: crosshair; min-width: 100px; }
  .cal-day-col:last-child { border-right: none; }
  .cal-today-col { background: rgba(96,196,132,0.03); }
  .cal-hour-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--border); pointer-events: none; z-index: 0; }
  .cal-half-line { position: absolute; left: 0; right: 0; height: 1px; background: rgba(56,56,90,0.45); pointer-events: none; z-index: 0; }
  .cal-now-overlay { position: absolute; left: 54px; right: 0; height: 2px; background: var(--red); pointer-events: none; z-index: 5; opacity: 0.85; }
  .cal-now-overlay::before { content: ''; position: absolute; left: -4px; top: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); }

  /* Events */
  .cal-event { position: absolute; left: 3px; right: 3px; border-radius: 5px; padding: 3px 6px 2px; cursor: pointer; overflow: hidden; z-index: 2; transition: filter 0.1s; user-select: none; touch-action: none; }
  .cal-event:hover { filter: brightness(1.18); z-index: 3; }
  .cal-event-inner { pointer-events: none; }
  .cal-event-name { font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 1.3; }
  .cal-event-time { font-size: 10px; color: rgba(240,240,250,0.6); display: block; margin-top: 1px; }
  .cal-event-resize { position: absolute; bottom: 0; left: 0; right: 0; height: 8px; cursor: ns-resize; border-radius: 0 0 5px 5px; touch-action: none; }

  /* Month view */
  .cal-month-view { flex: 1; display: flex; flex-direction: column; background: var(--surface); border-radius: 13px; border: 1px solid var(--border); overflow: hidden; min-height: 0; }
  .cal-month-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border); background: var(--raised); flex-shrink: 0; }
  .cal-month-weekday { padding: 8px 0; text-align: center; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }
  .cal-month-grid { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
  .cal-month-row { display: grid; grid-template-columns: repeat(7, 1fr); flex: 1; border-bottom: 1px solid var(--border); min-height: 0; }
  .cal-month-row:last-child { border-bottom: none; }
  .cal-month-cell { padding: 7px 8px; border-right: 1px solid var(--border); cursor: pointer; overflow: hidden; transition: background 0.1s; display: flex; flex-direction: column; }
  .cal-month-cell:last-child { border-right: none; }
  .cal-month-cell:hover { background: rgba(255,255,255,0.03); }
  .cal-month-out .cal-month-day-num { color: var(--text-dim); opacity: 0.4; }
  .cal-month-day-num { font-size: 12px; color: var(--text-sub); width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 50%; margin-bottom: 4px; flex-shrink: 0; }
  .cal-month-today .cal-month-day-num { background: var(--green); color: var(--bg); font-weight: 600; }
  .cal-month-event { font-size: 10px; font-weight: 500; color: var(--text); border-radius: 3px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; cursor: pointer; }
  .cal-month-more { font-size: 10px; color: var(--text-dim); padding: 0 2px; }

  /* Modal */
  #cal-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 1000; }
  #cal-modal { position: fixed; z-index: 1001; background: var(--raised); border: 1px solid var(--border); border-radius: 14px; padding: 22px 22px 18px; width: 390px; left: 50%; top: 50%; transform: translate(-50%,-50%); box-shadow: 0 20px 60px rgba(0,0,0,0.7); }
  .cal-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
  .cal-modal-title { font-size: 15px; font-weight: 600; }
  .cal-modal-close { font-size: 20px; color: var(--text-dim); line-height: 1; }
  .cal-modal-close:hover { color: var(--text-sub); }
  .cal-modal-input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px; color: var(--text); margin-bottom: 12px; font-family: inherit; outline: none; display: block; box-sizing: border-box; }
  .cal-modal-input:focus { border-color: var(--text-dim); }
  .cal-modal-input::placeholder { color: var(--text-dim); }
  .cal-modal-row { display: flex; gap: 8px; margin-bottom: 12px; }
  .cal-modal-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
  .cal-modal-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
  .cal-modal-input-sm { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; font-size: 13px; color: var(--text); font-family: inherit; outline: none; width: 100%; box-sizing: border-box; color-scheme: dark; }
  .cal-modal-input-sm:focus { border-color: var(--text-dim); }
  select.cal-modal-input-sm { -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%239898c8' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer; }
  select.cal-modal-input-sm option { background: var(--raised); color: var(--text); }
  .cal-modal-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
  .cal-modal-delete { font-size: 13px; color: var(--red); opacity: 0.75; }
  .cal-modal-delete:hover { opacity: 1; }
  .cal-modal-cancel { padding: 7px 16px; border-radius: 7px; font-size: 13px; color: var(--text-sub); background: var(--surface); border: 1px solid var(--border); }
  .cal-modal-save { padding: 7px 16px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--bg); background: var(--green); }
  .cal-modal-save:hover { opacity: 0.9; }
  .cal-allday-toggle { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; user-select: none; }
  .cal-allday-toggle input { width: 14px; height: 14px; accent-color: var(--green); cursor: pointer; }
  .cal-allday-toggle span { font-size: 13px; color: var(--text-sub); }
  .cal-import-btn { padding: 6px 12px; border-radius: 7px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 500; color: var(--text-sub); transition: all 0.15s; }
  .cal-import-btn:hover { color: var(--text); background: var(--raised); }

  /* Task right-click menu */
  #task-ctx-menu { position: fixed; z-index: 999; background: var(--raised); border: 1px solid var(--border); border-radius: 10px; padding: 5px; min-width: 190px; box-shadow: 0 10px 36px rgba(0,0,0,0.55); display: none; }
  #task-ctx-menu.visible { display: block; }

  /* All-day strip */
  .cal-allday-strip { display: flex; flex-shrink: 0; border-bottom: 1px solid var(--border); background: var(--surface); }
  .cal-allday-gutter { width: 54px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: flex-end; padding: 5px 8px 5px 0; position: sticky; left: 0; z-index: 11; background: var(--surface); }
  .cal-allday-gutter-lbl { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; line-height: 1.8; }
  .cal-allday-cell { flex: 1; border-right: 1px solid var(--border); padding: 3px 3px; display: flex; flex-direction: column; gap: 2px; min-height: 26px; min-width: 100px; }
  .cal-allday-cell:last-child { border-right: none; }
  .cal-allday-event { font-size: 10px; font-weight: 500; color: var(--text); border-radius: 3px; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; transition: filter 0.1s; }
  .cal-allday-event:hover { filter: brightness(1.2); }
  /* Archived-tasks chip in all-day strip */
  .cal-allday-archived { font-size: 10px; font-weight: 500; border-radius: 3px; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; opacity: 0.75; transition: opacity 0.12s; font-style: italic; letter-spacing: 0.01em; }
  .cal-allday-archived:hover { opacity: 1; }

  /* ── Agenda (list) view ──────────────────────────────────────────────────── */
  .cal-agenda-wrap { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0; background: var(--surface); border-radius: 13px; border: 1px solid var(--border); }
  .cal-agenda-empty { display: flex; align-items: center; justify-content: center; flex: 1; color: var(--text-dim); font-size: 13px; min-height: 200px; }
  .cal-agenda-day { border-bottom: 1px solid var(--border); }
  .cal-agenda-day:last-child { border-bottom: none; }
  .cal-agenda-date { display: flex; align-items: baseline; gap: 8px; padding: 11px 18px 8px; position: sticky; top: 0; background: var(--raised); z-index: 5; border-bottom: 1px solid var(--border); }
  .cal-agenda-dow { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
  .cal-agenda-dnum { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-sub); }
  .cal-agenda-today-badge { font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--bg); background: var(--green); border-radius: 4px; padding: 1px 5px; }
  .cal-agenda-row { display: flex; align-items: center; gap: 12px; padding: 8px 18px; cursor: pointer; transition: background 0.1s; border-bottom: 1px solid rgba(56,56,90,0.25); }
  .cal-agenda-row:last-child { border-bottom: none; }
  .cal-agenda-row:hover { background: rgba(255,255,255,0.03); }
  .cal-agenda-row.sel { background: rgba(96,196,132,0.07); }
  .cal-agenda-cb { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: all 0.12s; }
  .cal-agenda-cb.checked { background: var(--green); border-color: var(--green); color: var(--bg); font-size: 10px; }
  .cal-agenda-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .cal-agenda-time { font-size: 11px; color: var(--text-dim); width: 80px; flex-shrink: 0; }
  .cal-agenda-name { font-size: 13px; flex: 1; }
  .cal-agenda-cat { font-size: 10px; border-radius: 3px; padding: 1px 6px; font-weight: 500; flex-shrink: 0; }
  /* Bulk action bar */
  .cal-bulk-bar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--raised); border: 1px solid var(--border); border-radius: 10px; margin-top: 10px; flex-shrink: 0; }
  .cal-bulk-count { font-size: 13px; font-weight: 600; flex: 1; color: var(--text-sub); }
  .cal-bulk-sel { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12px; color: var(--text); font-family: inherit; outline: none; -webkit-appearance: none; appearance: none; }
  .cal-bulk-apply { padding: 6px 14px; border-radius: 6px; background: var(--green); color: var(--bg); font-size: 12px; font-weight: 600; }
  .cal-bulk-delete { padding: 6px 14px; border-radius: 6px; background: rgba(224,112,112,0.15); border: 1px solid rgba(224,112,112,0.3); color: var(--red); font-size: 12px; font-weight: 500; }
  .cal-bulk-clear { font-size: 12px; color: var(--text-dim); }
  /* Reclassify styles removed — bulk edit now lives entirely in List view */

  @media (max-width: 640px) {
    /* Core */
    html, body { overflow: auto; }
    #app { height: auto; min-height: 100vh; overflow: visible; }
    main { padding: 10px 12px 28px; flex-direction: column; overflow: visible; gap: 12px; min-height: 0; }

    /* Header */
    header { padding: 12px 14px 0; }
    .logo-label { display: none; }
    .logo-name { font-size: 17px; }
    nav { gap: 2px; }
    .tab-btn { padding: 5px 10px; font-size: 12px; }
    .sync-dot { margin-right: 10px; }

    /* Quadrant panels */
    .quadrant-wrap { min-height: 0; }
    .grid { gap: 6px; }
    .qpanel { min-height: 170px; padding: 10px 11px; }
    .axis-x { font-size: 9px; padding: 3px 0; }
    .axis-y { display: none; }
    .middle-row { gap: 0; }
    .task-text { font-size: 13px; }
    .q-label { font-size: 13px; }
    .q-sub { font-size: 9px; }
    .task-item { padding: 6px 8px; }

    /* Done stack */
    .done-stack { width: 100%; height: auto; flex-direction: column; }
    .done-list { flex-direction: row; flex-wrap: wrap; padding: 10px 14px; gap: 8px; max-height: 160px; overflow-y: auto; }
    .done-item { flex: 0 0 auto; min-width: 100px; }
    .done-count { font-size: 22px; }

    /* Calendar wrap — full height on mobile */
    .cal-wrap { flex: 1; min-height: 70vh; }
    #cal-content { flex: 1; min-height: 60vh; }

    /* Calendar toolbar */
    .cal-toolbar { flex-wrap: wrap; gap: 8px; padding-bottom: 8px; }
    .cal-nav-group { gap: 5px; min-width: 0; }
    .cal-heading { font-size: 12px; }
    .cal-view-group { gap: 4px; }
    .cal-import-btn { font-size: 11px; padding: 4px 8px; }
    .cal-add-btn { font-size: 12px; padding: 5px 10px; }

    /* Week grid — wider columns so only ~3 days show before scroll */
    .cal-week-inner { min-width: calc(40px + 7 * 114px); }
    .cal-day-col { min-width: 114px; }
    .cal-day-head { min-width: 114px; padding: 7px 0; }
    .cal-allday-cell { min-width: 114px; }
    .cal-gutter-head { width: 40px; }
    .cal-time-gutter { width: 40px; }
    .cal-allday-gutter { width: 40px; }
    .cal-now-overlay { left: 40px; }
    .cal-time-label { font-size: 8px; right: 2px; }
    .cal-day-name { font-size: 9px; letter-spacing: 0.03em; margin-bottom: 3px; }
    .cal-day-num { font-size: 15px; width: 26px; height: 26px; }

    /* Event text wraps on mobile instead of truncating */
    .cal-event-name { white-space: normal; word-break: break-word; font-size: 10px; line-height: 1.25; }
    .cal-event-time { font-size: 9px; }
    .cal-event { padding: 2px 4px 2px; }

    .cal-allday-event { font-size: 9px; padding: 1px 4px; }
    .cal-allday-gutter-lbl { font-size: 8px; }

    /* Month view */
    .cal-month-cell { padding: 4px 5px; min-height: 54px; }
    .cal-month-day-num { font-size: 11px; width: 18px; height: 18px; }
    .cal-month-event { font-size: 9px; }

    /* Modal — full width */
    #cal-modal { width: calc(100vw - 24px); left: 12px; top: 50%; transform: translateY(-50%); }
    .cal-modal-row { flex-wrap: wrap; gap: 8px; }
    .cal-modal-field { min-width: calc(50% - 4px); }

    /* Heatmap */
    .heatmap-wrap { gap: 24px; padding: 0 0 16px; }

    /* Context menus */
    #ctx-menu, #task-ctx-menu, #day-popup { min-width: 160px; }
  }

  /* Landscape phone */
  @media (max-width: 900px) and (orientation: landscape) {
    html, body { overflow: hidden; }
    #app { height: 100vh; overflow: hidden; }
    main { overflow: hidden; padding: 8px 14px 14px; flex-direction: row; }
    header { padding: 10px 16px 0; }
    .logo-name { font-size: 16px; }
    .tab-btn { padding: 4px 10px; font-size: 11px; }
    /* Quadrant: two-col grid fills height */
    .quadrant-wrap { min-height: 0; flex: 1; }
    .qpanel { min-height: 0; }
    .done-stack { width: 180px; height: auto; }
    /* Calendar: full height single panel */
    .cal-wrap { min-height: 0; flex: 1; }
    #cal-content { min-height: 0; flex: 1; }
    .cal-week-container { min-height: 0; }
    .cal-toolbar { padding-bottom: 6px; flex-wrap: nowrap; }
    .cal-heading { font-size: 11px; }
    .cal-week-inner { min-width: calc(36px + 7 * 56px); }
    .cal-day-col { min-width: 56px; }
    .cal-day-head { min-width: 56px; }
    .cal-allday-cell { min-width: 56px; }
    .cal-gutter-head, .cal-time-gutter, .cal-allday-gutter { width: 36px; }
    .cal-now-overlay { left: 36px; }
    .cal-event-name { white-space: normal; word-break: break-word; font-size: 9px; }
    .cal-time-label { font-size: 8px; }
  }
