@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Brand color tokens ───────────────────────────────────────────────────── */
:root {
  --kch-navy:        #28357c;
  --kch-navy-soft:   #354096;
  --kch-gold:        #e1b12f;
  --kch-gold-rgb:    225,177,47;
  --kch-gold-mid:    #d6b163;
  --kch-gold-light:  #dfc37f;
  --kch-gold-deep:   #cc9a32;
  --kch-orange:      #f39200;
  --kch-orange-deep: #ec6608;
  --kch-coral:       #e94a49;
  --kch-teal:        #377d90;
  --kch-blue:        #405fa9;

  /* Dark-mode surfaces — warm */
  --kch-bg:          #0d0a02;
  --kch-surface:     rgba(225,177,47,.065);
  --kch-border:      rgba(225,177,47,.15);
  --kch-text:        rgba(255,255,255,.92);
  --kch-muted:       rgba(255,230,180,.42);

  --kch-radius:      14px;
  --kch-radius-sm:   9px;
  --kch-shadow:      0 4px 24px rgba(0,0,0,.35), 0 1px 4px rgba(0,0,0,.2);
  --kch-shadow-md:   0 12px 48px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3);
  --kch-t:           .18s ease;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  /* Fixed gradient mesh — stays in place as content scrolls */
  background-color: #0d0a02;
  background-image:
    radial-gradient(ellipse 80% 55% at 12% 18%, rgba(225,177,47,.15) 0%, transparent 60%),
    radial-gradient(ellipse 65% 45% at 85% 85%, rgba(243,146,0,.10)  0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 55% -5%, rgba(40,53,124,.35)  0%, transparent 50%);
  background-attachment: fixed;
  color: var(--kch-text);
  margin: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ──────────────────────────────────────────────────────────────── */
.kch-navbar {
  background: rgba(8,6,1,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(225,177,47,.1);
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}

.kch-navbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 58px;
  flex-wrap: wrap;
}

.kch-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  white-space: nowrap;
}

.kch-logo-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(225,177,47,.14);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px;
  padding: 3px 7px;
  line-height: 0;
}

.kch-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  display: block;
}

.kch-brand-text {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--kch-gold);
  letter-spacing: -0.02em;
}

.kch-nav {
  display: flex;
  gap: 0.125rem;
  flex: 1;
}

.kch-nav-link {
  display: inline-block;
  padding: 0.3125rem 0.75rem;
  border-radius: 6px;
  color: rgba(255,255,255,.5);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--kch-t), color var(--kch-t);
}
.kch-nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.kch-nav-link.active {
  color: var(--kch-gold);
  background: rgba(225,177,47,.12);
}

.kch-navbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  margin-left: auto;
}

.kch-user-name {
  color: rgba(255,255,255,.38);
  font-size: 0.8125rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-kch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.875rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: background var(--kch-t), border-color var(--kch-t), color var(--kch-t), box-shadow var(--kch-t);
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}
.btn-kch-sm { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }

/* Gold primary */
.btn-kch-primary {
  background: var(--kch-gold);
  color: #1a1209;
  border-color: var(--kch-gold);
}
.btn-kch-primary:hover {
  background: var(--kch-gold-deep);
  border-color: var(--kch-gold-deep);
  box-shadow: 0 2px 12px rgba(var(--kch-gold-rgb),.45);
}

/* Outline — for dark backgrounds */
.btn-kch-outline {
  background: transparent;
  color: rgba(255,255,255,.6);
  border-color: rgba(255,255,255,.2);
}
.btn-kch-outline:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-color: rgba(255,255,255,.38);
}

/* Gold outline — for card Save buttons */
.btn-kch-gold {
  background: rgba(225,177,47,.1);
  color: var(--kch-gold);
  border-color: rgba(225,177,47,.28);
}
.btn-kch-gold:hover {
  background: rgba(225,177,47,.18);
  border-color: var(--kch-gold);
  box-shadow: 0 0 0 3px rgba(var(--kch-gold-rgb),.14);
}

/* ── Login form (inside dark navbar) ─────────────────────────────────────── */
.kch-login-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.kch-nav-input {
  padding: 0.3125rem 0.625rem;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,.14);
  background: rgba(225,177,47,.09);
  color: #fff;
  font-size: 0.8125rem;
  width: 115px;
  outline: none;
  transition: border-color var(--kch-t), background var(--kch-t);
  font-family: inherit;
}
.kch-nav-input::placeholder { color: rgba(255,255,255,.3); }
.kch-nav-input:focus { border-color: var(--kch-gold); background: rgba(225,177,47,.14); }

/* ── Telegram badge ──────────────────────────────────────────────────────── */
.kch-tg-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(55,125,144,.2);
  color: #7fd5e8;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(55,125,144,.35);
}

/* ── Flash alert ─────────────────────────────────────────────────────────── */
.kch-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--kch-radius-sm);
  background: rgba(225,177,47,.08);
  border: 1px solid rgba(225,177,47,.2);
  color: var(--kch-gold);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.kch-alert-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--kch-gold);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
  opacity: 0.55;
  font-family: inherit;
}
.kch-alert-close:hover { opacity: 1; }

/* ── Page shell ──────────────────────────────────────────────────────────── */
.kch-page {
  max-width: 980px;
  margin: 0 auto;
  padding: 2rem 1.25rem 5rem;
}

.kch-page-sub {
  color: rgba(255,255,255,.3);
  font-size: 0.875rem;
  margin: 0 0 1.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ── Section label ───────────────────────────────────────────────────────── */
.kch-section-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(225,177,47,.6);
  margin: 0 0 0.875rem;
}

/* ── View switcher tabs ──────────────────────────────────────────────────── */
.kch-view-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: var(--kch-radius-sm);
  padding: 0.25rem;
  width: fit-content;
  box-shadow: var(--kch-shadow);
}

.kch-view-tab {
  padding: 0.3125rem 0.875rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(255,255,255,.42);
  text-decoration: none;
  transition: background var(--kch-t), color var(--kch-t);
  white-space: nowrap;
}
.kch-view-tab:hover { color: rgba(255,255,255,.8); background: rgba(225,177,47,.09); }
.kch-view-tab.active {
  background: rgba(225,177,47,.15);
  color: var(--kch-gold);
  border: 1px solid rgba(225,177,47,.22);
}

/* ── Card entrance animation ─────────────────────────────────────────────── */
@keyframes kch-slide-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ── Event cards ─────────────────────────────────────────────────────────── */
.kch-cards { display: flex; flex-direction: column; gap: 0.875rem; margin-bottom: 3rem; }

.kch-card {
  background: rgba(225,177,47,.075);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--kch-radius);
  box-shadow: var(--kch-shadow);
  border: 1px solid rgba(225,177,47,.14);
  overflow: hidden;
  transition: box-shadow var(--kch-t), transform var(--kch-t), border-color var(--kch-t);
  animation: kch-slide-in .45s cubic-bezier(.22,.68,0,1.2) both;
}
.kch-card:hover {
  box-shadow: var(--kch-shadow-md);
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.16);
}

.kch-card-accent {
  height: 3px;
  background: linear-gradient(90deg, var(--kch-gold) 0%, var(--kch-orange) 100%);
}
/* Per-event colour: thicker accent bar tinted with the event colour. */
.kch-ev-card .kch-card-accent { height: 5px; background: var(--ev-bg); }
.kch-card.past .kch-card-accent { background: rgba(255,255,255,.12); }
.kch-card.past { opacity: 0.52; }
.kch-card.past:hover { opacity: 0.78; }

.kch-card-body { padding: 1.25rem 1.5rem; }

.kch-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.kch-event-name {
  font-size: 1.0625rem;
  font-weight: 600;
  color: rgba(255,255,255,.95);
  margin: 0 0 0.2rem;
  letter-spacing: -0.02em;
}

.kch-event-info {
  font-size: 0.8125rem;
  color: var(--kch-muted);
  margin: 0;
}

/* Markdown-rendered event notes in event card */
.kch-event-notes {
  font-size: 0.875rem;
  color: rgba(255,255,255,.82);
  margin: 0.5rem 0 0;
  line-height: 1.55;
}
.kch-event-notes > :first-child { margin-top: 0; }
.kch-event-notes > :last-child  { margin-bottom: 0; }
.kch-event-notes p  { margin: 0 0 0.5em; }
.kch-event-notes ul,
.kch-event-notes ol { margin: 0 0 0.5em; padding-left: 1.4em; }
.kch-event-notes li { margin: 0 0 0.15em; }
.kch-event-notes h1 { font-size: 1.1rem;  font-weight: 700; margin: .6em 0 .25em; border-bottom: 1px solid rgba(255,255,255,.12); padding-bottom: .2em; }
.kch-event-notes h2 { font-size: .95rem;  font-weight: 600; margin: .55em 0 .2em; }
.kch-event-notes h3 { font-size: .85rem;  font-weight: 600; margin: .5em 0 .15em; opacity: .9; }
.kch-event-notes strong { font-weight: 700; color: rgba(255,255,255,.95); }
.kch-event-notes em     { font-style: italic; }
.kch-event-notes code   { font-size: .8em; background: rgba(255,255,255,.1); padding: .1em .35em; border-radius: 3px; }
.kch-event-notes a      { color: var(--kch-gold); }

/* Small info snippet in grid headers */
.kch-ev-info-snippet {
  font-size: .68rem;
  opacity: .65;
  margin-top: 2px;
  white-space: normal;
  line-height: 1.3;
}

.kch-date-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(225,177,47,.12);
  color: var(--kch-gold);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid rgba(225,177,47,.25);
  flex-shrink: 0;
}

/* ── Roles grid inside card ──────────────────────────────────────────────── */
.kch-roles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 0.875rem 1.25rem;
}

.kch-role-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,.35);
  margin: 0 0 0.375rem;
}

.kch-role-people {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.kch-role-person {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  flex-wrap: wrap;
  color: rgba(255,255,255,.82);
}

.kch-att-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: rgba(225,177,47,.09);
  color: rgba(255,255,255,.4);
  border: 1px solid rgba(225,177,47,.14);
}

.kch-assigned-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: rgba(90,170,90,.15);
  color: #7dbd7d;
  border: 1px solid rgba(90,170,90,.3);
  letter-spacing: .02em;
}
[data-theme="light"] .kch-assigned-badge {
  background: rgba(60,140,60,.12);
  color: #2d7a2d;
  border-color: rgba(60,140,60,.3);
}

/* ── Availability form inside card ───────────────────────────────────────── */
.kch-avail-form-wrap {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

.kch-avail-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.kch-select, .kch-text-input {
  padding: 0.3375rem 0.625rem;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,.12);
  font-size: 0.8125rem;
  font-family: inherit;
  background: rgba(225,177,47,.09);
  color: rgba(255,255,255,.9);
  outline: none;
  transition: border-color var(--kch-t), box-shadow var(--kch-t);
}
.kch-select option { background: #1a2255; color: #fff; }
.kch-select:focus, .kch-text-input:focus {
  border-color: var(--kch-gold);
  box-shadow: 0 0 0 3px rgba(var(--kch-gold-rgb),.18);
}
.kch-text-input::placeholder { color: rgba(255,255,255,.28); }
.kch-select { min-width: 140px; }
.kch-text-input { min-width: 160px; flex: 1; max-width: 240px; }

/* ── Grid view ───────────────────────────────────────────────────────────── */
/* Synced top scrollbar — a thin strip above the grid that mirrors the
   table's horizontal scroll, so the slider sits on top instead of the
   bottom. Added/driven by topscroll.js. */
.kch-grid-topscroll {
  /* `scroll` (not `auto`) keeps the track visible at all times, even on
     systems that use auto-hiding overlay scrollbars. */
  overflow-x: scroll;
  overflow-y: hidden;
  border-radius: var(--kch-radius) var(--kch-radius) 0 0;
  margin-bottom: 4px;
  /* Firefox: a wider, easier-to-grab thumb. */
  scrollbar-width: auto;
  scrollbar-color: var(--kch-gold) rgba(255,255,255,.06);
}
.kch-grid-topscroll > div { height: 1px; }

/* WebKit/Chromium: a chunky, high-contrast slider that's easy to grab. */
.kch-grid-topscroll::-webkit-scrollbar {
  height: 14px;
}
.kch-grid-topscroll::-webkit-scrollbar-track {
  background: rgba(255,255,255,.06);
  border-radius: 7px;
}
.kch-grid-topscroll::-webkit-scrollbar-thumb {
  background: var(--kch-gold);
  border-radius: 7px;
  border: 3px solid transparent;
  background-clip: padding-box;
  min-width: 48px;
}
.kch-grid-topscroll::-webkit-scrollbar-thumb:hover {
  background: #f0c850;
  background-clip: padding-box;
}

[data-theme="light"] .kch-grid-topscroll {
  scrollbar-color: var(--kch-gold) rgba(0,0,0,.08);
}
[data-theme="light"] .kch-grid-topscroll::-webkit-scrollbar-track {
  background: rgba(0,0,0,.08);
}
/* When the top scrollbar is active, hide the wrap's own bottom scrollbar. */
.kch-grid-wrap.kch-has-topscroll { scrollbar-width: none; }
.kch-grid-wrap.kch-has-topscroll::-webkit-scrollbar { display: none; }

.kch-grid-wrap {
  overflow-x: auto;
  border-radius: var(--kch-radius);
  box-shadow: var(--kch-shadow);
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  margin-bottom: 3rem;
  animation: kch-slide-in .4s ease both;
}

.kch-grid-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
  width: 100%;
  color: rgba(255,255,255,.82);
}

.kch-grid-table th,
.kch-grid-table td {
  vertical-align: top;
  min-width: 160px;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  border-right: 1px solid rgba(255,255,255,.06);
}
.kch-grid-table th:last-child,
.kch-grid-table td:last-child { border-right: none; }
.kch-grid-table tr:last-child td { border-bottom: none; }

.kch-grid-hdr {
  position: sticky;
  left: 0;
  z-index: 2;
  background: rgba(15,10,2,.88);
  min-width: 140px;
  max-width: 170px;
  border-right: 2px solid rgba(255,255,255,.08) !important;
  font-weight: 600;
  font-size: 0.8125rem;
  color: rgba(255,255,255,.7);
}

.kch-grid-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(12,9,2,.97);
  color: rgba(255,255,255,.78);
  font-weight: 500;
  border-bottom: 2px solid rgba(225,177,47,.09) !important;
  border-right-color: rgba(225,177,47,.09) !important;
  text-align: center;
}
.kch-grid-table thead th.kch-grid-hdr {
  z-index: 3;
  background: rgba(8,5,0,.97);
  color: var(--kch-gold);
  text-align: left;
}

/* Per-event colour: filled grid header / event-row cell with contrasted text. */
.kch-grid-table thead th.kch-ev-colored,
.kch-grid-table tbody tr .kch-grid-hdr.kch-ev-colored,
.kch-grid-table tbody tr:nth-child(even) .kch-grid-hdr.kch-ev-colored,
.kch-grid-table tbody tr:hover .kch-grid-hdr.kch-ev-colored {
  background: var(--ev-bg) !important;
  color: var(--ev-fg) !important;
}
.kch-ev-colored * { color: var(--ev-fg) !important; }

.kch-grid-table tbody tr:nth-child(even) { background: rgba(255,255,255,.025); }
.kch-grid-table tbody tr:nth-child(even) .kch-grid-hdr { background: rgba(225,177,47,.075) !important; }
.kch-grid-table tbody tr:hover { background: rgba(225,177,47,.07); }
.kch-grid-table tbody tr:hover .kch-grid-hdr { background: rgba(225,177,47,.1) !important; }

/* ── Grid chips ──────────────────────────────────────────────────────────── */
.kch-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(225,177,47,.09);
  border: 1px solid rgba(225,177,47,.14);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  margin: 2px 2px 2px 0;
  color: rgba(255,255,255,.82);
}
.kch-chip .att { color: rgba(255,255,255,.38); font-size: 0.6875rem; }

.kch-chip-reserve {
  background: rgba(225,177,47,.12);
  color: var(--kch-gold);
  border: 1px dashed rgba(225,177,47,.35);
  font-style: italic;
}

.kch-reserve-row td { background: rgba(225,177,47,.05) !important; }
.kch-reserve-row .kch-grid-hdr { background: rgba(225,177,47,.1) !important; color: var(--kch-gold); font-weight: 600; }

.kch-my-avail-row td { background: rgba(100,180,255,.04) !important; }
.kch-my-avail-row .kch-grid-hdr { background: rgba(100,180,255,.09) !important; color: rgba(160,210,255,.85); font-weight: 600; }
.kch-avail-inline {
  min-width: 0 !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font-size: .75rem !important;
  padding: 0.2rem 0.5rem !important;
}
.kch-avail-saved { border-color: #5a5 !important; }

/* ── By Event (transpose): pinned left columns + collapsible category cols ─── */
.kch-grid-transpose .kch-col-event { min-width: 150px; width: 150px; max-width: 150px; }
.kch-grid-transpose .kch-col-myavail {
  position: sticky;
  left: 150px;
  z-index: 2;
  min-width: 140px; width: 150px; max-width: 160px;
  background: rgba(13,9,2,.92);
  border-right: 2px solid rgba(255,255,255,.08) !important;
}
.kch-grid-transpose td.kch-col-myavail { background: rgba(100,180,255,.06) !important; }
.kch-grid-transpose thead th.kch-col-myavail {
  z-index: 3; top: 0;
  background: rgba(8,5,0,.97);
  color: rgba(160,210,255,.9);
}
/* collapsed category column: shrink the lone spanning header to its label */
.kch-grid-transpose thead th.kch-cat-col-hdr.kch-col-collapsed { min-width: 0 !important; }
[data-theme="light"] .kch-grid-transpose .kch-col-myavail { background: #f3efe6; }
[data-theme="light"] .kch-grid-transpose td.kch-col-myavail { background: rgba(30,120,220,.06) !important; }
[data-theme="light"] .kch-grid-transpose thead th.kch-col-myavail { background: #efe9dc; color: #1a5ca8; }

.kch-mobile-my-avail {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-wrap: wrap;
}
.kch-mobile-my-avail-label {
  font-size: .75rem;
  color: rgba(160,210,255,.85);
  font-weight: 600;
  white-space: nowrap;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.kch-empty {
  text-align: center;
  padding: 3.5rem 1rem;
  color: rgba(255,255,255,.3);
  font-size: 0.9375rem;
  background: rgba(255,255,255,.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--kch-radius);
  border: 1px solid rgba(255,255,255,.08);
}

/* ── Desktop/mobile visibility helpers ──────────────────────────────────── */
.kch-mobile-only { display: none; }
.kch-desktop-only { display: block; }

/* ── Event header link + hover preview popup ─────────────────────────────── */
.kch-ev-link {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.kch-ev-link:hover { text-decoration: underline; }

.kch-ev-popups { position: static; }
.kch-ev-popup {
  position: fixed;
  display: none;
  z-index: 1000;
  width: 340px;
  max-width: calc(100vw - 16px);
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, .45));
  pointer-events: auto;
}
.kch-ev-popup .kch-card { margin: 0; }

/* ── Event detail page ───────────────────────────────────────────────────── */
.kch-event-detail { max-width: 560px; }
.kch-back-link { color: var(--kch-muted); text-decoration: none; }
.kch-back-link:hover { text-decoration: underline; }

/* ── Mobile grid (event cards for By Role / By Person) ───────────────────── */
.kch-mobile-grid { flex-direction: column; gap: 0.875rem; margin-bottom: 3rem; }

.kch-mobile-rows {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--kch-radius-sm);
  overflow: hidden;
}

.kch-mobile-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 0.875rem;
}
.kch-mobile-row:last-child { border-bottom: none; }
.kch-mobile-row:nth-child(even) { background: rgba(255,255,255,.025); }

.kch-mobile-row-reserve {
  background: rgba(225,177,47,.07) !important;
  color: var(--kch-gold);
}

.kch-mobile-row-label {
  font-weight: 600;
  font-size: 0.8125rem;
  color: rgba(255,255,255,.38);
  min-width: 90px;
  flex-shrink: 0;
  padding-top: 2px;
}

.kch-mobile-row-reserve .kch-mobile-row-label { color: var(--kch-gold); }

.kch-mobile-row-val {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  flex: 1;
}

.kch-mobile-person {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: rgba(255,255,255,.82);
}

/* ── Category collapsible rows ───────────────────────────────────────────── */
.kch-cat-hdr-row td { background: rgba(255,255,255,.055) !important; padding: .2rem .5rem !important; }
.kch-cat-hdr {
  font-size: .7rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: rgba(255,255,255,.38);
  border-right: none !important; user-select: none; cursor: pointer;
}
.kch-cat-group { margin-bottom: 2px; }
.kch-cat-group-hdr {
  font-size: .7rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: rgba(255,255,255,.38);
  padding: .3rem .5rem;
  background: rgba(255,255,255,.04);
  cursor: pointer; user-select: none; border-radius: 4px; margin-bottom: 2px;
}
.cat-chevron { margin-right: .3rem; font-size: .6rem; display: inline-block; }

/* ── Card stagger animation ──────────────────────────────────────────────── */
.kch-cards .kch-card:nth-child(1)  { animation-delay: .03s; }
.kch-cards .kch-card:nth-child(2)  { animation-delay: .08s; }
.kch-cards .kch-card:nth-child(3)  { animation-delay: .13s; }
.kch-cards .kch-card:nth-child(4)  { animation-delay: .18s; }
.kch-cards .kch-card:nth-child(5)  { animation-delay: .22s; }
.kch-cards .kch-card:nth-child(n+6){ animation-delay: .26s; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .kch-mobile-only  { display: flex; }
  .kch-desktop-only { display: none; }

  .kch-navbar-inner { padding: 0.5rem 1rem; min-height: auto; gap: 0.375rem; }
  .kch-nav { flex-wrap: wrap; }
  .kch-navbar-user { width: 100%; gap: 0.375rem; padding: 0 0 0.5rem; margin-left: 0; }
  .kch-nav-input { width: 100px; }
  .kch-page { padding: 1.25rem 1rem 3rem; }
  .kch-card-body { padding: 1rem 1.125rem; }
  .kch-card-header { flex-direction: column; }
  .kch-roles { grid-template-columns: 1fr 1fr; }
  .kch-view-tabs { width: 100%; }
  .kch-view-tab { flex: 1; text-align: center; }
  .kch-avail-form { flex-direction: column; align-items: stretch; }
  .kch-select, .kch-text-input { max-width: none; min-width: auto; }
  .kch-login-form { width: 100%; }
}

@media (max-width: 400px) {
  .kch-roles { grid-template-columns: 1fr; }
}

/* ── Smooth theme transitions ────────────────────────────────────────────── */
body,
.kch-navbar,
.kch-card,
.kch-grid-wrap,
.kch-grid-table th,
.kch-grid-table td,
.kch-chip,
.kch-view-tabs,
.kch-view-tab,
.kch-empty,
.kch-alert,
.kch-select,
.kch-text-input,
.kch-mobile-rows,
.kch-mobile-row,
.kch-cat-hdr-row td,
.kch-cat-group-hdr {
  transition:
    background-color .28s ease,
    background .28s ease,
    border-color .28s ease,
    color .18s ease,
    box-shadow .28s ease;
}

/* ── Theme toggle button ─────────────────────────────────────────────────── */
.btn-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1.5px solid rgba(225,177,47,.28);
  background: rgba(225,177,47,.1);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  color: var(--kch-gold);
  transition: background .18s, border-color .18s, transform .18s;
  font-family: inherit;
}
.btn-theme:hover {
  background: rgba(225,177,47,.2);
  border-color: var(--kch-gold);
  transform: rotate(20deg);
}

/* ══════════════════════════════════════════════════════════════════════════
   LIGHT MODE  —  [data-theme="light"] on <html>
   All overrides restore the original warm light palette.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Body ─────────────────────────────────────────────────────────────────── */
[data-theme="light"] body {
  background-color: #f7f4ef;
  background-image: none;
  color: #1a1a2e;
}

/* ── Navbar ───────────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-navbar {
  background: var(--kch-navy);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid rgba(255,255,255,.06);
  box-shadow: 0 2px 16px rgba(0,0,0,.3);
}
[data-theme="light"] .kch-logo-pill {
  background: #fff;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
[data-theme="light"] .kch-nav-input {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.18);
  color: #fff;
}
[data-theme="light"] .kch-nav-input:focus {
  background: rgba(255,255,255,.12);
  border-color: var(--kch-gold);
}

/* ── Page shell ───────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-page-sub      { color: #6b6879; }
[data-theme="light"] .kch-section-label { color: #6b6879; }

/* ── View tabs ────────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-view-tabs {
  background: #fff;
  border: 1px solid #e6dfd4;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
[data-theme="light"] .kch-view-tab         { color: #6b6879; }
[data-theme="light"] .kch-view-tab:hover   { color: #1a1a2e; background: #f7f4ef; }
[data-theme="light"] .kch-view-tab.active  {
  background: var(--kch-navy);
  color: #fff;
  border: none;
}

/* ── Alert ────────────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-alert {
  background: #fffbeb;
  border: 1px solid #f0d06b;
  color: #7d5a0a;
}
[data-theme="light"] .kch-alert-close { color: #7d5a0a; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-card {
  background: #ffffff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid #e6dfd4;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}
[data-theme="light"] .kch-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,.1), 0 8px 32px rgba(0,0,0,.07);
}
[data-theme="light"] .kch-card.past { opacity: .68; }
[data-theme="light"] .kch-card.past:hover { opacity: .88; }
[data-theme="light"] .kch-event-name  { color: #1a1a2e; }
[data-theme="light"] .kch-event-info  { color: #6b6879; }
[data-theme="light"] .kch-event-notes { color: #3a3848; }
[data-theme="light"] .kch-event-notes strong { color: #1a1a2e; }
[data-theme="light"] .kch-event-notes h1 { border-color: rgba(0,0,0,.1); }
[data-theme="light"] .kch-event-notes code { background: rgba(0,0,0,.06); }
[data-theme="light"] .kch-role-label  { color: #6b6879; }
[data-theme="light"] .kch-role-person { color: #1a1a2e; }

[data-theme="light"] .kch-date-badge {
  background: rgba(225,177,47,.12);
  color: #7a5a10;
  border-color: rgba(225,177,47,.3);
}
[data-theme="light"] .kch-att-badge {
  background: #f7f4ef;
  color: #6b6879;
  border-color: #e6dfd4;
}

/* ── Availability form ────────────────────────────────────────────────────── */
[data-theme="light"] .kch-avail-form-wrap { border-top-color: #e6dfd4; }
[data-theme="light"] .kch-select,
[data-theme="light"] .kch-text-input {
  background: #fff;
  border-color: #e6dfd4;
  color: #1a1a2e;
}
[data-theme="light"] .kch-select option { background: #fff; color: #1a1a2e; }
[data-theme="light"] .kch-text-input::placeholder { color: rgba(0,0,0,.3); }
[data-theme="light"] .kch-select:focus,
[data-theme="light"] .kch-text-input:focus {
  border-color: var(--kch-gold);
  box-shadow: 0 0 0 3px rgba(225,177,47,.15);
}
[data-theme="light"] .btn-kch-gold {
  background: transparent;
  color: #8a6010;
  border-color: var(--kch-gold-mid);
}
[data-theme="light"] .btn-kch-gold:hover {
  background: rgba(225,177,47,.1);
  border-color: var(--kch-gold);
}

/* ── Grid ─────────────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-grid-wrap {
  background: #fff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid #e6dfd4;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}
[data-theme="light"] .kch-grid-table { color: #1a1a2e; }
[data-theme="light"] .kch-grid-table th,
[data-theme="light"] .kch-grid-table td {
  border-color: #e6dfd4 !important;
}
[data-theme="light"] .kch-grid-hdr {
  background: #efecdf;
  color: #1a1a2e;
  border-right: 2px solid #e6dfd4 !important;
}
[data-theme="light"] .kch-grid-table thead th {
  background: var(--kch-navy);
  color: rgba(255,255,255,.88);
  border-bottom: 2px solid rgba(255,255,255,.08) !important;
  border-right-color: rgba(255,255,255,.1) !important;
}
[data-theme="light"] .kch-grid-table thead th.kch-grid-hdr {
  background: #1c2358;
  color: var(--kch-gold);
}
[data-theme="light"] .kch-grid-table tbody tr:nth-child(even)           { background: #faf8f3; }
[data-theme="light"] .kch-grid-table tbody tr:nth-child(even) .kch-grid-hdr { background: #e8e4d8 !important; }
[data-theme="light"] .kch-grid-table tbody tr:hover                     { background: rgba(225,177,47,.07); }
[data-theme="light"] .kch-grid-table tbody tr:hover .kch-grid-hdr       { background: #e2dcc8 !important; }

/* ── Grid chips ───────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-chip {
  background: #f7f4ef;
  border: 1px solid #e6dfd4;
  color: #1a1a2e;
}
[data-theme="light"] .kch-chip .att { color: #6b6879; }
[data-theme="light"] .kch-chip-reserve {
  background: rgba(225,177,47,.12);
  color: #7a5700;
  border: 1px dashed rgba(225,177,47,.45);
}
[data-theme="light"] .kch-reserve-row td                 { background: rgba(225,177,47,.06) !important; }
[data-theme="light"] .kch-reserve-row .kch-grid-hdr      { background: rgba(225,177,47,.14) !important; color: #7a5700; }
[data-theme="light"] .kch-my-avail-row td               { background: rgba(30,120,220,.04) !important; }
[data-theme="light"] .kch-my-avail-row .kch-grid-hdr    { background: rgba(30,120,220,.09) !important; color: #1a5ca8; }
[data-theme="light"] .kch-mobile-my-avail-label         { color: #1a5ca8; }
[data-theme="light"] .kch-mobile-my-avail               { border-top-color: #e6dfd4; }

/* ── Mobile rows ──────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-mobile-rows           { border-color: #e6dfd4; }
[data-theme="light"] .kch-mobile-row            { border-bottom-color: #e6dfd4; }
[data-theme="light"] .kch-mobile-row:nth-child(even) { background: #faf8f3; }
[data-theme="light"] .kch-mobile-row-reserve    { background: rgba(225,177,47,.07) !important; color: #7a5700; }
[data-theme="light"] .kch-mobile-row-reserve .kch-mobile-row-label { color: #7a5700; }
[data-theme="light"] .kch-mobile-row-label      { color: #6b6879; }
[data-theme="light"] .kch-mobile-person         { color: #1a1a2e; }

/* ── Category rows ────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-cat-hdr-row td  { background: #e8e3d6 !important; }
[data-theme="light"] .kch-cat-hdr         { color: #6b5e3e; }
[data-theme="light"] .kch-cat-group-hdr   { background: #f0ece2; color: #6b5e3e; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
[data-theme="light"] .kch-empty {
  background: #fff;
  backdrop-filter: none;
  border: 1px solid #e6dfd4;
  color: #6b6879;
}

/* ── User management ──────────────────────────────────────────────────────── */
.kch-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.kch-users-table th,
.kch-users-table td {
  text-align: left;
  padding: .5rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.kch-users-table th {
  color: var(--kch-muted);
  font-weight: 500;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.kch-role-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: .7rem;
  font-weight: 600;
  margin-right: 3px;
}
.kch-role-super { background: rgba(200,80,80,.2); color: #f88; }
.kch-role-owner { background: rgba(225,177,47,.2); color: var(--kch-gold); }
.kch-role-admin { background: rgba(80,150,220,.2); color: #7bc; }

.kch-invite-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .625rem;
}
.kch-checkbox-label {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .875rem;
  color: var(--kch-text);
  cursor: pointer;
}

/* ── Auth forms (invite / reset) ──────────────────────────────────────────── */
.kch-auth-form {
  display: flex;
  flex-direction: column;
}
.kch-field-label {
  font-size: .8125rem;
  color: var(--kch-muted);
  margin-bottom: .3rem;
}
.kch-auth-input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.kch-field-hint {
  font-size: .75rem;
  color: var(--kch-muted);
  margin: .3rem 0 0;
}

.kch-footer {
  margin-top: 2.5rem;
  padding: 1rem;
  text-align: center;
  font-size: .72rem;
  letter-spacing: .03em;
  color: var(--kch-muted);
}
