/* =========================================================
   Study Planner — design tokens
   Modern · Minimal · Soft & Friendly
   ========================================================= */
:root {
  --bg: #faf8f6;
  --sidebar: #f5f2ef;
  --surface: #ffffff;
  --surface-2: #f7f5f3;
  --hover: #f6f3f1;
  --border: #ece8e4;
  --border-strong: #ddd7d2;

  --text: #2c2a28;
  --text-2: #6e6964;
  --text-3: #a39d97;

  --accent: #dc8ea3;
  --accent-strong: #c9718a;
  --accent-soft: #fbecf0;
  --accent-softer: #fdf5f7;

  --danger: #cf6b62;
  --danger-soft: #fbeceb;
  --warn: #c98b33;
  --warn-soft: #fbf3e6;

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(60, 40, 40, 0.04);
  --shadow-pop: 0 8px 28px rgba(60, 40, 40, 0.12), 0 1px 3px rgba(60, 40, 40, 0.06);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
    'Noto Sans JP', 'Helvetica Neue', sans-serif;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.icon { flex: none; display: block; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }

/* ---------- Layout ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.main { flex: 1; min-width: 0; overflow: auto; padding: 20px 24px; }

/* ---------- Sidebar ---------- */
:root { --sidebar-w: 216px; --ease: cubic-bezier(.32, .72, 0, 1); }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--sidebar);
  border-right: 1px solid var(--border); overflow: hidden;
  transition: width .28s var(--ease), border-color .28s var(--ease);
}
.sidebar-inner {
  width: var(--sidebar-w); height: 100%; display: flex; flex-direction: column;
  padding: 18px 12px 14px; overflow-y: auto; transition: opacity .2s ease, transform .28s var(--ease);
}
.app.sidebar-hidden .sidebar { width: 0; border-right-width: 0; }
.app.sidebar-hidden .sidebar-inner { opacity: 0; transform: translateX(-24px); }
.main { transition: padding-left .28s var(--ease); }
.app.sidebar-hidden .main { padding-left: 60px; }
.app.no-anim .sidebar, .app.no-anim .sidebar-inner, .app.no-anim .main,
.app.no-anim .subject-collapse { transition: none; }

.sidebar-toggle {
  position: fixed; top: 15px; left: 14px; z-index: 20; width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: grid; place-items: center; border: 1px solid transparent; background: transparent; color: var(--text-2);
  transition: background .15s, border-color .15s, color .15s;
}
.sidebar-toggle:hover { background: var(--hover); color: var(--text); }
.app.sidebar-hidden .sidebar-toggle { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.app.sidebar-hidden .sidebar-toggle:hover { color: var(--accent-strong); border-color: var(--accent); }

.brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px 18px 38px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-size: 13px;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 500; }
.nav-item .soon { margin-left: auto; font-size: 10px; color: var(--text-3); }

.side-section { margin-top: 22px; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 6px 10px; color: var(--text-3); font-size: 11.5px; font-weight: 500; letter-spacing: .02em;
}
.side-head-toggle {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 3px 6px;
  margin-left: -6px; border-radius: 6px; color: inherit; font: inherit; letter-spacing: inherit;
}
.side-head-toggle:hover { background: var(--hover); color: var(--text-2); }
.side-head-toggle .chev { transition: transform .22s var(--ease); }
.subjects-collapsed .side-head-toggle .chev { transform: rotate(-90deg); }
/* Animate height via grid rows (0fr ↔ 1fr) so no fixed max-height is needed. */
.subject-collapse { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .25s var(--ease), opacity .2s ease; }
.subject-collapse > .subject-list { min-height: 0; overflow: hidden; }
.subjects-collapsed .subject-collapse { grid-template-rows: 0fr; opacity: 0; }
.subject-list { display: flex; flex-direction: column; gap: 1px; }
.subject-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 6px 6px 10px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text); border: 1px solid transparent;
}
.subject-item:hover { background: var(--hover); }
.subject-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-item .count { color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.subject-item .edit { opacity: 0; }
.subject-item:hover .edit { opacity: 1; }
.subject-item:hover .count { display: none; }
.subject-item.drop-target { background: var(--accent-softer); border-color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--dot, var(--text-3)); }
.side-foot { margin-top: auto; padding: 16px 10px 0; color: var(--text-3); font-size: 11px; line-height: 1.6; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); }
.btn-ghost-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-ghost-danger:hover { background: var(--danger-soft); }
.icon-btn {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  border: 0; background: transparent; color: var(--text-3);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.page-bank { max-width: 860px; }
.bank { padding: 20px 20px 24px; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h1 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.panel-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 180px; display: flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-3);
}
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; outline: 0; flex: 1; min-width: 0; background: transparent; color: var(--text); }
.select {
  height: 32px; padding: 0 28px 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a39d97' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center;
  appearance: none; -webkit-appearance: none; color: var(--text-2);
}
.select:focus { border-color: var(--accent); outline: 0; }

.bank-stats { display: flex; gap: 16px; color: var(--text-3); font-size: 12px; margin: -4px 2px 12px; }
.bank-stats b { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- Task groups ---------- */
.bank-groups { display: flex; flex-direction: column; gap: 14px; }
.group { border-radius: var(--radius); }
.group-head {
  display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 8px 0 12px;
  background: var(--tint); border-radius: 10px; cursor: pointer; user-select: none;
  border: 1px solid transparent;
}
.group-head .name { font-weight: 600; font-size: 13.5px; }
.group-head .meta { margin-left: auto; color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; display: flex; gap: 10px; }
.group-head .chev { color: var(--text-3); transition: transform .15s; }
.group.collapsed .chev { transform: rotate(-90deg); }
.group.collapsed .group-body { display: none; }
.group.drop-into .group-head { border-color: var(--accent); }
.group.drop-into .group-body { background: var(--accent-softer); border-radius: 0 0 10px 10px; }
.group-body { padding: 2px 0 0; }

.task-row {
  position: relative; display: grid; align-items: center; gap: 10px;
  grid-template-columns: 18px minmax(0, 1fr) auto 52px 42px 24px;
  min-height: 34px; padding: 4px 4px 4px 10px; border-bottom: 1px solid var(--border);
  cursor: grab; background: var(--surface);
}
.task-row:hover { background: var(--hover); }
.task-row:hover .more { opacity: 1; }
.task-row.dragging { opacity: .4; }
.task-row.drop-before::before, .task-row.drop-after::after {
  content: ''; position: absolute; left: 6px; right: 6px; height: 2px; border-radius: 2px; background: var(--accent);
}
.task-row.drop-before::before { top: -1px; }
.task-row.drop-after::after { bottom: -1px; }

.check {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-strong);
  background: var(--surface); padding: 0; display: grid; place-items: center; color: transparent;
}
.check:hover { border-color: var(--accent); }
.check.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.task-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.task-title .text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-title .icon { color: var(--text-3); flex: none; }
.plan-dot { display: none; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.task-row.done .plan-dot { background: var(--border-strong); }
.task-row.done .task-title .text { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); }

.pill {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 999px;
  font-size: 11px; color: var(--text-2); background: var(--surface-2); white-space: nowrap;
}
.pill.planned-date { background: var(--accent-softer); color: var(--accent-strong); }
.deadline, .est { font-size: 12px; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.deadline.none, .est.none { color: var(--border-strong); }
.deadline.soon { color: var(--warn); font-weight: 500; }
.deadline.overdue { color: var(--danger); font-weight: 500; }
.task-row.done .deadline, .task-row.done .est { color: var(--text-3); font-weight: 400; }
.more { opacity: 0; }

.quick-add { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; color: var(--text-3); }
.quick-add button { border: 0; background: transparent; color: var(--text-3); display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.quick-add button:hover { color: var(--accent-strong); }
.quick-add input {
  flex: 1; height: 28px; border: 1px solid var(--accent); border-radius: 7px; padding: 0 9px; outline: 0; color: var(--text);
}
.quick-hint { font-size: 11px; color: var(--text-3); white-space: nowrap; }

.empty {
  padding: 36px 16px; text-align: center; color: var(--text-3); border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty p { margin: 0 0 12px; }

/* Bank as the planner side panel */
.bank.compact { padding: 16px 14px 20px; }
.bank.compact .panel-sub { display: none; }
.bank.compact .panel-head h1 { font-size: 18px; }
.bank.compact .bank-stats { gap: 10px; flex-wrap: wrap; }
.bank.compact .task-row { gap: 7px; grid-template-columns: 18px minmax(0, 1fr) auto 40px 36px 22px; padding-left: 8px; }

/* Narrow Task Bank → compact rows. Measured on the panel itself (container
   query), so it follows the split-view resize, not the window width. */
.bank { container: bank / inline-size; }
@container bank (max-width: 440px) {
  .bank .group .task-row { grid-template-columns: 18px minmax(0, 1fr) 22px; gap: 8px; }
  .bank .group .task-row .plan-cell,
  .bank .group .task-row .deadline,
  .bank .group .task-row .est,
  .bank .group .task-title .icon { display: none; }
  .bank .group .plan-dot { display: block; }
}
.unplan-hint {
  display: none; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; padding: 14px;
  border: 1.5px dashed var(--accent); border-radius: var(--radius); color: var(--accent-strong); background: var(--accent-softer);
}
.bank.drop-unplan { border-color: var(--accent); background: var(--accent-softer); }
.bank.drop-unplan .unplan-hint { display: flex; }

/* ---------- Long-term Planner ---------- */
.page-planner { --handle: 16px; --bank-ratio: .35; display: flex; height: calc(100vh - 40px); }
.page-planner.bank-right { flex-direction: row-reverse; }
/* Bank takes its ratio of the width but shrinks first, so the calendar
   always keeps its min-width when the window gets narrow. */
.planner-bank { flex: 0 1 calc((100% - var(--handle)) * var(--bank-ratio)); min-width: 240px; min-height: 0; }
.planner-bank .bank { height: 100%; overflow-y: auto; }
.planner-cal { flex: 1 1 0; min-width: 480px; min-height: 0; }

.split-handle { flex: none; width: var(--handle); position: relative; cursor: col-resize; touch-action: none; }
.split-handle:focus-visible { outline: none; }
.split-handle::before {
  content: ''; position: absolute; top: 14px; bottom: 14px; left: 50%; width: 2px; margin-left: -1px;
  border-radius: 2px; background: var(--border); transition: background .15s, width .15s, margin-left .15s;
}
.split-handle:hover::before, .split-handle.active::before, .split-handle:focus-visible::before {
  width: 4px; margin-left: -2px; background: #eebccb;
}
body.is-resizing, body.is-resizing * { cursor: col-resize !important; user-select: none !important; }

.calendar { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.cal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cal-nav { display: flex; gap: 2px; }
.cal-title { margin: 0; font-size: 19px; font-weight: 600; min-width: 130px; }
.cal-legend { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 11.5px; margin-right: 6px; }
.legend-chip { width: 14px; height: 9px; border-radius: 3px; background: var(--accent-soft); border-left: 2px solid var(--accent); }
.legend-flag { color: var(--danger); margin-left: 8px; }
.cal-scroll { flex: 1; overflow-y: auto; position: relative; }

.cal-dow, .week-row { display: grid; --slot: 168px; }
.cal-dow.side-left, .week-row.side-left { grid-template-columns: var(--slot) repeat(7, minmax(0, 1fr)); }
.cal-dow.side-right, .week-row.side-right { grid-template-columns: repeat(7, minmax(0, 1fr)) var(--slot); }
.cal-dow {
  position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-3); text-align: center;
}
.cal-dow > div { padding: 7px 0; }
.cal-dow .weekend { color: var(--accent); }
.cal-dow .dow-slot { color: var(--text-2); font-weight: 500; background: var(--surface-2); }

.week-row { min-height: 104px; border-bottom: 1px solid var(--border); }
.day {
  min-width: 0; padding: 5px 5px 6px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px;
  background: var(--surface);
}
.week-row.side-right .day:first-child { border-left: 0; }
.day.alt-month { background: #fcfbf9; }
.day.month-first-week { box-shadow: inset 0 2px 0 var(--border-strong); }
.day.month-first-day { box-shadow: inset 0 2px 0 var(--border-strong), inset 2px 0 0 var(--border-strong); }
.day-num { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; padding: 1px 3px; display: flex; gap: 5px; align-items: baseline; }
.day.weekend .day-num { color: var(--accent); }
.day.past .day-num { color: var(--text-3); }
.month-label { font-weight: 600; color: var(--text); }
.day.today { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-softer); }
.day.today .day-num {
  align-self: flex-start; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-weight: 500;
}

.cal-chip {
  font-size: 11px; line-height: 1.35; padding: 2px 6px; border-radius: 5px; background: var(--tint);
  border-left: 2px solid var(--dot); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: grab;
}
.cal-chip.done { color: var(--text-3); text-decoration: line-through; }
.cal-deadline {
  display: flex; align-items: center; gap: 3px; font-size: 10.5px; color: var(--danger); padding: 0 3px; cursor: pointer;
  min-width: 0;
}
.cal-deadline span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-deadline.done { color: var(--text-3); text-decoration: line-through; }
.day.past .cal-deadline:not(.done) { opacity: .8; }

.week-slot {
  min-width: 0; padding: 6px 6px 8px; background: var(--surface-2); display: flex; flex-direction: column; gap: 3px;
  border: 1px solid transparent;
}
.week-row.side-right .week-slot { border-left-color: var(--border); }
.week-row.side-left .week-slot { border-right-color: var(--border); }
.week-slot.current { background: var(--accent-softer); }
.week-slot.drop-into { background: var(--accent-soft); border: 1px dashed var(--accent); }
.slot-head { display: flex; align-items: baseline; gap: 6px; padding: 1px 3px 3px; font-size: 11px; color: var(--text-3); }
.slot-range {
  font-variant-numeric: tabular-nums; border: 0; background: none; padding: 0; color: inherit; font-size: inherit;
  border-radius: 4px;
}
.slot-range:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.slot-now, .slot-rel { font-size: 10px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; }
.slot-rel { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.slot-total { margin-left: auto; color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.slot-task {
  display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 7px; background: var(--surface); border-radius: 6px;
  border: 1px solid var(--border); font-size: 11.5px; cursor: grab; min-width: 0;
}
.slot-task .dot { width: 7px; height: 7px; }
.slot-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-est { color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.slot-remove { width: 18px; height: 18px; display: none; }
.slot-task:hover .slot-remove { display: inline-grid; }
.slot-task:hover .slot-est { display: none; }
.slot-task.done .slot-title { color: var(--text-3); text-decoration: line-through; }
.slot-empty { font-size: 11px; color: var(--text-3); text-align: center; padding: 10px 0; border: 1px dashed var(--border-strong); border-radius: 6px; margin-top: 2px; }
.slot-note { font-size: 10.5px; color: var(--text-3); padding: 0 3px; }
.dragging { opacity: .4; }

/* ---------- Weekly Planner ---------- */
.page-weekly { max-width: 1040px; display: flex; flex-direction: column; gap: 12px; }
.wk-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wk-head h1 { margin: 0 6px 0 0; font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.wk-nav {
  display: flex; align-items: center; gap: 2px; height: 34px; padding: 0 4px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
}
.wk-range { min-width: 150px; text-align: center; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.btn:disabled { opacity: .45; cursor: default; background: var(--surface); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

.wk-goals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.wk-goal { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; cursor: text; min-width: 0; }
.wk-goal-icon {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong);
}
.wk-goal-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.wk-goal-label { font-size: 12.5px; font-weight: 600; }
.wk-goal input, .wk-message input {
  border: 0; outline: 0; background: transparent; padding: 2px 0; font-size: 12px; color: var(--text-2);
  text-overflow: ellipsis; width: 100%;
}
.wk-goal input.has-inherited::placeholder { color: var(--text-2); opacity: .75; }
.wk-goal:focus-within, .wk-message:focus-within { border-color: var(--accent); }
.wk-message {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--accent-softer);
  border-color: var(--accent-soft); cursor: text;
}
.wk-message input { color: var(--accent-strong); font-size: 13px; }
.wk-message input::placeholder { color: var(--accent-strong); opacity: .8; }
.wk-message-edit { color: var(--accent); opacity: .6; }

.wk-summary { display: flex; gap: 18px; color: var(--text-3); font-size: 12px; padding: 0 4px; }
.wk-summary b { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }

.wk-days { display: flex; flex-direction: column; gap: 8px; }
.wk-day { padding: 10px 14px 12px; border-radius: var(--radius); transition: border-color .12s, background .12s; }
.wk-day.today { border-color: var(--accent); }
.wk-day.past { background: #fdfcfb; }
.wk-day.drop-into, .wk-tray.drop-into { border-color: var(--accent); border-style: dashed; background: var(--accent-softer); }
.wk-day-head { display: flex; align-items: center; gap: 9px; min-width: 0; }
.wk-day-check {
  flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-strong);
  display: grid; place-items: center; color: transparent;
}
.wk-day-check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.wk-day-date { font-size: 15px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wk-dow { font-size: 13px; color: var(--text-2); }
.wk-day.weekend .wk-dow { color: var(--accent); }
.wk-day.past .wk-day-date { color: var(--text-2); }
.wk-day-deadlines {
  display: flex; align-items: center; gap: 3px; min-width: 0; font-size: 11px; color: var(--danger);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wk-cap { display: flex; align-items: center; gap: 12px; flex: none; font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.wk-cap-avail {
  border: 0; background: none; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; color: inherit; font-size: inherit;
}
.wk-cap-avail:hover { background: var(--hover); color: var(--text-2); }
.wk-cap-avail.overridden b { color: var(--accent-strong); }
.wk-cap-calc { margin-left: 3px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.wk-add-event {
  display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px; border-radius: 999px;
  border: 1px solid transparent; background: none; font-size: 11px; color: var(--text-3); opacity: 0; transition: opacity .12s;
}
.wk-day:hover .wk-add-event, .wk-add-event:focus-visible { opacity: 1; }
.wk-add-event:hover { border-color: var(--border); color: var(--text-2); background: var(--surface); }

/* Fixed events: grey, time-first, no checkbox — distinct from task cards */
.wk-events { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 27px; margin-bottom: 6px; }
.wk-event {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 26px; padding: 0 10px 0 8px;
  border: 0; border-left: 3px solid #b8b1ab; border-radius: 6px; background: var(--surface-2);
  font-size: 12px; color: var(--text-2); cursor: pointer;
}
.wk-event:hover { background: #efebe8; }
.wk-event .icon { color: var(--text-3); }
.wk-event-time { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; white-space: nowrap; }
.wk-event-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-event.not-counted { border-left-style: dashed; background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.cal-event {
  display: flex; align-items: center; gap: 3px; min-width: 0; font-size: 10.5px; color: var(--text-2); padding: 1px 4px;
  background: var(--surface-2); border-radius: 4px; cursor: pointer;
}
.cal-event span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event .icon { color: var(--text-3); }

/* Availability editors */
.avail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 6px 0 12px; }
.avail-row { display: flex; align-items: center; gap: 8px; }
.avail-row .input { width: 90px; }
.avail-day { width: 18px; font-weight: 600; }
.avail-row.weekend .avail-day, .avail-summary .weekend em { color: var(--accent); }
.avail-total { font-size: 12px; color: var(--text-2); }
.avail-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.avail-summary span {
  display: inline-flex; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2);
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.avail-summary em { font-style: normal; font-weight: 600; }
.wk-cap b { color: var(--text-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.wk-cap .over { color: var(--danger); }
.wk-bar { height: 3px; border-radius: 3px; background: var(--surface-2); margin: 8px 0 8px 27px; overflow: hidden; }
.wk-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.wk-bar.over span { background: var(--danger); }

.wk-tasks { container-type: inline-size; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding-left: 27px; }
.wk-task {
  display: flex; align-items: center; gap: 7px; min-width: 0; height: 32px; padding: 0 9px 0 7px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: grab;
}
.wk-task:hover { border-color: var(--border-strong); background: var(--hover); }
.wk-task .dot { width: 7px; height: 7px; }
.wk-task-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-task-est { flex: none; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.wk-task.done .wk-task-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.wk-task.done .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.wk-empty {
  grid-column: 1 / -1; font-size: 11.5px; color: var(--text-3); padding: 7px 10px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
@container (max-width: 560px) { .wk-tasks > .wk-task { grid-column: span 3; } }

.wk-tray {
  position: sticky; bottom: 0; z-index: 4; padding: 10px 14px 12px; margin-top: 4px;
  max-height: 36vh; overflow-y: auto; box-shadow: 0 -6px 18px rgba(60, 40, 40, .05);
  border-color: var(--accent-soft);
}
.wk-tray-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.wk-tray-icon {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong);
}
.wk-tray-title { font-weight: 600; font-size: 13px; }
.wk-tray .wk-tasks { padding-left: 0; }

@media (max-width: 900px) {
  .wk-goals { grid-template-columns: 1fr; }
  .wk-day-head { flex-wrap: wrap; }
}

/* Week picker modal */
.picker { display: flex; flex-direction: column; gap: 12px; max-height: 55vh; overflow-y: auto; padding-bottom: 4px; }
.picker-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 12.5px; padding: 0 2px 4px; }
.picker-row {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto 40px; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer;
}
.picker-row:hover { background: var(--hover); }
.picker-row input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.picker-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-meta { display: flex; align-items: center; gap: 3px; justify-content: flex-end; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- Settings page ---------- */
.page-title { font-size: 21px; font-weight: 600; margin: 0 0 16px; }
.settings { max-width: 640px; display: flex; flex-direction: column; gap: 14px; }
.settings .panel { padding: 18px 20px; }
.settings h3 { margin: 0 0 4px; font-size: 14px; }
.settings p { margin: 0 0 12px; color: var(--text-2); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; background: var(--surface-2); }
.seg button { border: 0; background: transparent; height: 26px; padding: 0 14px; border-radius: 6px; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow); font-weight: 500; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.settings .data-note { margin: 10px 0 0; font-size: 11.5px; color: var(--text-3); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(50, 40, 40, 0.18); display: grid; place-items: center;
  z-index: 50; padding: 16px; animation: fade .12s ease-out;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  max-height: calc(100vh - 32px); display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px 20px; }
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 8px 20px 4px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px 18px; }
.confirm-text { margin: 0 0 6px; color: var(--text-2); white-space: pre-line; }
@keyframes fade { from { opacity: 0; } }

/* ---------- Forms ---------- */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .field-label { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 11px; color: var(--text-3); }
.field .warn-text { font-size: 11px; color: var(--warn); }
.input, .textarea, .field .select {
  width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background-color: var(--surface); outline: 0;
}
.field .select { padding-right: 28px; color: var(--text); }
.input:focus, .textarea:focus, .field .select:focus { border-color: var(--accent); }
.input.title-input { height: 38px; font-size: 14px; }
.input.invalid { border-color: var(--danger); }
.textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.with-clear { display: flex; gap: 6px; align-items: center; }
.with-clear .input { flex: 1; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: 11.5px; color: var(--text-2);
}
.chip:hover { border-color: var(--accent); color: var(--accent-strong); }
.hours { display: flex; align-items: center; gap: 6px; }
.hours .input { width: 90px; }
.checkline { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-2); }
.checkline input { accent-color: var(--accent); width: 15px; height: 15px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; padding: 3px; background: none;
}
.swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--dot); }
.swatch.on { border-color: var(--dot); }

/* ---------- Menu & toast ---------- */
.menu {
  position: fixed; z-index: 60; min-width: 168px; padding: 5px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-pop);
}
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 9px; border: 0; background: transparent;
  border-radius: 6px; text-align: left; color: var(--text); font-size: 13px;
}
.menu-item .icon { color: var(--text-3); }
.menu-item:hover, .menu-item:focus { background: var(--hover); outline: 0; }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px; border-radius: 12px;
  background: #3a3532; color: #fff; box-shadow: var(--shadow-pop); animation: fade .15s ease-out;
}
.toast-action {
  display: flex; align-items: center; gap: 5px; border: 0; background: rgba(255, 255, 255, .12); color: #fff;
  height: 26px; padding: 0 10px; border-radius: 7px;
}
.toast-action:hover { background: rgba(255, 255, 255, .2); }

@media (max-width: 720px) {
  .sidebar, .sidebar-toggle { display: none; }
  .main, .app.sidebar-hidden .main { padding: 12px 16px; }
  .task-row { grid-template-columns: 18px minmax(0, 1fr) 46px 38px 24px; }
  .task-row .plan-cell { display: none; }
  .form { grid-template-columns: 1fr; }
}
