:root {
  color-scheme: light;
  --bg: #eef3ef;
  --panel: #fbfcf8;
  --panel-2: #f3f7f3;
  --text: #172421;
  --muted: #60716b;
  --line: #d6e1da;
  --accent: #32746d;
  --accent-strong: #1f5f58;
  --warn: #b94848;
  --shadow: 0 18px 55px rgba(28, 43, 38, .16);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(255,255,255,.45) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(rgba(255,255,255,.38) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--bg);
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 750;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr minmax(270px, 340px);
}

.app.editor-collapsed {
  grid-template-columns: minmax(220px, 280px) 1fr 52px;
}

.left-panel, .right-panel {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(12px);
  border-color: var(--line);
  padding: 22px;
  overflow: auto;
}

.left-panel {
  border-right: 1px solid var(--line);
}

.right-panel {
  border-left: 1px solid var(--line);
}

.brand-block, .panel-header, .panel-actions, .month-controls, .topbar, .topbar-actions, .form-actions, .two-col, .check-row {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  color: white;
  text-align: center;
  text-transform: uppercase;
  font-weight: 850;
  font-size: 15px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.24), transparent 55%),
    var(--accent);
  box-shadow: var(--shadow);
}

.brand-mark:focus {
  border: 0;
  box-shadow:
    var(--shadow),
    0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 19px;
}

h2 {
  font-size: 22px;
}

.brand-block p, .eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.month-controls {
  gap: 10px;
}

.month-title {
  flex: 1;
  text-align: center;
  font-weight: 850;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel);
  font-size: 24px;
}

.primary-action, .ghost-action, .danger-action {
  min-height: 39px;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 800;
}

.primary-action {
  color: #fff;
  background: var(--accent);
}

.primary-action:hover {
  background: var(--accent-strong);
}

.ghost-action {
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--panel);
}

.danger-action {
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line));
  background: color-mix(in srgb, var(--warn) 8%, var(--panel));
}

#todayBtn {
  width: 100%;
  margin: 16px 0 20px;
}

.mini-section {
  margin: 18px 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  background: var(--panel-2);
}

.segmented button {
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented button.active {
  color: #fff;
  background: var(--accent);
}

.swatches {
  display: flex;
  gap: 9px;
}

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
}

.swatch.active {
  border-color: var(--text);
}

.swatch.spruce { background: linear-gradient(135deg, #32746d, #eef3ef); }
.swatch.ink { background: linear-gradient(135deg, #2c3440, #d8dee8); }
.swatch.dark-purple { background: linear-gradient(135deg, #7b5aa6, #e8e2ee); }
.swatch.rosewood { background: linear-gradient(135deg, #8d4f5f, #f4ecee); }
.swatch.daylight { background: linear-gradient(135deg, #d29a28, #f7f6ed); }

.filter-list {
  display: grid;
  gap: 7px;
}

.filter-list label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-transform: none;
  letter-spacing: 0;
}

.filter-list input {
  width: 16px;
  height: 16px;
}

.workspace {
  min-width: 0;
  padding: 24px;
  overflow: auto;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h2 {
  font-size: clamp(26px, 4vw, 42px);
}

.topbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#importFile {
  display: none;
}

.sticky-board {
  position: relative;
  min-height: 190px;
  margin-bottom: 18px;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255,255,255,.34) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(255,255,255,.28) 1px, transparent 1px) 0 0 / 28px 28px,
    color-mix(in srgb, var(--panel) 55%, transparent);
  overflow: hidden;
}

.sticky-note {
  position: absolute;
  width: 210px;
  min-height: 142px;
  resize: both;
  overflow: auto;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(90, 76, 35, .18);
  border-radius: 6px;
  background: #fff2a8;
  color: #2f2a18;
  box-shadow: 0 14px 28px rgba(41, 36, 20, .18);
}

.sticky-note.dragging {
  z-index: 20;
  box-shadow: 0 18px 42px rgba(41, 36, 20, .24);
}

.sticky-note:focus-within {
  z-index: 30;
}

.sticky-note-new {
  background: color-mix(in srgb, var(--panel) 88%, white);
  border-style: dashed;
  color: var(--muted);
  box-shadow: none;
}

.sticky-note-new .sticky-text::placeholder {
  color: color-mix(in srgb, var(--muted) 78%, transparent);
}

.sticky-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 6px 7px 4px 10px;
  cursor: grab;
}

.sticky-note.dragging .sticky-bar {
  cursor: grabbing;
}

.sticky-date {
  font-size: 11px;
  font-weight: 850;
  color: rgba(47, 42, 24, .62);
}

.sticky-tools {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sticky-color {
  width: 20px;
  height: 20px;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 50%;
  padding: 0;
  background: transparent;
}

.sticky-delete {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: rgba(47, 42, 24, .8);
  background: rgba(255,255,255,.42);
  font-size: 18px;
  line-height: 1;
}

.sticky-text {
  flex: 1;
  min-height: 96px;
  width: 100%;
  border: 0;
  border-radius: 0 0 6px 6px;
  padding: 2px 13px 13px;
  background: transparent;
  color: inherit;
  resize: none;
  box-shadow: none;
}

.backup-reminder {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

.backup-reminder span {
  color: var(--muted);
  font-size: 13px;
}

.small-icon {
  width: 30px;
  height: 30px;
  font-size: 18px;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-header h2 {
  font-size: 18px;
}

.section-header span {
  color: var(--muted);
  font-size: 13px;
}

.sticky-text:focus {
  border: 0;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.46);
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 8px;
}

.week-day {
  min-height: 460px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: 0 8px 24px rgba(32, 43, 39, .08);
}

.week-day h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.weekday-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 8px;
}

.day-cell {
  min-height: 138px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: 0 8px 24px rgba(32, 43, 39, .08);
}

.day-cell.outside {
  opacity: .48;
}

.day-cell.today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.day-cell.dragging {
  outline: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

.day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.day-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 850;
}

.today .day-number {
  color: white;
  background: var(--accent);
}

.add-day {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, white);
  font-size: 20px;
}

.item-pill {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) 24px;
  align-items: start;
  gap: 7px;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 7px;
  background: white;
  text-align: left;
  color: var(--text);
}

.item-pill.flag-urgent {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, #d43f56 30%, transparent);
}

.item-pill.flag-waiting {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, #c08a1a 30%, transparent);
}

.item-pill.flag-follow {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, #5a6fcf 30%, transparent);
}

.item-flag {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.item-pill.done {
  opacity: .58;
  text-decoration: line-through;
}

.dot {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.item-main {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.item-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 750;
}

.item-time {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.item-delete {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: color-mix(in srgb, var(--warn) 8%, white);
  font-size: 17px;
  line-height: 1;
}

.item-delete:hover {
  color: white;
  background: var(--warn);
}

.more-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.day-image {
  aspect-ratio: 2 / 1;
  width: 100%;
  border-radius: 7px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.right-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.editor-collapsed .right-panel {
  padding: 12px 7px;
  overflow: hidden;
}

.editor-collapsed .editor-title,
.editor-collapsed #clearEditor,
.editor-collapsed #itemForm {
  display: none;
}

.editor-collapsed .panel-header {
  justify-content: center;
}

.editor-collapsed #toggleEditor {
  transform: rotate(180deg);
}

.panel-header {
  justify-content: space-between;
  gap: 12px;
}

.panel-actions {
  gap: 7px;
}

.panel-header.small {
  margin-bottom: 10px;
}

.panel-header.small h2 {
  font-size: 18px;
}

.two-col {
  gap: 10px;
}

.two-col > * {
  flex: 1;
  min-width: 0;
}

.check-row {
  align-self: end;
  height: 40px;
  gap: 9px;
  justify-content: flex-start;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.check-row label {
  margin: 0;
}

.form-actions {
  justify-content: space-between;
  margin-top: 16px;
}

.up-next {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}

.next-item, .agenda-item, .done-item {
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px;
  margin-bottom: 9px;
  background: white;
}

.next-item strong, .agenda-item strong, .done-item strong {
  display: block;
}

.next-item span, .agenda-item span, .done-item span {
  color: var(--muted);
  font-size: 13px;
}

.done-list {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}

.done-item {
  opacity: .72;
}

.agenda-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 84%, transparent);
}

.hidden {
  display: none !important;
}

[data-theme="ink"] {
  --bg: #d8dee8;
  --panel: #f7f8fb;
  --panel-2: #edf1f6;
  --text: #171d26;
  --muted: #5d6878;
  --line: #cbd3df;
  --accent: #3e5875;
  --accent-strong: #2c4057;
}

[data-theme="dark-purple"] {
  color-scheme: light;
  --bg: #e8e2ee;
  --panel: #fbf8ff;
  --panel-2: #f1ebf6;
  --text: #261c2f;
  --muted: #71617f;
  --line: #d5c8df;
  --accent: #7b5aa6;
  --accent-strong: #66498d;
  --warn: #b94868;
  --shadow: 0 18px 55px rgba(50, 34, 66, .18);
}

[data-theme="rosewood"] {
  --bg: #f4ecee;
  --panel: #fffafb;
  --panel-2: #f7eef1;
  --text: #2a1d22;
  --muted: #765f67;
  --line: #e5d3d8;
  --accent: #8d4f5f;
  --accent-strong: #713d4a;
}

[data-theme="daylight"] {
  --bg: #f7f6ed;
  --panel: #fffef7;
  --panel-2: #f2f0df;
  --text: #292618;
  --muted: #746e55;
  --line: #e2dec4;
  --accent: #a16d18;
  --accent-strong: #815711;
}

[data-font="serif"] {
  font-family: Georgia, "Times New Roman", serif;
}

[data-font="rounded"] {
  font-family: "Avenir Next", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
}

@media (max-width: 1120px) {
  .app {
    grid-template-columns: 230px 1fr;
  }

  .app.editor-collapsed {
    grid-template-columns: 230px 1fr;
  }

  .right-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: minmax(280px, 430px) 1fr;
  }

  .right-panel > .panel-header {
    grid-column: 1 / -1;
  }

  .editor-collapsed .right-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  .app {
    display: block;
  }

  .left-panel, .right-panel, .workspace {
    border: 0;
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .backup-reminder {
    grid-template-columns: 1fr auto;
  }

  .backup-reminder span,
  .backup-reminder .ghost-action {
    grid-column: 1 / -1;
  }

  .sticky-board {
    min-height: auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
    overflow: visible;
  }

  .sticky-note {
    position: static;
    width: 100%;
  }

  .weekday-row, .calendar-grid {
    grid-template-columns: repeat(7, minmax(64px, 1fr));
    gap: 5px;
  }

  .week-grid {
    grid-template-columns: 1fr;
  }

  .weekday-row span {
    font-size: 10px;
  }

  .day-cell {
    min-height: 112px;
    padding: 7px;
  }

  .right-panel {
    display: block;
  }
}

@media print {
  .left-panel, .right-panel, .topbar-actions, .sticky-board, .backup-reminder {
    display: none;
  }

  .app {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .day-cell {
    box-shadow: none;
    min-height: 120px;
    break-inside: avoid;
  }

  .calendar-grid,
  .weekday-row {
    gap: 4px;
  }

  body {
    background: white;
  }
}
