/* Janów — clean editorial theme: black-on-white, high-contrast serif display,
   generous whitespace, matching the camp's poster aesthetic. */

:root {
  --bg: #fbfaf7;        /* warm off-white */
  --surface: #ffffff;
  --surface-2: #f4f2ec;
  --border: #e6e2d8;
  --text: #15120d;      /* near-black, warm */
  --muted: #6f6a60;
  --accent: #15120d;    /* editorial = ink */
  --danger: #b42318;
  --ok: #287d3c;
  --radius: 10px;
  --maxw: 680px;
  --serif: "Didot", "Bodoni 72", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand { font-family: var(--serif); font-weight: 700; letter-spacing: 0.01em; }
h1 { line-height: 1.05; }

a { color: var(--text); text-underline-offset: 2px; }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* --- Landing / gate --- */
.gate-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
}
.gate-card h1 {
  font-size: 2.4rem;
  margin: 0 0 0.4rem;
}
.gate-card p.muted, p.muted {
  color: var(--muted);
  font-size: 0.95rem;
}
.gate-card p.muted { margin: 0 0 1.5rem; }

input, textarea, button, select { font: inherit; }

input[type="text"], input[type="password"], input[type="email"], input[type="datetime-local"], input[type="date"], input[type="time"] {
  width: 100%;
  padding: 0.8rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.12em;
}
input:focus, textarea:focus { outline: none; border-color: var(--text); }

button, .btn {
  display: inline-block;
  margin-top: 1rem;
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--text);
  color: #fff;
  border: 1px solid var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
button:hover, .btn:hover { opacity: 0.85; }

.error { color: var(--danger); font-size: 0.9rem; margin-top: 0.75rem; min-height: 1.2em; }

/* Gate consent: secondary "just now" button, scan hint, cookie note */
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--surface-2); opacity: 1; }
.scan-hint { color: var(--ok); font-size: 0.9rem; margin: 0.5rem 0 0.25rem; }
.cookie-note { font-size: 0.8rem; color: var(--muted); margin: 1rem 0 0; line-height: 1.4; }
.cookie-note a { color: var(--muted); }

/* Cookie policy / prose page */
.prose { line-height: 1.7; }
.prose h1 { font-size: 1.9rem; margin: 0.5rem 0 1rem; }
.prose h2 { font-size: 1.25rem; margin: 1.75rem 0 0.5rem; }
.prose ul { padding-left: 1.2rem; }
.prose code { background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.9em; }
.cookie-table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.92rem; }
.cookie-table th, .cookie-table td { text-align: left; vertical-align: top; padding: 0.6rem; border: 1px solid var(--border); }
.cookie-table th { background: var(--surface-2); }

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(251,250,247,0.9);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.topbar { flex-wrap: nowrap; gap: 0.5rem; }
.topbar .brand {
  font-size: 1.5rem; text-decoration: none; color: var(--text);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* --- Top bar actions + side drawer (native popover) --- */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--text);
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  margin: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.menu-btn:hover { background: var(--surface-2); opacity: 1; }
.menu-ic { display: block; }

/* The drawer is a [popover]: the UA keeps it display: none until the menu
   button opens it; open, it renders in the top layer as a fixed right panel
   (so the topbar's backdrop-filter does not trap its position: fixed). */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  height: 100dvh;
  width: min(20rem, 86vw);
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0 0 1.5rem;
  border: none;
  border-left: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
  box-shadow: -8px 0 32px rgba(0,0,0,.12);
  transform: translateX(100%);
  transition: transform .22s ease, overlay .22s allow-discrete, display .22s allow-discrete;
}
.drawer:popover-open {
  display: flex;
  flex-direction: column;
  transform: translateX(0);
}
@starting-style {
  .drawer:popover-open { transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .drawer { transition: none; }
}
.drawer::backdrop { background: rgba(0,0,0,.35); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem .5rem 1.25rem;
  position: sticky;
  top: 0;
  background: inherit;
}
.drawer-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-close {
  background: none;
  border: none;
  color: var(--muted);
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  margin: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.drawer-close:hover { background: var(--surface-2); color: var(--text); opacity: 1; }

.drawer-section {
  padding: .5rem .75rem;
  display: flex;
  flex-direction: column;
}
.drawer-section + .drawer-section { border-top: 1px solid var(--border); }
.drawer-label {
  margin: .5rem .5rem .25rem;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  color: var(--muted);
  font-family: var(--sans);
}
.drawer a {
  display: block;
  padding: .7rem .75rem;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.3;
}
.drawer a:hover, .drawer a:focus-visible { background: var(--surface-2); }
.drawer a[aria-current="page"] { font-weight: 700; background: var(--surface-2); }

.drawer-logout {
  margin-top: auto;
  padding: .75rem 1.25rem 0;
  border-top: 1px solid var(--border);
}
.drawer-logout button.linklike {
  font-size: 1rem;
  color: var(--danger);
  padding: .6rem 0;
  width: auto;
}

.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-size: 0.9rem; margin: 0 0 0.5rem; }
.back-link:hover { color: var(--text); }

.form-actions { display: flex; align-items: center; gap: 1.25rem; margin-top: 1.75rem; }
.form-actions button[type="submit"] { margin-top: 0; }
.btn-secondary { color: var(--muted); text-decoration: none; }
.btn-secondary:hover { color: var(--text); text-decoration: underline; }

/* --- Feed --- */
.post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.post h2 { margin: 0 0 0.35rem; font-size: 1.6rem; line-height: 1.15; }
.post .meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 1rem; text-transform: uppercase; letter-spacing: 0.06em; }
.post .body { font-size: 1.02rem; }
.post .body img, .post .body video { max-width: 100%; border-radius: 6px; }
.post .media { margin-top: 1rem; display: grid; gap: 0.75rem; }
.post .media img, .post .media video { width: 100%; border-radius: 6px; display: block; border: 1px solid var(--border); }
.post .media img, .post .body img { cursor: zoom-in; }

/* Tap-to-enlarge overlay */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

/* Document (PDF) attachment */
.doc-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}
.doc-link:hover { border-color: var(--text); }
.doc-link .doc-ic { font-size: 1.3rem; }

.empty { color: var(--muted); text-align: center; padding: 4rem 1rem; font-style: italic; }

button.linklike {
  width: auto; margin: 0; padding: 0;
  background: none; color: var(--muted); border: none; font-weight: 400;
}
button.linklike:hover { background: none; color: var(--text); text-decoration: underline; opacity: 1; }
button.linklike.danger { color: var(--danger); }

/* --- Admin --- */
.admin-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }
.admin-actions .btn { width: auto; margin: 0; }

.post-form label { display: block; margin: 1.25rem 0 0.4rem; font-weight: 600; }
.post-form input[type="text"], .post-form input[type="datetime-local"], .post-form input[type="date"], .post-form input[type="time"] { text-align: left; letter-spacing: normal; }
.post-form input[type="file"] { display: block; margin-top: 0.4rem; color: var(--muted); }
.post-form textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}
.post-form textarea:focus { outline: none; border-color: var(--text); }
#editor { background: #fff; color: #111; border-radius: 0 0 8px 8px; min-height: 200px; font-family: var(--sans); }
.ql-toolbar.ql-snow { border-radius: 8px 8px 0 0; background: var(--surface-2); border-color: var(--border); }
.ql-container.ql-snow { border-color: var(--border); }
.post-form button[type="submit"] { width: auto; margin-top: 1.75rem; }

.media-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

.list-head { display: flex; align-items: center; justify-content: space-between; }
.list-head .btn { width: auto; margin: 0; }
.admin-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border);
}
.row-actions { display: flex; align-items: center; gap: 1rem; white-space: nowrap; font-size: 0.9rem; }
.admin-row .meta { color: var(--muted); font-size: 0.8rem; }

/* --- Access codes --- */
.code-create {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem;
  margin: 1.25rem 0 2rem; padding: 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.code-create label { display: flex; flex-direction: column; gap: 0.4rem; font-weight: 600; }
.code-create input { text-align: left; letter-spacing: normal; }
.code-create button { width: auto; margin: 0; }
label.checkbox { flex-direction: row; align-items: center; gap: 0.45rem; font-weight: 400; }
label.checkbox input { width: auto; }

.code-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.code-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; text-align: center;
}
.code-card .qr { background: #fff; border-radius: 6px; padding: 6px; border: 1px solid var(--border); }
.code-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.3rem; letter-spacing: 0.12em; margin: 0.7rem 0 0.2rem; }
.badge { display: inline-block; font-size: 0.7rem; padding: 0.12rem 0.5rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; }
.badge.ok { background: rgba(40,125,60,0.12); color: var(--ok); }
.badge.off { background: rgba(180,35,24,0.1); color: var(--danger); }
.badge.email { background: rgba(21,18,13,0.08); color: var(--text); }
.code-actions { display: flex; justify-content: center; gap: 1rem; margin-top: 0.75rem; font-size: 0.9rem; }
.hashmono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Prevent long links/words from forcing horizontal scroll on narrow screens. */
.post .body, .post h2, .admin-row, .doc-link { overflow-wrap: anywhere; }
img, video { max-width: 100%; }

/* --- Phone polish --- */
@media (max-width: 480px) {
  .container { padding: 1.1rem 1rem 3rem; }
  .post { padding: 1.25rem; }
  .post h2 { font-size: 1.35rem; }
  .post .body { font-size: 1rem; }
  .gate-card { padding: 2rem 1.5rem; }
  .gate-card h1 { font-size: 2rem; }
  .topbar { padding: 0.85rem 1rem; }
  .topbar .brand { font-size: 1.3rem; }
  .code-create { padding: 1rem; gap: 0.85rem; }
  .code-create label, .code-create button, .code-create input { width: 100%; }
  /* Comfortable tap targets for admin row actions. */
  .row-actions { gap: 1.25rem; }
  .row-actions a, .row-actions button { padding: 0.25rem 0; }
}

/* --- Feed: search box + category tabs + category chip --- */
.feed-search { display: flex; gap: 0.5rem; margin: 0 0 1rem; }
.feed-search input[type="search"] {
  flex: 1; min-width: 0;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.feed-search button { width: auto; margin: 0; white-space: nowrap; }
.feed-searchinfo {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.9rem;
  color: var(--muted); font-size: 0.9rem; margin: 0 0 1.25rem;
}
.feed-clear { color: var(--muted); text-decoration: none; white-space: nowrap; }
.feed-clear:hover { color: var(--text); }

/* Horizontally-scrollable tab bar (mobile-first). */
.tabs {
  display: flex; gap: 0.4rem;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 0 0 1.25rem; padding-bottom: 0.35rem;
  scrollbar-width: thin;
}
.tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted);
  text-decoration: none; font-size: 0.9rem; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.tab-count { font-size: 0.75rem; opacity: 0.7; }

/* Category chip shown on each post card. */
.post .meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.cat-chip {
  display: inline-block; padding: 0.05rem 0.5rem;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 0.7rem; letter-spacing: 0.05em; color: var(--muted);
}

/* Category admin: add form + rename rows. */
.cat-add { display: flex; gap: 0.5rem; margin: 0 0 1.75rem; }
.cat-add input { flex: 1; min-width: 0; text-align: left; letter-spacing: normal; padding: 0.7rem 0.9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text); }
.cat-add button { width: auto; margin: 0; white-space: nowrap; }
.cat-rename { display: flex; gap: 0.5rem; align-items: center; flex: 1; margin: 0; }
.cat-rename input { flex: 1; min-width: 0; padding: 0.5rem 0.7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text); }
.cat-rename button { width: auto; margin: 0; }

/* Edition header above the feed, and the event list on the group page. */
.edition-head { margin: 0 0 1.25rem; }
.edition-head h1 { margin: 0.25rem 0 0.35rem; font-size: 1.6rem; overflow-wrap: anywhere; }
.edition-when { font-weight: 600; margin: 0; }
.edition-where { color: var(--muted); margin: 0; }
.edition-desc { margin: 0.4rem 0 0; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.edition-admin { align-items: flex-start; flex-wrap: wrap; }
.edition-admin form.post-form { flex: 1 1 18rem; margin: 0; }
.edition-admin .post-form button[type="submit"] { margin-top: 0.75rem; }

/* --- Events: upcoming / past list on the group page --- */
.feed-search + .events-heading { margin-top: 0.5rem; }
.events-heading {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 1.75rem 0 0.75rem;
}
.events { display: grid; gap: 0.75rem; }
.event-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
}
.event-card:hover, .event-card:focus-visible { border-color: var(--text); }
.event-date {
  flex: 0 0 auto; width: 3.25rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0.35rem 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.event-day { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; line-height: 1; }
.event-mon { font-size: 0.7rem; letter-spacing: 0.08em; color: var(--muted); margin-top: 0.15rem; }
.event-date-none { color: var(--muted); font-size: 1.2rem; }
.event-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 0.15rem;
  overflow-wrap: break-word;
}
.event-name { font-family: var(--serif); font-size: 1.05rem; font-weight: 700; line-height: 1.25; }
.event-meta { font-size: 0.85rem; color: var(--muted); }
.event-desc {
  font-size: 0.9rem; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.event-count { flex: 0 0 auto; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.event-card.past { opacity: 0.75; }
/* Phone: the post count moves under the text column so the name gets the width. */
@media (max-width: 480px) {
  .event-card { flex-wrap: wrap; row-gap: 0.35rem; }
  .event-body { flex-basis: calc(100% - 4.25rem); }
  .event-count { margin-left: 4.25rem; }
}
.event-card.past .event-date { background: transparent; }

/* --- Calendar: month view, agenda list, admin date/time row --- */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0.25rem 0 1rem;
}
.cal-head h1 { margin: 0; font-size: 1.5rem; text-align: center; }
.cal-nav {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
  font-size: 1.4rem;
}
.cal-nav:hover { border-color: var(--text); }
.cal-nav.disabled { opacity: 0.3; pointer-events: none; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-wd {
  background: var(--surface-2);
  text-align: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.45rem 0;
  font-weight: 600;
}
.cal-day {
  background: var(--surface);
  min-height: 6.5rem;
  padding: 0.35rem;
  position: relative;
  min-width: 0;
}
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-num { color: var(--muted); opacity: 0.6; }
.cal-day.past:not(.today) .cal-num { color: var(--muted); }
.cal-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}
.cal-day.today .cal-num { background: var(--text); color: var(--bg); }
/* A day tile is a whole-tile <button> (it opens the day's sheet) or <a> (a
   reachable day of another month): reset them so every tile looks the same
   as the plain <div> tiles. */
button.cal-day, a.cal-day {
  font: inherit;
  color: inherit;
  text-align: inherit;
  border: none;
  border-radius: 0;
  margin: 0;
  width: auto;
  /* A button centres its content vertically; lay tiles out top-down like the
     plain <div> tiles so day numbers line up across the row. */
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
button.cal-day:hover, a.cal-day:hover,
button.cal-day:focus-visible, a.cal-day:focus-visible { background: var(--surface-2); }
button.cal-day:focus-visible, a.cal-day:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}
.cal-items {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}
/* In the grid the name is what matters: it wraps (up to three lines) instead of
   being cut, and the time is left to the sheet that opens on tap. */
.cal-item {
  display: block;
  font-size: 0.78rem;
  line-height: 1.25;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  background: var(--surface-2);
  overflow-wrap: break-word;
  hyphens: auto;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cal-dot { display: none; }

/* Phone: compact day cells, a single dot per day with entries. */
@media (max-width: 640px) {
  button.cal-day, a.cal-day, .cal-day {
    min-height: 3rem;
    padding: 0.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .cal-items { display: none; }
  .cal-dot {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text);
    margin-top: 0.15rem;
  }
  .cal-wd { font-size: 0.7rem; }
  .cal-head h1 { font-size: 1.25rem; }
}

/* Agenda list inside the sheets. */
/* The month grid needs more room than the reading column on wide screens. */
.container.cal { max-width: 1040px; }
/* Room at the bottom so the fixed month-list bar never hides the last row. */
.cal { padding-bottom: 6rem; }
/* An untimed entry has no time column, so its title follows the date directly. */
.cal-entry-time:empty { display: none; }
.cal-agenda {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}
.cal-entry {
  display: grid;
  grid-template-columns: auto auto 1fr;
  column-gap: 0.75rem;
  align-items: baseline;
  padding: 0.8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scroll-margin-top: 5rem;
}
.cal-entry-date { font-weight: 700; white-space: nowrap; }
.cal-entry-time { color: var(--muted); white-space: nowrap; min-width: 2.8rem; }
.cal-entry-title { overflow-wrap: break-word; min-width: 0; }
@media (max-width: 480px) {
  .cal-entry-title { grid-column: 1 / -1; }
}

/* --- Bottom sheets (native popover): a day's entries, the month's list --- */
.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  max-height: 80dvh;
  overflow-y: auto;
  padding: 0 1rem calc(1.25rem + env(safe-area-inset-bottom));
  border: none;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 -8px 32px rgba(0,0,0,.15);
  transform: translateY(100%);
  transition: transform .25s ease, overlay .25s allow-discrete, display .25s allow-discrete;
}
.sheet:popover-open { transform: translateY(0); }
@starting-style {
  .sheet:popover-open { transform: translateY(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .sheet { transition: none; }
}
.sheet::backdrop { background: rgba(0,0,0,.35); }

.sheet-grip {
  width: 2.5rem;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: .6rem auto .25rem;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: inherit;
  padding: .5rem 0 .75rem;
  z-index: 1;
}
.sheet-head h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.sheet-close {
  background: none;
  border: none;
  color: var(--muted);
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  margin: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.sheet-close:hover { background: var(--surface-2); color: var(--text); opacity: 1; }

/* The bar fixed at the bottom of the screen that opens the month's list. */
.sheet-peek {
  white-space: nowrap;
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  width: auto;
  max-width: calc(100% - 2rem);
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .8rem 1.25rem;
  border: none;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  cursor: pointer;
}
.sheet-count {
  background: rgba(255,255,255,.2);
  padding: .05rem .5rem;
  border-radius: 999px;
  font-size: .85rem;
}

/* Admin event form: start date, start time and end date in one row. */
.cal-form-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0 1rem;
}
@media (max-width: 480px) {
  .cal-form-row { grid-template-columns: 1fr; }
}

/* ============================================================================
   Świętajno skin — a restrained Tolkien/LOTR signal over the same layout.
   Switched on by <html data-theme="swietajno"> (set from SITE_THEME env).
   Aged parchment + deep pine ink + antique gold, and an engraved-titling feel
   on the wordmark. Same editorial bones as Janów, cooler and older.
   ============================================================================ */
:root[data-theme="swietajno"] {
  --bg: #e7e3d5;        /* cool aged parchment (de-yellowed) */
  --surface: #f4f1e7;   /* lighter vellum for cards */
  --surface-2: #ddd6c4; /* raised parchment */
  --border: #c4b9a1;    /* worn edge */
  --text: #23271d;      /* deep pine ink (also the button fill) */
  --muted: #6a6353;     /* faded taupe */
  --accent: #7d6a45;    /* muted bronze (was antique gold) */
  --ok: #3f6b3a;        /* forest green */
  --serif: "Palatino Linotype", "Book Antiqua", "Iowan Old Style", Palatino, "URW Palladio L", Georgia, serif;
}

/* The topbar background is a literal off-white in the base theme — re-skin it
   to translucent parchment so the header matches. */
:root[data-theme="swietajno"] .topbar {
  background: rgba(240, 230, 205, 0.92);
}

/* Engraved-titling wordmark: uppercase, widely tracked — the LOTR signal,
   kept to the brand and the gate heading only ("just enough"). */
/* Engraved-titling wordmark — the topbar brand and the landing hero: uppercase,
   widely tracked, grand (but clamped so even a long site name fits the card). */
:root[data-theme="swietajno"] .topbar .brand {
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
:root[data-theme="swietajno"] .gate-card h1.wordmark {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: clamp(2rem, 6vw, 2.5rem);
  overflow-wrap: anywhere;
}
/* Generic gate headings (admin sign-in, "brak dostępu"): same carved caps, but
   sized/tracked so a long word like "ADMINISTRATORA" fits inside the card. */
:root[data-theme="swietajno"] .gate-card h1 {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: clamp(1.35rem, 4.5vw, 1.7rem);
  overflow-wrap: anywhere;
}

/* --- Ornaments (all inline SVG / CSS — no external assets, CSP-safe) --- */

/* Faint aged-parchment mottling behind everything. */
:root[data-theme="swietajno"] body {
  background-image:
    radial-gradient(circle at 15% 20%, rgba(110, 100, 78, 0.05), transparent 55%),
    radial-gradient(circle at 85% 12%, rgba(95, 88, 72, 0.045), transparent 50%),
    radial-gradient(circle at 50% 88%, rgba(105, 98, 78, 0.045), transparent 55%);
  background-attachment: fixed;
}

/* Engraved vine flourish beneath the gate wordmark. */
:root[data-theme="swietajno"] .gate-card h1::after {
  content: "";
  display: block;
  height: 20px;
  margin: 0.8rem auto 0;
  background: center/contain no-repeat url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='20' viewBox='0 0 160 20'><g stroke='%237d6a45' stroke-width='1.1' fill='none' stroke-linecap='round'><path d='M14 10 C40 10 44 4 60 10'/><path d='M146 10 C120 10 116 4 100 10'/><path d='M60 10 C68 4 72 4 80 10'/><path d='M100 10 C92 4 88 4 80 10'/></g><path d='M80 4 L84 10 L80 16 L76 10 Z' fill='%237d6a45'/><circle cx='14' cy='10' r='1.6' fill='%237d6a45'/><circle cx='146' cy='10' r='1.6' fill='%237d6a45'/></svg>");
}

/* Small gold sprigs flanking the topbar wordmark. */
:root[data-theme="swietajno"] .topbar .brand::before,
:root[data-theme="swietajno"] .topbar .brand::after {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  vertical-align: 0.1em;
  background: center/contain no-repeat url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'><path d='M8 2 L10 8 L8 14 L6 8 Z' fill='%237d6a45'/><circle cx='2' cy='8' r='1.3' fill='%237d6a45'/><circle cx='14' cy='8' r='1.3' fill='%237d6a45'/></svg>");
}
:root[data-theme="swietajno"] .topbar .brand::before { margin-right: 0.55rem; }
:root[data-theme="swietajno"] .topbar .brand::after { margin-left: 0.55rem; }

/* Inner keyline frame on the gate card — an illuminated-page/cartouche feel. */
:root[data-theme="swietajno"] .gate-card { position: relative; }
:root[data-theme="swietajno"] .gate-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(125, 106, 69, 0.35);
  border-radius: calc(var(--radius) - 4px);
  pointer-events: none;
}

/* Short gold rule under each post title. */
:root[data-theme="swietajno"] .post h2::after {
  content: "";
  display: block;
  width: 52px;
  height: 2px;
  margin-top: 0.55rem;
  background: linear-gradient(90deg, var(--accent), transparent);
}

/* --- Cinzel: an inscriptional titling face, self-hosted (CSP: font-src 'self') --- */
@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/cinzel-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/cinzel-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Carved-caps titling on the wordmark and post headings. */
:root[data-theme="swietajno"] .topbar .brand,
:root[data-theme="swietajno"] .gate-card h1,
:root[data-theme="swietajno"] .post h2 {
  font-family: "Cinzel", var(--serif);
  font-weight: 700;
}
:root[data-theme="swietajno"] .post h2 { letter-spacing: 0.02em; }

/* Illuminated drop-cap on the first paragraph of each post. */
:root[data-theme="swietajno"] .post .body > p:first-of-type::first-letter {
  font-family: "Cinzel", var(--serif);
  font-size: 3.1em;
  line-height: 0.72;
  float: left;
  margin: 0.06em 0.1em 0 0;
  color: var(--accent);
  font-weight: 700;
}

/* Gilded primary buttons — gold keyline, filling with gold on hover (skips the
   link-style and outline buttons). */
:root[data-theme="swietajno"] button[type="submit"]:not(.btn-outline):not(.linklike),
:root[data-theme="swietajno"] .btn:not(.btn-outline):not(.linklike) {
  border: 1px solid var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  letter-spacing: 0.04em;
}
:root[data-theme="swietajno"] button[type="submit"]:not(.btn-outline):not(.linklike):hover,
:root[data-theme="swietajno"] .btn:not(.btn-outline):not(.linklike):hover {
  background: var(--accent);
  color: #fff;
  opacity: 1;
}

/* Gilded quotes, gold prose links, flourish horizontal rules. */
:root[data-theme="swietajno"] .post .body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  font-style: italic;
  color: var(--muted);
}
:root[data-theme="swietajno"] .post .body a {
  color: #6b6047;
  text-decoration-color: var(--accent);
}
:root[data-theme="swietajno"] .post .body hr {
  border: none;
  height: 18px;
  margin: 1.5rem auto;
  background: center/auto 100% no-repeat url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='20' viewBox='0 0 160 20'><g stroke='%237d6a45' stroke-width='1.1' fill='none' stroke-linecap='round'><path d='M14 10 C40 10 44 4 60 10'/><path d='M146 10 C120 10 116 4 100 10'/><path d='M60 10 C68 4 72 4 80 10'/><path d='M100 10 C92 4 88 4 80 10'/></g><path d='M80 4 L84 10 L80 16 L76 10 Z' fill='%237d6a45'/><circle cx='14' cy='10' r='1.6' fill='%237d6a45'/><circle cx='146' cy='10' r='1.6' fill='%237d6a45'/></svg>");
}

/* Double gold rule under the topbar; faint gold top edge on each post card. */
:root[data-theme="swietajno"] .topbar {
  border-bottom: 3px double rgba(125, 106, 69, 0.5);
}
:root[data-theme="swietajno"] .post {
  border-top: 2px solid rgba(125, 106, 69, 0.3);
}

/* Corner studs on the gate-card frame — leather-binding / framed-map feel. */
:root[data-theme="swietajno"] .gate-card::before {
  background:
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M4 1 L7 4 L4 7 L1 4 Z' fill='%237d6a45'/></svg>") left 3px top 3px no-repeat,
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M4 1 L7 4 L4 7 L1 4 Z' fill='%237d6a45'/></svg>") right 3px top 3px no-repeat,
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M4 1 L7 4 L4 7 L1 4 Z' fill='%237d6a45'/></svg>") left 3px bottom 3px no-repeat,
    url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'><path d='M4 1 L7 4 L4 7 L1 4 Z' fill='%237d6a45'/></svg>") right 3px bottom 3px no-repeat;
}


/* ============================================================================
   Notifications — the opt-in card on the feed, the iOS add-to-home-screen
   instructions, and the "send a notification" checkbox in the post editor.
   ============================================================================ */
/* Notification bell in the top bar + its dropdown. */
.push-bell { position: relative; display: inline-flex; align-items: center; }
.bell-btn {
  width: auto; margin: 0; padding: 0.25rem;
  background: none; border: none; color: var(--muted);
  display: inline-flex; align-items: center; cursor: pointer; position: relative;
}
.bell-btn:hover { background: none; color: var(--text); opacity: 1; }
.bell-ic { display: block; }
.bell-dot {
  position: absolute; top: 1px; right: 1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ok); border: 1.5px solid var(--surface);
}

/* The dropdown, anchored to the bell, right-aligned so it stays on screen. */
.push-pop {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: min(320px, calc(100vw - 2rem));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.18);
  padding: 1rem; z-index: 60;
  max-height: min(70vh, 540px); overflow-y: auto;
  text-align: left;
}
.push-pop[hidden] { display: none; }

.push-state { display: block; }
.push-state[hidden] { display: none; }
/* Actions fill the dropdown width and sit under the text. */
.push-pop .push-state button { width: 100%; margin-top: 0.85rem; }

.push-text { flex: 1 1 16rem; min-width: 0; }
.push-text strong { display: block; }
.push-text p { margin: 0.25rem 0 0; font-size: 0.9rem; }

/* Buttons in this card size to their label instead of filling the row, which is
   what the global button rule does. */
.push-state button {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}

/* The numbered iPhone instructions. */
.push-steps {
  margin: 0.6rem 0 0;
  padding-left: 1.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.push-steps li { margin-bottom: 0.35rem; }
.push-steps strong { display: inline; color: var(--text); }

/* Inline iOS share glyph, aligned with the surrounding sentence. */
.ios-share {
  vertical-align: -0.2em;
  margin: 0 0.15em;
}

.push-pop .error { margin: 0.75rem 0 0; }

/* Checkbox + explanation row, used by the post editor's notify toggle. */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}
.check-row input[type="checkbox"] {
  width: auto;
  margin: 0.2rem 0 0;
  flex: 0 0 auto;
}
.check-row .meta {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Match the parchment skin: the dropdown reads as a raised vellum panel. */
:root[data-theme="swietajno"] .push-pop {
  border-top: 2px solid rgba(125, 106, 69, 0.3);
}

/* ============================================================================
   Modern skin — clean, app-like look for youth groups.
   Switched on by <html data-theme="modern">.
   Cool light canvas, indigo accent, system sans, softly rounded cards and a
   frosted topbar — a current mobile-app feel (Linear / Notion / iOS settings).
   Everything below is scoped to :root[data-theme="modern"], so the default
   Janów skin and the Świętajno skin are untouched.
   ============================================================================ */
:root[data-theme="modern"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --border: #e3e6ef;
  --text: #12131a;
  --muted: #5f6676;
  --accent: #5b5bd6;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(91, 91, 214, 0.10);
  --ok: #1f8a5b;
  --danger: #d92d20;
  --radius: 16px;
  --serif: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
}

/* --- Typography: tight app-style headings, accent links --- */
:root[data-theme="modern"] h1,
:root[data-theme="modern"] h2,
:root[data-theme="modern"] h3,
:root[data-theme="modern"] .brand {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.02em;
}
:root[data-theme="modern"] h1 { line-height: 1.15; }
:root[data-theme="modern"] a { color: var(--accent); }

/* Post meta reads like an app timestamp, not an editorial credit line. */
:root[data-theme="modern"] .post .meta {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
}

/* Neutralise any drop cap or decorative ornament for this theme. */
:root[data-theme="modern"] .post .body > p:first-of-type::first-letter {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  float: none;
  margin: 0;
  color: inherit;
  font-weight: inherit;
}
:root[data-theme="modern"] .post h2::after,
:root[data-theme="modern"] .gate-card h1::after,
:root[data-theme="modern"] .topbar .brand::before,
:root[data-theme="modern"] .topbar .brand::after {
  content: none;
}

/* --- Page background: soft accent glow at the top --- */
:root[data-theme="modern"] body {
  background-color: var(--bg);
  background-image: radial-gradient(1200px 400px at 50% -200px, rgba(91, 91, 214, 0.12), transparent 70%);
  background-attachment: fixed;
}

/* --- Topbar: frosted glass, gradient wordmark --- */
:root[data-theme="modern"] .topbar {
  background: rgba(255, 255, 255, 0.8);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
:root[data-theme="modern"] .topbar .brand {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* --- Drawer: accent icon buttons, rounded panel, gradient title --- */
:root[data-theme="modern"] .menu-btn,
:root[data-theme="modern"] .drawer-close { color: var(--accent); }
:root[data-theme="modern"] .menu-btn:hover,
:root[data-theme="modern"] .drawer-close:hover {
  background: var(--accent-soft);
  opacity: 1;
}
:root[data-theme="modern"] .drawer {
  border-left: none;
  box-shadow: -12px 0 40px rgba(16,24,40,.18);
  border-radius: 20px 0 0 20px;
}
:root[data-theme="modern"] .drawer-title {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
:root[data-theme="modern"] .drawer a { color: var(--text); }
:root[data-theme="modern"] .drawer a:hover { background: var(--accent-soft); }
:root[data-theme="modern"] .drawer a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}
:root[data-theme="modern"] .drawer::backdrop {
  background: rgba(16,24,40,.35);
  backdrop-filter: blur(2px);
}

/* --- Buttons: filled accent. The carve-outs keep link-style, outline and
   ghost icon buttons (bell, menu/close, Quill toolbar) untouched. --- */
:root[data-theme="modern"] button:not(.linklike):not(.btn-outline):not(.bell-btn):not(.menu-btn):not(.drawer-close):not(.cal-day):not(.sheet-close):not(.sheet-peek):not([class*="ql-"]),
:root[data-theme="modern"] .btn:not(.linklike):not(.btn-outline) {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}
:root[data-theme="modern"] button:not(.linklike):not(.btn-outline):not(.bell-btn):not(.menu-btn):not(.drawer-close):not(.cal-day):not(.sheet-close):not(.sheet-peek):not([class*="ql-"]):hover,
:root[data-theme="modern"] .btn:not(.linklike):not(.btn-outline):hover {
  background: #4a4ac4;
  opacity: 1;
}
:root[data-theme="modern"] .btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
}
:root[data-theme="modern"] .btn-outline:hover {
  background: var(--accent-soft);
  color: var(--accent);
  opacity: 1;
}
:root[data-theme="modern"] button.linklike {
  background: none;
  color: var(--accent);
  border: none;
}
:root[data-theme="modern"] button.linklike:hover {
  background: none;
  color: #4a4ac4;
  text-decoration: underline;
  opacity: 1;
}
:root[data-theme="modern"] button.linklike.danger,
:root[data-theme="modern"] button.linklike.danger:hover {
  color: var(--danger);
}

/* --- Inputs, textareas, selects (Quill's own controls are left alone) --- */
:root[data-theme="modern"] input[type="text"],
:root[data-theme="modern"] input[type="password"],
:root[data-theme="modern"] input[type="email"],
:root[data-theme="modern"] input[type="datetime-local"],
:root[data-theme="modern"] input[type="date"],
:root[data-theme="modern"] input[type="time"],
:root[data-theme="modern"] input[type="search"],
:root[data-theme="modern"] textarea,
:root[data-theme="modern"] select:not([class*="ql-"]) {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
}
:root[data-theme="modern"] input[type="text"]:focus,
:root[data-theme="modern"] input[type="password"]:focus,
:root[data-theme="modern"] input[type="email"]:focus,
:root[data-theme="modern"] input[type="datetime-local"]:focus,
:root[data-theme="modern"] input[type="date"]:focus,
:root[data-theme="modern"] input[type="time"]:focus,
:root[data-theme="modern"] input[type="search"]:focus,
:root[data-theme="modern"] textarea:focus,
:root[data-theme="modern"] select:not([class*="ql-"]):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.25);
}
/* Dress up selects so they no longer read as raw browser controls. */
:root[data-theme="modern"] select:not([class*="ql-"]) { padding: 0.55rem 0.75rem; }

/* --- Cards --- */
:root[data-theme="modern"] .post,
:root[data-theme="modern"] .gate-card,
:root[data-theme="modern"] .code-card,
:root[data-theme="modern"] .code-create,
:root[data-theme="modern"] .doc-link {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
:root[data-theme="modern"] .post h2 {
  font-size: 1.25rem;
  line-height: 1.3;
}
:root[data-theme="modern"] .post .media img,
:root[data-theme="modern"] .post .media video,
:root[data-theme="modern"] .post .body img {
  border-radius: 12px;
}

/* --- Gate (landing) card --- */
:root[data-theme="modern"] .gate-card h1.wordmark {
  font-size: clamp(1.5rem, 6vw, 1.85rem);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --- Tabs --- */
:root[data-theme="modern"] .tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.55rem 0.95rem; /* tall enough for a 40px tap target */
}
:root[data-theme="modern"] .tab:hover {
  border-color: var(--accent);
  color: var(--text);
}
:root[data-theme="modern"] .tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
:root[data-theme="modern"] .tab.active .tab-count {
  color: #fff;
  opacity: 0.85;
}

/* --- Category chips --- */
:root[data-theme="modern"] .cat-chip {
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
}

/* --- Editions / events --- */
:root[data-theme="modern"] .edition-desc { color: var(--muted); }
:root[data-theme="modern"] .edition-when { color: var(--accent); }
:root[data-theme="modern"] .events-heading { color: var(--muted); }
:root[data-theme="modern"] .event-card {
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
:root[data-theme="modern"] .event-card:hover,
:root[data-theme="modern"] .event-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-1px);
}
:root[data-theme="modern"] .event-date {
  background: var(--accent-soft);
  border: none;
  border-radius: 12px;
}
:root[data-theme="modern"] .event-day { color: var(--accent); font-weight: 800; }
:root[data-theme="modern"] .event-mon { color: var(--accent); font-weight: 700; }
:root[data-theme="modern"] .event-name { font-family: var(--sans); font-weight: 700; }
:root[data-theme="modern"] .event-card.past .event-date { background: var(--surface-2); }
:root[data-theme="modern"] .event-card.past .event-day,
:root[data-theme="modern"] .event-card.past .event-mon { color: var(--muted); }

/* --- Admin --- */
:root[data-theme="modern"] .admin-row { border-bottom-color: var(--border); }

/* Badges keep their meaning; the e-mail badge goes accent. */
:root[data-theme="modern"] .badge.email {
  background: var(--accent-soft);
  color: var(--accent);
}

/* The empty state reads like an app placeholder, not an editorial aside. */
:root[data-theme="modern"] .empty {
  font-style: normal;
  color: var(--muted);
}

/* --- Notification bell / dropdown + check row: recolour only, layout kept --- */
:root[data-theme="modern"] .bell-btn { color: var(--accent); }
:root[data-theme="modern"] .bell-btn:hover {
  background: none;
  color: #4a4ac4;
  opacity: 1;
}
:root[data-theme="modern"] .push-pop {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
:root[data-theme="modern"] .check-row .meta { color: var(--muted); }

/* --- Phone polish: comfortable tap targets on a 360px screen --- */
@media (max-width: 480px) {
  :root[data-theme="modern"] .row-actions a,
  :root[data-theme="modern"] .row-actions button { padding: 0.6rem 0.25rem; }
}

/* --- Calendar: month view, agenda list, admin date/time row --- */
:root[data-theme="modern"] .cal-nav {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
}
:root[data-theme="modern"] .cal-nav:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
:root[data-theme="modern"] .cal-grid {
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}
:root[data-theme="modern"] .cal-day.today .cal-num {
  background: var(--accent);
  color: #fff;
}
:root[data-theme="modern"] .cal-item {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
:root[data-theme="modern"] .cal-dot { background: var(--accent); }
:root[data-theme="modern"] .cal-entry { box-shadow: var(--shadow); }
:root[data-theme="modern"] .cal-entry-date { color: var(--accent); }
:root[data-theme="modern"] button.cal-day:hover,
:root[data-theme="modern"] a.cal-day:hover,
:root[data-theme="modern"] button.cal-day:focus-visible,
:root[data-theme="modern"] a.cal-day:focus-visible { background: var(--accent-soft); }
:root[data-theme="modern"] button.cal-day:focus-visible,
:root[data-theme="modern"] a.cal-day:focus-visible { outline-color: var(--accent); }
:root[data-theme="modern"] .sheet-close { color: var(--accent); }
:root[data-theme="modern"] .sheet-close:hover { background: var(--accent-soft); opacity: 1; }
:root[data-theme="modern"] .sheet::backdrop {
  background: rgba(16,24,40,.35);
  backdrop-filter: blur(2px);
}
:root[data-theme="modern"] .sheet-peek {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 20px rgba(91,91,214,.35);
}
