@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --accent: #3f6bc7;
  --page-bg: #faf9f6;
  --surface: #ffffff;
  --input-bg: #ffffff;
  --text: #1f1e1b;
  --muted: #6f6c64;
  --faint: #a3a097;
  --faint2: #bcb9b0;
  --card-border: #ecebe4;
  --divider: #f2f1ec;
  --task-bg: #fbfaf7;
  --btn-border: #e2e0d8;
  --btn-bg: #ffffff;
  --btn-text: #5c594f;
  --chip-bg: #f1f0ea;
  --chip-text: #5c594f;
  --overlay: rgba(28, 27, 25, 0.34);
  --shadow: 0 24px 60px rgba(28, 27, 25, 0.22);
  --check-fill: #1c1b19;
  --check-mark: #ffffff;
  --box-bg: #ffffff;
  --box-border: #d6d3ca;
  --muted-done: #a8a59c;
  --muted-skip: #b4b1a8;
  --done-green: #2f7d51;
  --skip-grey: #8a8880;
}

body.dark {
  --page-bg: #171613;
  --surface: #211f1b;
  --input-bg: #1b1a16;
  --text: #ece9e2;
  --muted: #a8a49a;
  --faint: #7a766d;
  --faint2: #8a867d;
  --card-border: #302d28;
  --divider: #2a2823;
  --task-bg: #1b1a16;
  --btn-border: #38352f;
  --btn-bg: #26241f;
  --btn-text: #c9c5bc;
  --chip-bg: #2a2823;
  --chip-text: #c9c5bc;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  --check-fill: #ece9e2;
  --check-mark: #171613;
  --box-bg: #1b1a16;
  --box-border: #45413a;
  --muted-done: #6f6b62;
  --muted-skip: #6f6b62;
  --done-green: #3a9463;
}

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

body {
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font-family: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif;
  padding: 36px 40px 60px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, button { font-family: inherit; }
input:focus, textarea:focus { outline: none; }

.mono { font-family: 'IBM Plex Mono', monospace; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-text);
  border-radius: 8px; padding: 7px 13px; font-size: 12.5px; font-weight: 500; cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn-accent {
  border: none; background: var(--accent); color: #fff; border-radius: 7px;
  font-size: 12px; font-weight: 500; padding: 5px 11px; cursor: pointer;
}

/* Header */
.wp-header {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap;
  margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--card-border);
}
.wp-eyebrow {
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--faint); font-weight: 500; margin-bottom: 8px;
}
.wp-year-row { display: flex; align-items: flex-end; gap: 14px; }
.wp-year { font-size: 44px; font-weight: 600; letter-spacing: -0.02em; line-height: 0.9; }
.wp-year-nav { font-size: 12px; color: var(--faint2); padding-bottom: 6px; }
.wp-year-nav a { color: inherit; }
.wp-year-nav a:hover { color: var(--text); text-decoration: none; }
.wp-year-nav-disabled { color: var(--faint2); opacity: 0.6; cursor: default; }
.wp-header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Layout */
.layout { display: flex; gap: 18px; align-items: stretch; min-width: 1500px; }

.sidebar { width: 272px; flex: none; position: relative; min-height: 400px; }
.sidebar.sidebar-right { width: 290px; }
.sidebar-inner {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--card-border); border-radius: 12px;
  padding: 15px 13px 16px;
}
.sidebar-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--divider);
}
.sidebar-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.sidebar-body { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -13px; padding: 0 13px; }
.empty-hint { font-size: 12.5px; color: var(--faint2); padding: 14px 4px; }

.kw-groups { display: flex; flex-direction: column; gap: 12px; }
.kw-heading-row { display: flex; align-items: baseline; gap: 7px; margin-bottom: 4px; }
.kw-heading { font-size: 12px; font-weight: 500; color: var(--text); }
.kw-range { font-size: 10px; color: var(--faint2); }
.kw-tasks {
  display: flex; flex-direction: column; gap: 5px;
  padding-left: 12px; border-left: 1px solid var(--divider);
}

.task-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 5px 6px; border-radius: 7px; background: var(--task-bg);
}
.task-item-row { display: flex; align-items: center; gap: 7px; }
.task-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; }
.task-title { font-size: 13px; font-weight: 500; line-height: 1.25; }
.task-title.done { color: var(--muted-done); text-decoration: line-through; }
.task-title.skipped { color: var(--muted-skip); text-decoration: line-through; font-style: italic; }
.task-note { font-size: 11px; color: var(--faint2); padding-left: 14px; line-height: 1.3; }
.task-actions { display: flex; gap: 4px; padding-left: 14px; margin-top: 1px; }
.task-actions form { display: inline; margin: 0; }

.btn-mini {
  border: none; border-radius: 5px; font-size: 10.5px; font-weight: 500;
  padding: 3px 8px; cursor: pointer; background: var(--chip-bg); color: var(--chip-text);
}
.btn-mini.done-on { background: var(--done-green); color: #fff; }
.btn-mini.skip-on { background: var(--skip-grey); color: #fff; }
.btn-edit {
  border: 1px solid var(--btn-border); border-radius: 5px; font-size: 10.5px; font-weight: 500;
  padding: 2px 8px; cursor: pointer; background: var(--btn-bg); color: var(--muted);
}

/* Month grid */
.month-grid { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.month-card {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: 12px;
  padding: 13px 11px 8px; display: flex; flex-direction: column;
}
.month-card.selected { border-color: var(--accent); }
.month-head {
  all: unset; cursor: pointer; display: flex; align-items: baseline; justify-content: space-between;
  gap: 6px; padding-bottom: 9px; margin-bottom: 5px; border-bottom: 2px solid var(--divider); width: 100%;
}
.month-card.selected .month-head { border-bottom-color: var(--accent); }
.month-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.month-card.selected .month-name { color: color-mix(in oklab, var(--accent) 82%, var(--text)); }

.week-cell {
  border-left: 2px solid transparent; border-radius: 0 6px 6px 0;
  padding: 6px 8px 6px 9px; margin-bottom: 2px;
}
.week-cell.current { border-left-color: var(--accent); background: color-mix(in oklab, var(--accent) 14%, var(--surface)); }
.week-cell-head { display: flex; align-items: baseline; gap: 7px; }
.week-kw { font-size: 11px; font-weight: 500; }
.week-cell.current .week-kw { color: color-mix(in oklab, var(--accent) 70%, var(--text)); }
.week-range { font-size: 10px; color: var(--faint2); }

.cell-task { display: flex; align-items: flex-start; gap: 7px; margin-top: 6px; }
.cell-task.skipped { opacity: 0.6; }
.cell-check {
  flex: none; width: 14px; height: 14px; margin-top: 1px; border: 1.5px solid var(--box-border);
  background: var(--box-bg); border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: var(--check-mark); line-height: 1;
}
.cell-check.done { background: var(--check-fill); border-color: var(--check-fill); }
.cell-task-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cell-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; }
.cell-title { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-title.done, .cell-title.skipped { color: var(--muted-done); text-decoration: line-through; }
.cell-note {
  font-size: 11px; color: var(--faint2); margin-top: 1px; padding-left: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Legend */
.legend-block { border-top: 1px solid var(--card-border); margin-top: 26px; padding-top: 18px; }
.legend-list { display: flex; gap: 26px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 9px; }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; }
.legend-name { font-size: 13.5px; font-weight: 500; }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50;
}
.modal-card {
  width: 440px; max-width: 100%; background: var(--surface); border-radius: 14px;
  box-shadow: var(--shadow); padding: 22px 22px 20px;
}
.modal-card.wide { width: 480px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.modal-close { all: unset; cursor: pointer; color: var(--faint); font-size: 20px; line-height: 1; padding: 0 4px; }

.field-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.text-input, .textarea-input {
  width: 100%; border: 1px solid var(--btn-border); background: var(--input-bg); border-radius: 8px;
  padding: 9px 11px; font-size: 14px; color: var(--text); margin-bottom: 16px;
}
.textarea-input { height: 70px; resize: vertical; font-size: 13.5px; line-height: 1.4; margin-bottom: 20px; }

.chip-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 16px; }
.chip-input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--btn-border);
  background: var(--input-bg); border-radius: 8px; padding: 6px 11px; cursor: pointer;
  font-size: 12.5px; font-weight: 500; color: var(--text);
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--chip-color, currentColor); }
.chip-input:checked + .chip { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, var(--surface)); }
.chip-input:focus-visible + .chip { outline: 2px solid var(--accent); outline-offset: 1px; }

.kw-field-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.kw-stepper { position: relative; display: inline-flex; }
.kw-input {
  width: 90px; border: 1px solid var(--btn-border); background: var(--input-bg); border-radius: 8px;
  padding: 9px 22px 9px 11px; font-size: 14px; color: var(--text);
}
/* Hide the native spinner: it silently refuses to step past min/max with
   no event firing, so wraparound can only be driven by our own buttons. */
.kw-input::-webkit-inner-spin-button, .kw-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.kw-input { -moz-appearance: textfield; }
.kw-stepper-buttons {
  position: absolute; right: 4px; top: 0; bottom: 0;
  display: flex; flex-direction: column; justify-content: center;
}
.kw-step-btn {
  all: unset; cursor: pointer; line-height: 1; font-size: 7px; color: var(--faint);
  padding: 2px 4px;
}
.kw-step-btn:hover { color: var(--text); }
.kw-field-hint { font-size: 12.5px; color: var(--muted); }

.modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-actions form { margin: 0; }
.modal-actions-right { display: flex; gap: 9px; margin-left: auto; }
.btn-delete { border: none; background: none; color: #c0554a; font-size: 12.5px; font-weight: 500; cursor: pointer; padding: 8px 2px; }
.btn-cancel {
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-text);
  border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn-save { border: none; background: var(--accent); color: #fff; border-radius: 8px; padding: 9px 18px; font-size: 13px; font-weight: 600; cursor: pointer; }

.settings-subtitle { font-size: 11.5px; color: var(--faint2); margin-bottom: 8px; }
.darkmode-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; margin-bottom: 6px; border-bottom: 1px solid var(--divider);
}
.darkmode-label { font-size: 13.5px; font-weight: 500; }
.darkmode-desc { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.toggle-switch {
  flex: none; width: 46px; height: 26px; border-radius: 13px; border: none; cursor: pointer;
  background: #d6d3ca; position: relative; padding: 0;
}
.toggle-switch.on { background: var(--accent); }
.toggle-knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: left 0.15s;
}
.toggle-switch.on .toggle-knob { left: 23px; }

.cat-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--divider); }
.cat-row-form { display: flex; align-items: center; gap: 12px; flex: 1; }
.cat-name-input {
  width: 150px; flex: none; border: 1px solid var(--btn-border); background: var(--input-bg);
  border-radius: 7px; padding: 8px 10px; font-size: 13.5px; color: var(--text);
}
.swatch-row { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.swatch-input { position: absolute; opacity: 0; width: 0; height: 0; }
.swatch {
  display: inline-block; width: 20px; height: 20px; border-radius: 50%;
  background: var(--swatch-color); border: 2px solid var(--surface); cursor: pointer;
}
.swatch-input:checked + .swatch { outline: 2px solid var(--text); outline-offset: 1px; }
.cat-save {
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-text);
  border-radius: 6px; padding: 6px 10px; font-size: 12px; cursor: pointer;
}
.cat-delete { all: unset; cursor: pointer; color: #c0554a; font-size: 18px; line-height: 1; padding: 0 4px; }

.settings-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--divider);
}
.btn-add-cat {
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-text);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn-done-settings { border: none; background: var(--accent); color: #fff; border-radius: 8px; padding: 9px 18px; font-size: 13px; font-weight: 600; cursor: pointer; }
