/* The day-column view. Heights come from --px-per-min and the minute counts
   set on each element, so zooming changes one variable and nothing re-renders. */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.bar-title { font-size: 1.05rem; font-weight: 600; }
.bar-actions { display: flex; align-items: center; gap: 0.5rem; }
.bar-owner {
  font-size: 0.8rem;
  color: var(--text-dim);
}
a.btn { text-decoration: none; display: inline-block; }
.dlg-note { font-size: 0.82rem; color: var(--text-dim); margin: 0; }
.dlg-link { font-size: 0.78rem; width: 100%; }

.bar-sync {
  font-size: 0.72rem;
  color: var(--text-dim);
  min-width: 3.5rem;
  text-align: right;
}
.bar-sync[data-state="warn"] { color: var(--c-dept); }
.bar-pick {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: none;
  padding: 0.1rem 0.2rem;
  cursor: pointer;
}

.btn {
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 400;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #f5f5f5; border-color: var(--text-dim); }
.btn-icon { padding: 0.4rem 0.6rem; font-size: 1rem; line-height: 1; }
.zoom { display: flex; gap: 2px; }

/* ── Stage ───────────────────────────────────────────────────── */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.stage {
  --head-h: 52px;
  display: flex;
  flex: 1;
  min-height: 0;
}

.gutter {
  flex: 0 0 74px;
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.gutter-head {
  height: var(--head-h);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.gutter-body {
  position: relative;
  height: calc(var(--day-min) * var(--px-per-min) * 1px);
  will-change: transform;
}

.tick {
  position: absolute;
  left: 0;
  right: 6px;
  top: calc(var(--off) * var(--px-per-min) * 1px);
  height: calc(var(--dur) * var(--px-per-min) * 1px);
  padding: 2px 6px 0 8px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tick-name {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.tick-time { font-size: 0.58rem; color: var(--line-strong); }

/* ── Scroller ────────────────────────────────────────────────── */

/* Scrolls on both axes: sideways through days, and downward when a day runs
   past the window, which it will as soon as anything sits outside the normal
   periods. The gutter is kept in step from JS. */
.scroller {
  flex: 1;
  overflow: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.scroller::-webkit-scrollbar { width: 0; height: 0; }
.scroller:focus-visible { outline: 2px solid var(--c-meeting); outline-offset: -2px; }

.track {
  display: flex;
  gap: var(--col-gap);
  /* Half a viewport of padding each side, so the first and last day can
     actually reach the centre of the screen. */
  padding-inline: calc(50% - var(--col-w) / 2);
  width: max-content;
}

.col {
  flex: 0 0 var(--col-w);
  width: var(--col-w);
  scroll-snap-align: center;
}

.col-head {
  position: sticky;
  top: 0;
  z-index: 70;
  height: var(--head-h);
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0 0.5rem 0.4rem;
  border-bottom: 1px solid var(--line);
  align-content: flex-end;
  flex-wrap: wrap;
  background: var(--bg);
}
.col-day { font-size: 0.9rem; font-weight: 600; letter-spacing: -0.02em; }
.col-date { font-size: 0.75rem; color: var(--text-dim); }
.col-week {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-dim);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 0 4px;
}
.col-state {
  flex-basis: 100%;
  font-size: 0.6rem;
  color: var(--c-dept);
}

.col-body {
  position: relative;
  height: calc(var(--day-min) * var(--px-per-min) * 1px);
  background-image: var(--rules);
}

/* Today's column carries the only strong marker on the page. */
.col.is-today .col-head {
  border-bottom: 2px solid var(--text);
  margin-bottom: -1px;
}
.col.is-today .col-day { color: var(--text); }

.col.is-off .col-body { opacity: 0.5; }

/* Weekends are real days, just quieter ones. */
.col.is-weekend .col-head { background: #fbfbfb; }
.col.is-weekend .col-day,
.col.is-weekend .col-date { color: var(--text-dim); }
.col.is-weekend.is-today .col-day { color: var(--text); }

/* Zoomed out far enough and there is no room for words. Drop them in the
   order they stop being worth the space, rather than letting them collide. */
.stage[data-density="tight"] .entry-detail,
.stage[data-density="tight"] .entry-time,
.stage[data-density="tight"] .col-date { display: none; }

.stage[data-density="cramped"] .entry-detail,
.stage[data-density="cramped"] .entry-time,
.stage[data-density="cramped"] .entry-loc,
.stage[data-density="cramped"] .col-date,
.stage[data-density="cramped"] .col-state { display: none; }
.stage[data-density="cramped"] .entry-name { font-size: 0.66rem; }

.stage[data-density="tiny"] .entry-body { display: none; }
.stage[data-density="tiny"] .col-date,
.stage[data-density="tiny"] .col-week,
.stage[data-density="tiny"] .col-state { display: none; }
.stage[data-density="tiny"] .col-day { font-size: 0.58rem; }
.stage[data-density="tiny"] .slot { display: none; }

/* However far out you are, hovering still tells you what something is. */
.stage[data-density="tiny"] .entry:hover,
.stage[data-density="cramped"] .entry:hover {
  z-index: 80;
  overflow: visible;
}
.stage[data-density="tiny"] .entry:hover .entry-body,
.stage[data-density="cramped"] .entry:hover .entry-body {
  display: flex;
  position: absolute;
  top: 0;
  left: 0;
  min-width: 160px;
  padding: 5px 7px;
  border-radius: var(--radius);
  background: var(--c);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}
.stage[data-density="cramped"] .entry:hover .entry-loc,
.stage[data-density="cramped"] .entry:hover .entry-time { display: block; }

/* ── Empty slots ─────────────────────────────────────────────── */

/* A free period is a target. It stays almost invisible until pointed at,
   so an empty day still reads as empty rather than as a form to fill in. */
.slot {
  position: absolute;
  top: calc(var(--off) * var(--px-per-min) * 1px);
  height: calc(var(--dur) * var(--px-per-min) * 1px);
  left: 0;
  right: 2px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--line-strong);
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}
.slot:hover, .slot:focus-visible {
  opacity: 1;
  background: #f6f6f6;
  outline: none;
}
.slot-plus { font-size: 1rem; }
.col.is-past .slot { display: none; }

/* While dragging, every landing place should be visible without hunting. */
.track.is-dragging .slot { opacity: 1; background: #fafafa; }
.track.is-dragging .slot.is-target {
  background: #eee;
  outline: 2px solid var(--text);
  outline-offset: -2px;
}
.entry.is-source { opacity: 0.35; }

/* ── Entries ─────────────────────────────────────────────────── */

.entry {
  position: absolute;
  top: calc(var(--off) * var(--px-per-min) * 1px);
  height: calc(var(--dur) * var(--px-per-min) * 1px);
  left: calc((var(--col) / var(--cols)) * 100%);
  width: calc((1 / var(--cols)) * 100% - 2px);
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
}

.entry-bg {
  position: absolute;
  inset: 0;
  background: var(--c);
  z-index: 0;
}

/* The elapsed part of a lesson in progress. Same computed colour as a
   finished lesson and a past day, so the three read as one idea. */
.entry-wash {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--elapsed, 0%);
  background: var(--c-past);
  z-index: 1;
}

.entry-body {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 6px;
  color: var(--fg);
  line-height: 1.2;
}
.entry-name { font-size: 0.74rem; font-weight: 500; }
.entry-loc { font-size: 0.64rem; opacity: 0.82; }
.entry-detail { font-size: 0.6rem; opacity: 0.75; }
.entry-time { font-size: 0.58rem; opacity: 0.6; margin-top: auto; }

/* A ten-minute event is a stripe. This is the honest rendering, not a
   fallback: it is what ten minutes looks like beside an hour. */
.entry.is-stripe .entry-body { display: none; }

.entry.is-stripe:hover,
.entry.is-stripe:focus-within {
  height: auto;
  min-height: 58px;
  z-index: 60;
  overflow: visible;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.entry.is-stripe:hover .entry-body,
.entry.is-stripe:focus-within .entry-body { display: flex; }

/* Time that has passed. One colour, three situations. */
.entry.is-elapsed .entry-bg,
.col.is-past .entry .entry-bg { background: var(--c-past); }
.entry.is-elapsed .entry-body,
.col.is-past .entry .entry-body { color: var(--text-dim); }
.col.is-past .entry .entry-wash { display: none; }

.entry { cursor: pointer; }

.entry-x {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 3;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #1a1a1a;
  font-size: 0.85rem;
  line-height: 1;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.12s;
}
.entry:hover .entry-x, .entry-x:focus-visible { opacity: 1; }
.entry-x:hover { background: #fff; }
/* A stripe is too short to hold the X until it has been opened up. */
.entry.is-stripe:not(:hover) .entry-x { display: none; }

/* ── Undo ────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 250;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 0.82rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.toast-undo {
  color: var(--bg);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Pattern editor sheet ────────────────────────────────────── */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
.sheet-ask { margin: 0; font-size: 1.05rem; }
.sheet-actions { display: flex; align-items: center; gap: 1rem; }
.sheet-note { font-size: 0.76rem; color: var(--text-dim); }
.sheet-body { flex: 1; overflow: auto; padding: 1.5rem; }

.now-rule {
  position: absolute;
  left: -2px;
  right: -2px;
  top: calc(var(--off) * var(--px-per-min) * 1px);
  height: 0;
  border-top: 2px solid #d13b2e;
  z-index: 40;
  pointer-events: none;
}
.now-rule::before {
  content: '';
  position: absolute;
  left: -3px;
  top: -4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d13b2e;
}

/* ── Empty state ─────────────────────────────────────────────── */

.empty {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.empty .btn { padding: 0.55rem 1.1rem; }
