/* ============ View switch (map / Gantt) ============ */
.vseg { position: relative; display: flex; padding: 3px; border-radius: 11px; background: var(--surface-2); }
.vseg button {
  position: relative; z-index: 1; width: 84px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-3);
  transition: color .2s, transform .25s var(--spring);
}
.vseg button svg.i { width: 15px; height: 15px; }
.vseg button:hover, .vseg button.on { color: var(--text); }
.vseg button:active { transform: scale(.92); }
.vseg .seg-thumb { width: 84px; height: 30px; border-radius: 8px; top: 3px; left: 3px; }
.vseg.sm button, .vseg.sm .seg-thumb { width: 74px; height: 26px; font-size: 12.5px; }
#viewSwitch {
  position: fixed; top: 20px; right: calc(max(var(--ri), 12px) + 10px); z-index: 17;
  background: var(--glass); backdrop-filter: blur(20px);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  transition: right .45s var(--ease);
}
body.gantt-mode #viewSwitch { box-shadow: none; background: var(--surface-2); border-color: transparent; }

/* ============ Gantt ============ */
#gantt {
  position: fixed; z-index: 5;
  left: max(var(--li), 12px); right: max(var(--ri), 12px); top: 12px; bottom: 72px;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
  transition: left .45s var(--ease), right .45s var(--ease);
  animation: ganttIn .35s var(--ease);
  --gl: 300px;
}
#gantt[hidden] { display: none; }
@keyframes ganttIn { from { opacity: 0; transform: translateY(6px); } }
/* the map and its own controls step aside */
body.gantt-mode #canvas, body.gantt-mode #hint,
body.gantt-mode #zoomOut, body.gantt-mode #zoomLabel, body.gantt-mode #zoomIn,
body.gantt-mode #toolbar .split, body.gantt-mode #fitBtn, body.gantt-mode #groupBtn,
body.gantt-mode #toolbar > .tb-sep:nth-of-type(1) { display: none; }

.g-top {
  display: flex; align-items: center; gap: 8px; flex: none;
  height: 54px; padding: 0 290px 0 12px; border-bottom: 1px solid var(--border);
}
body.sb-collapsed .g-top { padding-left: 58px; }
.g-flex { flex: 1; }
.g-btn {
  height: 32px; padding: 0 12px; border-radius: 9px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  transition: background-color .15s, color .15s, transform .25s var(--spring);
}
.g-btn svg.i { width: 15px; height: 15px; }
.g-btn:hover { background: var(--hover); color: var(--text); }
.g-btn:active { transform: scale(.94); }
.g-btn.toggle.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.g-btn.primary { color: var(--on-accent); background: var(--accent); }
.g-btn.primary:hover { color: var(--on-accent); background: color-mix(in srgb, var(--accent) 86%, #000); }

#ganttScroll { flex: 1; overflow: auto; position: relative; overscroll-behavior: contain; }
.g-sheet { position: relative; width: calc(var(--gl) + var(--tw)); min-height: 100%; }
.g-head { position: sticky; top: 0; z-index: 4; display: flex; height: 52px; background: var(--surface); border-bottom: 1px solid var(--border); }
.g-corner {
  position: sticky; left: 0; z-index: 2; flex: none; width: var(--gl);
  display: flex; align-items: flex-end; gap: 6px; padding: 0 0 9px 16px;
  font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em;
  background: var(--surface); border-right: 1px solid var(--border);
}
.g-corner span { font-weight: 600; opacity: .7; }
.g-scale { position: relative; flex: none; user-select: none; }
.g-tier { position: absolute; left: 0; right: 0; }
.g-tier.top { top: 0; height: 24px; }
.g-tier.bottom { top: 24px; height: 28px; }
.g-cell {
  position: absolute; top: 0; bottom: 0; overflow: hidden; white-space: nowrap;
  display: flex; align-items: center; gap: 3px; padding-left: 7px;
  font-size: 11.5px; color: var(--text-3); border-left: 1px solid var(--border);
}
.g-tier.top .g-cell { font-weight: 650; color: var(--text-2); font-size: 12px; }
.g-tier.bottom.day .g-cell { flex-direction: column; justify-content: center; gap: 0; padding: 0; line-height: 1.15; }
.g-tier.bottom.day .g-cell b { font-weight: 600; font-size: 12px; color: var(--text-2); }
.g-tier.bottom.day .g-cell i { font-style: normal; font-size: 9.5px; }
.g-tier.bottom .g-cell.we b { color: var(--text-3); }
.g-tier.bottom .g-cell.now { color: var(--accent); font-weight: 700; }
.g-tier.bottom.day .g-cell.now b { color: var(--on-accent); background: var(--accent); border-radius: 6px; padding: 0 4px; }

.g-rows { position: relative; }
.g-bg { position: absolute; top: 0; left: var(--gl); pointer-events: none; }
.g-we { position: absolute; top: 0; bottom: 0; background: var(--hover); opacity: .6; }
.g-ml { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); opacity: .75; z-index: 1; }

.g-row { position: relative; display: flex; height: 36px; }
.g-row:hover .g-track { background-color: var(--hover); }
.g-row.sel .g-track { background-color: color-mix(in srgb, var(--accent) 9%, transparent); }
.g-row.dim { opacity: .3; }
.g-label {
  position: sticky; left: 0; z-index: 3; flex: none; width: var(--gl); min-width: 0;
  display: flex; align-items: center; gap: 7px; padding: 0 12px 0 calc(8px + var(--d) * 18px);
  background: var(--surface); border-right: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.g-row:hover .g-label { background-image: linear-gradient(var(--hover), var(--hover)); }
.g-row.sel .g-label { background-image: linear-gradient(color-mix(in srgb, var(--accent) 11%, transparent), color-mix(in srgb, var(--accent) 11%, transparent)); }
.g-caret, .g-caret-gap { flex: none; width: 20px; height: 20px; }
.g-caret { display: grid; place-items: center; border-radius: 6px; color: var(--text-3); transition: background-color .15s, color .15s; }
.g-caret svg.i { width: 14px; height: 14px; transform: rotate(90deg); transition: transform .25s var(--spring); }
.g-caret.shut svg.i { transform: rotate(0); }
.g-caret:hover { background: var(--active); color: var(--text); }
.g-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.g-row.root .g-dot { width: 11px; height: 11px; }
.g-row.root .g-title { font-weight: 650; }
.g-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.g-title.done { color: var(--text-3); text-decoration: line-through; }
.g-title.empty { color: var(--text-3); font-style: italic; }
.g-meta { flex: none; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.g-track { position: relative; flex: none; height: 36px; }
.g-row.undated .g-track { cursor: crosshair; }

.g-bar {
  position: absolute; top: 7px; height: 22px; border-radius: 7px; min-width: 8px; z-index: 1;
  display: flex; align-items: center; cursor: grab; user-select: none;
  background-color: color-mix(in srgb, var(--c) 85%, transparent);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--c) 40%, transparent);
  transition: box-shadow .15s, filter .15s;
}
.g-bar:hover { filter: brightness(1.06); box-shadow: 0 3px 10px color-mix(in srgb, var(--c) 45%, transparent); }
.g-txt {
  flex: 1; min-width: 0; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--ink, #fff); display: flex; align-items: center; gap: 4px;
  pointer-events: none;
}
.g-txt svg.i { width: 13px; height: 13px; flex: none; }
.g-bar.narrow .g-txt { overflow: visible; position: absolute; left: calc(100% + 6px); padding: 0; color: var(--text-2); }
.g-bar.done { background-color: color-mix(in srgb, var(--c) 30%, var(--surface-2)); box-shadow: none; }
.g-bar.done .g-txt { color: var(--text-2); }
.g-bar.late { box-shadow: 0 0 0 2px var(--danger); }
.g-bar.progress { background-image: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(255, 255, 255, .2) 6px 12px); }
.g-bar.drawing { opacity: .7; pointer-events: none; }
.g-h { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; z-index: 1; }
.g-h.l { left: -2px; }
.g-h.r { right: -2px; }
.g-h::after { content: ""; position: absolute; top: 6px; bottom: 6px; left: 4px; width: 2px; border-radius: 2px; background: var(--ink, #fff); opacity: 0; transition: opacity .15s; }
.g-bar:hover .g-h::after { opacity: 1; }

.g-ms { position: absolute; top: 9px; width: 18px; height: 18px; margin-left: -9px; cursor: grab; user-select: none; z-index: 1; }
.g-ms span { position: absolute; inset: 2px; border-radius: 3px; transform: rotate(45deg); background: var(--c); box-shadow: 0 1px 3px color-mix(in srgb, var(--c) 50%, transparent); transition: transform .2s var(--spring); }
.g-ms:hover span { transform: rotate(45deg) scale(1.18); }
.g-ms em { position: absolute; left: 24px; top: 0; line-height: 18px; white-space: nowrap; font-style: normal; font-size: 12px; color: var(--text-2); pointer-events: none; }
.g-ms.done span { background: color-mix(in srgb, var(--c) 35%, var(--surface-2)); box-shadow: none; }
.g-ms.late span { box-shadow: 0 0 0 2px var(--danger); }

.g-sum {
  position: absolute; top: 14px; height: 8px; pointer-events: none;
  border: 2px solid color-mix(in srgb, var(--c) 70%, transparent); border-bottom: 0; border-radius: 3px 3px 0 0;
  background: color-mix(in srgb, var(--c) 14%, transparent);
}

.g-tip {
  position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none;
  padding: 5px 9px; border-radius: 7px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--tip-bg); color: var(--tip-fg); box-shadow: var(--shadow-md);
  opacity: 0; transition: opacity .12s;
}
.g-tip.show { opacity: 1; }
body.g-dragging, body.g-dragging * { cursor: grabbing !important; }
/* a month's name stays in view while its start is scrolled away under the names column */
.g-tier.top .g-cell { overflow: visible; }
.g-stick { position: sticky; left: calc(var(--gl) + 8px); }
/* narrow card: the buttons keep their icons only */
.g-top { container-type: inline-size; }
@container (max-width: 640px) { .g-btn:not(.primary) span { display: none; } }

/* ============ Dependencies: arrows from a task's end to the start of the next one ============ */
.g-links { position: absolute; top: 0; left: var(--gl); z-index: 2; overflow: visible; pointer-events: none; }
.g-dep { fill: none; stroke: var(--text-3); stroke-width: 1.6; stroke-linejoin: round; opacity: .75; }
.g-dep.late { stroke: var(--danger); opacity: 1; }
.g-arr { fill: var(--text-3); }
.g-arr.late { fill: var(--danger); }
.g-dep-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.g-dep-hit:hover { stroke: color-mix(in srgb, var(--accent) 22%, transparent); }
.g-draft { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 5; }
/* the grip that starts a link: a ring just past the bar's end, shown on hover */
.g-link {
  position: absolute; top: 50%; right: -17px; width: 12px; height: 12px; margin-top: -6px; z-index: 2;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--c);
  cursor: crosshair; opacity: 0; transform: scale(.6);
  transition: opacity .15s, transform .2s var(--spring);
}
.g-ms .g-link { right: auto; left: 22px; }
.g-ms em { left: 40px; }
.g-bar:hover .g-link, .g-ms:hover .g-link, .g-link:hover { opacity: 1; transform: none; }
.g-link:hover { transform: scale(1.2); background: var(--c); }
.g-bar.narrow .g-txt { left: calc(100% + 24px); }
.g-row.link-target .g-track { background-color: color-mix(in srgb, var(--accent) 14%, transparent); }
body.g-linking, body.g-linking * { cursor: crosshair !important; }
@media (pointer: coarse) { .g-link { opacity: .9; transform: none; } }

/* checklist progress: the done share of a bar is shaded */
.g-prog { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px 0 0 7px; background: rgba(0, 0, 0, .16); pointer-events: none; }
.g-txt small { font-size: 10.5px; font-weight: 600; opacity: .8; }
