/* Chronicle — editorial calendar. Warm paper, near-black ink, burnt sienna. */

:root {
  color-scheme: light dark;
  --paper: #F6F1E7;
  --paper-2: #EEE5D2;
  --ink: #33302B;
  --ink-soft: #6E675C;
  --ink-faint: #98917F;
  --line: #E4DAC8;
  --line-strong: #D2C6AC;
  --accent: #B4552D;
  --accent-soft: #F2E0D3;
  --bad: #A63D2F;
  --bad-soft: rgba(166, 61, 47, .12);
  --on-accent: #fff;
  --white: #FDFAF3;

  --c-moss: #6a7f4f;   --c-moss-bg: #e9edde;
  --c-indigo: #4c5b9e; --c-indigo-bg: #e3e6f4;
  --c-ochre: #b07d2e;  --c-ochre-bg: #f4e9d2;
  --c-plum: #8d5273;   --c-plum-bg: #f0e2ea;
  --c-teal: #3e7f83;   --c-teal-bg: #dfeceb;
  --c-rust: #b1502e;   --c-rust-bg: #f5e2d8;
  --c-slate: #5d6673;  --c-slate-bg: #e6e8ea;
  --c-pine: #3c6b50;   --c-pine-bg: #dfeae2;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 6px;
  --shadow: 0 8px 30px rgba(32, 36, 46, .14), 0 2px 8px rgba(32, 36, 46, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #201B16;
    --paper-2: #332C23;
    --ink: #EDE6D9;
    --ink-soft: #B0A695;
    --ink-faint: #7D7466;
    --line: #3B342A;
    --line-strong: #4A4234;
    --accent: #D97B50;
    --accent-soft: #46301F;
    --bad: #D06A5B;
    --bad-soft: rgba(208, 106, 91, .16);
    --on-accent: #201B16;
    --white: #2A241D;
    --c-moss: #97AE73;   --c-moss-bg: #333828;
    --c-indigo: #98A5DA; --c-indigo-bg: #2C3044;
    --c-ochre: #D9A84E;  --c-ochre-bg: #3E321F;
    --c-plum: #C490AC;   --c-plum-bg: #3B2C35;
    --c-teal: #82B4B8;   --c-teal-bg: #26383a;
    --c-rust: #D97B50;   --c-rust-bg: #40291D;
    --c-slate: #A3ACBA;  --c-slate-bg: #32363C;
    --c-pine: #7FAE90;   --c-pine-bg: #263A2E;
    --shadow: 0 8px 30px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 14px; line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- layout */

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: var(--paper); flex: none;
}
.brand {
  font-family: "Shantell Sans", var(--serif); font-size: 21px; font-weight: 600;
  letter-spacing: .01em; margin-right: 6px; user-select: none;
}
.brand .dot { color: var(--accent); }
.masthead {
  font-family: var(--serif); font-size: 19px; font-weight: 500;
  min-width: 180px;
}
.topbar .spacer { flex: 1; }

.btn {
  background: var(--white); border: 1px solid var(--line-strong);
  color: var(--ink); border-radius: var(--radius); padding: 6px 13px;
}
.btn:hover { border-color: var(--ink-faint); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 85%, var(--paper)); }
.btn.today { font-weight: 600; }
.nav-arrows { display: flex; gap: 2px; }
.nav-arrows .btn { padding: 6px 10px; }

.view-switch { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.view-switch button {
  border: 0; background: var(--white); padding: 6px 14px; color: var(--ink-soft);
}
.view-switch button + button { border-left: 1px solid var(--line); }
.view-switch button.active { background: var(--ink); color: var(--paper); }

.user-chip { color: var(--ink-soft); font-size: 13px; }
.user-chip button { border: 0; background: none; color: var(--accent); padding: 0 0 0 8px; }

.body { display: flex; flex: 1; min-height: 0; }

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  width: 232px; flex: none; border-right: 1px solid var(--line);
  padding: 14px; overflow-y: auto; background: var(--paper);
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .masthead { font-size: 16px; min-width: 0; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
}

.mini { margin-bottom: 18px; user-select: none; }
.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mini-title { font-family: var(--serif); font-size: 14px; font-weight: 600; }
.mini-head button { border: 0; background: none; color: var(--ink-soft); padding: 2px 7px; border-radius: 4px; }
.mini-head button:hover { background: var(--paper-2); }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-grid .dow { text-align: center; font-size: 10px; color: var(--ink-faint); padding: 2px 0; }
.mini-grid .day {
  text-align: center; font-size: 11px; padding: 4px 0; border-radius: 4px;
  cursor: pointer; color: var(--ink);
}
.mini-grid .day.out { color: var(--ink-faint); }
.mini-grid .day:hover { background: var(--paper-2); }
.mini-grid .day.today { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.mini-grid .day.focus:not(.today) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.side-section { margin-bottom: 16px; }
.side-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-faint); margin: 0 0 6px; display: flex; justify-content: space-between; align-items: center;
}
.side-label button { border: 0; background: none; color: var(--ink-soft); font-size: 15px; padding: 0 4px; border-radius: 4px; }
.side-label button:hover { color: var(--accent); }

.cal-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; border-radius: 4px; }
.cal-row:hover { background: var(--paper-2); }
.cal-row input[type=checkbox] { display: none; }
.cal-swatch {
  width: 13px; height: 13px; border-radius: 4px; flex: none; cursor: pointer;
  border: 2px solid var(--sw, var(--ink)); background: var(--sw, var(--ink));
}
.cal-row.off .cal-swatch { background: transparent; }
.cal-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.cal-row.off .cal-name { color: var(--ink-faint); }
.cal-shared-tag { font-size: 10px; color: var(--ink-faint); }
.cal-menu-btn { border: 0; background: none; color: var(--ink-faint); padding: 0 4px; visibility: hidden; }
.cal-row:hover .cal-menu-btn { visibility: visible; }

/* ---------------------------------------------------------------- month view */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.month { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.month-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line); flex: none;
}
.month-dow div {
  padding: 6px 8px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-faint);
}
.month-grid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); min-height: 0; }
.mday {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 4px 4px 2px; min-height: 0; overflow: hidden; position: relative;
  display: flex; flex-direction: column; gap: 2px; cursor: cell;
}
.mday:nth-child(7n) { border-right: 0; }
.mday .dnum {
  font-size: 12px; padding: 1px 5px; align-self: flex-start; border-radius: 9px;
  color: var(--ink-soft); user-select: none;
}
.mday.out { background: var(--paper-2); }
.mday.out .dnum { color: var(--ink-faint); }
.mday.today .dnum { background: var(--accent); color: var(--on-accent); font-weight: 700; }

.chip {
  font-size: 12px; line-height: 1.25; padding: 1px 6px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; user-select: none; flex: none;
  background: var(--bg, var(--paper-2)); color: var(--fg, var(--ink));
  border-left: 3px solid var(--fg, var(--ink));
}
.chip.timed { background: transparent; border-left-width: 0; padding-left: 4px; }
.chip.timed .chip-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--fg); margin-right: 4px; vertical-align: baseline;
}
.chip.timed .chip-time { color: var(--ink-soft); margin-right: 3px; font-variant-numeric: tabular-nums; }
.chip.declined { text-decoration: line-through; opacity: .55; }
.chip .rec-mark { opacity: .6; font-size: 10px; margin-left: 3px; }
.more-link {
  font-size: 11px; color: var(--ink-soft); cursor: pointer; padding: 0 6px;
  border: 0; background: none; text-align: left; flex: none;
}
.more-link:hover { color: var(--accent); }
.chip.dragging, .evblock.dragging { opacity: .45; }
.mday.drop-target { background: var(--accent-soft); }

/* ---------------------------------------------------------------- week/day view */

.timegrid { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tg-head { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tg-gutter { width: 52px; flex: none; }
.tg-head-days { flex: 1; display: grid; }
.tg-head-day { padding: 6px 8px 2px; text-align: center; border-left: 1px solid var(--line); user-select: none; }
.tg-head-day .dow { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.tg-head-day .dnum {
  font-family: var(--serif); font-size: 22px; line-height: 1.2; display: inline-block;
  min-width: 34px; border-radius: 17px; cursor: pointer;
}
.tg-head-day.today .dnum { background: var(--accent); color: var(--on-accent); }

.allday-row { display: flex; border-bottom: 1px solid var(--line); flex: none; max-height: 90px; overflow-y: auto; }
.allday-label { width: 52px; flex: none; font-size: 10px; color: var(--ink-faint); padding: 4px 6px; text-align: right; }
.allday-days { flex: 1; display: grid; }
.allday-cell { border-left: 1px solid var(--line); padding: 2px 3px; display: flex; flex-direction: column; gap: 2px; min-height: 24px; cursor: cell; }

.tg-scroll { flex: 1; overflow-y: auto; position: relative; }
.tg-body { display: flex; position: relative; }
.hour-gutter { width: 52px; flex: none; position: relative; }
.hour-label {
  position: absolute; right: 8px; transform: translateY(-50%);
  font-size: 10px; color: var(--ink-faint); font-variant-numeric: tabular-nums;
}
.tg-days { flex: 1; display: grid; position: relative; }
.tg-col { border-left: 1px solid var(--line); position: relative; cursor: cell; }
.hour-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); pointer-events: none; }
.hour-line.half { border-top-style: dotted; opacity: .55; }

.now-line {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 2px solid var(--accent); z-index: 5; pointer-events: none;
}
.now-line::before {
  content: ""; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}

.evblock {
  position: absolute; border-radius: 5px; overflow: hidden; cursor: pointer;
  background: var(--bg); color: var(--fg);
  border-left: 3px solid var(--fg);
  padding: 2px 6px; font-size: 12px; line-height: 1.25;
  box-shadow: 0 0 0 1px var(--paper);
  user-select: none; touch-action: none;
}
.evblock .ev-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evblock .ev-time { font-size: 11px; opacity: .75; font-variant-numeric: tabular-nums; }
.evblock.short { display: flex; gap: 5px; align-items: baseline; padding-top: 0; padding-bottom: 0; }
.evblock.declined { text-decoration: line-through; opacity: .55; }
.evblock .resize-h {
  position: absolute; left: 0; right: 0; height: 6px; cursor: ns-resize;
}
.evblock .resize-h.top { top: 0; } .evblock .resize-h.bot { bottom: 0; }
.evblock.preview { opacity: .8; border-style: dashed; pointer-events: none; z-index: 8; }

/* ---------------------------------------------------------------- popover */

.overlay { position: fixed; inset: 0; z-index: 40; }
.popover {
  position: fixed; z-index: 50; width: 380px; max-width: calc(100vw - 20px);
  max-height: calc(100vh - 24px); overflow-y: auto;
  background: var(--white); border: 1px solid var(--line-strong);
  border-radius: 10px; box-shadow: var(--shadow); padding: 16px;
}
.popover h3 { margin: 0 0 10px; font-family: var(--serif); font-size: 17px; }
.popover .row { display: flex; gap: 8px; margin-bottom: 9px; align-items: center; }
.popover .row.wrap { flex-wrap: wrap; }
.popover label.inline { display: flex; gap: 6px; align-items: center; color: var(--ink-soft); font-size: 13px; }
.popover input[type=text], .popover input[type=email], .popover textarea, .popover select,
.popover input[type=date], .popover input[type=time], .popover input[type=number] {
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 6px 8px; background: var(--paper); width: 100%;
}
.popover input:focus, .popover textarea:focus, .popover select:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.popover .title-input { font-size: 16px; font-weight: 600; }
.popover textarea { resize: vertical; min-height: 52px; }
.popover .field-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); margin: 10px 0 4px; }
.popover .actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.popover .actions .danger { color: var(--bad); background: none; border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 6px 12px; margin-right: auto; }
.popover .actions .danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.popover .close-x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 18px; color: var(--ink-faint); }
.popover .close-x:hover { color: var(--ink); }

.color-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.color-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-dot.sel { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--white); }

.att-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
/* The feel layer: the day's honest second column. */
.feel-strip {
  position: absolute; top: 0; bottom: 0; left: 0; width: 7px;
  cursor: pointer; opacity: .8; z-index: 3;
}
.feel-strip:not(.painted):hover { background: var(--paper-2); }
.feel-strip.painted { filter: blur(1px) saturate(.9); }
.feel-strip .feel-dot {
  position: absolute; left: 0; width: 7px; height: 7px; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--ink-faint);
  filter: none; cursor: pointer;
}
.feel-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.feel-pick {
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--white); color: var(--ink); padding: 4px 11px;
  font-size: 12px; position: relative;
}
.feel-pick::before {
  content: ""; display: inline-block; width: 9px; height: 9px;
  border-radius: 50%; background: var(--f); margin-right: 6px;
}
.feel-pick:hover { border-color: var(--f); }
.feel-pick.sel { border-color: var(--f); box-shadow: inset 0 0 0 1px var(--f); }

.gcal-box { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.gcal-box .gcal-row { display: flex; gap: 8px; align-items: center; }
.gcal-box .gcal-row select { flex: 1; min-width: 0; }
.gcal-muted { color: var(--ink-soft); }
.gcal-muted a { color: inherit; }
.gcal-error { color: var(--bad); font-size: 12px; }

.att-row { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.att-status { font-size: 11px; padding: 1px 7px; border-radius: 8px; background: var(--paper-2); color: var(--ink-soft); }
.att-status.accepted { background: var(--c-pine-bg); color: var(--c-pine); }
.att-status.declined { background: var(--bad-soft); color: var(--bad); }
.att-row .busy-tag { font-size: 11px; color: var(--bad); font-weight: 600; }
.att-row .free-tag { font-size: 11px; color: var(--c-pine); }
.att-row button { border: 0; background: none; color: var(--ink-faint); padding: 0 3px; }
.att-row button:hover { color: var(--bad); }

.rem-list { display: flex; flex-wrap: wrap; gap: 6px; }
.rem-tag { display: inline-flex; gap: 5px; align-items: center; background: var(--paper-2); padding: 2px 9px; border-radius: 10px; font-size: 12px; }
.rem-tag button { border: 0; background: none; padding: 0; color: var(--ink-faint); }

/* scope dialog */
.scope-dialog {
  position: fixed; z-index: 60; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--white); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow); padding: 18px 20px; width: 320px;
}
.scope-dialog h4 { margin: 0 0 12px; font-family: var(--serif); }
.scope-dialog .opt { display: block; width: 100%; text-align: left; margin-bottom: 6px; background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px 12px; }
.scope-dialog .opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.scope-dialog .cancel { border: 0; background: none; color: var(--ink-soft); margin-top: 4px; }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.toast {
  background: var(--ink); color: var(--paper); border-radius: 8px; padding: 10px 14px;
  box-shadow: var(--shadow); display: flex; gap: 10px; align-items: baseline;
  animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateY(8px); opacity: 0; } }
.toast .t-title { font-weight: 600; }
.toast .t-when { font-size: 12px; opacity: .75; }
.toast button { border: 0; background: none; color: var(--accent-soft); font-size: 12px; }

/* day panel (from +N more) */
.day-panel-list { display: flex; flex-direction: column; gap: 4px; }

/* ---------------------------------------------------------------- login & rsvp */

.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 20% -10%, var(--accent-soft), transparent 60%),
    var(--paper);
}
.login-card {
  width: 360px; max-width: calc(100vw - 32px); background: var(--white);
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 30px 28px;
  box-shadow: var(--shadow);
}
.login-brand { font-family: "Shantell Sans", var(--serif); font-size: 30px; margin: 0 0 4px; }
.login-brand::after { content: "."; color: var(--accent); }
.login-sub { color: var(--ink-soft); margin: 0 0 18px; }
.login-card input[type=email] {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 9px 11px; background: var(--paper); margin-bottom: 10px;
}
.login-card button[type=submit], .rsvp-actions button {
  width: 100%; background: var(--ink); color: var(--paper); border: 0;
  border-radius: var(--radius); padding: 9px 0; font-weight: 600;
}
.login-card button[type=submit]:hover { background: color-mix(in srgb, var(--ink) 85%, var(--paper)); }
.login-msg { min-height: 20px; color: var(--ink-soft); font-size: 13px; }
.login-msg a { color: var(--accent); }

.rsvp-title { font-family: var(--serif); margin: 2px 0 6px; font-size: 22px; }
.rsvp-when { color: var(--ink-soft); margin: 0 0 6px; }
.rsvp-status { font-size: 13px; color: var(--ink-soft); }
.rsvp-actions { display: flex; gap: 10px; margin-top: 14px; }
.rsvp-actions .rsvp-yes { background: var(--c-pine); }
.rsvp-actions .rsvp-yes:hover { background: color-mix(in srgb, var(--c-pine) 85%, var(--ink)); }
.rsvp-actions .rsvp-no { background: var(--white); color: var(--bad); border: 1px solid var(--line-strong); }
.rsvp-actions .rsvp-no:hover { background: var(--bad-soft); }

a.brand { text-decoration: none; color: inherit; }
a.brand:hover .brandsub { color: var(--accent); }
.brandsub { font-style: italic; opacity: .85; }

/* -- people: presence pane + invite -------------------------------- */
.presence-pane { min-width: 340px; max-width: 420px; max-height: 70vh; overflow-y: auto; }
.presence-add input[type="date"] { width: 8.5em; }
.presence-add input[type="text"] { flex: 1; min-width: 6em; }
.presence-add { display: flex; gap: 6px; align-items: center; }
