:root {
  --bg: #f6f5ef;
  --ink: #1a1815;
  --ink-mid: #5a554b;
  --ink-muted: #8a8478;
  --rule: #e6e3d8;
  --rule-soft: #efece2;
  --card: #fff;
  --accent: #4a6b3a;
  --lime: #b6c64a;
  --danger: #a23b3b;

  --c-work:     #4a6b3a;
  --c-meeting:  #6e5a8a;
  --c-personal: #b8762b;
  --c-health:   #3d7558;
  --c-admin:    #75695a;
  --c-focus:    #3a6b85;
  --c-errand:   #a64646;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
.muted { color: var(--ink-muted); font-size: 0.9em; }
.hidden { display: none !important; }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.55rem 1rem;
  background: var(--card); border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 600; letter-spacing: 0.02em; flex: 1; }
.brand-text { font-size: 1.05rem; }
.topbar-tools { display: flex; gap: 0.7rem; align-items: center; }
.topbar-tools .who { color: var(--ink-muted); font-size: 0.85em; }
.logout-form { margin: 0; }
button.link, button.icon {
  background: none; border: 0; color: var(--ink-mid); cursor: pointer;
  padding: 0.3rem 0.5rem; border-radius: 4px; font: inherit;
}
button.link:hover, button.icon:hover { background: var(--bg); color: var(--ink); }

main { padding: 0.75rem 1rem 4rem; max-width: 1200px; margin: 0 auto; }

/* ── FullCalendar tweaks ── */
.fc { --fc-border-color: var(--rule); --fc-today-bg-color: #faf8e8; font-size: 0.92em; }
.fc .fc-toolbar-title { font-size: 1.2rem; font-weight: 600; }
.fc .fc-button {
  background: var(--card); border: 1px solid var(--rule); color: var(--ink-mid);
  text-transform: none; font-weight: 500; box-shadow: none; padding: 0.3rem 0.65rem;
}
.fc .fc-button:hover { background: var(--rule-soft); color: var(--ink); }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.fc .fc-button-primary:disabled { background: var(--rule-soft); border-color: var(--rule); color: var(--ink-muted); }
.fc-event { border: 0; padding: 1px 3px; font-size: 0.85em; cursor: pointer; }
.fc-event .fc-event-main, .fc-event .fc-event-title, .fc-event .fc-event-time { color: #fff; }
.fc-event:hover { filter: brightness(1.05); }
.fc-daygrid-event, .fc-timegrid-event { border-radius: 5px; }

/* Event type colours */
.ev-type-work     { background-color: var(--c-work); }
.ev-type-meeting  { background-color: var(--c-meeting); }
.ev-type-personal { background-color: var(--c-personal); }
.ev-type-health   { background-color: var(--c-health); }
.ev-type-admin    { background-color: var(--c-admin); }
.ev-type-focus    { background-color: var(--c-focus); }
.ev-type-errand   { background-color: var(--c-errand); }
/* list (agenda) view dots */
.fc-list-event.ev-type-work     td.fc-list-event-dot-wrap .fc-list-event-dot,
.fc-list-event .fc-list-event-dot { border-color: currentColor; }

/* Done + cancelled states */
.fc-event.ev-done { opacity: 0.5; }
.fc-event.ev-done .fc-event-title { text-decoration: line-through; }
.fc-event.ev-cancelled { opacity: 0.45; }
.fc-event.ev-cancelled .fc-event-title,
.fc-event.ev-cancelled .fc-event-time { text-decoration: line-through; }
.fc-event.ev-cancelled .fc-event-main { font-style: italic; }
.fc-list-event.ev-done .fc-list-event-title,
.fc-list-event.ev-cancelled .fc-list-event-title { text-decoration: line-through; color: var(--ink-muted); }

/* ── Floating add button ── */
#fab {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 20;
  width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 1.6rem; line-height: 1;
  box-shadow: 0 6px 18px rgba(0,0,0,.22);
}
#fab:hover { background: #3d5a30; }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0; background: rgba(20,25,22,0.4); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 1rem; backdrop-filter: blur(3px);
}
.modal-card {
  background: var(--card); border-radius: 12px; padding: 1.1rem 1.35rem 1.25rem;
  width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  box-shadow: 0 14px 40px rgba(0,0,0,.18); animation: pop .12s ease-out;
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.modal-head h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.modal-card .row { display: flex; gap: 0.5rem; }
.modal-card .row > label { flex: 1; }
.modal-card label.big input { font-size: 1.05rem; padding: 0.65rem 0.8rem; }
.checkbox-row {
  display: flex !important; flex-direction: row !important; align-items: center;
  gap: 0.4rem; align-self: flex-end; padding-bottom: 0.55rem;
}
.checkbox-row input { width: auto !important; margin: 0 !important; }
.checkbox-row span { margin: 0 !important; color: var(--ink); }
.modal-card .actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.modal-card .actions button { padding: 0.5rem 1rem; border-radius: 6px; border: 0; font: inherit; cursor: pointer; }
.modal-card .actions button[type=submit] { background: var(--accent); color: #fff; font-weight: 600; }
.modal-card .actions button.ghost { background: var(--rule-soft); color: var(--ink-mid); }
.modal-card .actions button.danger { background: var(--danger); color: #fff; margin-right: auto; }

/* ── Forms ── */
form label { display: block; margin: 0.7rem 0; font-size: 0.85em; color: var(--ink-mid); }
form label > span { display: block; margin-bottom: 0.2rem; }
form input, form select, form textarea {
  display: block; width: 100%; padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--card);
  font: inherit; color: var(--ink);
}
form input:focus, form select:focus, form textarea:focus {
  outline: none; border-color: var(--lime); box-shadow: 0 0 0 3px rgba(182,198,74,0.18);
}

/* ── Auth ── */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: 10px;
  padding: 2rem; width: 100%; max-width: 380px; box-shadow: 0 1px 2px rgba(0,0,0,.02);
}
.card h1 { margin: 0 0 0.25rem; }
.card form button[type=submit] {
  display: block; width: 100%; padding: 0.65rem; margin-top: 1rem;
  background: var(--accent); color: #fff; border: 0; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer;
}
.error {
  background: #fbeaea; border: 1px solid #e7c0c0; color: var(--danger);
  padding: 0.5rem 0.7rem; border-radius: 6px; margin-bottom: 0.5rem; font-size: 0.9em;
}
