:root{
  --bg:#faf7f2;
  --surface:#ffffff;
  --surface-2:#f0ebe2;
  --line:#e3ddd0;
  --ink:#221f1a;
  --muted-text:#7a7367;
  --accent:#c25a2b;
  --accent-ink:#ffffff;
  --focus:#1c6dd0;
  --shadow:0 1px 2px rgba(40,30,15,0.05);
  --cat-movie:#3b7fc4; --cat-fitness:#3f9d63; --cat-social:#d0524a;
  --cat-meetup:#9161c9; --cat-spiritual:#c95f8a; --cat-work:#2f8f93; --cat-event:#c96a3b;
  --cat-manutd:#da020e;
  --danger:#c0392f; --danger-bg:rgba(192,57,47,0.08);
  --going:#2f9e6a;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0b0e14; --surface:#151a23; --surface-2:#1d232e; --line:#2a313d;
    --ink:#edeae3; --muted-text:#8b94a3;
    --accent:#e8834e; --accent-ink:#1a1005; --focus:#5b9bef;
    --shadow:0 1px 2px rgba(0,0,0,0.3);
    --cat-movie:#5b9bd8; --cat-fitness:#57b97c; --cat-social:#e86b62;
    --cat-meetup:#a87fd8; --cat-spiritual:#db7ba3; --cat-work:#46a8ac; --cat-event:#dd8a5a;
    --cat-manutd:#f0454f;
    --danger:#f0857c; --danger-bg:rgba(240,90,80,0.1);
    --going:#43c088;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
  overflow-x: hidden; /* safety net: nothing should ever cause a horizontal scrollbar */
}
/* Fluid width that fills small screens and grows to a comfortable cap on
   large ones. Padding scales with the viewport so a phone isn't cramped and
   a desktop isn't hard against the edge. */
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: clamp(16px, 4vw, 28px) clamp(14px, 4vw, 32px) 60px; }

/* ── Masthead ── */
.masthead { margin-bottom: 18px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--accent); margin: 0 0 3px; }
h1 { font-size: 23px; font-weight: 800; letter-spacing: -0.3px; margin: 0; text-wrap: balance; }
.summary { font-size: 13px; color: var(--muted-text); margin: 5px 0 0; }
.summary b { color: var(--ink); font-weight: 700; }

/* ── Filter stack ── */
.filters { display: flex; flex-direction: column; gap: 14px; margin: 18px 0 8px; }
.fgroup-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted-text); margin-bottom: 7px; display: flex; align-items: center; gap: 7px;
}
.fgroup-label .step {
  width: 16px; height: 16px; border-radius: 50%; background: var(--surface-2); color: var(--muted-text);
  font-size: 9.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}
.fgroup-label.with-action { justify-content: space-between; }
.fgroup-label.with-action > span { display: inline-flex; align-items: center; gap: 7px; }
.date-jump {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px;
}
.date-jump input[type="date"] {
  border: none; background: transparent; color: var(--ink); font-family: inherit;
  font-size: 11.5px; font-weight: 600; cursor: pointer; padding: 0; color-scheme: light dark;
}
.date-jump input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; }

/* Week navigation: prev/next flanking the day strip */
.week-nav { display: flex; align-items: stretch; gap: 7px; }
.week-nav .chiprow { flex: 1; }
.wk-btn {
  flex: none; width: 34px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted-text); border-radius: 11px; font-size: 18px; font-weight: 700; line-height: 1;
  cursor: pointer; font-family: inherit;
}
.wk-btn:hover { color: var(--ink); border-color: var(--accent); }
.wk-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Wrap instead of horizontal-scroll so there are no scrollbars on desktop
   (or anywhere). On a narrow phone chips just flow onto a second row. */
.chiprow { display: flex; flex-wrap: wrap; gap: 7px; }

/* Day chips */
.day {
  position: relative;
  flex: 1 1 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 7px 8px 6px; cursor: pointer; text-align: center; min-width: 42px; max-width: 74px;
  font-family: inherit; color: var(--ink);
}
.day .going-dot {
  position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--going); box-shadow: 0 0 0 2px var(--surface), 0 0 5px var(--going);
}
.day.on .going-dot { box-shadow: 0 0 0 2px var(--accent), 0 0 5px var(--going); }
.day .dow { display: block; font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted-text); }
.day .dom { display: block; font-size: 15px; font-weight: 800; margin-top: 1px; }
.day.on { background: var(--accent); border-color: var(--accent); }
.day.on .dow { color: var(--accent-ink); opacity: 0.85; }
.day.on .dom { color: var(--accent-ink); }

/* Pill chips (time, mood, location) */
.pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--muted-text);
  border-radius: 20px; padding: 7px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; user-select: none; white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pill .n { opacity: 0.6; font-weight: 500; }
.pill .x { font-weight: 700; font-size: 14px; line-height: 1; opacity: 0.7; margin-left: 1px; }
.pill.on:hover .x { opacity: 1; }
.pill.on { color: var(--ink); border-color: var(--pill-c, var(--accent)); background: color-mix(in srgb, var(--pill-c, var(--accent)) 13%, var(--surface)); }
.pill.all.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill:focus-visible, .day:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Refine (secondary) */
.refine-toggle {
  align-self: flex-start; background: none; border: none; color: var(--focus);
  font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; padding: 2px 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.refine-toggle .chev { transition: transform 0.15s ease; }
.refine-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .refine-toggle .chev { transition: none; } }
.refine { display: none; flex-direction: column; gap: 12px; padding: 14px; background: var(--surface-2); border-radius: 12px; }
.refine.open { display: flex; }
.refine-empty { font-size: 12px; color: var(--muted-text); line-height: 1.5; }

/* ── Results ── */
.results { margin-top: 22px; display: flex; flex-direction: column; gap: 22px; }
.section-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.section-head .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; align-self: center; }
.section-head h2 { font-size: 15px; font-weight: 800; margin: 0; }
.section-head .count { font-size: 12px; color: var(--muted-text); font-weight: 600; }

/* Auto-fill grid: one column on a phone, filling to 2-3 on tablet/desktop
   without any breakpoint math. min(100%, 320px) stops a card from ever
   being wider than its container on the narrowest screens. */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 8px; align-items: start; }
.card {
  display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--cat-c); border-radius: 11px; padding: 12px 13px;
  box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%; font-family: inherit; color: inherit;
  border-top: none; border-right: none; border-bottom: none;
}
.card:hover { background: color-mix(in srgb, var(--cat-c) 5%, var(--surface)); }
.card:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.card .time { flex: none; width: 66px; font-size: 13px; font-weight: 800; line-height: 1.25; padding-top: 1px; }
.card .time .dur { display: block; font-size: 10px; font-weight: 500; color: var(--muted-text); margin-top: 2px; }
.card .allday-time { font-size: 12px; font-weight: 800; line-height: 1.15; color: var(--accent); display: inline-block; }
.allday-tag {
  font-size: 9px; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}
.card .body { flex: 1; min-width: 0; }
.card .title { font-size: 14px; font-weight: 700; line-height: 1.3; }
.card.going { border-color: var(--going); box-shadow: 0 0 0 1px var(--going), var(--shadow); }
.going-tag {
  display: inline-block; margin-left: 7px; font-size: 9.5px; font-weight: 800;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--going);
  vertical-align: middle;
}
.card .meta { font-size: 11.5px; color: var(--muted-text); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card .src { font-size: 9px; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; padding: 2px 6px; border-radius: 5px; }
.card .venue { font-weight: 600; color: var(--ink); }
.card .fmt { font-size: 9px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); color: var(--muted-text); }

.empty { text-align: center; padding: 44px 20px; color: var(--muted-text); font-size: 14px; background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; }
.empty .big { font-size: 15px; font-weight: 700; color: var(--ink); display: block; margin-bottom: 6px; }

.error-note {
  padding: 10px 12px; font-size: 12px; color: var(--danger); line-height: 1.4;
  background: var(--danger-bg); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: 10px;
}

/* ── Details sheet ── */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.18s ease; z-index: 50;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 560px; max-height: 82vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-bottom: none;
  border-radius: 16px 16px 0 0; padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1); position: relative;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .sheet-backdrop, .sheet { transition: none; } }
.sheet-close {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px;
  border-radius: 50%; border: none; background: var(--surface-2); color: var(--muted-text);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.sheet-close:hover { background: var(--line); color: var(--ink); }
.sheet-cat {
  display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 3px 9px; border-radius: 20px; margin-bottom: 10px;
}
.sheet-img { display: block; width: 100%; max-height: 300px; object-fit: contain; border-radius: 12px; margin-bottom: 14px; background: var(--surface-2); }
.sheet-title { font-size: 19px; font-weight: 800; line-height: 1.3; padding-right: 32px; margin-bottom: 10px; text-wrap: balance; }
.sheet-desc { font-size: 13.5px; line-height: 1.5; color: var(--muted-text); margin-bottom: 14px; }
.going-btn {
  display: block; width: 100%; margin-bottom: 10px; padding: 12px; border-radius: 10px;
  font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  background: var(--surface-2); color: var(--ink); border: 1.5px solid var(--line);
}
.going-btn:hover { border-color: var(--going); }
.going-btn.on { background: var(--going); border-color: var(--going); color: #fff; }
.going-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.sheet-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.sheet-row { display: flex; gap: 10px; font-size: 13.5px; }
.sheet-row .k { flex: none; width: 76px; color: var(--muted-text); }
.sheet-row .v { color: var(--ink); font-weight: 500; }
.sheet-link {
  display: inline-flex; align-items: center; gap: 6px; width: 100%; justify-content: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13.5px;
  padding: 12px; border-radius: 10px; text-decoration: none;
}
.sheet-link:hover { filter: brightness(0.95); }

/* ── Feedback FAB + panel ── */
.fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font-size: 26px; font-weight: 800; font-family: inherit; line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.fab:hover { filter: brightness(1.05); }
.fab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.fab-panel {
  position: fixed; right: 18px; bottom: 80px; z-index: 60;
  width: min(340px, calc(100vw - 36px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28); padding: 16px;
  opacity: 0; transform: translateY(8px) scale(0.98); pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.fab-panel.open { opacity: 1; transform: none; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .fab-panel { transition: none; } }
.fab-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.fab-panel-head strong { font-size: 14px; }
.fab-close { background: none; border: none; color: var(--muted-text); font-size: 20px; cursor: pointer; line-height: 1; padding: 0 2px; }
.fab-close:hover { color: var(--ink); }
.fab-field { display: block; margin-bottom: 10px; }
.fab-field > span { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted-text); margin-bottom: 5px; }
.fab-field > span em { font-weight: 500; text-transform: none; letter-spacing: 0; }
.fab-field input, .fab-field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; font-family: inherit; font-size: 13.5px; color: var(--ink); resize: vertical;
}
.fab-field input:focus, .fab-field textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.fab-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fab-send {
  width: 100%; background: var(--accent); color: var(--accent-ink); border: none; border-radius: 9px;
  padding: 10px; font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.fab-send:hover { filter: brightness(1.05); }
.fab-send:disabled { opacity: 0.6; cursor: default; }
.fab-status { font-size: 12px; color: var(--muted-text); margin: 8px 0 0; min-height: 15px; text-align: center; }

::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
