/* Office bookings (docs/OFFICE_ROOMS_PLAN.md): the room calendar (rooms-calendar.js) and the parts of the
   tutor's page (bookings.html) and the manager's (manager.html, manager/bookings.js) around it, and the
   "Need a room at the office?" box in both lesson forms. Every class starts "rc-"; the colours are
   ui.css's tokens. */
/* ---------- Toolbar ---------- */
.rc-panel { position: relative; }
.rc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 16px 20px; border-bottom: 1px solid var(--ot-line-soft); }
.rc-nav { display: flex; align-items: center; gap: 6px; }
.rc-iconbtn { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--ot-line-button); border-radius: var(--ot-r-sm); background: var(--ot-surface); color: var(--ot-ink-2); cursor: pointer; }
.rc-iconbtn:hover { background: #F5F8FA; border-color: var(--ot-line-input); }
.rc-range { font-size: 17px; font-weight: 700; margin: 0 6px 0 4px; white-space: nowrap; }
.rc-bar-end { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rc-date { min-height: 40px; padding: 6px 10px; width: auto; }

/* ---------- Legend ---------- */
.rc-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 10px 20px; list-style: none; font-size: 13.5px; color: var(--ot-ink-2); background: #FAFBFC; border-bottom: 1px solid var(--ot-line-soft); }
.rc-legend li { display: inline-flex; align-items: center; gap: 7px; }
.rc-sw { width: 16px; height: 14px; border-radius: 4px; border: 1px solid var(--ot-line-button); background: var(--ot-surface); flex: none; }
.rc-sw.rc-ok { background: var(--ot-blue-soft); border-color: var(--ot-blue-soft-line); box-shadow: inset 3px 0 0 var(--ot-blue-strong); }
.rc-sw.rc-wait { background: var(--ot-warn-bg); border: 1.5px dashed var(--ot-warn); }
.rc-sw.rc-busy { background: #E3E8EE; border-color: #C9D2DB; }
.rc-sw.rc-closed { background: repeating-linear-gradient(135deg, #EEF1F4 0 3px, #DDE3E9 3px 5px); border-color: #D3DAE1; }
.rc-lanekey { margin-left: auto; color: var(--ot-muted); }
.rc-lanekey b { color: var(--ot-ink-2); }

/* ---------- The grid ---------- */
.rc-scroll { position: relative; max-height: min(72vh, 760px); overflow-y: auto; border-radius: 0 0 var(--ot-r-md) var(--ot-r-md); }
.rc-grid { --rc-q: 14px; display: grid; grid-template-columns: 56px repeat(var(--rc-cols), minmax(0, 1fr)); }
.rc-hcell { position: sticky; top: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; background: var(--ot-surface); border-bottom: 1px solid var(--ot-line); padding: 10px 6px 8px; text-align: center; min-width: 0; }
.rc-hcell + .rc-hcell { border-left: 1px solid var(--ot-line-soft); }
.rc-hday { display: block; font-size: 13px; font-weight: 600; color: var(--ot-muted); letter-spacing: .02em; }
.rc-hdate { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 4px; border-radius: 999px; font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; }
.rc-today .rc-hdate { background: var(--ot-blue-strong); color: #fff; }
.rc-today .rc-hday { color: var(--ot-blue-strong); }
.rc-hhours { display: block; font-size: 12.5px; color: var(--ot-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.rc-hhours.rc-changed { display: block; margin: 3px auto 0; padding: 0 8px; border-radius: 999px; background: var(--ot-warn-bg); color: var(--ot-warn); font-weight: 650; box-shadow: inset 0 0 0 1px var(--ot-warn-line); }
.rc-htag { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; background: #EEF2F6; color: var(--ot-ink-2); white-space: nowrap; }
.rc-htag.rc-warn { background: var(--ot-warn-bg); color: var(--ot-warn); }
.rc-edit { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; margin-top: 4px; padding: 0 8px; border: 1px solid var(--ot-line-button); border-radius: 6px; background: var(--ot-surface); font: 600 12.5px var(--ot-font); color: var(--ot-blue-strong); cursor: pointer; }
.rc-edit:hover { background: var(--ot-blue-soft); border-color: var(--ot-blue-soft-line); }
.rc-edit .ot-ic { width: 14px; height: 14px; }
.rc-lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-self: stretch; margin-top: auto; padding-top: 8px; font-size: 11.5px; font-weight: 700; color: var(--ot-muted); }
.rc-lanes span + span { border-left: 1px solid var(--ot-line-soft); }
.rc-hroom { font-size: 15px; font-weight: 700; color: var(--ot-ink); display: block; }
.rc-hroom-s { font-size: 12.5px; color: var(--ot-muted); }
.rc-corner { position: sticky; top: 0; z-index: 5; background: var(--ot-surface); border-bottom: 1px solid var(--ot-line); }

/* the time column */
.rc-times { position: relative; height: var(--rc-h); }
.rc-times span { position: absolute; right: 8px; transform: translateY(-50%); font-size: 12px; color: var(--ot-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rc-times span:first-child { transform: none; }

/* one day (week view) or one room (day view) */
.rc-col { position: relative; height: var(--rc-h); border-left: 1px solid var(--ot-line-soft);
  background-image: linear-gradient(var(--ot-line-soft) 1px, transparent 1px), linear-gradient(#F3F6F8 1px, transparent 1px);
  background-size: 100% calc(var(--rc-q) * 4), 100% calc(var(--rc-q) * 2); }
.rc-col.rc-wk { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rc-lane { position: relative; min-width: 0; }
.rc-lane + .rc-lane { border-left: 1px dashed #E3E8ED; }

/* everything placed on the grid */
.rc-at { position: absolute; left: 2px; right: 2px; }
.rc-span { left: 0; right: 0; }

/* closed: outside hours, a closed day, a closure */
.rc-closed { z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 6px; overflow: hidden;
  background: repeating-linear-gradient(135deg, #F1F3F6 0 6px, #E5E9EE 6px 9px); }
.rc-closed-l { display: inline-block; max-width: calc(100% - 8px); padding: 1px 7px; border-radius: 6px; background: var(--ot-surface); border: 1px solid #D3DAE1; font-size: 12px; font-weight: 650; color: var(--ot-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-closed-r { display: block; max-width: calc(100% - 8px); margin-top: 3px; padding: 0 6px; border-radius: 5px; background: rgba(255,255,255,.92); font-size: 11.5px; color: var(--ot-ink-2); text-align: center; overflow-wrap: anywhere; }
.rc-lane .rc-closed { padding-top: 4px; }

/* free time: one button per run, quiet until hovered or focused */
.rc-free { z-index: 2; display: flex; align-items: flex-start; justify-content: center; padding: 6px 0 0; border: 0; border-radius: 6px; background: transparent; color: var(--ot-blue-strong); font: 600 12.5px var(--ot-font); cursor: pointer; }
.rc-free span { opacity: 0; display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px; border-radius: 6px; background: var(--ot-surface); }
.rc-free:hover, .rc-free:focus-visible { background: var(--ot-blue-tint); box-shadow: inset 0 0 0 1.5px var(--ot-blue-soft-line); }
.rc-free:hover span, .rc-free:focus-visible span { opacity: 1; }
.rc-free:focus-visible { outline: 3px solid var(--ot-blue-strong); outline-offset: -3px; }
.rc-free .ot-ic { width: 14px; height: 14px; }

/* bookings */
.rc-b { z-index: 3; display: flex; flex-direction: column; gap: 1px; min-height: 24px; padding: 4px 6px 4px 8px; overflow: hidden; border: 0; border-radius: 7px; text-align: left; font: 500 12.5px/1.3 var(--ot-font); color: var(--ot-ink); }
button.rc-b { cursor: pointer; }
.rc-b.rc-ok { background: var(--ot-blue-soft); box-shadow: inset 3px 0 0 var(--ot-blue-strong); }
button.rc-b.rc-ok:hover { background: #DCEDF9; }
.rc-b.rc-wait { background: var(--ot-warn-bg); border: 1.5px dashed var(--ot-warn); padding-left: 7px; }
button.rc-b.rc-wait:hover { background: #FFEDD1; }
.rc-b.rc-busy { background: #E3E8EE; color: var(--ot-ink-2); border: 1px solid #CDD5DD; }
.rc-b > * { flex: none; }
.rc-b-t { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-b-n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-b-s { color: var(--ot-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-b .ot-badge { align-self: flex-start; margin-top: 3px; padding: 1px 8px; font-size: 12px; }
.rc-b.rc-wait .rc-b-t { color: var(--ot-warn); }
.rc-b:focus-visible { outline: 3px solid var(--ot-blue-strong); outline-offset: 1px; }
.rc-wk .rc-b { padding: 3px 2px 3px 6px; font-size: 11.5px; line-height: 1.25; letter-spacing: -.01em; }
.rc-wk .rc-b.rc-wait { padding-left: 4px; }
.rc-wk .rc-b-t, .rc-wk .rc-b-n { text-overflow: clip; }
.rc-day-v .rc-b { padding: 6px 10px 6px 12px; font-size: 13.5px; }
.rc-day-v .rc-b.rc-wait { padding-left: 11px; }
.rc-day-v .rc-b .ot-badge { position: absolute; top: 5px; right: 6px; margin: 0; }
.rc-day-v .rc-b-t { padding-right: 96px; }

/* the past, and now */
.rc-past { z-index: 5; left: 0; right: 0; top: 0; background: rgba(244,246,248,.55); pointer-events: none; }
.rc-now { z-index: 6; left: 0; right: 0; height: 2px; background: var(--ot-blue); pointer-events: none; }
.rc-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--ot-blue); }

/* ---------- Day buttons (the week on a phone) ---------- */
.rc-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 12px 12px 10px; border-bottom: 1px solid var(--ot-line-soft); }
.rc-dbtn { position: relative; display: grid; justify-items: center; gap: 1px; min-height: 58px; padding: 6px 0 8px; border: 1px solid var(--ot-line-button); border-radius: 10px; background: var(--ot-surface); font: 600 12px var(--ot-font); color: var(--ot-ink-2); cursor: pointer; }
.rc-dbtn b { font-size: 17px; font-weight: 750; color: var(--ot-ink); font-variant-numeric: tabular-nums; }
.rc-dbtn[aria-pressed="true"] { background: var(--ot-blue-strong); border-color: var(--ot-blue-strong); color: #fff; }
.rc-dbtn[aria-pressed="true"] b { color: #fff; }
.rc-dbtn.rc-dclosed:not([aria-pressed="true"]) { background: repeating-linear-gradient(135deg, #F4F6F8 0 5px, #E9EDF1 5px 7px); color: var(--ot-muted); }
.rc-dbtn.rc-dclosed:not([aria-pressed="true"]) b { color: var(--ot-muted); }
.rc-dot { position: absolute; bottom: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--ot-blue-strong); }
.rc-dot.rc-dot-warn { background: var(--ot-warn); }
.rc-dbtn[aria-pressed="true"] .rc-dot { background: #fff; }
.rc-dayline { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--ot-line-soft); }
.rc-dayline h3 { font-size: 16px; }
.rc-dayline p { margin: 0; font-size: 13.5px; color: var(--ot-muted); }

/* ---------- Page panels ---------- */
.rc-list { list-style: none; margin: 0; padding: 0; }
.rc-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 24px; }
.rc-row + .rc-row { border-top: 1px solid var(--ot-line-soft); }
.rc-cal { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 12px; background: var(--ot-blue-soft); color: var(--ot-blue-strong); line-height: 1.1; text-align: center; }
.rc-cal small { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.rc-cal b { font-size: 20px; font-weight: 750; color: var(--ot-ink); }
.rc-row-t { font-weight: 700; }
.rc-row-s { font-size: 14px; color: var(--ot-muted); }
.rc-row-n { font-size: 14px; color: var(--ot-ink-2); margin-top: 2px; }
.rc-row-acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.rc-row .ot-badge { margin-top: 4px; }
.rc-why { font-size: 14px; color: var(--ot-ink-2); margin-top: 2px; }
.rc-req .rc-cal { background: var(--ot-warn-bg); color: var(--ot-warn); }

/* ---------- The booking form ---------- */
.rc-rooms { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rc-rooms .ot-box { min-height: 72px; }
.rc-room-off .ot-box { background: #F6F8FA; border-style: dashed; cursor: not-allowed; }
.rc-room-off .ot-box::before { background: #EEF1F4; }
.rc-room-off .ot-t { color: var(--ot-ink-2); }
.rc-room-off input { cursor: not-allowed; }
.rc-st { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; font-weight: 600; }
.rc-st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.rc-st.rc-free-t { color: var(--ot-ok); }
.rc-st.rc-busy-t { color: var(--ot-muted); }
.rc-st.rc-closed-t { color: var(--ot-muted); }
.rc-studs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 16px; }
.rc-times-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.rc-summary { display: flex; gap: 12px; align-items: center; }
.rc-summary .rc-cal { width: 48px; height: 48px; }

/* the usual hours and a day's hours */
.rc-hours { display: grid; gap: 0; }
.rc-hrow { display: grid; grid-template-columns: 130px 112px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 0; }
.rc-hrow + .rc-hrow { border-top: 1px solid var(--ot-line-soft); }
.rc-hrow-day { font-weight: 700; }
.rc-ranges { display: flex; flex-direction: column; gap: 8px; }
.rc-range-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rc-range-row .ot-input { width: 132px; min-height: 40px; padding: 6px 10px; }
.rc-range-row .rc-to { color: var(--ot-muted); font-size: 14px; }
.rc-closedtxt { color: var(--ot-muted); font-size: 14.5px; }
.rc-mini { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 8px; border: 0; background: none; color: var(--ot-blue-strong); font: 600 14px var(--ot-font); cursor: pointer; border-radius: 6px; }
.rc-mini:hover { background: var(--ot-blue-soft); }
.rc-rm { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: none; color: var(--ot-muted); cursor: pointer; }
.rc-rm:hover { background: #F1F4F7; color: var(--ot-bad); }
.rc-clash { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--ot-line); border-radius: var(--ot-r-md); }
.rc-clash li { padding: 10px 14px; font-size: 14.5px; }
.rc-clash li + li { border-top: 1px solid var(--ot-line-soft); }
.rc-clash b { display: block; }

/* the call to action in a lesson form */
.rc-cta { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--ot-r-md); border: 1px solid var(--ot-blue-soft-line); background: var(--ot-blue-soft); }
.rc-cta-t { display: flex; gap: 10px; align-items: flex-start; }
.rc-cta-t .ot-ic { color: var(--ot-blue-strong); margin-top: 2px; }
.rc-cta b { display: block; }
.rc-cta span.rc-cta-s { font-size: 14px; color: var(--ot-ink-2); }

/* ---------- Loading and failed ---------- */
.rc-loading { display: grid; gap: 14px; padding: 24px 20px; }
.rc-loading .ot-skel { height: 28px; }
.rc-failed { display: grid; gap: 12px; justify-items: start; padding: 20px; }
.rc-notice { margin: 12px 20px 0; }
.rc-msg:empty { display: none; }
.rc-msg { margin-bottom: 16px; }
.rc-section-gap { margin-top: 24px; }
.rc-section-after { margin-bottom: 24px; }
.rc-head-acts { display: flex; gap: 10px; flex-wrap: wrap; }
.rc-inline-btn { margin-top: 8px; }
.rc-empty-note { padding: 4px 24px 22px; color: var(--ot-muted); }
.rc-list-msg { padding: 8px 24px 20px; }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .rc-bar { padding: 12px; gap: 8px; }
  .rc-head-acts { width: 100%; }
  .rc-range { font-size: 15.5px; margin: 0 2px; }
  .rc-legend { padding: 8px 12px; gap: 4px 12px; font-size: 12.5px; }
  .rc-scroll { max-height: none; overflow: visible; }
  .rc-hcell, .rc-corner { top: 60px; }
  .rc-grid { grid-template-columns: 40px repeat(var(--rc-cols), minmax(0, 1fr)); }
  .rc-times span { right: 4px; font-size: 11px; }
  .rc-hroom { font-size: 13px; }
  .rc-b { padding: 4px 5px 4px 7px; font-size: 12px; }
  .rc-day-v .rc-b { padding: 5px 6px 5px 8px; font-size: 12.5px; }
  .rc-row { grid-template-columns: 48px minmax(0, 1fr); padding: 14px 16px; gap: 12px; }
  .rc-row .rc-cal { width: 48px; height: 48px; }
  .rc-row-acts { grid-column: 1 / -1; justify-content: flex-start; }
  .rc-show-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rc-show { padding: 0 10px; }
  .rc-day-v .rc-b .ot-badge { display: none; }
  .rc-day-v .rc-b-t { padding-right: 0; }
  .rc-rooms { grid-template-columns: minmax(0, 1fr); }
  .rc-times-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rc-times-row > :first-child { grid-column: 1 / -1; }
  .rc-hrow { grid-template-columns: minmax(0, 1fr) auto; }
  .rc-hrow .rc-ranges { grid-column: 1 / -1; }
  .rc-range-row .ot-input { width: auto; flex: 1 1 0; min-width: 0; }
  .rc-range-row .rc-mini { flex-basis: 100%; justify-content: flex-start; }
}

/* ---------- Contrast themes and print ---------- */
@media (forced-colors: active) {
  .rc-b, .rc-closed-l, .rc-dbtn, .rc-free span { border: 1px solid CanvasText; }
  .rc-b.rc-wait { border-style: dashed; }
  .rc-dbtn[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .rc-dbtn[aria-pressed="true"] b { color: HighlightText; }
  .rc-now, .rc-now::before { forced-color-adjust: none; background: Highlight; }
}
@media print {
  .rc-scroll { max-height: none; overflow: visible; }
  .rc-free, .rc-bar-end, .rc-edit { display: none !important; }
}
