:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16191f;
  --muted: #646b78;
  --faint: #a3a9b4;
  --line: #e3e6eb;
  --accent: #1f5fd1;
  --tax: #2563eb;
  --social: #8b5cf6;
  --safe: #16a34a;
  --tight: #e08a00;
  --due: #d62612;
  --safe-bg: #e8f6ec;
  --tight-bg: #fdf1dc;
  --due-bg: #fdecea;
  --holiday: #d62612;
  --holiday-bg: #fdecea;
  --sel-bg: #e8effc;
  --chip-bg: #eef0f3;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216;
    --surface: #181b21;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --faint: #5c6370;
    --line: #2a2e36;
    --accent: #7aa7ff;
    --tax: #6c9cff;
    --social: #a78bfa;
    --safe: #4ade80;
    --tight: #fbbf24;
    --due: #ff7a6b;
    --safe-bg: #15301f;
    --tight-bg: #3a2c10;
    --due-bg: #3a1d1a;
    --holiday: #ff7a6b;
    --holiday-bg: #3a1d1a;
    --sel-bg: #1d2a42;
    --chip-bg: #232730;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #181b21;
  --text: #e8eaee;
  --muted: #9aa1ad;
  --faint: #5c6370;
  --line: #2a2e36;
  --accent: #7aa7ff;
  --tax: #6c9cff;
  --social: #a78bfa;
  --safe: #4ade80;
  --tight: #fbbf24;
  --due: #ff7a6b;
  --safe-bg: #15301f;
  --tight-bg: #3a2c10;
  --due-bg: #3a1d1a;
  --holiday: #ff7a6b;
  --holiday-bg: #3a1d1a;
  --sel-bg: #1d2a42;
  --chip-bg: #232730;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.45 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}
h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}
button,
select {
  font: inherit;
  color: inherit;
}
a {
  color: var(--accent);
}
.muted {
  color: var(--muted);
}

/* Header */
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 8px;
  max-width: 1480px;
  margin: 0 auto;
}
.top h1 {
  font-size: 22px;
  font-weight: 650;
}
.top h1 span {
  color: var(--muted);
  font-weight: 500;
}
.sub {
  margin: 4px 0 0;
  color: var(--muted);
}
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn,
.actions select {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover {
  border-color: var(--accent);
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  padding: 8px 24px 16px;
  max-width: 1480px;
  margin: 0 auto;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.segmented button {
  border: 0;
  background: none;
  padding: 6px 12px;
  cursor: pointer;
}
.segmented button + button {
  border-left: 1px solid var(--line);
}
.segmented button[aria-checked="true"] {
  background: var(--sel-bg);
  color: var(--accent);
  font-weight: 600;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.toggle input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  margin: 0;
}

/* Calendar feeds menu */
.feeds {
  position: relative;
}
.feeds summary {
  list-style: none;
}
.feeds summary::-webkit-details-marker {
  display: none;
}
.feeds-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  width: min(380px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.feeds-menu p {
  margin: 0 0 8px;
  font-size: 12.5px;
}
.feed {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 5px 0;
  border-top: 1px solid var(--line);
}
.feed span {
  flex: 1;
}
.feed.recommended span {
  font-weight: 650;
}
.feed.recommended span::after {
  content: " ✓";
  color: var(--safe);
}
.chip {
  border: 1px solid transparent;
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip[aria-pressed="false"] {
  opacity: 0.45;
  text-decoration: line-through;
}
.chip:hover {
  border-color: var(--line);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
  padding: 0 24px 24px;
  max-width: 1480px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 1000px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 600px) {
  .top,
  .filters,
  .layout {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* Year overview */
.months {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.month {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
}
.month.current {
  border-color: var(--accent);
}
.month h3 {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.month h3 small {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.wd {
  font-size: 11px;
  color: var(--faint);
  text-align: center;
  padding-bottom: 2px;
}
.day {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 6px;
  background: none;
  padding: 0;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: default;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.day.weekend {
  color: var(--faint);
}
.day.holiday {
  color: var(--holiday);
  background: var(--holiday-bg);
}
.day.past {
  opacity: 0.5;
}
.day.has {
  cursor: pointer;
}
.day.due {
  font-weight: 700;
}
.day.has:hover {
  background: var(--sel-bg);
}
.day.today {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.day.selected {
  background: var(--accent);
  color: #fff;
  opacity: 1;
}
.day .dots {
  display: flex;
  gap: 2px;
  height: 6px;
  align-items: flex-end;
}
.dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.dot.tax {
  background: var(--tax);
}
.dot.social {
  background: var(--social);
}
.day.selected .dot {
  background: #fff;
}
.mark {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-bottom: 6px solid var(--safe);
}
.mark.tight {
  border-bottom-color: var(--tight);
}
.day.selected .mark {
  border-bottom-color: #fff;
}
.legend .mark {
  border-left-width: 5px;
  border-right-width: 5px;
  border-bottom-width: 8px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
  margin: 12px 2px 0;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .dot {
  width: 7px;
  height: 7px;
}
.sw {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
}
.sw.holiday {
  background: var(--holiday-bg);
  border: 1px solid var(--holiday);
}
.sw.today {
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* Side panel */
.panel {
  position: sticky;
  top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
}
@media (max-width: 1000px) {
  .panel {
    position: static;
    max-height: none;
    order: -1;
  }
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-size: 16px;
  font-weight: 650;
}
.link {
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}
.panel-body {
  overflow-y: auto;
  padding: 4px 16px 16px;
}
.date-group {
  padding-top: 14px;
}
.date-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 4px 0;
  z-index: 1;
}
.date-head strong {
  font-size: 14px;
}
.rel {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.rel.soon {
  color: var(--holiday);
  font-weight: 600;
}
.card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--tax);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--surface);
}
.card.social {
  border-left-color: var(--social);
}
.card.status-safe {
  background: var(--safe-bg);
}
.card.status-tight {
  background: var(--tight-bg);
}
.card.status-due {
  background: var(--due-bg);
}
.pill {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 650;
  padding: 1px 8px;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
}
.pill.safe {
  background: var(--safe);
}
.pill.tight {
  background: var(--tight);
}
.pill.due {
  background: var(--due);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill {
    color: #111;
  }
}
:root[data-theme="dark"] .pill {
  color: #111;
}
.timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.timeline span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.card li strong {
  display: block;
  font-weight: 600;
}
.card li .bg-text {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}
.card summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 10px;
}
.card summary::-webkit-details-marker {
  display: none;
}
.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge {
  font-size: 11.5px;
  font-weight: 650;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--chip-bg);
}
.card-name {
  font-size: 12px;
  color: var(--muted);
}
.preview {
  margin: 4px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card[open] .preview {
  display: none;
}
.card ul {
  margin: 0;
  padding: 0 12px 10px 28px;
}
.card li {
  margin: 4px 0;
}
.card .group {
  margin: 0;
  padding: 0 12px 4px;
  font-size: 12px;
  color: var(--muted);
}
.card .note {
  margin: 0;
  padding: 0 12px 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.moved {
  font-size: 11.5px;
  color: var(--muted);
}
.more {
  display: block;
  width: 100%;
  margin-top: 12px;
}
.empty {
  padding: 16px 0;
  color: var(--muted);
}

/* Footer */
.foot {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 24px 32px;
  color: var(--muted);
  font-size: 12.5px;
}
.foot p {
  margin: 4px 0;
}
