:root {
  --bg: #F7F8F6;
  --card: #ffffff;
  --ink: #1c211d;
  --muted: #5f665d;
  --line: #e3e6e1;
  --green: #364F38;
  --green-deep: #0F3A22;
  --soft: #eaf6f4;
  --chip: #eef0ec;
  --email: #2F7D3E;
  --social: #C2603A;
  --ard: #D9CF00;
  --mm: #7B4FD6;
  --learn: #2F7D3E;
  --nc: #C2603A;
  --top-h: 72px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141815; --card: #1d221e; --ink: #eef1ec; --muted: #a3aa9f; --line: #2c332d;
    --green: #A8E063; --green-deep: #A8E063; --soft: #233027; --chip: #283029;
    --email: #7cc98a; --social: #e58f6c; --learn: #7cc98a; --nc: #e58f6c; --mm: #ab8cf0; --ard: #ECF014;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141815; --card: #1d221e; --ink: #eef1ec; --muted: #a3aa9f; --line: #2c332d;
  --green: #A8E063; --green-deep: #A8E063; --soft: #233027; --chip: #283029;
  --email: #7cc98a; --social: #e58f6c; --learn: #7cc98a; --nc: #e58f6c; --mm: #ab8cf0; --ard: #ECF014;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 Figtree, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

/* Top bar */
.top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  min-height: var(--top-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.nav-btn {
  width: 40px; height: 40px; border-radius: 50%;
  font-size: 28px; line-height: 1; color: var(--muted);
  display: grid; place-items: center;
}
.nav-btn:hover { background: var(--chip); }
.nav-btn.small { width: 36px; height: 36px; font-size: 24px; }
.date-btn {
  flex: 1; text-align: center; padding: 4px 8px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center;
}
.date-btn:hover { background: var(--chip); }
.date-week { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.date-day { font-family: "DM Serif Display", Georgia, serif; font-size: 26px; line-height: 1.1; }
.caret { font-family: Figtree, sans-serif; font-size: 14px; color: var(--muted); vertical-align: middle; }
.today-btn {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 16px); z-index: 12;
  font-size: 15px; font-weight: 700; padding: 10px 18px; border-radius: 999px;
  background: var(--green); color: var(--bg); box-shadow: 0 6px 18px rgba(0,0,0,.18);
}

/* Month picker */
.picker {
  position: absolute; left: 0; right: 0;
  top: calc(env(safe-area-inset-top) + var(--top-h));
  z-index: 15;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0,0,0,.12);
  padding: 12px 16px 16px;
  max-width: 520px; margin: 0 auto;
  border-radius: 0 0 16px 16px;
}
.picker-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.picker-title { font-family: "DM Serif Display", Georgia, serif; font-size: 22px; padding: 4px 12px; border-radius: 10px; }
.picker-title:hover { background: var(--chip); }
.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 4px 0 12px; }
.months button { padding: 8px 0; border-radius: 8px; background: var(--chip); font-weight: 600; font-size: 14px; }
.months button.on { background: var(--green); color: var(--bg); }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.grid .wd { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.grid .cell {
  aspect-ratio: 1 / 1; max-height: 52px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-weight: 500;
}
.grid .cell:hover { background: var(--chip); }
.grid .cell.other { color: var(--muted); opacity: .45; }
.grid .cell.today { box-shadow: inset 0 0 0 1.5px var(--green); }
.grid .cell.sel { background: var(--green); color: var(--bg); }
.grid .dots { display: flex; gap: 3px; height: 6px; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.dot.email { background: var(--email); }
.dot.social { background: var(--social); }
.grid .cell.sel .dot { background: var(--bg); }
.legend { display: flex; gap: 16px; justify-content: center; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend .dot { margin-right: 6px; }
.scrim { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.2); }

/* Swipeable days */
.viewport { flex: 1; overflow: hidden; position: relative; }
.track { display: flex; width: 300%; height: 100%; transform: translateX(-33.3333%); will-change: transform; }
.track.anim { transition: transform .25s ease-out; }
.day {
  width: 33.3333%; height: 100%;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 40px);
}
.day > * { max-width: 640px; margin-left: auto; margin-right: auto; }

.section-label {
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 8px auto 10px;
  display: flex; align-items: center; gap: 8px;
}
.section-label .count { font-weight: 600; background: var(--chip); border-radius: 999px; padding: 0 8px; letter-spacing: 0; }
.section-label + .empty { margin-top: 0; }
.gap { height: 18px; }

.card {
  display: block; text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 10px;
}
.email-card { display: grid; grid-template-columns: 74px 1fr; gap: 10px; border-left: 4px solid var(--email); }
.email-time { font-weight: 700; font-size: 15px; }
.email-time small { display: block; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.email-title { font-weight: 600; line-height: 1.3; }
.email-aud { font-size: 14px; color: var(--muted); margin-top: 4px; }

.brand { margin-bottom: 14px; }
.brand-name { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; margin: 0 auto 8px; }
.brand-name .dot { width: 10px; height: 10px; }
.brand-name .count { font-size: 13px; color: var(--muted); font-weight: 600; }
.brand.none .brand-name { color: var(--muted); font-weight: 600; font-size: 15px; }
.brand.none .brand-name::after { content: "Nothing planned"; font-weight: 400; font-size: 14px; margin-left: auto; }

.post { cursor: pointer; }
.post-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--chip); }
.chip.status { background: var(--soft); color: var(--green-deep); }
.chip.status.scheduled { background: var(--green); color: var(--bg); }
.chip.status.draft { background: transparent; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.post-copy {
  white-space: pre-line; font-size: 15px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.post.open .post-copy { -webkit-line-clamp: unset; display: block; }
.post-links { margin-top: 8px; font-size: 14px; display: none; gap: 14px; }
.post.open .post-links { display: flex; }
.post-links a { color: var(--green-deep); font-weight: 600; }

.empty { color: var(--muted); font-size: 15px; padding: 2px 0 8px; }
.loading { color: var(--muted); padding: 32px 0; text-align: center; }
.err { font-size: 14px; color: var(--social); margin-bottom: 10px; }
.updated { text-align: center; font-size: 12px; color: var(--muted); margin-top: 24px; }
.updated a { color: var(--muted); }

/* Login */
body.login { display: grid; place-items: center; overflow: auto; padding: 16px; }
.login-box { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login-box h1 { font-family: "DM Serif Display", Georgia, serif; font-weight: 400; font-size: 34px; margin: 0 0 8px; }
.login-box label { font-weight: 600; font-size: 14px; }
.login-box input { font: inherit; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 16px; }
.login-box button { padding: 12px; border-radius: 10px; background: var(--green); color: var(--bg); font-weight: 700; }
.login-error { color: var(--social); margin: 0; font-size: 14px; }
