:root {
  --ink: #16202b;
  --muted: #5d6b79;
  --line: #e3e8ee;
  --bg: #f6f8fa;
  --card: #ffffff;
  --brand: #0b5cad;
  --free: #1f8a5b;
  --free-bg: #e6f4ec;
  --free-hover: #cdebd9;
  --busy: #8a96a3;
  --busy-bg: #e9edf1;
  --error: #b42318;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: flex-end;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem 1rem;
}
.top h1 { margin: 0 0 .25rem; font-size: 1.6rem; }
.lead { margin: 0; color: var(--muted); max-width: 46ch; }

.controls { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--card); padding: 3px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: .4rem 1rem; border-radius: 999px; cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--brand); color: #fff; }
.segmented button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.legend { display: flex; gap: 1rem; list-style: none; margin: 0; padding: 0; color: var(--muted); font-size: .9rem; }
.legend li { display: flex; align-items: center; gap: .4rem; }
.swatch { width: 22px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.free { background: var(--free-bg); border: 1px solid var(--free); }
.swatch.busy { background: repeating-linear-gradient(135deg, var(--busy-bg), var(--busy-bg) 3px, #d5dbe1 3px, #d5dbe1 6px); border: 1px solid #cdd4db; }

main { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem 3rem; }

#calendar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  transition: opacity .15s;
}
#calendar.is-loading { opacity: .55; }

.notice { margin: 0 0 1rem; padding: .75rem 1rem; border-radius: var(--radius); background: #eaf2fb; color: #123d68; }
.notice[data-kind="error"] { background: #fdecea; color: var(--error); }
.tz { color: var(--muted); font-size: .85rem; }

/* FullCalendar tuning */
.fc { --fc-border-color: var(--line); --fc-today-bg-color: #fbfcfe; --fc-now-indicator-color: var(--brand); }
.fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 600; }
.fc .fc-button-primary { background: var(--card); color: var(--ink); border-color: var(--line); text-transform: none; }
.fc .fc-button-primary:hover { background: var(--bg); color: var(--ink); border-color: var(--line); }
.fc .fc-button-primary:not(:disabled):active,
.fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--bg); color: var(--ink); }
.fc .fc-button-primary:disabled { background: var(--card); color: var(--muted); border-color: var(--line); opacity: .6; }
.fc .fc-non-business { background: rgba(140, 150, 160, .06); }
.fc .fc-col-header-cell-cushion { color: var(--ink); text-decoration: none; text-transform: capitalize; padding: .5rem 0; }
.fc .fc-timegrid-slot-label-cushion { color: var(--muted); font-size: .8rem; }
.fc .fc-timegrid-slot { height: 2.2rem; }

.fc .ev-free {
  background: var(--free-bg);
  border: 1px solid var(--free);
  border-radius: 6px;
  cursor: pointer;
  box-shadow: none;
}
.fc .ev-free:hover, .fc .ev-free:focus-visible { background: var(--free-hover); }
.fc .ev-free .ev-label { color: var(--free); }
.fc .ev-busy {
  background: repeating-linear-gradient(135deg, var(--busy-bg), var(--busy-bg) 6px, #e2e7ec 6px, #e2e7ec 12px);
  border: 1px solid #cdd4db;
  border-radius: 6px;
  cursor: default;
}
.fc .ev-busy .ev-label { color: var(--busy); }
.ev-label { font-size: .8rem; font-weight: 600; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Dialog */
dialog {
  width: min(520px, calc(100vw - 2rem));
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 20px 60px rgba(16, 24, 40, .25);
}
dialog::backdrop { background: rgba(16, 24, 40, .45); }
dialog form, dialog .done { padding: 1.5rem; display: grid; gap: .9rem; }
dialog h2 { margin: 0; font-size: 1.25rem; }
.when { margin: .25rem 0 0; color: var(--brand); font-weight: 600; }
dialog label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
dialog label.inline { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.optional { color: var(--muted); font-weight: 400; }
input, textarea {
  font: inherit; padding: .6rem .7rem; border: 1px solid #cfd6de; border-radius: 8px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
input[type="radio"] { width: auto; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: .4rem; }
legend { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.error { color: var(--error); margin: 0; }
dialog footer { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .3rem; }
dialog button {
  font: inherit; font-weight: 600; border-radius: 8px; padding: .6rem 1.2rem; cursor: pointer;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
}
dialog button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
dialog button:disabled { opacity: .6; cursor: wait; }

@media (max-width: 760px) {
  .top { padding-top: 1.25rem; }
  .top h1 { font-size: 1.3rem; }
  #calendar { padding: .5rem; }
  .fc .fc-toolbar { flex-wrap: wrap; gap: .5rem; }
}
