/* Окно встречи v2 — hour grid (.g-*). Owner: agent B. Requires tokens.css + base.css.
   Sizes in rem / tokens so large system fonts scale (P45); JS reads row height from the DOM. */

.g-root {
  --g-col-w: var(--g-col-min);
  --g-temp-w: 96px;
  --g-sbw: 0px;
  --g-sbh: 0px;
  --g-rail-total: calc(var(--g-rail-w) + var(--g-fit-w));
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
  color: var(--ink);
}
.g-scroller {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.g-head, .g-body, .g-readout {
  display: flex;
  width: max-content;
  min-width: 100%;
}
.g-c { width: var(--g-col-w); flex: 0 0 auto; min-width: 0; }
.g-c.is-temp { width: var(--g-temp-w); }
.g-c.is-last { flex-grow: 1; }
.g-probe { position: absolute; visibility: hidden; pointer-events: none; width: var(--g-col-min); height: 0; top: 0; left: 0; }

/* ---------- head (sticky top) ---------- */
.g-head {
  position: sticky;
  top: 0;
  z-index: calc(var(--z-sticky) + 1);
  height: var(--g-head-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.g-head-rail {
  position: sticky;
  left: 0;
  z-index: 1;
  display: flex;
  flex: 0 0 auto;
  width: var(--g-rail-total);
  background: var(--surface);
}
.g-col-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding: var(--sp-1) 6px;
  border-left: 1px solid var(--grid-line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  overflow: hidden;
  transition: background-color var(--t-fast) var(--ease);
}
/* head cell = head button (open / drag) + one-click × in the top-right corner */
.g-hcell { position: relative; display: flex; min-width: 0; }
.g-hcell > .g-col-head { flex: 1 1 auto; width: 100%; cursor: grab; }
.g-hcell--home { width: 100%; }
.g-col-x {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 1.75rem;                         /* 28 px */
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  font-size: 0.875rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.g-hcell:hover .g-col-x, .g-col-x:focus-visible { opacity: 1; }
.g-col-x:hover { background: var(--surface-2); color: var(--danger, var(--ink)); }
@media (hover: none) { .g-col-x { opacity: .75; } } /* touch: always visible */
.g-hcell.is-dragged { z-index: 3; opacity: .85; box-shadow: var(--shadow-handle-drag); }
.is-reordering, .is-reordering .g-col-head { cursor: grabbing; }
.g-drop {
  position: absolute;
  top: 0;
  left: 0;
  z-index: calc(var(--z-sticky) + 3);
  width: 4px;
  border-radius: 2px;
  background: var(--ink);
  pointer-events: none;
}
button.g-col-head:hover { background: var(--surface-2); }
button.g-col-head:focus-visible { outline-offset: -2px; }
.g-col-head--home { width: 100%; border-left: 0; padding: var(--sp-1) 2px var(--sp-1) var(--sp-1); }
.g-h-name {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  font: var(--fw-semibold) var(--fs-city)/var(--lh-tight) var(--f-ui);
  white-space: nowrap;
}
.g-h-nm { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.g-h-flag { width: 1rem; height: 0.6875rem; margin-right: 3px; }
.g-h-name.is-tight { font-size: var(--fs-meta); }
.g-h-home { display: inline-grid; flex: 0 0 auto; margin-right: 2px; font-size: 0.875rem; /* 14 px icon */ }
.g-h-real--home { display: flex; align-items: center; color: var(--ink-2); }
.g-h-real-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* "дом" / "casa" / a long real name */
/* "home" / "casa" are a letter longer than "дом": one font step down and tighter icon gaps before an ellipsis */
.g-h-real--home.is-tight { font-size: var(--fs-caption); }
.g-h-real--home.is-tight .g-h-home { margin-right: 1px; }
.g-h-real--home.is-tight .g-h-flag { margin-right: 2px; }
.g-h-now {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-width: 0;
  font: var(--fw-regular) var(--fs-meta)/var(--lh-tight) var(--f-time);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.g-h-ap { font-size: var(--fs-caption); }
.g-col-head--home .g-h-now { gap: 2px; }
.g-root.g-h12 .g-col-head.g-col-head--home { padding-left: 2px; } /* "12:35pm ✓" needs the full 64 px rail */
.g-h-st { font-size: var(--fs-caption); } /* 12 px status glyph, colour from .st[data-st] */
.g-h-diff { display: none; font-family: var(--f-ui); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; }
.g-wide .g-h-diff { display: inline; }
.g-h-real {
  font: var(--fw-regular) var(--fs-meta)/var(--lh-tight) var(--f-ui);
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-h-diff--line { font: var(--fw-regular) var(--fs-meta)/var(--lh-tight) var(--f-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-wide .g-h-diff--line { display: block; }
.g-large .g-h-real:not(.g-h-real--home), .g-large .g-h-diff { display: none; }

.g-col-head--temp {
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: center;
  gap: 0;
  padding: 0 2px;
  border: 1px dashed var(--ink-2);
}
.g-col-head--temp .g-h-name { padding: 0 var(--sp-1); }
.g-temp-actions { display: flex; justify-content: center; gap: 2px; }

/* ---------- body ---------- */
.g-body {
  position: relative;
  touch-action: pan-x pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}
.g-root.is-dragging .g-body { cursor: grabbing; }
.g-rail {
  position: sticky;
  left: 0;
  z-index: var(--z-sticky);
  display: grid;
  grid-template-columns: var(--g-rail-w) var(--g-fit-w);
  flex: 0 0 auto;
  background: var(--surface);
}
.g-root.is-scrolled-x .g-rail,
.g-root.is-scrolled-x .g-head-rail,
.g-root.is-scrolled-x .g-ro-rail { box-shadow: var(--shadow-edge); }
.g-cols { position: relative; display: flex; flex: 1 0 auto; }
.g-col { border-left: 1px solid var(--grid-line); }

/* ---------- cells ---------- */
.g-cell {
  position: relative;
  display: grid;
  place-items: center;
  height: var(--g-row-h);
  border-bottom: 1px solid var(--grid-line);
  background-color: var(--cell-work);
  color: var(--cell-ink);
  font: var(--fw-medium) var(--fs-cell)/var(--lh-tight) var(--f-time);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.g-cell.is-work, .g-seg.is-work { background-color: var(--cell-work); }
.g-cell.is-dusk, .g-seg.is-dusk { background-color: var(--cell-dusk); }
.g-cell.is-night, .g-seg.is-night { background-color: var(--cell-night); }
.g-cell.is-off, .g-seg.is-off { background-image: var(--cell-off-fill); }
.g-cell.is-split { background: none; }
.g-cell.ink-night { color: var(--cell-night-ink); }
.g-cell.ink-dusk { color: var(--cell-dusk-ink); }
.g-seg { position: absolute; left: 0; right: 0; }
.g-t { position: relative; z-index: 1; }
.g-mm { font-size: var(--fs-cell-min); color: var(--cell-ink-2); }
.g-cell.ink-night .g-mm { color: var(--cell-night-ink); }
.g-cell.has-tag { padding-top: 0.875rem; }
/* compact rows (the day fits one screen): smaller digits, tags on one line with the hour */
.g-compact .g-cell { font-size: var(--fs-cell-min); }
.g-compact .g-cell.has-tag { padding-top: 0; }
.g-compact .g-tag { top: 50%; transform: translateY(-50%); }
/* midnight row: the hour stays centred like every other cell, the day ("вт 10") follows it as a small index */
.g-compact .g-cell:has(.g-tag--date) { grid-template-columns: 1fr auto 1fr; column-gap: 4px; }
.g-compact .g-cell:has(.g-tag--date) > .g-t { grid-column: 2; grid-row: 1; }
.g-compact .g-tag--date { position: static; transform: none; grid-column: 3; grid-row: 1; justify-self: start; }
/* 12-hour clock: "12am" + "11/09" (≈ 70 px) can't sit centred in the 64 px rail or a 72 px column. Where the short
   date is shown, the hour and the date are centred as a pair and the am/pm goes (the date already marks the new day). */
.g-compact.g-h12:not(.g-date-full) .g-cell:has(.g-tag--date),
.g-compact.g-h12 .g-rail-cells .g-cell:has(.g-tag--date) { grid-template-columns: auto auto; justify-content: center; column-gap: 3px; }
.g-compact.g-h12:not(.g-date-full) .g-cell:has(.g-tag--date) > .g-t,
.g-compact.g-h12 .g-rail-cells .g-cell:has(.g-tag--date) > .g-t { grid-column: 1; }
.g-compact.g-h12:not(.g-date-full) .g-cell:has(.g-tag--date) .g-tag--date,
.g-compact.g-h12 .g-rail-cells .g-cell:has(.g-tag--date) .g-tag--date { grid-column: 2; }
.g-compact.g-h12:not(.g-date-full) .g-cell:has(.g-tag--date) .g-ap,
.g-compact.g-h12 .g-rail-cells .g-cell:has(.g-tag--date) .g-ap { display: none; }
/* full date (10.11.2026) where it fits; short (10.11) in compact rows of narrower columns and in the home rail */
.g-tag__short { display: none; }
.g-compact:not(.g-date-full) .g-tag__full, .g-compact .g-rail-cells .g-tag__full { display: none; }
.g-compact:not(.g-date-full) .g-tag__short, .g-compact .g-rail-cells .g-tag__short { display: inline; }
.g-compact .g-tag--delta { display: none; }      /* the date tag at midnight already marks the day change */
.g-compact .g-tag--dst > span { display: none; } /* icon only; the text stays in the title */
.g-tag {
  position: absolute;
  top: 2px;
  z-index: 1;
  font: var(--fw-semibold) var(--fs-caption)/1.15 var(--f-ui);
  color: var(--cell-ink-2);
  white-space: nowrap;
}
.g-cell.ink-night .g-tag { color: var(--cell-night-ink); }
.g-tag--date { left: var(--sp-1); }
.g-tag--delta { right: var(--sp-1); }
.g-tag--dst {
  left: var(--sp-1);
  right: var(--sp-1);
  display: flex;
  align-items: flex-start;
  gap: 2px;
  white-space: normal;
  color: var(--cell-ink);
}
.g-cell.ink-night .g-tag--dst { color: var(--cell-night-ink); }
.g-tag--dst > svg { color: var(--warn); margin-top: 1px; }
.g-cell.is-dst::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--warn);
  z-index: 2;
}
.g-cell.is-dst:has(.g-tag--dst > span) { place-items: end center; padding: 0 0 2px; }
.g-cell.is-dst .g-tag--date, .g-cell.is-dst .g-tag--delta { display: none; }
.g-rail-cells .g-tag--dst { left: auto; right: 2px; }

/* ---------- fit strip (P15) ---------- */
.g-fit { position: relative; border-left: 1px solid var(--surface); }
.g-fs { position: absolute; left: 0; right: 0; }
.g-fs[data-r="0"], .g-ro-fit[data-rank="0"], .g-fit-tip__sw[data-r="0"] { background: var(--fit-ok); }
.g-fs[data-r="1"], .g-ro-fit[data-rank="1"], .g-fit-tip__sw[data-r="1"] { background: var(--fit-mid-fill); }
.g-fs[data-r="2"], .g-ro-fit[data-rank="2"], .g-fit-tip__sw[data-r="2"] { background: var(--fit-bad); }
.g-fit { cursor: help; }
/* tooltip next to the strip: colour meaning at the hovered time + the cities that are not working */
.g-fit-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: calc(var(--z-sticky) + 10);
  width: max-content;
  max-width: min(22rem, 70vw);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop, 0 4px 16px rgb(0 0 0 / .14));
  font-size: .8125rem;
  line-height: 1.35;
  pointer-events: none;
}
.g-fit-tip[hidden] { display: none; }
.g-fit-tip__h { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.g-fit-tip__h b { font-weight: 600; font-variant-numeric: tabular-nums; }
.g-fit-tip__sw { flex: none; width: 10px; height: 10px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08); }
.g-fit-tip__row { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--ink-2, var(--ink)); }
.g-fit-tip__row .flag { flex: none; }
.g-fit-tip__nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-fit-tip__st { flex: none; color: var(--muted, var(--ink-2)); font-variant-numeric: tabular-nums; }
.g-fit-tip__more { color: var(--muted, var(--ink-2)); }

/* ---------- band, now line ---------- */
/* the meeting slot: an outlined row across all columns (starts at "now", moves on click), no orange plate */
.g-band {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  background: var(--sel-bg);
  border-block: 2px solid var(--sel-line);
  border-right: 2px solid var(--sel-line);
  border-radius: 0 6px 6px 0;
  pointer-events: none;
  will-change: transform;
}
.g-band.cut-top { border-top: 0; }
.g-band.cut-bottom { border-bottom: 0; }
.g-band--rail {
  right: auto;
  width: var(--g-rail-total);
  z-index: 1;
  border-right: 0;
  border-left: 2px solid var(--sel-line);
  border-radius: 6px 0 0 6px;
}
/* "×" on the selected hour's frame, at its left edge in the rail */
.g-band-x {
  position: absolute;
  top: 0;
  left: 3px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--sel-line);
  color: var(--surface);
  font-size: 10px;
  cursor: pointer;
  opacity: .85;
}
.g-band-x:hover, .g-band-x:focus-visible { opacity: 1; }
.g-band-x::before { content: ""; position: absolute; inset: -8px; } /* bigger hit area */
/* mouse hover: the hovered hour row, outlined across all columns */
.g-hover {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  pointer-events: none;
  border-block: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  border-radius: 0 6px 6px 0;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.g-hover--rail {
  right: auto;
  width: var(--g-rail-total);
  border-right: 0;
  border-left: 2px solid var(--ink);
  border-radius: 6px 0 0 6px;
}
.g-now {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 4;                             /* above the outlined slot row: the "now" line is always visible */
  background: var(--now);
  pointer-events: none;
}
.g-now--rail { background: var(--now); z-index: 3; }
.g-now-label {
  position: absolute;
  left: 2px;
  bottom: 2px;
  padding: 0 var(--sp-1);
  border-radius: var(--r-pill);
  background: var(--now);
  color: var(--surface);
  font: var(--fw-semibold) var(--fs-caption)/1.3 var(--f-ui);
  white-space: nowrap;
}

/* ---------- handle (P16) and end handle (P29) ---------- */
.g-handle {
  position: absolute;
  top: 0;
  left: calc((var(--g-rail-w) - 3.75rem) / 2);
  z-index: 3;
  display: grid;
  place-items: center;
  width: 3.75rem;                         /* 60 px */
  height: max(var(--tap), 2.75rem);       /* 44 px touch zone around the 32 px pill */
  touch-action: none;
  cursor: grab;
  will-change: transform;
  pointer-events: none;                   /* no plate to drag: the row outline is the selection */
}
/* the pill only appears for keyboard users (the handle stays a focusable slider) */
.g-handle:not(:focus-visible) .g-handle-pill { opacity: 0; }
.g-handle-pill {
  display: grid;
  place-items: center;
  width: 100%;
  height: 2rem;                           /* 32 px */
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-handle);
  font: var(--fw-bold) var(--fs-readout)/1 var(--f-time);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: -0.02em;
  transition: box-shadow var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}
.g-handle-pill.is-12h { font-size: var(--fs-meta); }
.g-handle:hover .g-handle-pill { filter: brightness(.94); }
.g-handle:focus-visible { outline: none; }
.g-handle:focus-visible .g-handle-pill { outline: 2px solid var(--focus); outline-offset: 2px; }
.g-handle.is-dragging { cursor: grabbing; }
.g-handle.is-dragging .g-handle-pill { box-shadow: var(--shadow-handle-drag); }
.g-handle-end {
  --g-end-mark: 22px;
  display: none;                          /* duration is set in the meeting panel */
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: var(--g-rail-w);
  height: var(--tap);
  touch-action: none;
  cursor: ns-resize;
  will-change: transform;
}
.g-handle-end::after {
  content: "";
  position: absolute;
  left: 50%;
  top: var(--g-end-mark);
  width: 1.5rem;
  height: 6px;
  margin: -3px 0 0 -0.75rem;
  border-radius: var(--r-pill);
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}
.g-handle-end.is-dragging::after { box-shadow: 0 0 0 2px var(--surface), var(--shadow-handle); }

/* ---------- readout (P17, sticky bottom) ---------- */
.g-readout {
  position: sticky;
  bottom: 0;
  z-index: calc(var(--z-sticky) + 1);
  height: var(--g-readout-h);
  background: var(--surface);
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.g-ro-rail {
  position: sticky;
  left: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--g-rail-w) var(--g-fit-w);
  flex: 0 0 auto;
  background: var(--surface);
}
.g-ro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  padding: 2px 6px;
  border-left: 1px solid var(--grid-line);
  overflow: hidden;
  white-space: nowrap;
}
.g-ro--home { border-left: 0; padding-left: var(--sp-1); }
.g-ro-start { font: var(--fw-bold) var(--fs-readout)/var(--lh-tight) var(--f-time); font-variant-numeric: tabular-nums; }
.g-ro-ap { margin-left: 1px; font-size: var(--fs-meta); font-weight: var(--fw-regular); } /* "6am": am/pm smaller, like the cells */
.g-ro-end, .g-ro-date { font: var(--fw-regular) var(--fs-meta)/var(--lh-tight) var(--f-time); color: var(--ink-2); }
.g-ro-date, .g-ro-end.is-date { font-family: var(--f-ui); }
.g-large .g-ro-end:not(.is-date) { display: none; }
.g-ro-l2 { display: flex; align-items: center; gap: 3px; min-width: 0; }
.g-ro-st { overflow: hidden; }
.g-ro-ico { display: none; }
.g-narrow .g-ro, .g-narrow .g-col-head:not(.g-col-head--temp) { padding-left: var(--sp-1); padding-right: 2px; }
.g-narrow .g-ro-ico { display: inline-flex; }
.g-narrow .g-ro-st > svg { display: none; }
.g-ro-fit { align-self: stretch; }
.g-readout:hover .g-ro { background: color-mix(in srgb, var(--surface), var(--ink) 4%); }

/* ---------- overlays: right tail + "+N", jump to meeting ---------- */
.g-tail {
  position: absolute;
  top: 0;
  bottom: var(--g-sbh);
  right: var(--g-sbw);
  z-index: 5;
  width: 24px;
  background: linear-gradient(to right, transparent, var(--surface));
  pointer-events: none;
}
.g-more {
  position: absolute;
  right: var(--g-sbw);
  top: calc((var(--g-head-real, var(--g-head-h)) - var(--tap)) / 2);
  z-index: 6;
  display: grid;
  place-items: center;
  min-width: var(--tap);
  height: var(--tap);
  padding: 0 2px;
}
.g-more-pill {
  display: grid;
  place-items: center;
  min-width: 2rem;
  height: 1.75rem;
  padding: 0 var(--sp-2);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--surface);
  font: var(--fw-semibold) var(--fs-caption)/1 var(--f-ui);
  box-shadow: var(--shadow-handle);
}
.g-more:hover .g-more-pill { filter: brightness(1.15); }
.g-jump {
  position: absolute;
  left: 0;
  top: calc(var(--g-head-real, var(--g-head-h)) + var(--sp-1));
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: var(--g-rail-w);
  min-height: var(--tap);
  padding: 0 2px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-handle);
  font: var(--fw-semibold) var(--fs-caption)/1.1 var(--f-time);
  white-space: nowrap;
}
.g-jump > svg { transform: rotate(90deg); font-size: 1rem; }
.g-jump.is-down { top: auto; bottom: calc(var(--g-ro-real, var(--g-readout-h)) + var(--g-sbh) + var(--sp-1)); }
.g-jump.is-down > svg { transform: rotate(-90deg); }
.g-jump-t { overflow: hidden; text-overflow: ellipsis; }

@media (forced-colors: active) {
  .g-handle-pill, .g-jump, .g-more-pill { forced-color-adjust: none; border: 1px solid CanvasText; }
  .g-band { border-color: Highlight; }
}

/* ---------- large root font (P45: ≥ 20 px) ---------- */
.g-large .g-col-head, .g-large .g-ro { padding-left: 3px; padding-right: 3px; }
.g-large .g-ro-start { font-size: var(--fs-cell); }
.g-large .g-h-now { gap: 2px; }
