:root{
  --dw-cal-bg: var(--base-3);
  --dw-cal-text: var(--contrast);
  --dw-cal-muted: var(--contrast-3);
  --dw-cal-accent: var(--accent);
  --dw-cal-focus: var(--contrast);
  --dw-cal-grid: var(--base);
  --dw-cal-out: var(--base-2);
}

/* Card container */
.dw-cal{
  background: var(--dw-cal-bg);
  color: var(--dw-cal-text);
  border: 1px solid var(--dw-cal-grid);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  overflow: hidden; /* lets table corners clip cleanly when collapsed */
}

/* Toolbar */
.dw-cal__toolbar{
  display:flex; align-items:center; gap:.75rem; justify-content:space-between;
  margin: .25rem 0 .75rem; flex-wrap:wrap;
}
.dw-cal__label{font-weight:700; color:var(--dw-cal-focus);}

.dw-cal__nav{
  font-family: system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  border: 1px solid var(--dw-cal-grid);
  background: var(--base-2);
  color: var(--dw-cal-focus);
  padding:.35rem .6rem; border-radius:.6rem; cursor:pointer; line-height:1;
  transition: background .2s, color .2s, border-color .2s;
}
.dw-cal__nav:hover{ background: var(--accent); color: var(--base-3); border-color: var(--accent); }
.dw-cal__nav:focus{ outline:2px solid var(--dw-cal-accent); outline-offset:2px; }
.dw-cal__toggle{ margin-left:auto; text-decoration:underline; color:var(--accent); }
.dw-cal__toggle:hover{ color: var(--accent-hover); }

/* =========================
   Cohesive grid styling
   ========================= */
.dw-cal__grid{
  width:100%;
  border-collapse: collapse;      /* <- single, unified lines */
  table-layout: fixed;
  border: 1px solid var(--dw-cal-grid); /* outer stroke */
  border-radius: 10px;            /* works with overflow:hidden on parent */
  background: var(--base-3);
}

/* Header and body cells share the SAME border rules */
.dw-cal__grid th,
.dw-cal__grid td{
  border: 1px solid var(--dw-cal-grid);
  padding: .5rem;
  vertical-align: top;
}

/* Header look */
.dw-cal__grid thead th{
  font-size: .85rem;
  color: var(--dw-cal-muted);
  background: #fafbfc; /* subtle contrast vs cells */
  font-weight: 600;
}

/* Day cells */
.dw-cal__grid td{
  height: 6.25rem;
  background: var(--base-3);
}
.dw-cal__cell.is-out{
  background: var(--dw-cal-out);
  color: var(--dw-cal-muted);
}

/* Day link */
.dw-cal__day{
  display:block; height:100%; position:relative; text-decoration:none; color:inherit;
  padding: .35rem .5rem .9rem;
}
.dw-cal__day:focus{ outline:2px solid var(--dw-cal-accent); outline-offset:-2px; }
.dw-cal__num{ font-weight:600; }
.dw-cal__dots{
  position:absolute; bottom:.45rem; left:.55rem; letter-spacing:.12rem; color:var(--accent);
}
.dw-cal__cell.has-events .dw-cal__num{ color: var(--dw-cal-accent); }

/* Responsive tweaks */
@media (max-width:640px){
  .dw-cal__grid td{ height: 4.5rem; }
  .dw-cal__grid th{ font-size:.75rem; }
}

/* Drawer */
.dw-cal__drawer{
  position:relative; margin-top:1rem; border:1px solid var(--dw-cal-grid);
  border-radius:.75rem; padding:.75rem; background:var(--base-3);
  display:none;
}
.dw-cal.drawer-open .dw-cal__drawer{ display:block; }
.dw-cal__drawer-head{ display:flex; align-items:center; justify-content:space-between; gap:.5rem; }
.dw-cal__drawer-date{ margin:0; font-size:1.05rem; color:var(--dw-cal-focus); }
.dw-cal__drawer-close{
  font-family: system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  border:1px solid var(--dw-cal-grid); background:var(--base-2); color:var(--dw-cal-focus);
  border-radius:.5rem; padding:.25rem .5rem; cursor:pointer;
}
.dw-cal__drawer-close:hover{ background:var(--accent); color:var(--base-3); border-color:var(--accent); }

.dw-cal__events{ list-style:none; margin:.75rem 0 0; padding:0; display:grid; gap:.5rem; }
.dw-cal__event-link{ text-decoration:none; font-weight:600; color:var(--dw-cal-focus); }
.dw-cal__event-link:hover{ color:var(--dw-cal-accent); }
.dw-cal__event-meta{ font-size:.9rem; color:var(--dw-cal-muted); }
.dw-cal__events-empty{ color:var(--dw-cal-muted); }

/* Utility */
.dw-sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0;
}

/* pointer only when the day actually has events (after JS upgrades) */
.dw-cal__cell.has-events .dw-cal__day { cursor: pointer; }

/* ---------- Mobile polish (<= 480–640px) ---------- */

/* Never wrap weekday labels or day numbers */
.dw-cal__grid th,
.dw-cal__num,
.dw-cal__day { white-space: nowrap; }

/* Use tabular numerals so numbers line up nicely */
.dw-cal__num { font-variant-numeric: tabular-nums; }

/* Make nav arrows visible + tappable */
.dw-cal__nav {
  width: 32px; height: 32px; padding: 0;
  display: inline-grid; place-items: center;
  background: var(--dw-cal-bg);
  color: var(--dw-cal-text);
  border: 1px solid var(--dw-cal-grid);
  border-radius: 999px;
}
.dw-cal__nav:hover,
.dw-cal__nav:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--dw-cal-accent, #E6007E) inset;
}

/* Base tightening for small screens */
@media (max-width: 640px) {
  .dw-cal { padding: .75rem; }
  .dw-cal__toolbar { gap: .5rem; }
  .dw-cal__label { font-size: 1rem; }

  .dw-cal__grid { table-layout: fixed; }
  .dw-cal__grid th { 
    font-size: .72rem; 
    padding: .35rem .4rem; 
    text-transform: none; 
  }

  .dw-cal__grid td { 
    height: 4rem;             /* was 6.5rem; keeps grid compact */
    padding: 0;               /* avoid inner growth */
  }

  .dw-cal__day { 
    padding: .4rem .45rem .35rem; 
    line-height: 1; 
  }

  .dw-cal__num { 
    display: inline-block; 
    font-size: .95rem; 
    line-height: 1; 
  }

  .dw-cal__dots { 
    bottom: .35rem; 
    left: .45rem; 
    letter-spacing: .15rem; 
  }

  .dw-cal__drawer { 
    margin-top: .75rem; 
    padding: .6rem; 
  }
}

/* Extra-tight phones */
@media (max-width: 380px) {
  .dw-cal__grid th { font-size: .68rem; }
  .dw-cal__num { font-size: .9rem; }
  .dw-cal__grid td { height: 3.6rem; }
}

.dw-cal__event-cardmeta { margin-top: .25rem; }
.dw-cal__event-cardmeta .dw-card-meta { margin: 0; }

/* Remove unwanted space below h4 links in calendar drawer */
.dw-cal__drawer .dw-cal__event-title {
  margin: 0;               /* kill default margins */
  padding: 0;              /* keep tight */
  font-size: 1.1rem;         /* or inherit your body size */
  line-height: 1.4;        /* adjust if needed for legibility */
}

.dw-cal__drawer .dw-cal__event-title {
  margin: 0;
  font-weight: normal; /* let the link carry the weight */
}
.dw-cal__drawer .dw-cal__event-link {
  font-weight: 600;
  display: inline-block;
}

/* Empty-results state */
.dw-cal--empty .dw-cal__nav { display: none; }

.dw-cal__empty {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px dashed var(--dw-cal-grid);
  border-radius: .75rem;
  background: var(--base-3);
  color: var(--dw-cal-text);
  text-align: center;
}
.dw-cal__empty h3 { margin: 0 0 .4rem; font-size: 1.1rem; color: var(--dw-cal-focus); }
.dw-cal__empty p { margin: 0 0 .8rem; color: var(--dw-cal-muted); }
.dw-cal__empty-actions { display: inline-flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }

.dw-cal__btn {
  display: inline-block;
  padding: .5rem .9rem;
  border-radius: .6rem;
  text-decoration: none;
  font-weight: 600;
}
.dw-cal__btn--primary {
  background: var(--dw-cal-accent);
  color: var(--base-3);
}
.dw-cal__btn--primary:hover { filter: brightness(0.95); }
.dw-cal__btn--link { color: var(--dw-cal-accent); text-decoration: underline; }

/* Calendar empty-state buttons */
.dw-cal__empty .dw-cal__btn {
  display: inline-block;
  padding: .75rem 1.25rem;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
}

.dw-cal__empty .dw-cal__btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--base-3) !important;       /* force white text */
}

.dw-cal__empty .dw-cal__btn--primary:hover,
.dw-cal__empty .dw-cal__btn--primary:focus {
  background: var(--accent-hover, #e00078);
  border-color: var(--accent-hover, #e00078);
  color: var(--base-3) !important;
}

/* Secondary link-style button in the empty state */
.dw-cal__empty .dw-cal__btn--link {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
  text-decoration: underline;
}

/* ── MOBILE-ONLY: lock the calendar toolbar, full-width, no layout shift ── */
@media (max-width: 700px){
  .dw-cal__toolbar{
    display: grid;
    grid-template-columns: 48px 1fr 48px;   /* prev | month | next */
    grid-template-rows: auto auto;          /* row 1 = nav, row 2 = toggle link */
    align-items: center;
    gap: .5rem .75rem;
    width: 100%;
    padding: .25rem .5rem;
  }

  /* Fixed-size tap targets = stable row height */
  .dw-cal__nav{
    width: 48px; height: 48px;
    border-radius: 999px;
    display: grid; place-items: center;
    flex: 0 0 48px; /* guard if any flex styles leak in */
  }

  /* Explicit placement */
  .dw-cal__nav--prev{ grid-column: 1; grid-row: 1; justify-self: start; }
  .dw-cal__label   {
    grid-column: 2; grid-row: 1;
    text-align: center; font-weight: 700;
    white-space: nowrap; min-height: 1.8em; /* prevents jumpy height */
  }
  .dw-cal__nav--next{ grid-column: 3; grid-row: 1; justify-self: end; }

  /* Put “Switch to list view” on its own row on mobile */
  .dw-cal__toggle{
    grid-column: 1 / -1;   /* full width below nav row */
    grid-row: 2;
    justify-self: end;
    margin-left: 0;        /* override any desktop rule */
  }
}

/* Tiny phones: soften month label size */
@media (max-width: 420px){
  .dw-cal__label{ font-size: clamp(1rem, 2.8vw + .8rem, 1.25rem); }
}