:root {
  color-scheme: light;
  --ink: #17231e;
  --muted: #69746f;
  --line: #dfe5e1;
  --line-strong: #c9d2cd;
  --surface: #ffffff;
  --surface-alt: #f4f6f4;
  --surface-warm: #f5f1e9;
  --canvas: #eef1ee;
  --green: #174c3c;
  --green-soft: #e3eee9;
  --lime: #b9d787;
  --amber: #8b5a14;
  --amber-soft: #f8ecd8;
  --red: #9c3b32;
  --red-soft: #f8e5e2;
  --blue: #315f85;
  --blue-soft: #e5edf4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { height: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  height: 100%;
  min-width: 320px;
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
}

button, select, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--lime) 75%, white);
  outline-offset: 2px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.app-header {
  flex-shrink: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  position: relative;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.header-spacer { flex: 1; }

.rail-toggle {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
}
.rail-toggle-glyph, .rail-toggle-glyph::before, .rail-toggle-glyph::after {
  display: block;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.rail-toggle-glyph { position: relative; }
.rail-toggle-glyph::before, .rail-toggle-glyph::after { content: ""; position: absolute; left: 0; }
.rail-toggle-glyph::before { top: -5px; }
.rail-toggle-glyph::after { top: 5px; }

.context-crumb {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding-left: 10px;
  border-left: 1px solid var(--line);
  font-size: .78rem;
}
.context-crumb span { color: var(--line-strong); }
.context-crumb strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.context-crumb #stripModule { flex-shrink: 0; color: var(--green); font-weight: 800; }
.context-crumb #stripCase { max-width: 170px; color: var(--muted); font-weight: 650; }
.crumb-node { max-width: 320px; }

.save-chip {
  flex-shrink: 0;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: .68rem;
  white-space: nowrap;
}
.save-chip strong { font-weight: 700; }

.app-header select#sessionSelect {
  flex: 0 1 auto;
  width: clamp(150px, 22vw, 290px);
  min-width: 120px;
  height: 32px;
  padding: 0 26px 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .76rem;
}

.status-toggle { position: relative; flex-shrink: 0; padding: 7px 11px; }
.status-toggle.has-attention::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.status-tray {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}
.tray-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--green);
  color: white;
  font-family: Georgia, serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.brand { flex-shrink: 0; }
.brand strong { letter-spacing: -.02em; font-size: .92rem; white-space: nowrap; }

.runtime-bar {
  display: flex;
  align-items: center;
  min-width: 0;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.runtime-item {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
  font-size: .75rem;
}
.runtime-item:last-child { border-right: 0; }
.runtime-item small { color: var(--muted); }
.runtime-item strong { font-size: .76rem; }
.runtime-node { max-width: 230px; }
.runtime-node strong { overflow: hidden; text-overflow: ellipsis; }
.runtime-item i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent);
}
.status-online { color: var(--green); }
.status-offline { color: var(--red); }

.preflight-control { display: flex; align-items: center; gap: 8px; }

.badge, .operation-state, .artifact-status, .node-status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-weight: 750;
  letter-spacing: .04em;
}
.badge { padding: 7px 10px; font-size: .7rem; }
.badge-neutral { background: var(--surface-alt); color: var(--muted); border: 1px solid var(--line); }
.badge-ready { background: var(--green-soft); color: var(--green); }
.badge-conditions { background: var(--amber-soft); color: var(--amber); }
.badge-error { background: var(--red-soft); color: var(--red); }

.text-button {
  padding: 1px 3px;
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-size: .7rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.icon-button, .secondary-button, .primary-button, .retry-button, .diagnostic-button {
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: .8rem;
}
.icon-button, .secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
}
.primary-button {
  border: 1px solid var(--green);
  background: var(--green);
  color: white;
}
.retry-button, .diagnostic-button {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
}
.diagnostic-button { color: var(--ink); }
button:disabled { opacity: .5; cursor: wait; }

.overview-panel {
  flex-shrink: 0;
  max-height: min(330px, 42dvh);
  overflow-y: auto;
  margin: 16px 24px 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-warm);
}
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 1.35rem; }
.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, white 55%, transparent);
  overflow: hidden;
}
.overview-grid > div { min-width: 0; padding: 12px; border-right: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
.overview-grid > div:last-child { border-right: 0; }
.overview-grid > div:nth-child(3n) { border-right: 0; }
.overview-grid > div:nth-child(-n+6) { border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
.overview-grid small, .overview-grid strong { display: block; }
.overview-grid small { color: var(--muted); font-size: .67rem; text-transform: uppercase; letter-spacing: .07em; }
.overview-grid strong { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; font-size: .78rem; white-space: nowrap; }
.bootstrap-tools { margin-top: 12px; color: var(--muted); font-size: .7rem; }
.bootstrap-tools summary { width: fit-content; cursor: pointer; font-weight: 750; }
.bootstrap-tools p { margin: 8px 0; }

.operation-panel {
  flex-shrink: 0;
  margin: 8px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.operation-panel[data-operation-status="READY"][data-reconciliation-status="SYNCED"] { display: none; }
.app-shell.status-open .operation-panel { display: block; }
.operation-state-row { display: flex; align-items: center; gap: 10px; font-size: .78rem; }
.operation-state { padding: 4px 7px; font-size: .62rem; }
.state-working { background: var(--blue-soft); color: var(--blue); }
.state-ready { background: var(--green-soft); color: var(--green); }
.state-error { background: var(--red-soft); color: var(--red); }
.state-escalation { background: var(--amber-soft); color: var(--amber); }
.elapsed { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.operation-track { height: 2px; margin-top: 9px; overflow: hidden; background: var(--surface-alt); }
.operation-track span { display: block; width: 100%; height: 100%; background: var(--green); transform-origin: left; }
.operation-panel.is-working .operation-track span { width: 32%; animation: working-track 1.35s ease-in-out infinite; }
.operation-panel.has-error { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.operation-panel.has-escalation { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.operation-error { display: flex; align-items: center; gap: 10px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); color: var(--red); font-size: .75rem; }
.operation-error code { color: var(--muted); font-size: .68rem; }
.operation-actions { display: flex; gap: 7px; margin-left: auto; }
.diagnostic-report { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.diagnostic-report summary { width: fit-content; cursor: pointer; color: var(--ink); font-size: .72rem; font-weight: 750; }
.diagnostic-report pre { max-height: 240px; margin: 9px 0 0; padding: 10px; overflow: auto; border-radius: 8px; background: var(--surface-alt); color: var(--ink); font: .68rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.sync-warning { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); color: var(--ink); }
.sync-warning-heading, .sync-warning-heading > div { display: flex; align-items: center; gap: 9px; }
.sync-warning-heading { justify-content: space-between; }
.sync-state { padding: 4px 7px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-size: .62rem; font-weight: 750; }
.sync-warning p { margin: 8px 0; color: var(--muted); font-size: .72rem; }
.sync-diagnostic { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 0; }
.sync-diagnostic div { min-width: 0; }
.sync-diagnostic dt { color: var(--muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .05em; }
.sync-diagnostic dd { margin: 2px 0 0; overflow-wrap: anywhere; font: .68rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

@keyframes working-track {
  from { transform: translateX(-110%); }
  to { transform: translateX(340%); }
}

.workspace {
  flex: 1;
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) minmax(250px, 310px);
  gap: 10px;
  padding: 10px 16px 16px;
  min-height: 0;
  overflow: hidden;
}
.workspace.context-collapsed { grid-template-columns: 56px minmax(0, 1fr); }
.workspace.context-collapsed .context-panel { display: none; }
.panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.panel-heading, .chat-heading {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.panel-heading h2, .chat-heading h2 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 1.08rem; }
.eyebrow { margin: 0; color: var(--muted); font-size: .62rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.module-chip { padding: 5px 7px; border-radius: 7px; background: var(--surface-alt); color: var(--green); font-size: .7rem; font-weight: 800; }

.roadmap-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 0;
  padding: 10px 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.rail-node {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.rail-node:hover { background: var(--surface-alt); }
.rail-node i {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
}
.rail-node.is-complete i { border-color: var(--green); background: var(--green); }
.rail-node.needs-revision i { border-color: var(--red); background: var(--red-soft); }
.rail-node.is-current i { border-color: var(--green); background: var(--lime); }
.rail-node.is-current::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 3px;
  background: var(--green);
}
.rail-index { position: absolute; bottom: 1px; right: 3px; color: var(--muted); font-size: .5rem; font-weight: 800; }

.roadmap-scrim {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(23, 35, 30, .3);
}

.roadmap-panel {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: min(320px, 86vw);
  border-radius: 0 14px 14px 0;
  box-shadow: 0 20px 60px rgba(23, 35, 30, .22);
  transform: translateX(-101%);
  /* Collapsed drawer leaves the tab order and the accessibility tree. */
  visibility: hidden;
  transition: transform .18s ease, visibility 0s linear .18s;
}
.workspace:not(.roadmap-collapsed) .roadmap-panel {
  transform: none;
  visibility: visible;
  transition: transform .18s ease, visibility 0s;
}
@media (prefers-reduced-motion: reduce) {
  .roadmap-panel, .workspace:not(.roadmap-collapsed) .roadmap-panel { transition: none; }
}
.roadmap-panel .panel-heading { flex-shrink: 0; flex-wrap: wrap; min-height: 0; padding: 14px 16px; }
.roadmap { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0; }
.context-panel { overflow-y: auto; }

.roadmap-node {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  position: relative;
  padding: 9px 14px;
}
.roadmap-node::before {
  content: "";
  position: absolute;
  left: 23px;
  top: 29px;
  bottom: -9px;
  width: 1px;
  background: var(--line);
}
.roadmap-node:last-child::before { display: none; }
.node-marker {
  z-index: 1;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: transparent;
  font-size: .65rem;
  font-weight: 900;
}
.roadmap-node.is-current { background: linear-gradient(90deg, var(--green-soft), transparent); }
.roadmap-node.is-current .node-marker { border-color: var(--green); box-shadow: inset 0 0 0 4px white; background: var(--green); }
.roadmap-node.is-complete .node-marker { border-color: var(--green); background: var(--green); color: white; }
.node-copy { min-width: 0; }
.node-copy strong { display: block; font-size: .78rem; line-height: 1.25; }
.node-status { margin-top: 4px; padding: 2px 0; color: var(--muted); font-size: .55rem; }
.roadmap-node.is-current .node-status { color: var(--green); }
.roadmap-node.needs-revision .node-status { color: var(--red); }
.roadmap-legend { flex-shrink: 0; display: flex; flex-direction: column; gap: 7px; margin: 8px 14px 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .64rem; }
.roadmap-legend span { display: flex; align-items: center; gap: 7px; }
.roadmap-legend i { width: 8px; height: 8px; border-radius: 50%; }
.legend-current { background: var(--lime); }
.legend-complete { background: var(--green); }
.legend-revision { background: var(--red); }
.legend-pending { background: var(--line-strong); }

.chat-panel { display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 24px max(20px, calc((100% - 900px) / 2)) 28px; background: linear-gradient(180deg, #fbfcfb, var(--surface)); }
.empty-chat { max-width: 420px; margin: 80px auto; text-align: center; color: var(--muted); }
.empty-chat strong { display: block; margin-bottom: 6px; color: var(--ink); font-family: Georgia, serif; font-size: 1.25rem; }
.msg { position: relative; max-width: 100%; margin: 14px 0; }
.msg.user { max-width: 78%; }
.msg .msg-label { display: block; margin: 0 0 5px 3px; color: var(--muted); font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.msg .msg-content { padding: 12px 15px; border-radius: 13px; line-height: 1.6; font-size: .9rem; overflow-wrap: anywhere; }
.msg.user { margin-left: auto; }
.msg.user .msg-label { text-align: right; }
.msg.user .msg-content { background: var(--green); color: white; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant .msg-content { border: 1px solid var(--line); background: var(--surface); border-bottom-left-radius: 4px; }
.msg.assistant .msg-content > :first-child { margin-top: 0; }
.msg.assistant .msg-content > :last-child { margin-bottom: 0; }
.msg.assistant .msg-content p, .reading-body p { margin: 0 0 .75em; }
.msg.assistant .msg-content h2, .reading-body h2 { margin: 1.2em 0 .5em; font-family: Georgia, serif; font-size: 1.08rem; line-height: 1.3; }
.msg.assistant .msg-content h3, .reading-body h3 { margin: 1em 0 .4em; font-size: .9rem; line-height: 1.35; }
.msg.assistant .msg-content ul, .reading-body ul,
.msg.assistant .msg-content ol, .reading-body ol { margin: .45em 0 .85em; padding-left: 1.4rem; }
.msg.assistant .msg-content li, .reading-body li { margin: .28em 0; padding-left: .12rem; }
.msg.assistant .msg-content blockquote, .reading-body blockquote { margin: .75em 0; padding: .7em .85em; border-left: 3px solid var(--lime); background: var(--surface-alt); color: var(--ink); }
.msg.assistant .msg-content code, .reading-body code { padding: .08em .28em; border-radius: 4px; background: var(--surface-alt); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84em; }
.msg.assistant .msg-content pre, .reading-body pre { margin: .75em 0; padding: .8em; overflow-x: auto; border-radius: 7px; background: #18231e; color: #f3f6f4; white-space: pre; }
.msg.assistant .msg-content pre code, .reading-body pre code { padding: 0; background: transparent; color: inherit; }
.msg.is-pending .msg-content { opacity: .72; }
.read-button {
  position: absolute;
  top: 0;
  right: 0;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity .12s ease;
}
.msg:hover .read-button, .read-button:focus-visible { opacity: 1; }

.reading-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.reading-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}
.reading-title { color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.reading-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 32px max(20px, calc((100% - 820px) / 2)) 64px;
  line-height: 1.7;
  font-size: .98rem;
}
.reading-body > :first-child { margin-top: 0; }
.reading-body h2 { font-size: 1.3rem; }
.reading-body h3 { font-size: 1.02rem; }

.composer { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; flex-shrink: 0; padding: 10px max(12px, calc((100% - 900px) / 2)) 12px; border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea { display: block; width: 100%; min-height: 42px; height: 42px; max-height: 40dvh; overflow-y: auto; resize: none; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink); line-height: 1.4; }
.send-button { min-width: 82px; height: 42px; padding: 0 14px; }
.composer-field { min-width: 0; }
.composer-limit { display: flex; justify-content: space-between; gap: 10px; margin: 5px 2px 0; color: var(--muted); font-size: .62rem; }
.composer-limit.is-over { color: var(--red); font-weight: 700; }
.composer-limit span:last-child { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.composer-actions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.composer-toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .68rem; cursor: pointer; user-select: none; }
.composer-toggle input { flex-shrink: 0; margin: 0; cursor: pointer; }
.composer-toggle:has(input:checked) { color: var(--ink); font-weight: 700; }

.artifact-card { margin: 14px; padding: 14px; border-radius: 11px; background: var(--green); color: white; }
.artifact-card small { opacity: .7; font-size: .65rem; text-transform: uppercase; letter-spacing: .07em; }
.artifact-card h3 { margin: 8px 0 12px; font-family: Georgia, serif; font-size: 1rem; line-height: 1.3; }
.artifact-status { padding: 5px 7px; background: rgba(255,255,255,.14); color: white; font-size: .58rem; }
.context-section { padding: 2px 14px 15px; }
.subheading-row { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.subheading-row h3 { margin: 0; font-size: .75rem; }
.subheading-row span { color: var(--muted); font-size: .65rem; }
.context-note { margin: -2px 0 8px; color: var(--muted); font-size: .62rem; line-height: 1.35; }
.file-list, .evidence-list { list-style: none; margin: 0; padding: 0; }
.file-list { max-height: 235px; overflow-y: auto; }
.file-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.file-item:last-child { border-bottom: 0; }
.file-copy { min-width: 0; }
.file-copy strong, .file-copy small { display: block; }
.file-copy strong { overflow: hidden; text-overflow: ellipsis; font-size: .68rem; white-space: nowrap; }
.file-copy small { margin-top: 2px; color: var(--muted); font-size: .6rem; }
.download-link { padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; color: var(--green); font-size: .62rem; font-weight: 750; text-decoration: none; }
.evidence-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.evidence-item:last-child { border-bottom: 0; }
.evidence-item p { margin: 0; font-size: .68rem; line-height: 1.35; }
.evidence-item span { display: inline-block; margin-top: 4px; color: var(--green); font-size: .56rem; font-weight: 800; letter-spacing: .04em; }
.empty-list { padding: 12px 0; color: var(--muted); font-size: .7rem; }

.conditions-dialog { width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 14px; padding: 0; color: var(--ink); box-shadow: 0 24px 70px rgba(23,35,30,.22); }
.conditions-dialog::backdrop, .state-import-dialog::backdrop { background: rgba(23,35,30,.38); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 1.2rem; }
.conditions-dialog ul { margin: 0; padding: 18px 18px 18px 38px; }
.conditions-dialog li { margin-bottom: 10px; line-height: 1.4; font-size: .85rem; }
.state-import-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 1px solid var(--line); border-radius: 14px; padding: 0; color: var(--ink); box-shadow: 0 24px 70px rgba(23,35,30,.22); }
.state-import-body { padding: 18px; }
.state-import-body > p { margin: 0 0 12px; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.state-import-body label { display: block; margin-bottom: 6px; font-size: .72rem; font-weight: 750; }
.state-import-body textarea { width: 100%; resize: vertical; padding: 10px; border: 1px solid var(--line-strong); border-radius: 9px; font: .72rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.state-import-preview { margin-top: 12px; }
.state-import-preview strong { font-size: .72rem; }
.state-import-preview pre { max-height: 190px; margin: 6px 0 0; padding: 10px; overflow: auto; border-radius: 8px; background: var(--surface-alt); font: .68rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }
.state-import-status { min-height: 1.2em; margin-top: 10px !important; color: var(--ink) !important; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 56px minmax(0, 1fr) 260px; }
  .crumb-node { max-width: 220px; }
  .context-crumb #stripCase { max-width: 120px; }
  .overview-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 980px) {
  .brand strong { display: none; }
  .context-crumb #stripCase { display: none; }
  .context-crumb span:first-of-type { display: none; }
  .workspace, .workspace.context-collapsed { grid-template-columns: 56px minmax(0, 1fr); }
  /* Context becomes an overlay-style full-width panel instead of squeezing the chat. */
  .workspace .context-panel { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(340px, 90vw); border-radius: 14px 0 0 14px; box-shadow: 0 20px 60px rgba(23, 35, 30, .22); }
  .workspace.context-collapsed .context-panel { display: none; }
}

@media (max-width: 680px) {
  html, body { height: auto; overflow: auto; }
  .app-shell { height: auto; min-height: 100dvh; overflow: visible; }
  .app-header { flex-wrap: wrap; padding: 8px 12px; }
  .context-crumb { order: 3; width: 100%; padding-left: 0; border-left: 0; }
  .header-spacer { display: none; }
  .app-header select#sessionSelect { flex: 1; width: auto; min-width: 120px; }
  .status-tray { padding: 10px 12px; }
  .runtime-bar { width: 100%; }
  .overview-panel { margin: 10px 12px 0; }
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid > div { border-bottom: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
  .overview-grid > div:nth-child(2n) { border-right: 0; }
  .overview-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .operation-panel { margin: 8px 12px 0; }
  .operation-error { align-items: flex-start; flex-wrap: wrap; }
  .operation-error code { width: 100%; }
  .workspace, .workspace.context-collapsed { grid-template-columns: 44px minmax(0, 1fr); padding: 8px 10px 14px; }
  .roadmap-rail { padding: 6px 0; }
  .rail-node { width: 30px; height: 30px; }
  .chat-panel { min-height: 70dvh; }
  .messages { padding: 14px; }
  .msg.user { max-width: 94%; }
  .composer { grid-template-columns: 1fr; padding: 10px 12px 12px; }
  .composer-actions { flex-direction: row; align-items: center; justify-content: space-between; }
  .send-button { width: 100%; }
  .reading-body { padding: 20px 16px 48px; }
}
