/* Google-Calendar-style shell around EventCalendar. Our own CSS (no upstream assets). */
:root {
  --bg: #fff;
  --surface: #fff;
  --surface-2: #f1f3f4;
  --text: #3c4043;
  --text-strong: #202124;
  --muted: #70757a;
  --line: #dadce0;
  --accent: #1a73e8;
  --accent-soft: #e8f0fe;
  --accent-text: #185abc;
  --danger: #d93025;
  --shadow: 0 1px 3px rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --radius: 8px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/20px Roboto, "Segoe UI", Arial, Helvetica, sans-serif;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "top top" "side main";
  height: 100vh;
}
.app:not(.sidebar-open) { grid-template-columns: 0 1fr; }
.app:not(.sidebar-open) .sidebar { visibility: hidden; }
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px 8px 8px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.topbar-spacer { flex: 1; }
.brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--text); text-decoration: none;
  font-size: 22px; line-height: 24px;
  padding: 0 28px 0 4px; min-width: max-content;
}
.period-title {
  margin: 0 0 0 12px;
  font-size: 22px; line-height: 28px; font-weight: 400; color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar {
  grid-area: side;
  overflow-y: auto;
  padding: 8px 0 24px;
  min-width: 0;
}
.main { grid-area: main; position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.ec-host { flex: 1; min-height: 0; }

/* ---------- buttons ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: rgba(60, 64, 67, .08); }
.icon-btn:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 36px; padding: 0 16px; border-radius: 4px;
  border: 1px solid transparent; background: transparent;
  font-weight: 500; letter-spacing: .25px; cursor: pointer;
}
.btn.outline { border-color: var(--line); color: var(--text); margin-right: 8px; }
.btn.outline:hover { background: var(--surface-2); }
.btn.text { color: var(--accent); padding: 0 8px; }
.btn.text:hover { background: var(--accent-soft); }
.btn.text.danger { color: var(--danger); }
.btn.text.danger:hover { background: #fce8e6; }
.btn.primary { background: var(--accent); color: #fff; padding: 0 24px; }
.btn.primary:hover { background: #1765cc; box-shadow: 0 1px 2px rgba(60, 64, 67, .3); }
.btn.primary:disabled { background: #a8c7fa; cursor: default; }
.btn.dropdown { padding-right: 6px; }
.btn.dropdown svg { width: 20px; height: 20px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #8e24aa; color: #fff; display: grid; place-items: center;
  font-weight: 500; margin-left: 8px; flex: none;
}

/* ---------- search ---------- */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: 8px;
  height: 44px; padding: 0 12px; margin-right: 12px;
  width: min(360px, 28vw);
}
.search svg { color: var(--muted); }
.search input { border: 0; background: transparent; flex: 1; font: inherit; font-size: 16px; outline: none; min-width: 0; }

/* ---------- menu ---------- */
.view-switch { position: relative; }
.menu {
  position: absolute; right: 8px; top: 40px; z-index: 30;
  background: var(--surface); box-shadow: var(--shadow); border-radius: 4px;
  padding: 8px 0; min-width: 180px;
}
.menu button {
  display: flex; justify-content: space-between; width: 100%;
  border: 0; background: transparent; padding: 8px 16px; text-align: left; cursor: pointer;
}
.menu button:hover, .menu button[aria-checked="true"] { background: var(--surface-2); }
kbd { font: inherit; color: var(--muted); }

/* ---------- sidebar ---------- */
.create-btn {
  display: inline-flex; align-items: center; gap: 12px;
  margin: 8px 0 16px 8px; height: 56px; padding: 0 24px 0 16px;
  border: 0; border-radius: 16px; background: #fff;
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);
  font-weight: 500; font-size: 14px; color: var(--text-strong); cursor: pointer;
}
.create-btn svg { width: 28px; height: 28px; color: var(--accent); }
.create-btn:hover { background: #f6fafe; box-shadow: 0 1px 3px 0 rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15); }

.mini { padding: 0 8px 0 20px; user-select: none; }
.mini-head { display: flex; align-items: center; justify-content: space-between; padding-left: 4px; }
.mini-head span { font-weight: 500; color: var(--text-strong); }
.mini-head .icon-btn { width: 28px; height: 28px; }
.mini-head .icon-btn svg { width: 18px; height: 18px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 28px); gap: 2px 1px; margin-top: 4px; }
.mini-grid .dow { font-size: 10px; font-weight: 500; color: var(--muted); text-align: center; line-height: 24px; }
.mini-grid button {
  width: 24px; height: 24px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; font-size: 10px; font-weight: 500; cursor: pointer; justify-self: center;
}
.mini-grid button:hover { background: var(--surface-2); }
.mini-grid button.other { color: var(--muted); font-weight: 400; }
.mini-grid button.in-range { background: var(--accent-soft); border-radius: 0; width: 100%; color: var(--accent-text); }
.mini-grid button.selected { background: #d2e3fc; color: var(--accent-text); border-radius: 50%; width: 24px; }
.mini-grid button.today { background: var(--accent); color: #fff; border-radius: 50%; width: 24px; }

.cal-section { margin-top: 12px; }
.cal-section-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  border: 0; background: transparent; padding: 6px 16px 6px 24px;
  font-weight: 500; font-size: 16px; color: var(--text-strong); cursor: pointer;
}
.cal-section-head:hover { background: var(--surface-2); }
.cal-section-head svg { width: 20px; height: 20px; color: var(--muted); transition: transform .15s; }
.cal-section-head[aria-expanded="false"] svg { transform: rotate(180deg); }
.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-list li label {
  display: flex; align-items: center; gap: 14px; padding: 4px 16px 4px 26px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-list li label:hover { background: var(--surface-2); }
.cal-list input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--cal-color); flex: none; }
.cal-list .cal-name { overflow: hidden; text-overflow: ellipsis; }

/* ---------- EventCalendar theme ---------- */
.ec {
  --ec-border-color: var(--line);
  --ec-today-bg-color: transparent;
  --ec-highlight-color: transparent;
  --ec-event-bg-color: var(--accent);
  --ec-event-text-color: #fff;
  --ec-text-color: var(--text);
  --ec-bg-color: var(--bg);
  --ec-now-indicator-color: #ea4335;
  height: 100%;
  font-size: 12px;
}
.ec-toolbar { display: none !important; }
.ec-col-head, .ec-day-head { color: var(--muted); font-size: 11px; font-weight: 500; text-transform: uppercase; }
.ec-time-grid .ec-col-head { padding: 6px 0 4px; }
.ec-col-head .gc-dow { display: block; letter-spacing: .8px; }
.ec-col-head .gc-dom {
  display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  font-size: 26px; font-weight: 400; color: var(--text); text-transform: none; cursor: pointer; margin-top: 2px;
}
.ec-col-head .gc-dom:hover { background: var(--surface-2); }
.ec-col-head.ec-highlight .gc-dow { color: var(--accent); }
.ec-col-head.ec-highlight .gc-dom { background: var(--accent); color: #fff; }
.ec-month-view .ec-day-head { font-size: 12px; text-align: center; }
.ec-month-view .ec-day.ec-highlight .ec-day-head span,
.ec-month-view .ec-day.ec-highlight .ec-day-head time {
  background: var(--accent); color: #fff; border-radius: 50%;
}
.ec-month-view .ec-day-head time, .ec-month-view .ec-day-head span {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
}
.ec-event { border-radius: 4px; box-shadow: none; font-size: 12px; line-height: 16px; }
.ec-time-grid .ec-event { border: 1px solid #fff; }
.ec-event-title { font-weight: 500; }
.ec-event.gc-past { opacity: .62; }
.ec-event.gc-declined { background: #fff !important; color: var(--text) !important; outline: 1px solid var(--line); }
.ec-event.gc-declined .ec-event-title { text-decoration: line-through; }
.ec-day-grid.ec-month-view .ec-event:not(.gc-allday) { background: transparent !important; color: var(--text) !important; }
.ec-day-grid.ec-month-view .ec-event:not(.gc-allday) .ec-event-body { display: flex; align-items: center; }
.ec-day-grid.ec-month-view .ec-event:not(.gc-allday) .ec-event-body::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--gc-dot, var(--accent)); margin: 0 6px 0 2px; flex: none;
}
.ec-day-grid.ec-month-view .ec-event:not(.gc-allday):hover { background: var(--surface-2) !important; }
.ec-day-grid.ec-month-view .ec-event-time { margin-right: 4px; font-weight: 400; }
.gc-ev { overflow: hidden; line-height: 15px; padding: 1px 2px; }
.gc-ev b { font-weight: 500; }
.gc-ev .gc-t { opacity: .95; }
.gc-ev.short { white-space: nowrap; text-overflow: ellipsis; }
/* Schedule (list) view */
.ec-list .ec-day { border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 120px 1fr; padding: 8px 0; }
.ec-list .ec-day-head { grid-row: 1 / span 99; align-self: start; flex-direction: row !important; align-items: baseline; background: transparent; border: 0; margin: 0; padding: 4px 0 0 16px; display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; }
.ec-list .ec-day-head time:first-child { font-size: 24px; line-height: 28px; font-weight: 400; min-width: 36px; color: var(--text-strong); text-transform: none; }
.ec-list .ec-day-head .ec-day-side { float: none; font-weight: 400; }
.ec-list .ec-event { display: flex; align-items: center; gap: 16px; padding: 6px 16px; border-radius: 24px; background: transparent !important; color: var(--text) !important; cursor: pointer; }
.ec-list .ec-event:hover { background: var(--surface-2) !important; }
.ec-list .ec-event-tag { width: 12px; height: 12px; border-radius: 50%; flex: none; margin: 0; }
.ec-list .ec-event-body { display: grid; grid-template-columns: 170px 1fr; align-items: center; text-align: left; gap: 8px; flex: 1; }
.ec-list .ec-event-time { color: var(--text); font-size: 13px; margin: 0; }
.ec-list .ec-event-title { font-size: 14px; font-weight: 500; margin: 0; }
.ec-list .ec-day.ec-highlight .ec-day-head time:first-child { color: var(--accent); }
.ec-sidebar { color: var(--muted); font-size: 10px; }
.ec-selecting, .ec-preview { opacity: .9; }

/* ---------- popover ---------- */
.popover {
  position: fixed; z-index: 40; width: 448px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 24px 38px 3px rgba(0,0,0,.14), 0 9px 46px 8px rgba(0,0,0,.12), 0 11px 15px -7px rgba(0,0,0,.2);
  padding: 8px 8px 20px;
}
.pop-actions { display: flex; justify-content: flex-end; gap: 2px; }
.pop-actions .icon-btn svg { width: 20px; height: 20px; }
.pop-body { padding: 0 20px 0 12px; }
.pop-row { display: grid; grid-template-columns: 40px 1fr; align-items: start; margin-top: 12px; }
.pop-row .row-icon, .pop-row .swatch { justify-self: center; }
.pop-row .row-icon { width: 20px; height: 20px; color: var(--muted); }
.swatch { width: 14px; height: 14px; border-radius: 4px; margin-top: 6px; }
.pop-title { font-size: 22px; line-height: 28px; color: var(--text-strong); margin: 0; font-weight: 400; word-break: break-word; }
.pop-sub { color: var(--text); }
.pop-muted { color: var(--muted); font-size: 12px; }
.pop-desc { white-space: pre-wrap; word-break: break-word; }
.guests { list-style: none; margin: 4px 0 0; padding: 0; }
.guests li { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.guest-avatar { position: relative; width: 28px; height: 28px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 13px; flex: none; }
.guest-avatar .rsvp { position: absolute; right: -3px; bottom: -3px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; font-size: 8px; line-height: 9px; text-align: center; }
.rsvp.accepted { background: #188038; }
.rsvp.declined { background: #d93025; }
.rsvp.tentative { background: #f9ab00; }
.rsvp.needsAction { background: #9aa0a6; }

/* ---------- dialogs ---------- */
dialog { border: 0; padding: 0; border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
dialog::backdrop { background: rgba(32, 33, 36, .45); }
.event-dialog { width: 720px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); }
.event-dialog form { padding: 12px 24px 16px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h2 { font-size: 16px; font-weight: 500; margin: 0; color: var(--muted); }
.title-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); font: inherit; font-size: 22px; line-height: 32px;
  padding: 8px 0 6px 52px; outline: none; color: var(--text-strong);
}
.title-input:focus { border-bottom: 2px solid var(--accent); padding-bottom: 5px; }
.dlg-grid { margin-top: 8px; }
.icon-row { display: grid; grid-template-columns: 52px 1fr; align-items: start; padding: 8px 0; }
.row-icon { color: var(--muted); margin-top: 6px; }
.row-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.row-main input:not([type="checkbox"]):not([type="radio"]), .row-main select, .row-main textarea {
  font: inherit; color: var(--text); background: var(--surface-2); border: 0; border-bottom: 1px solid transparent;
  border-radius: 4px 4px 0 0; padding: 8px 10px; min-height: 36px; outline: none;
}
.row-main input:focus, .row-main select:focus, .row-main textarea:focus { border-bottom: 2px solid var(--accent); }
.row-main textarea { resize: vertical; }
.when { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.when .to { color: var(--muted); }
.when-opts { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.check, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input, .radio input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.inline-select { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.inline-select select { max-width: 340px; }
.guest-add { display: flex; gap: 8px; }
.guest-add input { flex: 1; }
.guest-list, .reminder-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.guest-list li { display: flex; align-items: center; gap: 10px; }
.guest-list li .icon-btn { width: 28px; height: 28px; margin-left: auto; }
.guest-list li .icon-btn svg, .reminder-list .icon-btn svg { width: 18px; height: 18px; }
.reminder-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reminder-list input[type="number"] { width: 76px; }
.cal-pick { flex-direction: row; flex-wrap: wrap; }
.dlg-error { color: var(--danger); margin: 8px 0 0 52px; }
.dlg-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.scope-dialog { width: 360px; }
.scope-dialog form { padding: 24px 24px 16px; display: flex; flex-direction: column; gap: 14px; }
.scope-dialog h2 { margin: 0 0 4px; font-size: 22px; font-weight: 400; color: var(--text-strong); }
.scope-note { margin: 0; color: var(--muted); font-size: 12px; }

/* ---------- search results ---------- */
.search-results { position: absolute; inset: 0; background: var(--bg); overflow-y: auto; padding: 16px 24px; z-index: 5; }
.search-results h2 { font-size: 16px; font-weight: 500; margin: 0 0 12px; color: var(--muted); }
.search-results ul { list-style: none; margin: 0; padding: 0; }
.search-results li button {
  display: grid; grid-template-columns: 160px 14px 160px 1fr; gap: 16px; align-items: center; width: 100%;
  border: 0; background: transparent; text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.search-results li button:hover { background: var(--surface-2); }
.search-results .dot { width: 12px; height: 12px; border-radius: 50%; }

/* ---------- misc ---------- */
.loading-bar { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--accent) 0 30%, var(--accent-soft) 30%); background-size: 200% 100%; animation: load 1s linear infinite; z-index: 10; }
@keyframes load { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.snackbar {
  position: fixed; left: 24px; bottom: 24px; z-index: 50; background: #323232; color: #fff; border-radius: 4px;
  padding: 14px 24px; box-shadow: var(--shadow); max-width: 560px;
}
.fatal { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; text-align: center; padding: 16px; z-index: 60; }
.fatal div { max-width: 520px; }
.fatal h2 { font-weight: 400; color: var(--text-strong); }

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 0 1fr; }
  .sidebar { visibility: hidden; }
  .app.sidebar-open.force-open { grid-template-columns: 256px 1fr; }
  .app.sidebar-open.force-open .sidebar { visibility: visible; }
  .brand span, .search { display: none; }
  .brand { padding-right: 8px; }
  .period-title { font-size: 18px; }
}
@media (max-width: 600px) {
  .brand, .avatar { display: none; }
  .topbar { padding-right: 8px; }
  .btn.outline { padding: 0 10px; margin-right: 4px; }
  .period-title { margin-left: 4px; font-size: 16px; }
  .popover { left: 16px !important; right: 16px; width: auto; }
}
