/* ============================================================================
   CIMUNICH CALENDAR — styles
   Quiet printed-bulletin look: warm paper, deep ink, one burgundy accent.
   ============================================================================ */

:root {
  --paper:      #f7f4ee;
  --card:       #fffdf9;
  --ink:        #1f2430;
  --ink-soft:   #5f6472;
  --ink-faint:  #9a9ca6;
  --line:       #e4ded2;
  --line-soft:  #efeae0;
  --accent:     #8a2e3b;
  --accent-soft:#f5e8e6;
  --accent-ink: #fff8f4;
  --today:      #8a2e3b;
  --we:         #faf7f1;

  --radius: 14px;
  --maxw: 1180px;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --shadow-sm: 0 1px 2px rgba(31,36,48,.06);
  --shadow-md: 0 1px 2px rgba(31,36,48,.05), 0 10px 30px -18px rgba(31,36,48,.35);
  --shadow-lg: 0 24px 60px -20px rgba(31,36,48,.45);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px 72px; }

/* ---------- masthead -------------------------------------------------------*/
.masthead {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 40px 0 20px;
  border-bottom: 1px solid var(--ink);
}
.kicker {
  font-size: 11.5px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent);
}
.brand h1 {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(40px, 7vw, 64px); line-height: 1; letter-spacing: -.015em;
  margin: 8px 0 0;
}

.mast-right { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: flex-end; }
.lang { display: inline-flex; background: var(--line-soft); border-radius: 9px; padding: 3px; }
.lang button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--ink-soft);
  padding: 5px 10px; border-radius: 6px;
}
.lang button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.admin-bar { display: flex; align-items: center; gap: 14px; font-size: 13.5px; }
.admin-badge {
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; padding: 4px 9px; border-radius: 6px;
}
.admin-bar a, .admin-bar button {
  color: var(--ink-soft); text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; font-weight: 500;
}
.admin-bar a:hover, .admin-bar button:hover { color: var(--ink); text-decoration: underline; }

/* ---------- controls -------------------------------------------------------*/
.controls {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 22px 0 16px;
}
.month-nav { display: flex; align-items: center; gap: 6px; min-width: 0; }
.month-nav h2, .list-title {
  font-family: var(--font-display); font-weight: 500; font-size: 28px; line-height: 1.1;
  margin: 0 8px; min-width: 0; white-space: nowrap;
}
.month-nav h2 { width: 9.2em; text-align: center; }
.list-title { display: none; margin: 0; }
body[data-view="list"] .month-nav { display: none; }
body[data-view="list"] .list-title { display: block; }

.icon-btn, .text-btn {
  appearance: none; cursor: pointer; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; height: 38px;
  display: inline-grid; place-items: center; color: var(--ink);
  transition: border-color .15s, background .15s;
}
.icon-btn { width: 38px; }
.icon-btn svg { width: 18px; height: 18px; }
.text-btn { padding: 0 14px; font-weight: 600; font-size: 13.5px; margin-left: 6px; }
.icon-btn:hover, .text-btn:hover { border-color: var(--ink-soft); }

.controls-right { display: flex; align-items: center; gap: 10px; flex: none; }
.filter-btn {
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 11px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-soft);
  font: inherit; font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.filter-btn svg { width: 16px; height: 16px; flex: none; }
.filter-btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.filter-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.views {
  display: inline-flex; flex: none; background: var(--line-soft); border-radius: 11px; padding: 3px;
}
.views button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-weight: 600; font-size: 13.5px; color: var(--ink-soft);
  padding: 7px 16px; border-radius: 8px; transition: background .15s, color .15s;
}
.views button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.notice {
  margin: 0 0 14px; padding: 11px 14px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 500;
}

/* ---------- panels ---------------------------------------------------------*/
.panel { display: none; }
.panel.active { display: block; animation: rise .3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md); overflow: hidden;
}

/* ====================== MONTH ============================================= */
.dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.dow div {
  padding: 10px 10px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft);
}
.dow .we { color: var(--ink-faint); }

.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cell {
  min-height: 118px; min-width: 0; padding: 6px 6px 8px;
  border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  position: relative; cursor: default;
}
.cell:nth-child(7n) { border-right: 0; }
.cell.we { background: var(--we); }
.cell.outside .daynum { color: var(--ink-faint); }
.cell.outside .chips { opacity: .55; }
.daynum {
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%;
  margin-bottom: 3px;
}
.cell.today .daynum { background: var(--today); color: #fff; }

.chips { display: flex; flex-direction: column; gap: 2px; }
.chip {
  appearance: none; border: 0; background: none; cursor: pointer; text-align: left;
  display: flex; align-items: baseline; gap: 5px; min-width: 0; width: 100%;
  padding: 3px 6px; border-radius: 6px; font-size: 12.5px; line-height: 1.3; color: var(--ink);
  transition: background .12s;
}
.chip:hover { background: var(--accent-soft); }
.chip .t { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; flex: none; font-size: 11.5px; }
.chip .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chip.block { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip.block:hover { background: #74252f; }
.chip.cont { opacity: .72; }

.dots, .day-list { display: none; }

/* ====================== LIST ============================================== */
.list { padding-bottom: 6px; }
.list-month {
  padding: 22px 24px 8px; font-family: var(--font-display); font-size: 21px; font-weight: 500;
  border-top: 1px solid var(--line-soft);
}
.list-month:first-child { border-top: 0; }
.list-day {
  display: grid; grid-template-columns: 64px 1fr; gap: 14px;
  padding: 10px 24px; border-top: 1px solid var(--line-soft);
}
.list-month + .list-day { border-top: 0; }
.date-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 8px; line-height: 1;
}
.date-tile b { font-family: var(--font-display); font-weight: 500; font-size: 30px; }
.date-tile span { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin-top: 5px; }
.list-day.today .date-tile b, .list-day.today .date-tile span { color: var(--today); }
.list-evs { display: flex; flex-direction: column; min-width: 0; }

.ev-row {
  appearance: none; border: 0; background: none; cursor: pointer; text-align: left; width: 100%;
  display: grid; grid-template-columns: 112px 1fr 18px; gap: 14px; align-items: center;
  padding: 11px 10px; border-radius: 10px; transition: background .12s;
}
.ev-row:hover { background: var(--accent-soft); }
.ev-row + .ev-row { border-top: 1px solid var(--line-soft); border-radius: 0; }
.ev-row + .ev-row:hover { border-radius: 10px; }
.ev-time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13.5px; color: var(--accent); }
.ev-time span { color: var(--ink-faint); font-weight: 500; }
.ev-body { display: flex; flex-direction: column; min-width: 0; }
.ev-name { font-weight: 600; font-size: 15.5px; }
.ev-loc { color: var(--ink-soft); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { width: 18px; height: 18px; color: var(--ink-faint); }

.empty { padding: 56px 24px; text-align: center; color: var(--ink-soft); font-family: var(--font-display); font-size: 19px; }

.foot { margin-top: 22px; color: var(--ink-faint); font-size: 12.5px; }

/* ====================== MODAL ============================================= */
dialog#event-modal {
  border: 0; padding: 0; border-radius: 18px; background: var(--card); color: var(--ink);
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  box-shadow: var(--shadow-lg);
}
dialog#event-modal[open] { animation: pop .2s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
dialog#event-modal::backdrop { background: rgba(31,36,48,.42); backdrop-filter: blur(2px); }
.modal-inner { padding: 26px 26px 24px; position: relative; overflow-y: auto; max-height: inherit; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--line-soft); cursor: pointer; display: grid; place-items: center; color: var(--ink-soft);
}
.modal-close:hover { background: var(--line); color: var(--ink); }
.modal-close svg { width: 18px; height: 18px; }
.ev-date {
  font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
  padding-right: 44px;
}
#ev-title {
  font-family: var(--font-display); font-weight: 500; font-size: 28px; line-height: 1.15;
  margin: 6px 44px 16px 0; overflow-wrap: anywhere;
}
.ev-meta { display: flex; flex-direction: column; gap: 10px; }
.meta-row { display: flex; gap: 11px; align-items: flex-start; font-size: 15px; }
.meta-row svg { width: 19px; height: 19px; flex: none; color: var(--ink-soft); margin-top: 1px; }
.meta-row span { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.meta-row a { color: var(--accent); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.meta-row a:hover { text-decoration: underline; }
.ev-desc {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft);
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; color: var(--ink);
}
.ev-desc a { color: var(--accent); }

/* ====================== ADMIN CHAT ======================================== */
#chat-fab {
  position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 40;
  width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
  display: grid; place-items: center; box-shadow: var(--shadow-lg);
  transition: transform .15s ease, opacity .2s;
}
#chat-fab svg { width: 26px; height: 26px; }
#chat-fab:hover { transform: translateY(-2px); }
#chat-fab.away { opacity: 0; pointer-events: none; transform: scale(.85); }

#chat-panel {
  position: fixed; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 45;
  width: min(390px, calc(100vw - 28px)); height: min(560px, calc(100dvh - 44px));
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transform: translateY(12px) scale(.98);
  transition: opacity .2s ease, transform .2s ease;
}
#chat-panel.open { opacity: 1; pointer-events: auto; transform: none; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--line);
}
.chat-title { font-family: var(--font-display); font-weight: 500; font-size: 20px; }
.chat-sub { font-size: 12.5px; color: var(--ink-soft); }
#chat-close {
  width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--line-soft);
  cursor: pointer; display: grid; place-items: center; color: var(--ink-soft);
}
#chat-close svg { width: 17px; height: 17px; }
#chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg {
  max-width: 86%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45;
  overflow-wrap: break-word; animation: rise .2s ease both;
}
.chat-msg.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.chat-msg.assistant { align-self: flex-start; background: var(--paper); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg ul, .chat-msg ol { margin: 4px 0; padding-left: 18px; }
.chat-msg li { margin: 3px 0; }
.chat-msg.typing { color: var(--ink-faint); letter-spacing: .2em; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
#chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
#chat-input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink);
  padding: 10px 13px; border-radius: 11px; border: 1px solid var(--line); background: #fff; outline: none;
}
#chat-input:focus { border-color: var(--ink-soft); }
#chat-form button {
  flex: none; width: 44px; border-radius: 11px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
}
#chat-form button svg { width: 18px; height: 18px; }

/* ====================== RESPONSIVE ======================================== */
@media (max-width: 900px) {
  .cell { min-height: 96px; padding: 5px 4px 6px; }
  .chip { font-size: 11.5px; padding: 2px 4px; }
  .chip .t { display: none; }
}

@media (max-width: 640px) {
  .wrap { padding: 0 16px 90px; }
  .masthead { padding: 26px 0 14px; }
  .kicker { font-size: 10.5px; letter-spacing: .18em; }
  .masthead { position: relative; }
  .mast-right { width: 100%; justify-content: space-between; }
  .lang { position: absolute; top: 20px; right: 0; }
  .mast-right:has(.admin-bar[hidden]) { display: contents; }

  .controls { flex-wrap: wrap; gap: 12px; margin: 16px 0 12px; }
  .controls-right { order: -1; width: 100%; gap: 8px; }
  .views { flex: 1; }
  .views button { flex: 1; padding: 7px 10px; }
  .filter-btn { padding: 0 12px; }
  .month-nav { width: 100%; }
  .month-nav h2 { flex: 1; width: auto; font-size: 23px; margin: 0 4px; }
  .list-title { font-size: 23px; }

  /* month: compact grid with dots, events listed under it */
  .dow div { padding: 8px 0; text-align: center; font-size: 10.5px; letter-spacing: .06em; }
  .cell {
    min-height: 54px; padding: 4px 0 6px; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    -webkit-tap-highlight-color: transparent;
  }
  .cell.we { background: none; }
  .daynum { margin: 0; width: 30px; height: 30px; font-size: 14px; }
  .cell.selected .daynum { box-shadow: inset 0 0 0 1.5px var(--ink); }
  .cell.today.selected .daynum { box-shadow: 0 0 0 2px var(--card), 0 0 0 3.5px var(--today); }
  .chips { display: none; }
  .dots { display: flex; gap: 3px; align-items: center; height: 7px; }
  .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .55; }
  .dots i.b { opacity: 1; }
  .dots span { font-size: 10px; line-height: 1; color: var(--ink-soft); font-weight: 700; }
  .cell.outside .dots { opacity: .45; }

  .day-list {
    display: block; margin-top: 14px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: 6px 6px 8px;
  }
  .day-head { padding: 10px 10px 6px; font-family: var(--font-display); font-size: 19px; font-weight: 500; }
  .day-empty { padding: 12px 10px 10px; color: var(--ink-soft); font-size: 14px; }

  .ev-row { grid-template-columns: 1fr 18px; gap: 4px 10px; padding: 11px 10px; }
  .ev-time { grid-column: 1; grid-row: 1; font-size: 12.5px; }
  .ev-body { grid-column: 1; grid-row: 2; }
  .chev { grid-column: 2; grid-row: 1 / span 2; }

  .list-month { padding: 18px 16px 6px; font-size: 19px; }
  .list-day { grid-template-columns: 44px 1fr; gap: 6px; padding: 6px 10px 6px 12px; }
  .date-tile b { font-size: 24px; }

  /* modal becomes a bottom sheet */
  dialog#event-modal {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0;
    max-height: 88dvh;
  }
  dialog#event-modal[open] { animation: sheet .25s cubic-bezier(.2,.8,.2,1) both; }
  .modal-inner { padding: 22px 20px calc(24px + env(safe-area-inset-bottom)); }
  #ev-title { font-size: 25px; }

  #chat-panel { right: 0; bottom: 0; width: 100%; height: 100dvh; border-radius: 0; border: 0; }
  #chat-fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
}
@keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
