  /* ── Light theme ─────────────────────────────────────────────────────── */
  :root {
    --bg: #f5f2ec;
    --bg2: #fffefb;
    --bg3: #efeae1;
    --bg4: #e4ddd0;
    --border: rgba(48,42,34,0.10);
    --border2: rgba(48,42,34,0.18);
    --text: #2b2620;
    --text2: #6e6559;
    --text3: #a49a8b;
    --accent: #4a5ac9;
    --accent-dim: rgba(74,90,201,0.10);
    --good: #2e8f63;
    --good-dim: rgba(46,143,99,0.13);
    --warn: #b07818;
    --warn-dim: rgba(176,120,24,0.13);
    --danger: #c25642;
    --danger-dim: rgba(194,86,66,0.10);
    --shadow: 0 1px 2px rgba(48,42,34,0.05), 0 4px 14px rgba(48,42,34,0.05);
    --radius: 10px;
    --radius-sm: 6px;
  }

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

  body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
  }

  /* ── Layout ──────────────────────────────────────────────────────────── */
  .app { display: flex; height: 100vh; overflow: hidden; }

  .sidebar {
    width: 228px;
    min-width: 228px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 40;
  }

  .sidebar-logo { padding: 24px 20px 16px; border-bottom: 1px solid var(--border); }
  .logo-title { font-family: 'DM Serif Display', serif; font-size: 19px; line-height: 1.2; }
  .logo-title em { color: var(--accent); font-style: italic; }
  .logo-sub {
    font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text3);
    letter-spacing: 0.12em; text-transform: uppercase; margin-top: 3px;
  }

  .nav-section { padding: 14px 12px 4px; }
  .nav-section-label {
    font-family: 'DM Mono', monospace; font-size: 9px; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text3); padding: 0 8px; margin-bottom: 4px;
  }
  .nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer;
    color: var(--text2); font-size: 13.5px; user-select: none;
    transition: background 0.15s, color 0.15s;
  }
  .nav-item:hover { background: var(--bg3); color: var(--text); }
  .nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
  .nav-item .nav-ico { width: 18px; text-align: center; font-size: 14px; }
  .sidebar-foot { margin-top: auto; padding: 14px 20px; border-top: 1px solid var(--border); }
  .sidebar-version { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text3); margin-top: 8px; }

  .main { flex: 1; overflow-y: auto; }
  .page { display: none; padding: 30px 36px 90px; max-width: 1120px; margin: 0 auto; }
  .page.active { display: block; }

  .page-header { margin-bottom: 22px; }
  .page-title { font-family: 'DM Serif Display', serif; font-size: 28px; }
  .page-title em { color: var(--accent); font-style: italic; }
  .page-subtitle { font-size: 13px; color: var(--text2); margin-top: 3px; }
  .page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

  /* ── Cards & common bits ─────────────────────────────────────────────── */
  .card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  }
  .card-title {
    font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text2); margin-bottom: 12px;
  }
  .empty-state { color: var(--text3); font-size: 13px; text-align: center; padding: 26px 12px; line-height: 1.6; }

  .btn-primary {
    background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
    padding: 8px 16px; font-size: 13px; font-weight: 500; font-family: 'Outfit', sans-serif;
    cursor: pointer; transition: filter 0.15s;
  }
  .btn-primary:hover { filter: brightness(1.08); }
  .btn-cancel {
    background: transparent; color: var(--text2); border: 1px solid var(--border2);
    border-radius: var(--radius-sm); padding: 8px 16px; font-size: 13px;
    font-family: 'Outfit', sans-serif; cursor: pointer; transition: background 0.15s;
  }
  .btn-cancel:hover { background: var(--bg3); }
  .btn-danger {
    background: transparent; color: var(--danger); border: 1px solid var(--danger);
    border-radius: var(--radius-sm); padding: 8px 16px; font-size: 13px;
    font-family: 'Outfit', sans-serif; cursor: pointer;
  }
  .btn-danger:hover { background: var(--danger-dim); }
  .btn-sm { padding: 5px 10px; font-size: 12px; }
  .icon-btn {
    background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
    color: var(--text3); cursor: pointer; padding: 4px 7px; font-size: 13px; line-height: 1;
    font-family: 'Outfit', sans-serif;
  }
  .icon-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--border); }
  .icon-btn.danger:hover { background: var(--danger-dim); color: var(--danger); }

  .form-label { display: block; font-size: 12px; color: var(--text2); margin: 12px 0 5px; }
  .form-input, .form-select, .form-textarea {
    width: 100%; background: var(--bg2); border: 1px solid var(--border2);
    border-radius: var(--radius-sm); color: var(--text); padding: 8px 10px;
    font-size: 13.5px; font-family: 'Outfit', sans-serif; outline: none;
  }
  .form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
  .form-textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
  .form-row { display: flex; gap: 12px; }
  .form-row > * { flex: 1; min-width: 0; }
  .form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); margin-top: 12px; cursor: pointer; user-select: none; }
  .form-check input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
  .form-hint { font-size: 12px; color: var(--text3); margin: -1px 0 7px; }
  .day-picker { display: flex; gap: 6px; flex-wrap: wrap; }

  .search-input {
    background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--radius-sm);
    color: var(--text); padding: 8px 12px; font-size: 13px; font-family: 'Outfit', sans-serif;
    outline: none; min-width: 200px;
  }
  .search-input:focus { border-color: var(--accent); }

  .filter-btn {
    background: transparent; border: 1px solid var(--border2); border-radius: 999px;
    color: var(--text2); padding: 6px 13px; font-size: 12.5px; cursor: pointer;
    font-family: 'Outfit', sans-serif; display: inline-flex; align-items: center; gap: 6px;
    transition: background 0.15s;
  }
  .filter-btn:hover { background: var(--bg3); color: var(--text); }
  .filter-btn.active { background: var(--text); border-color: var(--text); color: var(--bg2); }
  .filter-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

  .area-chip {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; font-weight: 500;
  }
  .pill {
    display: inline-block; font-size: 10px; font-family: 'DM Mono', monospace;
    letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px;
  }
  .pill-opt { background: var(--bg3); color: var(--text2); }
  .pill-extra { background: var(--accent-dim); color: var(--accent); }
  .pill-skip { background: var(--warn-dim); color: var(--warn); }
  .pill-focus { background: var(--danger-dim); color: var(--danger); }
  .pill-normal { background: var(--bg3); color: var(--text2); }
  .pill-low { background: var(--bg3); color: var(--text3); }

  .group-label {
    font-family: 'DM Mono', monospace; font-size: 10.5px; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text3); margin: 20px 0 8px;
  }

  /* ── Dashboard ───────────────────────────────────────────────────────── */
  .stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
  .stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
  .stat-value { font-family: 'DM Serif Display', serif; font-size: 30px; line-height: 1.1; }
  .stat-value small { font-size: 16px; color: var(--text2); }
  .stat-label { font-size: 11.5px; color: var(--text2); margin-top: 4px; }

  .dash-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
  .dash-col { display: flex; flex-direction: column; gap: 14px; }

  .area-bar-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
  .area-bar-name { display: flex; align-items: center; gap: 7px; width: 150px; min-width: 0; font-size: 13px; }
  .area-bar-name span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bar-track { flex: 1; height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
  .bar-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
  .area-bar-val { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text2); min-width: 92px; text-align: right; }

  .cal-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
  .cal-cell {
    aspect-ratio: 1; border-radius: 5px; background: var(--bg3);
    display: flex; align-items: center; justify-content: center;
    font-size: 9.5px; font-family: 'DM Mono', monospace; color: var(--text3);
  }
  .cal-cell.partial { background: var(--good-dim); color: var(--good); }
  .cal-cell.full { background: var(--good); color: #fff; }
  .cal-cell.today { outline: 2px solid var(--accent); outline-offset: 1px; }
  .cal-legend { display: flex; gap: 14px; margin-top: 12px; font-size: 11px; color: var(--text2); }
  .cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
  .cal-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

  .glance-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
  .glance-row:last-child { border-bottom: none; }
  .glance-status { font-family: 'DM Mono', monospace; font-size: 11px; margin-left: auto; white-space: nowrap; }

  .recent-row { padding: 9px 0; border-bottom: 1px solid var(--border); }
  .recent-row:last-child { border-bottom: none; }
  .recent-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
  .recent-meta { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text2); margin-left: auto; }
  .level-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
  .level-full { background: var(--good); }
  .level-partial { background: var(--good-dim); border: 2px solid var(--good); }
  .level-none { background: var(--bg4); }

  /* ── Today ───────────────────────────────────────────────────────────── */
  .today-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
  .today-col { display: flex; flex-direction: column; gap: 16px; }

  .today-task {
    display: flex; align-items: center; gap: 12px; padding: 11px 10px;
    border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent;
    transition: background 0.15s;
  }
  .today-task:hover { background: var(--bg3); }
  .today-task.completed { opacity: 0.6; }
  .today-task.completed .tt-name { text-decoration: line-through; }
  .today-task.skipped { opacity: 0.55; }
  .today-task.skipped .tt-name { text-decoration: line-through; text-decoration-style: dotted; }
  .today-area-group {
    border: 1px solid var(--border); border-left: 3px solid var(--area-color);
    border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 10px;
    background: var(--bg2);
  }
  .today-area-group:last-child { margin-bottom: 0; }
  .today-area-group.priority-focus { box-shadow: 0 0 0 1px var(--area-dim); }
  .today-area-head {
    display: flex; align-items: center; gap: 7px; min-width: 0;
    padding: 7px 10px; background: var(--area-dim); border-bottom: 1px solid var(--border);
  }
  .today-area-icon { width: 18px; text-align: center; flex-shrink: 0; }
  .today-area-name {
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap; font-size: 12.5px; font-weight: 600;
  }
  .today-area-tasks .today-task { border-radius: 0; }
  .today-area-tasks .today-task + .today-task { border-top-color: var(--border); }
  .today-check {
    width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border2);
    display: flex; align-items: center; justify-content: center; font-size: 12px;
    color: transparent; flex-shrink: 0; transition: all 0.15s;
  }
  .today-task.completed .today-check { background: var(--good); border-color: var(--good); color: #fff; }
  .tt-info { flex: 1; min-width: 0; }
  .tt-name { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
  .tt-meta { font-size: 11.5px; color: var(--text2); margin-top: 2px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

  .summary-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); }
  .summary-row:last-child { border-bottom: none; }
  .summary-row .val { font-family: 'DM Mono', monospace; color: var(--text2); }
  .progress-track { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; margin-top: 10px; }
  .progress-fill { height: 100%; background: var(--good); border-radius: 4px; transition: width 0.3s; }

  /* ── Planner ─────────────────────────────────────────────────────────── */
  #page-planner { max-width: none; }
  .planner-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
  .plan-col {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 8px; min-width: 0; min-height: 180px; display: flex; flex-direction: column; box-shadow: var(--shadow);
  }
  .plan-col.today-col-hl { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
  .plan-col.drag-over { background: var(--accent-dim); border-color: var(--accent); }
  .plan-col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; min-width: 0; margin-bottom: 8px; }
  .plan-col-day { font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text2); }
  .plan-col.today-col-hl .plan-col-day { color: var(--accent); font-weight: 500; }
  .plan-col-load { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text3); white-space: nowrap; }
  .plan-col-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
  .plan-card {
    display: flex; align-items: center; gap: 5px; min-width: 0; background: var(--bg3);
    border-radius: var(--radius-sm); padding: 7px 6px; cursor: grab; font-size: 12px;
    border: 1px solid transparent;
  }
  .plan-card:active { cursor: grabbing; }
  .plan-card.dragging { opacity: 0.4; }
  .plan-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .plan-card-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .plan-card .pill { flex-shrink: 0; padding-left: 5px; padding-right: 5px; }
  .plan-card-x { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 13px; padding: 0 2px; }
  .plan-card-x:hover { color: var(--danger); }
  .plan-add {
    margin-top: 8px; background: none; border: 1px dashed var(--border2); border-radius: var(--radius-sm);
    color: var(--text3); font-size: 12px; padding: 6px; cursor: pointer; font-family: 'Outfit', sans-serif;
  }
  .plan-add:hover { color: var(--accent); border-color: var(--accent); }
  .plan-empty { font-size: 11px; color: var(--text3); text-align: center; padding: 14px 4px; }

  .day-chip {
    display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border2);
    font-size: 12px; color: var(--text2); cursor: pointer; user-select: none;
  }
  .day-chip.sel { background: var(--accent); border-color: var(--accent); color: #fff; }

  .pick-row {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px;
    border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent;
  }
  .pick-row:hover { background: var(--bg3); }
  .pick-info { flex: 1; min-width: 0; }
  .pick-name { font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
  .pick-days { font-family: 'DM Mono', monospace; font-size: 10.5px; color: var(--text3); margin-top: 2px; }
  .pick-state { font-size: 11.5px; color: var(--accent); white-space: nowrap; font-weight: 500; }
  .pick-state.on { color: var(--good); }

  /* ── Tasks library ───────────────────────────────────────────────────── */
  .library-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
  .lib-task {
    display: flex; align-items: center; gap: 12px; background: var(--bg2);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px;
    margin-bottom: 8px; box-shadow: var(--shadow);
  }
  .lib-task.archived-row { opacity: 0.62; }
  .lib-info { flex: 1; min-width: 0; }
  .lib-name { font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .lib-desc { font-size: 12px; color: var(--text2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lib-side { text-align: right; flex-shrink: 0; }
  .lib-sched { font-family: 'DM Mono', monospace; font-size: 10.5px; color: var(--text3); margin-top: 2px; }
  .lib-actions { display: flex; gap: 2px; flex-shrink: 0; }

  /* ── Areas ───────────────────────────────────────────────────────────── */
  .areas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
  .area-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border-top: 3px solid var(--border); }
  .area-card-top { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
  .area-swatch {
    width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center;
    justify-content: center; font-size: 20px; flex-shrink: 0;
  }
  .area-name { font-size: 15px; font-weight: 600; }
  .area-stat { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text2); padding: 4px 0; }
  .area-stat .val { font-family: 'DM Mono', monospace; }
  .area-actions { display: flex; gap: 6px; margin-top: 10px; }

  .color-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
  .color-swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
  .color-swatch.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg2) inset; }

  /* ── History ─────────────────────────────────────────────────────────── */
  .hist-row {
    display: flex; align-items: center; gap: 11px; background: var(--bg2);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 15px;
    margin-bottom: 7px; cursor: pointer; box-shadow: var(--shadow);
  }
  .hist-date { font-size: 13.5px; font-weight: 500; min-width: 150px; }
  .hist-sum { font-size: 12.5px; color: var(--text2); flex: 1; }
  .hist-detail {
    background: var(--bg3); border-radius: var(--radius); padding: 13px 15px;
    margin: -3px 0 8px; font-size: 12.5px; color: var(--text2); line-height: 1.7;
  }
  .hist-detail b { color: var(--text); font-weight: 600; }

  /* ── Sync ────────────────────────────────────────────────────────────── */
  .sync-dot {
    width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
    background: var(--bg4); border: 1px solid var(--border2); display: inline-block;
  }
  .sync-dot.ok { background: var(--good); border-color: var(--good); }
  .sync-dot.warn { background: var(--warn); border-color: var(--warn); }
  .sync-dot.err { background: var(--danger); border-color: var(--danger); }
  .sync-status-line { font-size: 12.5px; color: var(--text2); margin: 4px 0 14px; }
  .sync-note { font-size: 12.5px; color: var(--text2); line-height: 1.6; }
  .sync-account-row { font-size: 13px; color: var(--text2); padding: 3px 0; }

  /* ── Modals / toast ──────────────────────────────────────────────────── */
  .modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(43,38,32,0.45);
    z-index: 100; align-items: center; justify-content: center; padding: 18px;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: var(--bg2); border-radius: 14px; padding: 22px; width: 100%;
    max-width: 460px; max-height: 88vh; overflow-y: auto; box-shadow: 0 12px 44px rgba(48,42,34,0.25);
  }
  .modal-title { font-family: 'DM Serif Display', serif; font-size: 20px; margin-bottom: 6px; }
  .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

  /* ── Mobile ──────────────────────────────────────────────────────────── */
  .topbar {
    display: none; position: fixed; top: 0; left: 0; right: 0; height: 52px;
    background: var(--bg2); border-bottom: 1px solid var(--border); z-index: 50;
    align-items: center; gap: 12px; padding: 0 14px;
  }
  .hamburger { background: none; border: none; font-size: 20px; color: var(--text); cursor: pointer; padding: 6px; }
  .topbar-title { font-family: 'DM Serif Display', serif; font-size: 16px; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(43,38,32,0.35); z-index: 39; }
  .scrim.open { display: block; }

  @media (max-width: 940px) {
    .topbar { display: flex; }
    .app { height: auto; }
    .sidebar {
      position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-100%);
      transition: transform 0.2s ease; box-shadow: 0 0 30px rgba(48,42,34,0.2);
    }
    .sidebar.open { transform: translateX(0); }
    .main { height: auto; padding-top: 52px; }
    .page { padding: 20px 16px 90px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-grid, .today-grid { grid-template-columns: 1fr; }
    .planner-week { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; gap: 0; }
    .cal-grid { grid-template-columns: repeat(10, 1fr); }
  }
  @media (min-width: 941px) and (max-width: 1180px) {
    .plan-card .pill { display: none; }
  }
  @media (max-width: 520px) {
    .planner-week { grid-template-columns: 1fr; }
    .hist-date { min-width: 110px; }
  }

  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 4px; }
