:root {
  --bg: #e9ecf0;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --line: #d3d9e0;
  --line-soft: #e4e8ed;
  --text: #1d2530;
  --muted: #5a6574;
  --faint: #8a94a2;
  --accent: #de6511;
  --accent-ink: #ffffff;
  --accent-hover: #c2550b;
  --focus: #2f6fdb;
  --danger: #b42318;
  --warning: #b7791f;
  --select: #e3ecfb;
  --weekend: rgba(24, 32, 43, 0.045);
  --grid: rgba(24, 32, 43, 0.08);
  --summary: #3a4452;
  --viewer-bg: #eef1f4;
  --viewer-edge: #252c36;

  /* per-root bar hues, muted so the accent stays unique */
  --c0: #56708f;
  --c1: #3f8a86;
  --c2: #6d63a6;
  --c3: #7f8a3c;
  --c4: #9a5b78;
  --c5: #3f7cb5;
  --c6: #8a6b4a;
  --c7: #4f8a5c;

  --radius: 4px;
  --topbar-h: 68px;
  --row: 28px;
  --font: "IBM Plex Sans", "IBM Plex Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #20252d;
    --line: #313843;
    --line-soft: #272d36;
    --text: #d9dee6;
    --muted: #98a2b0;
    --faint: #6d7684;
    --accent: #e58044;
    --accent-ink: #14171c;
    --accent-hover: #f09360;
    --focus: #86aaf0;
    --danger: #ee8579;
    --select: #243149;
    --weekend: rgba(255, 255, 255, 0.03);
    --grid: rgba(255, 255, 255, 0.07);
    --summary: #c3cad4;
    --viewer-bg: #171b21;
    --viewer-edge: #0b0d10;
    --c0: #7f9bbd;
    --c1: #5fb0aa;
    --c2: #9a90d4;
    --c3: #a9b464;
    --c4: #c9869f;
    --c5: #6aa7de;
    --c6: #b89370;
    --c7: #74b584;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --surface: #1c2027; --surface-2: #20252d; --line: #313843; --line-soft: #272d36;
  --text: #d9dee6; --muted: #98a2b0; --faint: #6d7684; --accent: #e58044; --accent-ink: #14171c;
  --accent-hover: #f09360; --focus: #86aaf0; --danger: #ee8579; --select: #243149;
  --weekend: rgba(255, 255, 255, 0.03); --grid: rgba(255, 255, 255, 0.07); --summary: #c3cad4;
  --viewer-bg: #171b21; --viewer-edge: #0b0d10;
  --c0: #7f9bbd; --c1: #5fb0aa; --c2: #9a90d4; --c3: #a9b464; --c4: #c9869f; --c5: #6aa7de; --c6: #b89370; --c7: #74b584;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: 0.01em; }
.brand-tagline { font-size: 12px; color: var(--text); }
.brand-tagline [lang="hi"] { font-family: "IBM Plex Sans Devanagari", var(--font); }
.brand-tagline i { color: var(--muted); }
.brand-sub { font-size: 11px; color: var(--faint); }
.brand-mark {
  flex: 0 0 auto;
  width: 14px; height: 14px; border-radius: 2px;
  background: linear-gradient(var(--text) 0 0) 0 2px / 9px 3px no-repeat,
              linear-gradient(var(--muted) 0 0) 4px 6px / 10px 3px no-repeat,
              linear-gradient(var(--muted) 0 0) 2px 10px / 7px 3px no-repeat;
}
.model-meta { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-meta strong { color: var(--text); font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.lang-switch button { height: 30px; min-width: 44px; }
.lang-hi .brand-tagline i { display: none; }
@media (max-width: 1200px) { .brand-tagline i { display: none; } }
/* Devanagari has no case, and tracking breaks up conjuncts */
.lang-hi .panel-title,
.lang-hi .g-head .g-left,
.lang-hi .g-today-label { text-transform: none; letter-spacing: 0; font-size: 12px; }
.has-model .dropzone { flex-wrap: wrap; }
.dropzone span { white-space: nowrap; }

/* ------------------------------------------------------------------ controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn-small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.icon-btn {
  width: 28px; height: 28px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.stack { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 32px; padding: 5px 8px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { margin: 0; accent-color: var(--text); }
.hint, .note { font-size: 12px; color: var(--muted); }
.hint.is-llm::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--c1); vertical-align: 1px; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.segmented button { height: 28px; padding: 0 10px; border: 0; background: var(--surface); font-size: 13px; color: var(--muted); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--surface); }

/* ------------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) auto;
  height: calc(100% - var(--topbar-h));
}
.rail {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.panel { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-title { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
/* the feed drawer: slides in from the right, full height */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 46; width: min(420px, 100vw);
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.22); animation: drawer-in 0.16s ease-out;
}
@keyframes drawer-in { from { transform: translateX(16px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.drawer-scrim { position: fixed; inset: 0; z-index: 45; background: rgba(6, 8, 12, 0.32); }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 10px 16px; border-bottom: 1px solid var(--line-soft); }
.drawer-head .panel-title { flex: 1; margin: 0; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 16px; }
.drawer-body .feed-list { max-height: none; }
#feedBtn .count-badge { margin-left: 6px; }
@media (max-width: 860px) { .drawer { width: 100vw; } }

/* folding side panels: the title is the fold button, and a folded panel still shows its count */
.panel-title:has(.panel-toggle) { margin-bottom: 0; }
.panel-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 0 0 10px; margin: 0;
  border: 0; background: none; cursor: pointer; text-align: left;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit;
}
.panel-toggle:hover { color: var(--text); }
.panel-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.panel-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-chevron { flex: 0 0 10px; width: 10px; height: 10px; transition: transform 0.15s; }
.panel.is-folded .panel-chevron { transform: rotate(-90deg); }
.panel.is-folded > *:not(.panel-title):not(.panel-head) { display: none !important; }
.panel.is-folded .panel-head > *:not(.panel-title) { display: none; }
.panel.is-folded .panel-toggle { padding-bottom: 0; }
.panel.is-folded { padding-top: 10px; padding-bottom: 10px; }
.panel-badge {
  flex: 0 0 auto; padding: 0 6px; border-radius: 999px; font-size: 10px; letter-spacing: 0;
  background: color-mix(in srgb, var(--focus) 16%, transparent); color: var(--focus);
}
#checkPanel .panel-badge { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
#phPanel .panel-badge { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 18px 12px;
  border: 1px dashed var(--faint); border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer; text-align: center;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--text); border-style: solid; }
.dropzone-title { font-weight: 500; }
.dropzone-sub { font-size: 12px; color: var(--muted); }
.has-model .dropzone { padding: 10px; flex-direction: row; justify-content: center; gap: 6px; }

/* inventory */
.inv-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-bottom: 12px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.inv-summary div { background: var(--surface); padding: 6px 8px; }
.inv-summary b { display: block; font-size: 16px; font-weight: 600; }
.inv-summary span { font-size: 11px; color: var(--muted); }
.storey { padding: 8px 0; border-top: 1px solid var(--line-soft); }
.storey:first-child { border-top: 0; padding-top: 0; }
.storey-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 500; }
.storey-head small { color: var(--muted); font-weight: 400; font-size: 12px; }
.class-list { margin: 4px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px; }
.class-list li { font-size: 12px; padding: 1px 6px; border-radius: 3px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-soft); }
.class-list li b { color: var(--text); font-weight: 500; }

.schedule-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.schedule-list li { display: flex; align-items: center; gap: 4px; border-radius: var(--radius); }
.schedule-list .sched-btn {
  flex: 1; min-width: 0; text-align: left; padding: 6px 8px;
  border: 1px solid transparent; border-radius: var(--radius); background: transparent; cursor: pointer;
}
.schedule-list .sched-btn:hover { background: var(--surface-2); }
.schedule-list li.is-active .sched-btn { border-color: var(--line); background: var(--surface-2); }
.sched-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.sched-sub { display: block; font-size: 12px; color: var(--muted); }

/* element support card */
.elcard {
  position: absolute; right: 12px; bottom: 56px; z-index: 4; width: 320px; max-height: calc(100% - 130px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); font-size: 12px;
}
.elcard-head { display: flex; align-items: flex-start; gap: 8px; padding: 8px 6px 6px 10px; border-bottom: 1px solid var(--line-soft); }
.elcard-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.elcard-title b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.elcard-title span { color: var(--muted); }
.elcard-toggle { padding: 6px 10px 0; font-size: 12px; }
.elcard-body { overflow-y: auto; overflow-x: hidden; padding: 4px 10px 6px; }
.elcard-sec { margin-top: 8px; }
.elcard-sec h4 { margin: 0 0 4px; font-size: 11px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.elcard-sec h4 i { width: 8px; height: 8px; border-radius: 2px; background: var(--sw); }
.elcard-sec ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.elcard-sec li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.elcard-sec li button.link { flex: 1; min-width: 0; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.elcard-sec li button.link:hover { color: var(--focus); }
.elcard-sec li .meta { color: var(--muted); white-space: nowrap; }
.elcard-sec li .reject { padding: 0 4px; border: 0; background: none; color: var(--faint); cursor: pointer; font-size: 14px; line-height: 1; }
.elcard-sec li .reject:hover { color: var(--danger); }
.elcard-empty { color: var(--muted); }
.elcard-ground { margin-top: 8px; color: var(--muted); }
.elcard-engine { padding: 6px 10px 8px; border-top: 1px solid var(--line-soft); font-size: 11px; }
.elcard-props { padding: 6px 10px 8px; }
.elcard-props dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 10px; margin: 0 0 8px; }
.elcard-props dt { color: var(--muted); }
.elcard-props dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.elcard-props .meta { color: var(--muted); }
.elcard-props code { font-size: 11px; }
.elcard-props button.link { padding: 0; border: 0; background: none; color: var(--focus); cursor: pointer; font: inherit; text-align: left; }
.elcard-props button.link:hover { text-decoration: underline; }
.elcard-chain { display: flex; flex-direction: column; min-height: 0; flex: 1; border-top: 1px solid var(--line-soft); }
.g-row.is-element-task .g-left { box-shadow: inset 3px 0 0 var(--focus); }
.g-row.is-element-task:not(.is-selected) .g-left { background: color-mix(in srgb, var(--focus) 8%, transparent); }

/* right-click menu in 3D */
.menu.ctx-menu { position: fixed; top: 0; left: 0; right: auto; bottom: auto; z-index: 45; width: max-content; min-width: 200px; max-width: 300px; max-height: min(420px, calc(100vh - 16px)); }
.ctx-menu .menu-label { padding: 4px 8px 2px; font-size: 11px; font-weight: 600; color: var(--muted); }
.ctx-menu button span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden-chip { white-space: nowrap; }

/* BCF */
.bcf-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bcf-actions label.btn { cursor: pointer; }
.bcf-form { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.btn-primary-quiet { border-color: var(--text); font-weight: 600; }
.bcf-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 420px; overflow-y: auto; }
.bcf-topic { display: grid; grid-template-columns: 52px 1fr auto; gap: 2px 8px; padding: 6px; border: 1px solid var(--line-soft); border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.bcf-topic:hover { background: var(--surface-2); }
.bcf-topic.is-active { border-color: var(--focus); background: color-mix(in srgb, var(--focus) 6%, var(--surface)); }
.bcf-thumb { grid-row: 1 / span 2; width: 52px; height: 36px; border-radius: 3px; object-fit: cover; background: var(--viewer-bg); border: 1px solid var(--line-soft); }
.bcf-topic-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bcf-topic-meta { grid-column: 2; color: var(--muted); }
.bcf-topic .reject { grid-row: 1; grid-column: 3; padding: 0 4px; border: 0; background: none; color: var(--faint); font-size: 14px; cursor: pointer; }
.bcf-topic .reject:hover { color: var(--danger); }
.bcf-detail { grid-column: 1 / -1; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line-soft); color: var(--text); white-space: pre-wrap; }
.bcf-detail .bcf-comment { margin-top: 4px; color: var(--muted); }
.bcf-detail .bcf-comment b { color: var(--text); font-weight: 500; }
.bcf-warn { color: var(--warning); }
.check-export { margin-top: 8px; }

/* sequence check */
.check-summary { margin-top: 8px; }
.check-summary b { font-weight: 600; }
.check-summary .is-stale { color: var(--danger); }
.sev-counts { display: flex; gap: 10px; margin-top: 8px; font-size: 12px; }
.sev { display: inline-flex; align-items: center; gap: 4px; }
.sev::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sev); }
.sev-error { --sev: var(--danger); }
.sev-warning { --sev: #b7791f; }
.sev-info { --sev: var(--faint); }
.issue-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.issue {
  display: grid; grid-template-columns: 10px 1fr; gap: 2px 8px; padding: 6px 8px;
  border: 1px solid var(--line-soft); border-radius: var(--radius); cursor: pointer; font-size: 12px;
}
.issue:hover { background: var(--surface-2); }
.issue.is-active { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.issue::before { content: ""; grid-row: 1 / span 3; width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: var(--sev); }
.issue-text { color: var(--text); line-height: 1.35; }
.issue-meta { color: var(--muted); }
.issue-actions { display: flex; gap: 6px; }
.issue-actions button { padding: 0; border: 0; background: none; color: var(--focus); font-size: 12px; cursor: pointer; }
.check-ignored { margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; }
.check-ignored button { padding: 1px 6px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); font-size: 12px; cursor: pointer; }
.check-note { margin-top: 8px; }
.g-issue { flex: 0 0 6px; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--sev); }

/* ------------------------------------------------------------------ main */

.main { position: relative; min-width: 0; display: flex; flex-direction: column; }
.empty { margin: auto; max-width: 360px; padding: 24px; text-align: center; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-sub { color: var(--muted); }

.gantt-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.gantt-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.gantt-title { font-size: 15px; font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gantt-title small { font-weight: 400; color: var(--muted); margin-left: 8px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.gantt-scroll { flex: 1; min-height: 0; overflow: auto; background: var(--surface); }

/* ------------------------------------------------------------------ gantt */

.gantt {
  --left: 520px;
  --c-wbs: 60px; --c-name: 1fr; --c-date: 82px; --c-days: 50px;
  position: relative;
  min-height: 100%;
}
.g-row, .g-head-row { display: flex; }
.g-left {
  position: sticky; left: 0; z-index: 3;
  flex: 0 0 var(--left); width: var(--left);
  display: grid; grid-template-columns: var(--c-wbs) minmax(0, var(--c-name)) var(--c-date) var(--c-date) var(--c-days);
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.g-left > div { padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { position: relative; flex: 0 0 auto; }

.g-head { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.g-head .g-left { z-index: 6; align-items: end; padding-bottom: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.g-head .g-left .num, .g-row .num { text-align: right; }
.g-head .g-track { overflow: hidden; }
.g-months, .g-ticks { position: relative; height: 22px; }
.g-months { border-bottom: 1px solid var(--line-soft); }
.g-month { position: absolute; top: 0; height: 22px; padding: 3px 6px; font-size: 12px; font-weight: 500; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.g-tick { position: absolute; top: 0; height: 22px; padding-top: 4px; font-size: 11px; color: var(--muted); text-align: center; border-left: 1px solid var(--line-soft); overflow: hidden; }
.g-tick.is-weekend { color: var(--faint); }

.g-body { position: relative; }
.g-bg { position: absolute; top: 0; bottom: 0; pointer-events: none; z-index: 0; }
.g-weekend { position: absolute; top: 0; bottom: 0; background: var(--weekend); }
.g-line { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--grid); }
.g-line.is-month { background: var(--line); }
.g-today { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed var(--accent); z-index: 2; }
.g-today-label { position: absolute; top: 2px; left: 4px; font-size: 10px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }

.g-row { height: var(--row); border-bottom: 1px solid var(--line-soft); cursor: pointer; position: relative; z-index: 1; }
.g-row .g-left { align-items: center; font-size: 13px; }
.g-row:hover .g-left, .g-row:hover .g-track { background-color: var(--surface-2); }
.g-row:hover .g-track { background-color: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.g-row.is-selected .g-left { background: var(--select); }
.g-row.is-selected .g-track { background: color-mix(in srgb, var(--select) 60%, transparent); }
.g-row.is-summary .g-name { font-weight: 600; }
.g-wbs { color: var(--muted); font-size: 12px; }
.g-dates { color: var(--muted); font-size: 12px; }
.g-name { display: flex; align-items: center; gap: 2px; }
.g-name .label { overflow: hidden; text-overflow: ellipsis; }
.g-toggle {
  flex: 0 0 18px; width: 18px; height: 18px; padding: 0; border: 0; background: transparent; color: var(--muted);
  cursor: pointer; border-radius: 3px; display: inline-grid; place-items: center;
}
.g-toggle:hover { background: var(--line-soft); color: var(--text); }
.g-toggle svg { transition: transform 0.12s; }
.g-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.g-spacer { flex: 0 0 18px; }

.bar { position: absolute; top: 7px; height: 14px; border-radius: 2px; background: var(--bar); min-width: 3px; }
.bar.is-summary { top: 9px; height: 5px; border-radius: 0; background: var(--summary); }
.bar.is-summary::before, .bar.is-summary::after {
  content: ""; position: absolute; top: 0; width: 0; height: 0;
  border-top: 6px solid var(--summary);
}
.bar.is-summary::before { left: 0; border-right: 5px solid transparent; }
.bar.is-summary::after { right: 0; border-left: 5px solid transparent; }
.milestone { position: absolute; top: 8px; width: 12px; height: 12px; margin-left: -6px; background: var(--bar); transform: rotate(45deg); border-radius: 1px; }
.g-row.is-selected .bar:not(.is-summary), .g-row.is-selected .milestone { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--text); }
.g-row:not(.is-summary) .bar, .milestone { touch-action: none; }
body:not(.role-viewer) .bar:not(.is-summary), body:not(.role-viewer) .milestone { cursor: grab; }
body:not(.role-viewer) .bar:not(.is-summary)::before, body:not(.role-viewer) .bar:not(.is-summary)::after {
  content: ""; position: absolute; top: -3px; bottom: -3px; width: 7px; cursor: col-resize;
}
body:not(.role-viewer) .bar:not(.is-summary)::before { left: 0; }
body:not(.role-viewer) .bar:not(.is-summary)::after { right: 0; }
.is-dragging-bar { cursor: grabbing; user-select: none; }
.is-dragging-bar .bar, .is-dragging-bar .milestone { cursor: grabbing; }
.bar-label { position: absolute; top: 6px; font-size: 11px; color: var(--muted); white-space: nowrap; pointer-events: none; }

.g-playhead { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1.5px solid var(--text); z-index: 2; pointer-events: none; }
.g-playhead::before { content: ""; position: absolute; top: -1px; left: -5px; border: 4px solid transparent; border-top: 6px solid var(--text); }
.has-viewer .g-head .g-track { cursor: col-resize; }

/* ------------------------------------------------------------------ 3D viewer */

.gantt-shell[data-view="split"] .viewer { flex: 0 0 56%; border-bottom: 1px solid var(--line); }
.gantt-shell[data-view="3d"] .viewer { flex: 1; }
.gantt-shell[data-view="3d"] .gantt-scroll { display: none; }

.viewer { position: relative; min-height: 260px; background: var(--viewer-bg); overflow: hidden; }
.viewer-stage { position: absolute; inset: 0 0 44px 0; }
.viewer-gl { display: block; width: 100%; height: 100%; touch-action: none; }

.hud, .viewer-tools, .legend {
  position: absolute; z-index: 2;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.hud { top: 12px; left: 12px; padding: 8px 10px; min-width: 200px; max-width: min(320px, calc(100% - 24px)); pointer-events: none; }
.hud-date b { display: block; font-size: 15px; font-weight: 600; }
.hud-date span { font-size: 12px; color: var(--muted); }
.hud-active { list-style: none; margin: 6px 0 0; padding: 6px 0 0; border-top: 1px solid var(--line-soft); display: grid; gap: 3px; font-size: 12px; }
.hud-active:empty { display: none; }
.hud-active li { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hud-active .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud-active .count { color: var(--muted); }
.hud-active .sw { flex: 0 0 8px; height: 8px; }
.hud-active .muted { color: var(--muted); }

.viewer-tools { top: 58px; right: 12px; display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 10px; }
.viewer-filter {
  position: absolute; top: 12px; right: 12px; z-index: 3; display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 24px); padding: 4px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: var(--radius);
}
.viewer-filter input {
  width: 240px; min-width: 0; height: 28px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 3px; background: var(--surface); font-size: 13px;
}
.viewer-filter input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.viewer-filter .segmented button { height: 26px; }
.viewer-filter .segmented button:disabled { cursor: default; opacity: 0.5; }
.filter-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.filter-count.is-empty { color: var(--danger); }
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 5; min-width: 220px; max-height: 320px; overflow-y: auto;
  padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.menu button {
  display: flex; justify-content: space-between; gap: 16px; width: 100%; padding: 6px 8px;
  border: 0; border-radius: 3px; background: transparent; font-size: 13px; text-align: left; cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button b { font-weight: 500; }
.menu .menu-count { color: var(--muted); }
.menu .menu-sep { height: 1px; margin: 4px 0; background: var(--line-soft); }
.menu .menu-empty { padding: 6px 8px; font-size: 13px; color: var(--muted); }
.selbar {
  position: absolute; left: 12px; bottom: 56px; z-index: 2; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  max-width: calc(100% - 24px); padding: 5px 6px 5px 10px;
  background: var(--surface); border: 1px solid var(--focus); border-radius: var(--radius);
}
.selbar-count { font-weight: 600; font-size: 13px; color: var(--focus); }
.selbar-hint { font-size: 12px; color: var(--muted); }
.legend { left: 12px; bottom: 56px; margin: 0; padding: 5px 8px; list-style: none; display: flex; gap: 10px; font-size: 11px; color: var(--muted); pointer-events: none; }
.legend li { display: flex; align-items: center; gap: 4px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.sw-built { background: #b8b6b0; }
.sw-active { background: var(--c1); }
.sw-pending { border: 1px solid var(--c1); background: color-mix(in srgb, var(--c1) 18%, transparent); }
.sw-future { border: 1px dashed var(--faint); }
.sw-unscheduled { background: color-mix(in srgb, #b8b6b0 40%, transparent); border: 1px solid color-mix(in srgb, var(--faint) 60%, transparent); }

/* navigation cube (navcube.js), FreeCAD style: chamfered cube (26 facets) in a WebGL canvas, buttons around it */
.navcube { position: absolute; top: 96px; right: 8px; z-index: 2; width: 140px; height: 140px; }
.navcube-gl { position: absolute; left: 20px; top: 20px; width: 100px; height: 100px; }
.navcube-btn {
  position: absolute; width: 20px; height: 20px; padding: 3px; border: 0; border-radius: 3px;
  background: transparent; color: color-mix(in srgb, var(--muted) 75%, transparent); cursor: pointer;
}
.navcube-btn svg { display: block; width: 14px; height: 14px; }
.navcube-btn:hover, .navcube-btn:focus-visible { color: var(--focus); background: color-mix(in srgb, var(--surface) 80%, transparent); }
.navcube:not(:hover) .navcube-btn:not(:focus-visible) { opacity: 0.7; }
.nc-up { left: 60px; top: 0; }
.nc-down { left: 60px; bottom: 0; }
.nc-left { left: 0; top: 60px; }
.nc-right { right: 0; top: 60px; }
.nc-turn-left { left: 26px; top: 4px; }
.nc-turn-right { right: 26px; top: 4px; }
.nc-home { left: 0; top: 0; }
.nc-flip { right: 0; top: 0; }
.nc-menu { right: 0; bottom: 0; }
.navcube-menu {
  position: absolute; right: 0; top: 100%; z-index: 5; min-width: 140px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.navcube-menu button {
  display: block; width: 100%; padding: 6px 8px; border: 0; border-radius: 3px; background: transparent;
  font-size: 13px; text-align: left; color: var(--text); cursor: pointer;
}
.navcube-menu button:hover, .navcube-menu button:focus-visible { background: var(--surface-2); }

/* a model opened through a public read-only link: only what a visitor may see */
.is-shared #tourBtn, .is-shared #todayBtn, .is-shared #shareBtn, .is-shared #newModelBtn, .is-shared .topbar form,
.is-shared #exportBtn, .is-shared #feedPanel, .is-shared #filesPanel, .is-shared #checkPanel, .is-shared #bcfPanel,
.is-shared #phPanel, .is-shared #generatePanel, .is-shared #addRootTaskBtn, .is-shared #addTaskBtn,
.is-shared #trackWrap, .is-shared .inspector-actions { display: none !important; }
.is-shared .shared-tag { display: inline-flex; }
.shared-tag { display: none; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--focus) 14%, transparent); color: var(--focus); font-size: 12px; font-weight: 600; }

/* weather strip above the Gantt dates: daily high/low band, cold days, and the daylight band */
.g-weather { position: relative; border-bottom: 1px solid var(--line-soft); cursor: crosshair; }
.g-weather-key {
  position: absolute; left: 0; top: 0; width: var(--left); display: flex; flex-direction: column; justify-content: space-between;
  padding: 2px 8px 3px; font-size: 9px; letter-spacing: 0.04em; color: var(--muted); text-transform: none; pointer-events: none;
  border-bottom: 1px solid var(--line-soft); background: var(--surface);
}
.g-weather-key .wx-key-sun { color: var(--accent); }
.wx-svg { display: block; }
.wx-band { fill: color-mix(in srgb, var(--c1) 42%, transparent); stroke: none; }
.wx-line { fill: none; stroke: var(--c1); stroke-width: 1.2; opacity: 1; }
.wx-line.is-low { stroke: var(--focus); }
.wx-cold { fill: color-mix(in srgb, var(--focus) 24%, transparent); }
.wx-zero { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.6; }
.wx-day { fill: color-mix(in srgb, var(--accent) 30%, transparent); stroke: none; }
.wx-edge { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 2 3; }

/* the Export menu holds links as well as buttons */
.menu a[role="menuitem"] {
  display: block; padding: 6px 8px; border-radius: 3px; color: var(--text); font-size: 13px; text-decoration: none;
}
.menu a[role="menuitem"]:hover { background: var(--surface-2); }
.menu .is-disabled { opacity: 0.45; cursor: default; }
.menu .is-disabled:hover { background: transparent; }

/* printing the Gantt (Print / PDF): only the chart, scaled to the page, with a title block */
.print-head { display: none; }
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; color: #000; }
  .topbar, .rail, .inspector, .viewer, .playbar, .gantt-toolbar, .toasts, .busy, .tour-mask, .tour-bubble,
  .selbar, .elcard, .ctx-menu, .navcube { display: none !important; }
  .layout, .main, .gantt-shell, .gantt-scroll { display: block !important; height: auto !important; overflow: visible !important; }
  .print-head { display: block; margin-bottom: 8px; }
  .print-head h1 { margin: 0; font-size: 15pt; }
  .print-head p { margin: 2px 0 0; font-size: 9pt; color: #444; }
  .gantt { transform: scale(var(--print-scale, 1)); transform-origin: top left; }
  .g-row, .g-head-row { break-inside: avoid; }
  .g-left, .g-head { background: #fff !important; }
  .g-row:hover .g-left, .g-row:hover .g-track { background: none !important; }
  .bar, .milestone, .bar-actual, .bar-forecast { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* guided tour (tour.js): a hole in a dimmed page, plus a bubble */
.tour-mask {
  position: fixed; z-index: 90; border-radius: 6px; pointer-events: none;
  box-shadow: 0 0 0 9999px color-mix(in srgb, #06080c 62%, transparent), 0 0 0 2px var(--focus);
  transition: opacity 0.15s;
}
.tour-bubble {
  position: fixed; z-index: 91; width: min(330px, calc(100vw - 24px)); padding: 12px 14px 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28); font-size: 13px;
}
.tour-bubble h3 { margin: 2px 0 6px; font-size: 15px; font-weight: 600; }
.tour-count { margin: 0; font-size: 11px; color: var(--muted); }
.tour-text { margin: 0; line-height: 1.45; }
.tour-do { margin: 8px 0 0; padding: 6px 8px; border-radius: 4px; background: color-mix(in srgb, var(--focus) 12%, transparent); color: var(--focus); font-weight: 600; }
.tour-actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.tour-spacer { flex: 1; }

.viewer-status { position: absolute; inset: 0 0 44px 0; z-index: 3; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; background: var(--viewer-bg); }
.viewer-tip { position: fixed; z-index: 40; padding: 4px 8px; font-size: 12px; background: var(--text); color: var(--surface); border-radius: 3px; pointer-events: none; white-space: nowrap; }
.viewer-tip small { opacity: 0.75; margin-left: 6px; }
.viewer-tip { display: grid; gap: 1px; max-width: 360px; white-space: normal; line-height: 1.35; }
.viewer-tip b { font-weight: 600; }
.viewer-tip span { opacity: 0.8; }
.viewer-tip .tip-status { opacity: 1; font-weight: 600; }

.playbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 44px; z-index: 2;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--surface); border-top: 1px solid var(--line);
}
.play-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--text); }
.play-btn .i-pause, .play-btn.is-playing .i-play { display: none; }
.play-btn.is-playing .i-pause { display: block; }
#scrubber { flex: 1; min-width: 0; accent-color: var(--text); }
#speedSelect { height: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 12px; padding: 0 4px; }

/* ------------------------------------------------------------------ inspector */

.inspector {
  width: 320px; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--line);
  padding: 12px 16px 20px;
}
.inspector-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.inspector-head .panel-title { margin: 0; }
.facts { margin: 4px 0 0; font-size: 13px; display: grid; gap: 8px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; }
.inspector-actions { display: flex; justify-content: space-between; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line-soft); }

/* ------------------------------------------------------------------ overlays */

.busy { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); }
.busy-card { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--text); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 10px 12px; background: var(--text); color: var(--surface); border-radius: var(--radius); font-size: 13px; }
.toast.is-error { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .inspector { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; z-index: 20; box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12); }
}

@media (max-width: 760px) {
  body { font-size: 14px; }
  .brand-tagline i { display: none; }
  .topbar { height: auto; min-height: 48px; flex-wrap: wrap; padding: 8px 16px; gap: 8px 12px; }
  .model-meta { order: 3; flex-basis: 100%; }
  .layout { display: flex; flex-direction: column; height: auto; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .main { min-height: 70vh; }
  .gantt-shell { height: 70vh; flex: none; }
  .gantt { --left: 210px; --c-wbs: 44px; }
  .g-left { grid-template-columns: var(--c-wbs) minmax(0, 1fr); }
  .g-left .g-dates, .g-left .g-days { display: none; }
  .gantt-toolbar { padding: 8px 16px; }
  .gantt-shell[data-view="split"], .gantt-shell[data-view="3d"] { height: 88vh; }
  .gantt-shell[data-view="split"] .viewer { flex-basis: 58%; }
  .legend { display: none; }
  .hud { min-width: 0; top: 8px; left: 8px; padding: 6px 8px; max-width: calc(100% - 16px); }
  .hud-date b { font-size: 13px; }
  .hud-date span { font-size: 11px; }
  .hud-active li:nth-child(n + 3) { display: none; }
  .viewer-tools { top: auto; right: 8px; bottom: 52px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 16px); }
  .viewer-filter { top: auto; left: 8px; right: 8px; bottom: 98px; flex-wrap: wrap; }
  .viewer-filter input { flex: 1 1 140px; width: auto; }
  .menu { top: auto; bottom: calc(100% + 6px); }
  .selbar { left: 8px; bottom: auto; top: 88px; }
  .selbar-hint { display: none; }
  .elcard { left: 8px; right: 8px; width: auto; bottom: 52px; max-height: 55%; }
  .navcube { top: 4px; right: 2px; transform: scale(0.75); transform-origin: top right; }
  .hud { max-width: calc(100% - 120px); }
  .toolbar-right { flex-wrap: wrap; }
  .inspector { top: auto; left: 0; width: auto; max-height: 75vh; border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.14); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .spinner { animation: none; border-top-color: var(--muted); }
}

/* ------------------------------------------------------------------ home: workspaces, models, people */

body.home { height: auto; min-height: 100%; }
a.brand { color: inherit; text-decoration: none; }
.topbar-actions form { margin: 0; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.home-main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.home-title { font-size: 22px; font-weight: 600; }
.home-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.home-head-actions { display: flex; gap: 8px; }
.ws-switch select { height: 28px; margin-bottom: 6px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.home-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card-panel > .panel-title { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.sub-title { font-size: 13px; font-weight: 600; margin: 16px 0 8px; }
.dropzone-slim { margin-bottom: 12px; padding: 14px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table tr.is-disabled td { color: var(--faint); }
.cell-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.model-link { color: var(--text); font-weight: 600; text-decoration: none; }
.model-link:hover { color: var(--focus); text-decoration: underline; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 4px; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.member-list { list-style: none; margin: 0; padding: 0; }
.member-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.member-list li > div { flex: 1; min-width: 0; }
.member-list b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-list small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-list select { height: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0 6px; }
.invite-form { display: flex; flex-direction: column; gap: 8px; }
.invite-form .field-row { grid-template-columns: 1fr 120px; }
.invite-form > .btn { align-self: flex-start; }
.link-out { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 4px; }
.link-out input { height: 28px; min-width: 0; padding: 0 8px; border: 1px solid var(--focus); border-radius: var(--radius); background: var(--surface-2); font-size: 12px; }
.link-out .hint { grid-column: 1 / -1; }
.activity-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.activity-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.activity-list li small { color: var(--faint); white-space: nowrap; font-size: 12px; }
.activity-list b { font-weight: 500; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { flex: 1; min-width: 0; height: 28px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hint.is-error { color: var(--danger); }
.dialog { width: min(460px, calc(100% - 32px)); padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.dialog::backdrop { background: rgba(10, 14, 20, 0.45); }
.dialog > * + * { margin-top: 12px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head .panel-title { margin: 0; }

@media (max-width: 900px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .home .topbar-actions { flex-wrap: wrap; }
  .home-head { flex-direction: column; align-items: flex-start; }
  #modelTable th:nth-child(3), #modelTable td:nth-child(3) { display: none; }
  .row-actions { white-space: normal; }
  .row-actions .btn { margin: 2px 0 2px 4px; }
}

/* editor: read-only roles */
.readonly-banner { padding: 8px 16px; font-size: 13px; background: var(--select); color: var(--text); border-bottom: 1px solid var(--line); }
.readonly-tag { color: var(--text); }
.role-viewer #generatePanel,
.role-viewer #addRootTaskBtn,
.role-viewer .inspector-actions,
.role-viewer [data-delete-schedule],
.role-viewer [data-delete-topic],
.role-viewer [data-ignore],
.role-viewer [data-restore],
.role-viewer [data-reject],
.role-viewer #selBar,
.role-viewer #selectMenuBtn,
.role-viewer #filterSelect { display: none !important; }
.member-list b small { display: inline; color: var(--muted); font-weight: 400; }
.dialog-head .panel-title { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }

/* trades and people */
.crew-filter { display: flex; align-items: center; gap: 6px; }
.crew-filter select { height: 28px; max-width: 160px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 13px; }
.crew-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; background: var(--surface-2); }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--danger); }
.chip-empty { font-size: 12px; color: var(--faint); }
.chip-add { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-top: 6px; }
.chip-add input { height: 28px; min-width: 0; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.role-viewer .chip-add, .role-viewer #fillTradesBtn { display: none !important; }

/* billing and signups */
.billing-banner { margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--select); font-size: 13px; }
.billing-banner.is-warning { border-color: var(--warning); background: color-mix(in srgb, var(--warning) 14%, var(--surface)); }
.count-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.signup-note { white-space: normal !important; font-style: italic; }
#signupList li { align-items: flex-start; }

/* feeds */
.panel-head, .card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-head .panel-title { margin-bottom: 10px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; cursor: pointer; text-decoration: underline; margin-bottom: 10px; }
.link-btn:hover { color: var(--text); }
.card-head .link-btn { margin-bottom: 12px; }
.feed-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.feed-form textarea { width: 100%; min-height: 52px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); resize: vertical; }
.feed-form textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.feed-form-row { display: flex; align-items: center; gap: 6px; }
.feed-form-row .btn-primary-quiet { margin-left: auto; }
.feed-photo-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.feed-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.card-panel .feed-list { max-height: 560px; }
.feed-item { padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.feed-item:last-child { border-bottom: 0; }
.feed-head { display: flex; align-items: baseline; gap: 6px; }
.feed-head b { font-weight: 600; }
.feed-head small, .feed-item.is-auto small { color: var(--faint); font-size: 12px; white-space: nowrap; }
.feed-head small { margin-left: auto; }
.feed-del { width: 20px; height: 20px; font-size: 14px; }
.feed-body { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.feed-photo { display: block; max-width: 100%; max-height: 240px; margin-top: 6px; border-radius: var(--radius); border: 1px solid var(--line-soft); object-fit: cover; }
.feed-task { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 12px; cursor: pointer; }
.feed-task:hover { border-color: var(--focus); }
.feed-item.is-auto { display: flex; gap: 8px; color: var(--muted); }
.feed-item.is-auto > div { display: flex; justify-content: space-between; gap: 8px; flex: 1; min-width: 0; }
.feed-dot { flex: 0 0 auto; width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: var(--faint); }
.feed-model { color: var(--text); font-weight: 500; text-decoration: none; }
.feed-model:hover { text-decoration: underline; }
.feed-empty { font-size: 12px; color: var(--faint); padding: 4px 0; }

/* progress tracking */
.track-toggle { white-space: nowrap; font-size: 13px; }
.g-status { flex: 0 0 auto; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; border: 1.5px solid var(--faint); }
.g-status.st-INPROGRESS { border-color: var(--c5); background: linear-gradient(90deg, var(--c5) 50%, transparent 50%); }
.g-status.st-COMPLETED { border-color: var(--c7); background: var(--c7); }
.g-status.st-BLOCKED { border-color: var(--danger); background: var(--danger); }
.bar-actual { position: absolute; bottom: 3px; height: 4px; border-radius: 2px; background: var(--c5); }
.bar-actual.st-COMPLETED { background: var(--c7); }
.bar-actual.st-BLOCKED { background: var(--danger); }
.bar-forecast { position: absolute; top: 6px; height: calc(var(--row) - 14px); border: 1.5px dashed var(--c5); border-radius: 3px; background: transparent; pointer-events: none; }
.bar-forecast.is-late { border-color: var(--warning); }
.prog-box { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.prog-label { font-size: 12px; color: var(--muted); }
.prog-status { display: grid; grid-template-columns: repeat(4, 1fr); }
.prog-status button { font-size: 12px; padding: 0 4px; }
.prog-status button[aria-pressed="true"][data-status="COMPLETED"] { background: var(--c7); color: #fff; }
.prog-status button[aria-pressed="true"][data-status="BLOCKED"] { background: var(--danger); color: #fff; }
.prog-status button[aria-pressed="true"][data-status="INPROGRESS"] { background: var(--c5); color: #fff; }
.prog-status button:disabled { cursor: default; }
.prog-box > .btn { align-self: flex-start; }
.prog-history { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); }
.prog-history li { padding: 3px 0; border-top: 1px solid var(--line-soft); }
.prog-history b { color: var(--text); font-weight: 500; }
.prog-history small { display: block; font-style: italic; }
.feed-item.is-milestone { color: var(--text); font-weight: 500; }
.feed-item.is-milestone .feed-dot { background: var(--accent); width: 8px; height: 8px; }
.feed-item.is-blocked .feed-dot { background: var(--danger); }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 100; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation-name: confetti-fall; animation-timing-function: cubic-bezier(.2,.6,.4,1); animation-fill-mode: forwards; }
@keyframes confetti-fall { to { transform: translate(var(--drift), 105vh) rotate(var(--spin)); opacity: 0.2; } }

/* My tasks (phone first) */
body.today-page { height: auto; min-height: 100%; }
.today-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line); }
.today-bar .brand { gap: 8px; margin-right: auto; }
.today-bar .brand-name { font-size: 15px; }
.today-main { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
.today-empty { margin-top: 24px; color: var(--muted); }
.tgroup { margin-top: 20px; }
.tgroup .panel-title { display: flex; align-items: center; gap: 6px; }
.tcount { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.tcard { position: relative; margin-bottom: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--faint); border-radius: var(--radius); }
.tcard.st-INPROGRESS { border-left-color: var(--c5); }
.tcard.st-BLOCKED { border-left-color: var(--danger); }
.tcard.st-COMPLETED { border-left-color: var(--c7); opacity: 0.9; }
.tcard-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tcard-head b { font-size: 15px; font-weight: 600; }
.tchip { flex: 0 0 auto; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tchip.st-INPROGRESS { color: var(--c5); border-color: var(--c5); }
.tchip.st-BLOCKED { color: var(--danger); border-color: var(--danger); }
.tchip.st-COMPLETED { color: var(--c7); border-color: var(--c7); }
.tcard-sub, .tcard-dates, .tcard-wait { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.tcard-wait { color: var(--warning); }
.tcard-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tcard-actions .btn, .tcard-panel .btn { height: 40px; padding: 0 16px; font-size: 14px; }
.tcard-actions .btn.pct { padding: 0 10px; }
.tcard-actions .btn.pct.is-on { border-color: var(--c5); color: var(--c5); font-weight: 600; }
.tcard-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.tcard-panel .field { flex: 1 1 100%; }
.tcard-panel input[type="text"] { flex: 1 1 100%; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tcard-link { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--focus); }
.tcard-note { margin: 6px 0 0; padding: 6px 8px; font-size: 13px; border-radius: var(--radius); background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }

/* staging ribbon (see /env.js) */
.env-ribbon { position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; padding: 3px 8px; text-align: center; font: 600 12px/1.4 var(--font);
  letter-spacing: 0.04em; color: #1a1300; background: repeating-linear-gradient(135deg, #ffcf33 0 14px, #ffc107 14px 28px); pointer-events: none; }

/* model files, revisions and merging */
.files-list { list-style: none; margin: 0 0 8px; padding: 0; }
.files-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.files-list li > div { flex: 1; min-width: 0; }
.files-list b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files-list small { color: var(--muted); font-size: 12px; }
.files-actions { margin-bottom: 6px; }
.files-log { font-size: 12px; margin-top: 6px; }
.files-log summary { cursor: pointer; color: var(--muted); }
.files-log ul { list-style: none; margin: 6px 0 0; padding: 0; }
.files-log li { padding: 4px 0; border-top: 1px solid var(--line-soft); }
.files-log small { display: block; color: var(--faint); }
.rev-dialog { width: min(560px, calc(100% - 32px)); }
.rev-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rev-stats div { padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.rev-stats b { display: block; font-size: 18px; }
.rev-stats span { font-size: 12px; color: var(--muted); }
.rev-warn { padding: 8px 12px; border-left: 3px solid var(--warning); background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; font-size: 13px; }
.rev-warn ul { margin: 4px 0 0; padding-left: 18px; }
.rev-block summary { cursor: pointer; font-size: 13px; }
.rev-list { margin: 4px 0 0; padding-left: 18px; font-size: 12px; color: var(--muted); max-height: 160px; overflow-y: auto; }

/* dependencies */
.sub-box { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.link-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto 52px auto; gap: 4px; align-items: center; }
.link-list li small { color: var(--muted); }
.link-list .link-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-list select, .link-add select, .link-list input, .link-add input { height: 26px; font-size: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.link-list input, .link-add input { width: 52px; padding: 0 4px; }
.link-add { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 4px; align-items: center; }
.link-add #linkPred { grid-column: 1 / -1; }
.link-lag { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.g-links { position: absolute; top: 0; z-index: 2; pointer-events: none; overflow: visible; }
.g-links path { fill: none; stroke: var(--muted); stroke-width: 1.2; marker-end: url(#linkHead); opacity: 0.75; }
.g-links path.has-lag { stroke-dasharray: 3 2; }
.g-links marker path { fill: var(--muted); stroke: none; }
.gantt-toolbar .track-toggle { margin-right: 4px; }

/* placeholders (awaiting design) */
.bar.is-placeholder { background: repeating-linear-gradient(135deg, var(--bar) 0 5px, transparent 5px 10px) !important; border: 1px dashed var(--bar); }
.g-ph { flex: 0 0 auto; width: 8px; height: 8px; margin-right: 6px; border: 1.5px dashed var(--warning); border-radius: 2px; }
.g-ph.is-late { background: var(--danger); border: 1.5px solid var(--danger); }
.ph-classes { display: flex; flex-wrap: wrap; gap: 4px; }
.ph-chip { padding: 2px 8px; gap: 4px; cursor: pointer; }
.ph-chip input { margin: 0; }
.ph-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.ph-list li { padding: 6px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.ph-list li b { display: block; font-weight: 500; }
.ph-list li small { color: var(--muted); font-size: 12px; }
.ph-list li.is-late small { color: var(--danger); font-weight: 500; }
.rev-links { padding: 8px 12px; border-left: 3px solid var(--c1); background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.role-viewer #linkAdd, .role-viewer #phSave { display: none !important; }

/* site and weather */
.site-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; margin-top: 8px; }
.site-form input[type="text"] { height: 28px; min-width: 0; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.site-threshold { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.site-threshold input { width: 64px; height: 26px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.site-place { font-size: 13px; margin: 0 0 6px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.climate { width: 100%; border-collapse: collapse; font-size: 11px; table-layout: fixed; }
.climate caption { text-align: left; font-size: 11px; color: var(--muted); padding-bottom: 4px; }
.climate th, .climate td { padding: 2px 0; text-align: center; font-weight: 400; }
.climate th:first-child { text-align: left; color: var(--muted); width: 30px; }
.climate tr:first-child th { color: var(--muted); font-size: 10px; }
.climate td.is-cold { color: var(--c5); font-weight: 600; }
.cold-list { margin-top: 8px; font-size: 13px; }
.cold-list ul { list-style: none; margin: 4px 0; padding: 0; }
.cold-list li { padding: 4px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
.cold-list li small { display: block; color: var(--muted); font-size: 12px; }
.cold-list li.is-forecast small { color: var(--danger); }
.site-attrib { margin-top: 6px; font-size: 10px; }
.g-cold { flex: 0 0 auto; margin-right: 4px; font-style: normal; font-size: 11px; color: var(--c5); }
.g-cold.is-forecast { color: var(--danger); }
.feed-item.is-weather .feed-dot { background: var(--c5); }
.feed-item.is-weather { color: var(--text); }
.climate-caption { font-size: 11px; color: var(--muted); margin: 0 0 4px; }
.climate + .climate { margin-top: 4px; }
.climate th:first-child { width: 34px; }

/* theme button */
.theme-btn { min-width: 36px; justify-content: center; font-size: 15px; line-height: 1; }

/* explorer: folders and models */
.explorer-head { flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; font-size: 14px; }
.crumb { border: 0; background: none; padding: 2px 6px; border-radius: var(--radius); color: var(--muted); font: inherit; cursor: pointer; }
.crumb:hover { background: var(--surface-2); color: var(--text); }
.crumb.is-current { color: var(--text); font-weight: 600; cursor: default; }
.crumb-sep { color: var(--faint); }
.explorer-tools { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.explorer-tools input { height: 28px; width: 200px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.explorer-body { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; }
.folder-tree, .move-tree { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.folder-tree { border-right: 1px solid var(--line-soft); padding-right: 8px; max-height: 60vh; overflow-y: auto; }
.tree-node { display: flex; align-items: center; gap: 6px; width: 100%; padding: 5px 8px; border: 0; border-radius: var(--radius); background: none;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.tree-node span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-node:hover { background: var(--surface-2); }
.tree-node.is-current { background: var(--select); font-weight: 600; }
.ex-icon { flex: 0 0 auto; color: var(--muted); vertical-align: -3px; margin-right: 6px; }
.tree-node .ex-icon { margin-right: 0; }
.folder-link { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }
.is-drop, tr.is-drop td { outline: 2px dashed var(--focus); outline-offset: -2px; background: var(--select) !important; }
.move-tree { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; }
[draggable="true"] { cursor: grab; }
@media (max-width: 760px) {
  .explorer-body { grid-template-columns: minmax(0, 1fr); }
  .folder-tree { display: none; }
  .explorer-tools { margin-left: 0; width: 100%; }
  .explorer-tools input { flex: 1; width: auto; }
}
