/* ═════════════════════════════════════════════════════════════════════
   ANKLE OS - RECURSIVE SESSION AND DELEGATION ARCHITECTURE HARNESS
   Edge-to-Edge Desktop Shell with Multiple OS Themes (discmaster, ankle-2029, phosphor, paper, portal-2007, status-2007)
   ═════════════════════════════════════════════════════════════════════ */

/* ── 1. THEME PALETTES ─────────────────────────────────────────── */

:root {
  --topbar-h: 38px;
  --statusbar-h: 26px;
  --font-serif: "Times New Roman", Times, "Nimbus Roman No9 L", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Courier New", Courier, monospace;
}

/* Catalog tokens match _deploy/aleqth/theme.js. Component roles stay distinct. */
@font-face{font-family:InterAnkle;font-style:normal;font-weight:100 900;font-display:swap;src:url("/static/fonts/inter-latin.woff2") format("woff2")}
body.theme-discmaster,body[data-theme="discmaster"]{
  --bg: #c0c0c0;
  --fg: #000;
  --panel: #cacaca;
  --surface: #cacaca;
  --muted: #555;
  --line: #000;
  --link: #0000ee;
  --accent: #0000ee;
  --highlight: #ffffe0;
  --highlight-fg: #000;
  --radius: 0;
  --shadow: none;
  --body-font: "Times New Roman", Times, Georgia, serif;
  --mono-font: "Courier New", Courier, monospace;
  --divider: #000;
  --line-dark: #000;
  --border-color: #000;
  --readable-muted: #555;
  --titlebar-bg: #e8e8e8;
  --titlebar-fg: #000;
  --header-bg: #e8e8e8;
  --btn-bg: #c0c0c0;
  --btn-fg: #000;
  --btn-border: 2px outset #ffffff;
  --btn-border-active: 2px inset #ffffff;
  --control-border: 2px inset #ffffff;
  --panel-border: 2px outset #ffffff;
  --sunken-border: 2px inset #ffffff;
  --border-outer: #ffffff #808080 #808080 #ffffff;
  --border-inner: #808080 #ffffff #ffffff #808080;
}
body.theme-ankle-2029,body[data-theme="ankle-2029"]{
  --bg: #ffffff;
  --fg: #121212;
  --panel: #fafafa;
  --surface: #ffffff;
  --muted: #636363;
  --line: #e8e8e8;
  --link: #0a0a0a;
  --accent: #111111;
  --highlight: #f3f4f6;
  --highlight-fg: #121212;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --body-font: InterAnkle, Inter, Arial, sans-serif;
  --mono-font: InterAnkle, Inter, Arial, sans-serif;
  --divider: #e8e8e8;
  --line-dark: #e8e8e8;
  --border-color: #e8e8e8;
  --readable-muted: #636363;
  --titlebar-bg: #fafafa;
  --titlebar-fg: #121212;
  --header-bg: #fafafa;
  --btn-bg: #fafafa;
  --btn-fg: #121212;
  --btn-border: 1px solid #e8e8e8;
  --btn-border-active: 1px solid #111111;
  --control-border: 1px solid #e8e8e8;
  --panel-border: 1px solid #e8e8e8;
  --sunken-border: 1px solid #e8e8e8;
  --border-outer: #e8e8e8;
  --border-inner: #e8e8e8;
}
body.theme-phosphor,body[data-theme="phosphor"]{
  --bg: #0a0f08;
  --fg: #7fff6a;
  --panel: #0f170c;
  --surface: #0f170c;
  --muted: #4a8c3a;
  --line: #1f3316;
  --link: #c7ff00;
  --accent: #c7ff00;
  --highlight: rgba(127,255,106,.18);
  --highlight-fg: #7fff6a;
  --radius: 0;
  --shadow: 0 0 40px rgba(127,255,106,.15);
  --body-font: "Fragment Mono","Courier New",monospace;
  --mono-font: "Fragment Mono","Courier New",monospace;
  --divider: #1f3316;
  --line-dark: #1f3316;
  --border-color: #1f3316;
  --readable-muted: #7bac70;
  --titlebar-bg: #0f170c;
  --titlebar-fg: #7fff6a;
  --header-bg: #0f170c;
  --btn-bg: #0f170c;
  --btn-fg: #7fff6a;
  --btn-border: 1px solid #1f3316;
  --btn-border-active: 1px solid #c7ff00;
  --control-border: 1px solid #1f3316;
  --panel-border: 1px solid #1f3316;
  --sunken-border: 1px solid #1f3316;
  --border-outer: #1f3316;
  --border-inner: #1f3316;
}
body.theme-paper,body[data-theme="paper"]{
  --bg: #f8f3e6;
  --fg: #1a1a1a;
  --panel: #fffbf0;
  --surface: #fffbf0;
  --muted: #6a6458;
  --line: #1a1a1a;
  --link: #a42a00;
  --accent: #a42a00;
  --highlight: #fff2a8;
  --highlight-fg: #1a1a1a;
  --radius: 0;
  --shadow: 0 1px 2px rgba(0,0,0,.1);
  --body-font: "Times New Roman", Times, serif;
  --mono-font: "Courier New", Courier, monospace;
  --divider: #1a1a1a;
  --line-dark: #1a1a1a;
  --border-color: #1a1a1a;
  --readable-muted: #6a6458;
  --titlebar-bg: #fffbf0;
  --titlebar-fg: #1a1a1a;
  --header-bg: #fffbf0;
  --btn-bg: #fffbf0;
  --btn-fg: #1a1a1a;
  --btn-border: 1px solid #1a1a1a;
  --btn-border-active: 1px solid #a42a00;
  --control-border: 1px solid #1a1a1a;
  --panel-border: 1px solid #1a1a1a;
  --sunken-border: 1px solid #1a1a1a;
  --border-outer: #1a1a1a;
  --border-inner: #1a1a1a;
}
body.theme-portal-2007,body[data-theme="portal-2007"]{
  --bg: #191919;
  --fg: #f2f2f2;
  --panel: #333333;
  --surface: #333333;
  --muted: #aaaaaa;
  --line: #ff9900;
  --link: #ffb000;
  --accent: #ffb000;
  --highlight: #ff9900;
  --highlight-fg: #000000;
  --radius: 2px;
  --shadow: 0 2px 0 #000;
  --body-font: Arial, Helvetica, sans-serif;
  --mono-font: "Courier New", monospace;
  --divider: #4a4a4a;
  --line-dark: #4a4a4a;
  --border-color: #4a4a4a;
  --readable-muted: #aaaaaa;
  --titlebar-bg: #111111;
  --titlebar-fg: #f2f2f2;
  --header-bg: #333333;
  --btn-bg: #333333;
  --btn-fg: #f2f2f2;
  --btn-border: 1px solid #4a4a4a;
  --btn-border-active: 1px solid #ffb000;
  --control-border: 1px solid #4a4a4a;
  --panel-border: 1px solid #4a4a4a;
  --sunken-border: 1px solid #4a4a4a;
  --border-outer: #4a4a4a;
  --border-inner: #4a4a4a;
}
body.theme-status-2007,body[data-theme="status-2007"]{
  --bg: #9ae4e8;
  --fg: #333;
  --panel: #fff;
  --surface: #fff;
  --muted: #999;
  --line: #ccc;
  --link: #0000cc;
  --accent: #0000cc;
  --highlight: #ffff99;
  --highlight-fg: #333;
  --radius: 0;
  --shadow: none;
  --body-font: Helvetica, Arial, "Lucida Grande", sans-serif;
  --mono-font: Helvetica, Arial, "Lucida Grande", sans-serif;
  --divider: #ccc;
  --line-dark: #ccc;
  --border-color: #ccc;
  --readable-muted: #666666;
  --titlebar-bg: #fff;
  --titlebar-fg: #333;
  --header-bg: #fff;
  --btn-bg: #fff;
  --btn-fg: #333;
  --btn-border: 1px solid #ccc;
  --btn-border-active: 1px solid #0000cc;
  --control-border: 1px solid #ccc;
  --panel-border: 1px solid #ccc;
  --sunken-border: 1px solid #ccc;
  --border-outer: #ccc;
  --border-inner: #ccc;
}

/* ── 2. GLOBAL RESET & FULL-VIEWPORT LAYOUT ─────────────────────── */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  box-shadow: none;
  text-shadow: none;
  filter: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--body-font);
  font-size: 13px;
  line-height: 1.4;
}

.aos-shell {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

/* ── 3. EDGE-TO-EDGE TOPBAR ─────────────────────────────────────── */

#aos-topbar {
  height: var(--topbar-h);
  width: 100vw;
  background: var(--header-bg);
  border-bottom: 2px solid var(--line-dark, var(--line));
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  flex-shrink: 0;
  user-select: none;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-family: var(--mono-font);
  font-size: 12px;
}

.aos-logo {
  font-size: 15px;
}

.topbar-title {
  letter-spacing: 0.5px;
}

.session-badge {
  font-size: 11px;
  font-weight: normal;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.topbar-center {
  display: flex;
  align-items: center;
}

.pipeline-tracker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
}

.pipe-step.pipe-active {
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.pipe-arrow {
  color:var(--readable-muted,var(--muted));
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-chip {
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
}

.theme-picker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.wallpaper-picker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.wallpaper-picker-wrap select {
  font-family: var(--mono-font);
  font-size: 11px;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 3px;
}

/* ── INTERACTIVE COLUMN RESIZE SPLITTERS ──────────────────────── */
.grid-splitter {
  width: 5px;
  background: var(--line, #333333);
  cursor: col-resize;
  position: relative;
  z-index: 25;
  transition: background 0.15s ease;
  user-select: none;
  flex-shrink: 0;
}
.grid-splitter:hover,
.grid-splitter.dragging {
  background: var(--accent, #00ff66) !important;
}
@media (max-width: 900px) {
  .grid-splitter { display: none !important; }
}

.theme-label {
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
}

#theme-select {
  font-family: var(--mono-font);
  font-size: 11px;
  min-height: 24px;
  padding: 2px 6px;
  background: var(--surface);
  color: var(--fg);
  border: var(--control-border, 1px solid var(--line));
  outline: none;
  cursor: pointer;
}

.aos-btn {
  font-family: var(--mono-font);
  font-size: 11px;
  min-height: 24px;
  padding: 3px 8px;
  background: var(--btn-bg);
  color: var(--btn-fg, var(--fg));
  border: var(--btn-border);
  cursor: pointer;
  border-radius: 0;
}

.aos-btn:active {
  border: var(--btn-border-active);
}

/* ── 4. EDGE-TO-EDGE 3-COLUMN WORKSPACE GRID ───────────────────── */

#workspace-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr 340px;
  width: 100vw;
  height: calc(100vh - var(--topbar-h) - var(--statusbar-h));
  overflow: hidden;
  background: var(--panel);
}

.col-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-right: 2px solid var(--line-dark, var(--line));
  background: var(--panel);
}

.col-panel:last-child {
  border-right: none;
}

.panel-header {
  padding: 8px 12px;
  background: var(--header-bg);
  border: var(--panel-border, 0);
  border-bottom: 2px solid var(--line-dark, var(--line));
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  user-select: none;
}

.panel-header h3 {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  flex: 1;
}

.coord-status {
  font-family: var(--mono-font);
  font-size: 10px;
  font-weight: 700;
}

.panel-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  overflow-y: auto;
}

/* ── 5. COLUMN 1: SESSION TREE / NAVIGATION ────────────────────── */

.tree-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
}

.dot-active {
  font-size: 16px;
  line-height: 1;
}

.current-session-box .session-name {
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 8px;
  background: var(--surface);
  border: var(--sunken-border, 1px solid var(--line));
}

.tree-toggle {
  cursor: pointer;
  user-select: none;
}

.sub-tree {
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.tree-folder .folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
}

.tree-list {
  list-style: none;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 3px;
}

.tree-list li {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bullet {
  font-size: 11px;
}

.badge-isolation, .badge-gate {
  font-family: var(--mono-font);
  font-size: 9.5px;
  padding: 1px 4px;
  background: var(--surface);
  border: var(--sunken-border, 1px solid var(--line));
  margin-left: auto;
}

/* Tasks Checklist */
.task-checklist {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 3px 6px;
  background: var(--surface);
  border: var(--panel-border, 1px solid var(--line));
  cursor: pointer;
  user-select: none;
}

.task-item input[type="checkbox"] {
  cursor: pointer;
}

.task-item.completed {
  opacity: 0.6;
}

.task-item.completed span {
  text-decoration: line-through;
}

.tree-quick-add {
  margin-top: auto;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.tree-quick-add details summary {
  font-size: 11px;
  font-family: var(--mono-font);
  font-weight: 700;
  cursor: pointer;
}

.tree-quick-add form {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
}

.tree-quick-add input,
.tree-quick-add select {
  font-family: var(--mono-font);
  font-size: 11px;
  padding: 3px 5px;
  background: var(--surface);
  color: var(--fg);
  min-height: 24px;
  border: var(--control-border, 1px solid var(--line));
}

/* ── 6. COLUMN 2: WORKSPACE / CONVERSATION LAYER ───────────────── */

#col-workspace .panel-body {
  padding: 0;
  gap: 0;
  display: flex;
  flex-direction: column;
}

.dialogue-container {
  display: flex;
  flex-direction: column;
  height: 48%;
  min-height: 220px;
  border-bottom: 2px solid var(--line-dark, var(--line));
}

.dialogue-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
}

.chat-bubble {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.avatar-badge {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono-font);
  border: var(--panel-border, 1px solid var(--line));
  background: var(--header-bg);
  color: var(--fg);
  flex-shrink: 0;
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 92%;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-family: var(--mono-font);
  color:var(--readable-muted,var(--muted));
}

.sender-label {
  font-weight: 700;
  color: var(--fg);
}

.message-text {
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 10px;
  background: var(--panel);
  border: var(--sunken-border, 1px solid var(--line));
}

.dialogue-input-form {
  display: flex;
  padding: 8px 10px;
  background: var(--header-bg);
  border-top: 1px solid var(--line);
  gap: 8px;
}

.dialogue-input-form input {
  flex: 1;
  padding: 6px 10px;
  font-family: var(--body-font);
  font-size: 12px;
  background: var(--surface);
  color: var(--fg);
  border: var(--control-border, 1px solid var(--line));
  outline: none;
}

/* Active Work Area */
.active-work-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: var(--surface);
}

.work-area-tabs {
  display: flex;
  background: var(--header-bg);
  border-bottom: 2px solid var(--line-dark, var(--line));
}

.tab-btn {
  min-height: 28px;
  padding: 6px 14px;
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
  background: var(--panel, #c0c0c0);
  color: var(--fg, #000000);
  border: 2px outset #ffffff;
  border-bottom: 2px solid #808080;
  cursor: pointer;
  margin-right: 2px;
}

.tab-btn.active {
  background: #d4d0c8;
  font-weight: 800;
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-right: 2px solid #404040;
  border-bottom: 2px solid #d4d0c8;
  color: #000000;
  text-decoration: none;
}

.work-area-canvas {
  flex: 1;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.wip-placeholder {
  text-align: center;
  max-width: 380px;
}

.placeholder-icon {
  font-size: 38px;
  margin-bottom: 8px;
  line-height: 1;
}

.wip-placeholder h4 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  font-family: var(--mono-font);
}

.wip-placeholder p {
  font-size: 11.5px;
  color:var(--readable-muted,var(--muted));
}

/* ── 7. COLUMN 3: LEDGER + VERIFICATION ────────────────────────── */

.ledger-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 10px;
}

.ledger-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* Change Log */
.timeline-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-list li {
  font-size: 11px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.t-time {
  font-family: var(--mono-font);
  font-size: 10px;
  color:var(--readable-muted,var(--muted));
  flex-shrink: 0;
}

.t-bullet {
  font-size: 10px;
}

.t-desc {
  flex: 1;
}

/* Status Dashboard */
.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface);
  border: var(--sunken-border, 1px solid var(--line));
  padding: 6px 10px;
}

.metric-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
}

.m-label {
  width: 90px;
  color:var(--readable-muted,var(--muted));
}

.m-val {
  font-weight: 700;
  font-family: var(--mono-font);
}

/* Verification Checklist */
.verification-sub-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono-font);
  font-size: 9.5px;
  color:var(--readable-muted,var(--muted));
  margin-bottom: 2px;
}

.verification-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.verify-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  padding: 3px 6px;
  background: var(--surface);
  border: var(--panel-border, 1px solid var(--line));
  cursor: pointer;
  user-select: none;
}

.verify-item input[type="checkbox"] {
  cursor: pointer;
}

/* Review Outcome Actions */
.review-buttons {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.btn-review {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
  background: var(--surface);
  color: var(--fg);
  min-height: 28px;
  border: var(--btn-border);
  cursor: pointer;
}

.btn-review:hover {
  background: var(--header-bg);
}

.btn-accept {
  font-weight: 800;
}

.review-status-banner {
  font-family: var(--mono-font);
  font-size: 10px;
  padding: 5px 8px;
  background: var(--surface);
  border: var(--sunken-border, 1px solid var(--line));
  text-align: center;
}

/* State History */
.version-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.version-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 2px 4px;
  background: var(--surface);
  border: var(--sunken-border, 1px solid var(--line));
}

.v-tag {
  font-weight: 700;
  font-family: var(--mono-font);
}

.v-time {
  font-family: var(--mono-font);
  font-size: 10px;
  color:var(--readable-muted,var(--muted));
}

.v-summary {
  flex: 1;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
}

/* ── 8. EDGE-TO-EDGE STATUSBAR ─────────────────────────────────── */

#aos-statusbar {
  height: var(--statusbar-h);
  width: 100vw;
  background: var(--header-bg);
  border-top: 2px solid var(--line-dark, var(--line));
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  font-family: var(--mono-font);
  font-size: 10.5px;
  flex-shrink: 0;
  user-select: none;
}

.statusbar-sep {
  margin: 0 4px;
  color:var(--readable-muted,var(--muted));
}

.statusbar-contract,
.statusbar-governance {
  font-weight: 700;
}

/* ── 9. RESPONSIVE BREAKPOINT ──────────────────────────────────── */

@media (max-width: 900px) {
  #workspace-grid {
    grid-template-columns: 1fr;
    overflow-y: auto;
    height: auto;
  }
  .col-panel {
    border-right: none;
    border-bottom: 2px solid var(--line-dark, var(--line));
    height: auto;
  }

  .aos-btn,
  .btn-review,
  .tab-btn,
  .task-item,
  .verify-item,
  .file-pill,
  .btn-clear-scope,
  #theme-select,
  .chat-target-select,
  .subagent-model-select,
  .dialogue-input-form input,
  .tree-quick-add input,
  .tree-quick-add select {
    min-height: 44px;
  }
}

/* ── 10. HIERARCHICAL TREE & WORKSPACE UTILIZATION ─────────────── */

.scope-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: var(--surface);
  border: var(--panel-border, 1px solid var(--highlight));
  font-family: var(--mono-font);
  font-size: 10px;
}

.scope-info {
  display: flex;
  align-items: center;
  gap: 4px;
}

.scope-prefix {
  font-weight: 700;
  color:var(--accent);
}

.btn-clear-scope {
  font-size: 9.5px;
  padding: 1px 5px;
}

.tree-mode-badge {
  font-family: var(--mono-font);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  background: var(--surface);
  border: var(--sunken-border, 1px solid var(--line));
  margin-left: auto;
}

.hierarchical-tree-box {
  border: var(--sunken-border, 1px solid var(--line));
  background: var(--surface);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tree-section-header {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono-font);
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.hierarchical-tree-content {
  font-family: var(--mono-font);
  font-size: 11px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tree-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 0;
  cursor: pointer;
  user-select: none;
  white-space: normal;
  word-break: break-word;
  line-height: 1.35;
}

.tree-row:hover {
  background: var(--highlight);
  color: var(--highlight-fg);
}

.tree-row.active-scope {
  background: var(--highlight);
  color: var(--highlight-fg);
  font-weight: 700;
}

.tree-ascii {
  color:var(--readable-muted,var(--muted));
  user-select: none;
  font-family: var(--mono-font);
}

.tree-row:hover .tree-ascii,
.tree-row.active-scope .tree-ascii {
  color: var(--highlight-fg);
}

.tree-tag-badge {
  font-size: 9px;
  padding: 0 4px;
  border: var(--sunken-border, 1px solid var(--line));
  background: var(--panel);
  color: var(--fg);
  margin-left: auto;
}

.tree-row:hover .tree-tag-badge,
.tree-row.active-scope .tree-tag-badge {
  background: var(--highlight-fg);
  color:var(--accent);
  border-color: var(--highlight-fg);
}

/* File Manager & Code Editor */
.files-tab-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.file-pills-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.file-pill {
  font-family: var(--mono-font);
  font-size: 10.5px;
  padding: 2px 7px;
  background: var(--surface);
  min-height: 24px;
  border: var(--btn-border);
  cursor: pointer;
}

.file-pill:hover {
  border-color:var(--accent);
}

.file-pill.active {
  background: var(--highlight);
  color: var(--highlight-fg);
  border-color:var(--accent);
}

.file-editor-wrap {
  display: flex;
  flex-direction: column;
  border: var(--sunken-border, 1px solid var(--line));
  background: var(--surface);
}

.file-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: var(--header-bg);
  border-bottom: 2px solid var(--line-dark, var(--line));
  font-family: var(--mono-font);
  font-size: 10.5px;
}

.file-editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-editor-textarea {
  width: 100%;
  min-height: 220px;
  padding: 8px;
  font-family: var(--mono-font);
  font-size: 11px;
  line-height: 1.4;
  border: none;
  outline: none;
  background: var(--surface);
  color: var(--fg);
  resize: vertical;
}

/* Subagents Sandbox Grid */
.subagents-tab-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.subagents-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

.subagent-card {
  border: var(--panel-border, 1px solid var(--line));
  background: var(--surface);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subagent-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}

.subagent-name-role {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 11.5px;
}

.subagent-avatar-badge {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--fg);
  color: var(--surface);
  font-weight: 700;
  font-size: 10px;
}

.subagent-details-grid {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 4px 8px;
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
  font-family: var(--mono-font);
}

.subagent-actions-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

/* Contracts Table */
.contracts-section {
  border: var(--sunken-border, 1px solid var(--line));
  background: var(--surface);
  padding: 8px;
  margin-top: 8px;
}

.contracts-title {
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.contract-row {
  font-family: var(--mono-font);
  font-size: 10.5px;
  padding: 4px 6px;
  border-bottom: 1px dotted var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.contract-row:last-child {
  border-bottom: none;
}

/* Channel Selector & Interactive Agent Styles */
.channel-selector-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono-font);
  font-size: 11px;
}

.channel-label {
  font-weight: 700;
  font-size: 10px;
  color:var(--readable-muted,var(--muted));
  letter-spacing: 0.5px;
}

.chat-target-select {
  min-height: 24px;
  padding: 3px 6px;
  font-family: var(--mono-font);
  font-size: 11px;
  background: var(--surface);
  color: var(--fg);
  border: var(--control-border, 1px solid var(--line));
  outline: none;
}

.active-agent-model-badge {
  margin-left: auto;
  font-family: var(--mono-font);
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  background: var(--panel);
  border: var(--sunken-border, 1px solid var(--line));
  padding: 2px 6px;
}

.msg-model-tag {
  font-size: 9px;
  color:var(--readable-muted,var(--muted));
  border: var(--sunken-border, 1px solid var(--line));
  padding: 1px 4px;
  margin-left: 4px;
}

.chat-bubble.from-subagent .message-text {
  border-left: 3px solid var(--primary);
  background: var(--panel);
}

.chat-bubble.from-coord .message-text {
  border-left: 3px solid #00aa44;
  background: var(--surface);
}

.chat-bubble.from-coord .sender-label {
  color: #008833;
  font-weight: 700;
}

.subagent-model-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.subagent-model-select {
  flex: 1;
  font-family: var(--mono-font);
  font-size: 10px;
  min-height: 24px;
  padding: 2px 4px;
  background: var(--surface);
  color: var(--fg);
  border: var(--control-border, 1px solid var(--line));
}

.hermes-pool-card {
  background: var(--header-bg);
  border: var(--sunken-border, 1px solid var(--line));
  padding: 8px 10px;
  font-family: var(--mono-font);
  font-size: 11px;
  margin-bottom: 8px;
}


/* Operational desk: preserve ANKLE96 chrome; expose state, actions and evidence. */
.real-task-row { display:grid; grid-template-columns:38px minmax(0,1fr); gap:4px 8px; padding:8px 0; border-bottom:1px solid var(--line); }
.real-task-row small { grid-column:2; color:var(--readable-muted,var(--muted)); font:11px var(--mono-font); overflow-wrap:anywhere; }
.task-title-button,.task-group-button { text-align:left; color:var(--fg); font:inherit; background:transparent; border:0; cursor:pointer; white-space:normal; }
.task-title-button { line-height:1.4; }
.task-group-button { font-weight:700; margin-top:16px; padding:6px 0; }
.tree-semantic-bindings .current-session-box,.tree-semantic-bindings .delegations-box { display:none; }
.runtime-overview { padding:4px; width:100%; min-width:0; }
.overview-heading { display:flex; align-items:baseline; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.overview-heading h2 { margin:0; font-size:22px; }
.overview-heading span,.observation-time,.desk-hint { font:11px/1.6 var(--mono-font); color:var(--readable-muted,var(--muted)); overflow-wrap:anywhere; }
.overview-intro { line-height:1.5; }
.runtime-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.runtime-card { display:flex; flex-direction:column; gap:8px; padding:12px; background:var(--panel); border:var(--sunken-border,1px solid var(--line)); overflow-wrap:anywhere; }
.runtime-card strong { font:700 11px var(--mono-font); text-transform:uppercase; }
.runtime-card span { font-size:16px; }
.runtime-card small { color:var(--readable-muted,var(--muted)); line-height:1.4; }
.queue-list article { display:flex; flex-direction:column; gap:5px; padding:12px 0; border-bottom:1px solid var(--line); }
.queue-list small { font:11px/1.5 var(--mono-font); color:var(--readable-muted,var(--muted)); }
.subagent-card p { line-height:1.5; }
.subagent-card code { overflow-wrap:anywhere; }
#chat-feedback { padding:4px 10px; min-height:20px; font:11px var(--mono-font); }
.message-text { white-space:pre-wrap; overflow-wrap:anywhere; }
.channel-selector-bar { flex-wrap:wrap; }
.chat-target-select { min-width:0; max-width:100%; flex:1; }
.aos-btn[disabled] { cursor:default; opacity:.55; }
#workspace-grid > * { min-width:0; }
@media(max-width:700px) {
  .runtime-grid { grid-template-columns:1fr; }
  #aos-topbar { height:auto; flex-wrap:wrap; }
  .topbar-left,.topbar-right,.topbar-center { max-width:100%; flex-wrap:wrap; }
  .session-badge { max-width:100%; overflow-wrap:anywhere; white-space:normal; }
  .aos-btn,.tab-btn,.task-check,.task-title-button,.task-group-button,.file-pill,select,input,summary { min-height:44px; }
  .real-task-row { grid-template-columns:44px minmax(0,1fr); }
  .active-agent-model-badge { margin-left:0; }
  .work-area-tabs { overflow-x:auto; }
  .subagents-cards-grid { grid-template-columns:1fr; }
  #aos-statusbar { flex-wrap:wrap; height:auto; }
  .statusbar-center,.statusbar-right { white-space:normal; }
}

.native-result { white-space:pre-wrap; overflow-wrap:anywhere; font:12px/1.5 var(--mono-font); max-width:100%; }

/* Keep the desk usable at both a laptop width and the narrow in-app panel. */
#aos-topbar { height:auto; min-height:54px; gap:12px; padding:8px 12px; flex-wrap:wrap; }
.topbar-left { white-space:nowrap; flex-wrap:wrap; }
.topbar-center { display:none; }
.topbar-right { flex-wrap:wrap; gap:8px; }
#workspace-grid { height:auto; min-height:0; grid-template-columns:minmax(250px,22%) minmax(0,1fr) minmax(270px,23%); }
.panel-body { min-height:0; }
.task-check { white-space:nowrap; min-width:36px; padding:3px; }
.task-title-button { font:14px/1.4 var(--body-font); }
.task-group-button { font-size:13px; }
.work-area-canvas { display:block; overflow:auto; }
.status-dashboard-box { order:-3; }
.verification-box { order:-2; }
.review-actions-box { order:-1; }
.change-log-box { flex-shrink:0; }
#change-log-list { max-height:280px; overflow:auto; }
.m-label { width:auto; flex:1; }
#col-ledger .panel-body > * { flex-shrink:0; }
@media(max-width:900px) {
  html,body { height:auto; min-height:100%; overflow:auto; width:100%; }
  .aos-shell { position:static; height:auto; min-height:100vh; overflow:visible; width:100%; }
  #aos-topbar { width:100%; }
  .topbar-title { display:none; }
  #workspace-grid { width:100%; display:flex; flex-direction:column; flex:none; overflow:visible; }
  #col-workspace { order:0; }
  #col-session-tree { order:1; }
  #col-ledger { order:2; }
  .col-panel { height:auto; overflow:visible; }
  .panel-body { overflow:visible; }
  .dialogue-container { height:420px; min-height:420px; flex:none; }
  .dialogue-messages { min-height:120px; }
  .active-work-area { flex:none; overflow:visible; }
  .work-area-canvas { overflow:visible; min-height:240px; padding:12px; }
  .work-area-tabs { overflow-x:auto; }
  .work-area-tabs .tab-btn { flex-shrink:0; }
  .file-editor-textarea { min-height:320px; }
  .runtime-grid { grid-template-columns:1fr; }
  .btn-review { min-height:44px; }
  #aos-statusbar { position:static; width:100%; flex-wrap:wrap; height:auto; }
  .statusbar-left { flex-wrap:wrap; }
}

.new-file-name { min-width:90px; max-width:150px; background:var(--surface); color:var(--fg); border:var(--sunken-border,1px solid var(--line)); padding:4px 6px; }

/* Control foreground belongs to the control, not the page palette. */
.aos-btn { color:var(--btn-fg,var(--fg)); text-decoration:none; display:inline-flex; align-items:center; justify-content:center; }
.aos-btn:disabled { opacity:1; background:var(--header-bg); color:var(--readable-muted,var(--muted)); border-color:var(--readable-muted,var(--muted)); }
button:focus-visible,summary:focus-visible,input:focus-visible,select:focus-visible { outline:2px solid var(--accent);outline-offset:2px; }
.file-pill {color:var(--fg);}
[hidden] {display:none !important;}
.root-session-button {font:700 14px/1.4 var(--body-font);background:var(--header-bg);color:var(--fg);border:var(--sunken-border,1px solid var(--line));padding:10px;text-align:left;cursor:pointer;}
.session-branch {min-width:0;margin:6px 0;}
.session-branch > summary {cursor:pointer;font:700 12px/1.5 var(--body-font);padding:6px 0;overflow-wrap:anywhere;}
.session-branch > summary small {display:block;font:10px/1.5 var(--mono-font);color:var(--readable-muted,var(--muted));margin-left:14px;}
.branch-children {border-left:1px solid var(--muted);margin-left:5px;padding-left:10px;}
.branch-focus {background:transparent;color:var(--accent);border:0;text-decoration:underline;font:10px var(--mono-font);cursor:pointer;padding:4px 0;}
.real-task-row {grid-template-columns:25px minmax(0,1fr);gap:3px 5px;padding:7px 0;}
.real-task-row.selected {background:var(--header-bg);border-left:3px solid var(--accent);padding-left:4px;}
.task-check {min-width:24px;align-self:start;}
.task-title-button {font-size:12px;}
.real-task-row small {font-size:10px;}
.tree-agent {display:flex;gap:6px;width:100%;background:transparent;color:var(--fg);border:0;padding:7px 0;text-align:left;cursor:pointer;flex-wrap:wrap;align-items:center;}
.tree-agent small {margin-left:auto;color:var(--readable-muted,var(--muted));font:10px var(--mono-font);}
.agent-dot {color:var(--readable-muted,var(--muted));font-size:9px;}.agent-dot.busy {color:var(--accent);}
.msg-avatar {width:24px;height:24px;display:grid;place-items:center;flex:none;background:var(--header-bg);border:1px solid var(--line);font:700 11px var(--mono-font);}
.msg-wrapper {min-width:0;flex:1;}.msg-meta {display:flex;flex-wrap:wrap;align-items:center;gap:5px;font:10px var(--mono-font);margin-bottom:4px;}
.from-user {margin-left:20px;}.from-user .message-text {border-left:3px solid var(--accent);}
.dialogue-messages {min-height:0;}.dialogue-container {flex-shrink:0;height:48%;min-height:260px;}
.agent-progress {border:1px solid var(--line);background:var(--header-bg);padding:10px;margin-left:34px;font:12px/1.5 var(--body-font);white-space:pre-wrap;overflow-wrap:anywhere;}
.progress-heading {display:flex;gap:8px;align-items:center;margin-bottom:6px;font:11px var(--mono-font);}
.activity-pulse {width:9px;height:9px;background:var(--accent);animation:agent-pulse 1s steps(2,end) infinite;}
@keyframes agent-pulse {50%{opacity:.3;}}
@media(prefers-reduced-motion:reduce){.activity-pulse{animation:none;}}
#agent-activity {max-width:45%;font-size:10px;overflow-wrap:anywhere;}#agent-activity[data-busy="true"] {color:var(--accent);}
.dialogue-input-form input {min-width:0;}
.subagents-cards-grid {grid-template-columns:repeat(auto-fit,minmax(min(260px,100%),1fr));width:100%;}
.agent-console-heading {margin-bottom:14px;}.agent-console-heading h2 {font-size:20px;margin-bottom:5px;}.agent-console-heading small {display:block;color:var(--readable-muted,var(--muted));margin-top:6px;}
.subagent-card {padding:12px;gap:8px;min-width:0;}.subagent-card-header{align-items:start;gap:8px;}.connection-badge{font:10px var(--mono-font);border:1px solid var(--line);padding:2px 4px;}
.subagent-card label {font:11px/1.5 var(--mono-font);display:flex;flex-direction:column;gap:4px;}
.subagent-card input,.subagent-card select,.assignment-controls select {min-width:0;width:100%;padding:6px;background:var(--surface);color:var(--fg);border:var(--control-border,1px solid var(--muted));}
.binding-meta {white-space:pre-wrap;overflow-wrap:anywhere;font:10px/1.6 var(--mono-font);color:var(--readable-muted,var(--muted));}.agent-feedback {font-size:11px;overflow-wrap:anywhere;}
.assignment-controls {display:flex;flex-wrap:wrap;gap:6px;margin:10px 0;}.assignment-controls select {flex:1;min-width:130px;}
#col-session-tree .panel-header {flex-wrap:wrap;}#col-session-tree .panel-header h3{min-width:120px;}
@media(max-width:900px){.dialogue-container{height:470px;min-height:470px;}.real-task-row{grid-template-columns:44px minmax(0,1fr);}.tree-agent,.branch-focus,.root-session-button,.session-branch>summary{min-height:44px;}.subagent-card input,.subagent-card select{min-height:44px;}}

.delegation-editor{display:flex;flex-direction:column;gap:8px;margin-top:12px;}.delegation-editor input,.delegation-editor select{background:var(--surface);color:var(--fg);padding:8px;border:1px solid var(--muted);}

.mobile-desk-nav{display:none;}@media(max-width:900px){.mobile-desk-nav{display:flex;position:sticky;top:0;z-index:5;background:var(--header-bg);border-bottom:1px solid var(--line);}.mobile-desk-nav button{flex:1;min-height:44px;background:var(--header-bg);color:var(--fg);border:0;border-right:1px solid var(--line);font:700 11px var(--mono-font);}.col-panel,.work-area-canvas{scroll-margin-top:44px;}}
:root { --queue-border: var(--border-color, #888); }
.queue-console { flex: 0 0 auto; border-bottom: 1px solid var(--queue-border); padding: 6px 10px; font: 12px var(--mono-font, monospace); }
.queue-console summary { cursor: pointer; font-weight: bold; }
.queue-toolbar { display:flex; flex-wrap:wrap; gap:6px; align-items:center; margin:6px 0; }
.queue-toolbar button { min-height:32px; }
.queue-rows { max-height:130px; overflow:auto; display:grid; grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); gap:6px; }
.queue-row { display:flex; align-items:flex-start; gap:6px; border:1px solid var(--queue-border); padding:6px; min-width:0; }
.queue-row > span { min-width:0; }
.queue-row small { display:block; font-size:11px; margin-top:3px; }
.queue-reason { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
@media(max-width:650px) { .queue-toolbar button { min-height:44px; } .queue-rows { grid-template-columns:1fr; max-height:180px; } }

/* Theme chrome: no shared hard square/blue treatment outside Classic Silver. */
.aos-btn,#theme-select,.session-badge,.status-chip,.file-pill,.runtime-card,.subagent-card,.root-session-button,.message-text,.status-dashboard,.queue-row,.agent-progress,.new-file-name,.dialogue-input-form input,.subagent-card input,.subagent-card select,.file-editor-wrap{border-radius:var(--radius);}
.col-panel,.panel-header{border-color:var(--divider);}
.col-panel{border-right-width:1px;}
#aos-topbar{border-bottom:1px solid var(--divider);background:var(--titlebar-bg);color:var(--titlebar-fg);}
.panel-header{border:0;border-bottom:1px solid var(--divider);font-family:var(--body-font);}
.queue-console{background:var(--panel);--queue-border:var(--divider);}
.queue-row{background:var(--surface);}
.queue-row small{color:var(--readable-muted,var(--muted));}
.aos-btn:hover:not(:disabled){background:var(--highlight);color:var(--highlight-fg);}
.aos-btn:disabled{color:var(--readable-muted,var(--muted));border-color:var(--divider);}
#save-status-msg{color:var(--accent)!important;}
body.theme-ankle-2029 .aos-btn.primary{background:var(--accent);color:var(--surface);border-color:var(--accent);}
body.theme-ankle-2029 :is(.panel-header h3,.section-title,.topbar-title,.work-area-title){letter-spacing:normal;text-transform:none;}
body.theme-ankle-2029 :is(.runtime-card,.subagent-card,.message-text,.root-session-button){box-shadow:var(--shadow);}
body.theme-discmaster .panel-header{border:var(--panel-border);}
body.theme-discmaster .col-panel{border-right-width:2px;}
body.theme-discmaster #aos-topbar{border-bottom:2px solid #000;}
body.theme-portal-2007 :is(.panel-header h3,.section-title,.aos-brand){color:var(--accent);}
body.theme-portal-2007 :is(.message-text,.runtime-card,.subagent-card,.status-dashboard,.file-editor-wrap){border-color:var(--divider);}
body.theme-portal-2007 #aos-topbar{border-bottom:2px solid var(--line);}
body.theme-status-2007 #workspace-grid{background:var(--bg);gap:10px;padding:10px;}
body.theme-status-2007 .col-panel{border:1px solid var(--line);background:var(--panel);}
body.theme-paper :is(.message-text,.root-session-button){box-shadow:var(--shadow);}

/* Execution and autonomous evidence review belong to the ledger column. */
#col-ledger .queue-console { padding: 10px 0; margin-bottom: 12px; }
#col-ledger .queue-rows { grid-template-columns: minmax(0,1fr); max-height: 290px; }
#col-ledger .queue-row { min-width: 0; overflow-wrap: anywhere; }
#col-ledger .queue-toolbar { flex-wrap: wrap; }
#col-ledger .queue-toolbar button { flex: 1 1 120px; }
#col-ledger #queue-activity { flex-basis: 100%; }
#doctor-reviews { font-size: 12px; max-height: 260px; overflow: auto; }
#doctor-reviews details { border-bottom: 1px solid var(--divider); padding: 8px 0; overflow-wrap: anywhere; }
#doctor-reviews summary { cursor: pointer; }
#manual-review-buttons[hidden] { display: none; }

/* Live activity is readable without color or motion and survives collapsed branches. */
.session-activity { display:inline-flex; align-items:center; gap:6px; margin:4px 0 2px 8px; font:600 10px/1.5 var(--mono-font); color:var(--fg); padding:2px 6px; border:1px solid currentColor; border-radius:12px; }
.activity-ring { display:inline-block; width:10px; height:10px; border:2px solid currentColor; border-radius:50%; box-sizing:border-box; opacity:.45; }
[data-activity="working"] > .session-activity .activity-ring { opacity:1; border-right-color:transparent; animation:session-turn 1s linear infinite; }
.real-task-row[data-activity="working"], .root-session-button[data-activity="working"], .session-branch > summary[data-activity="working"] { box-shadow:inset 3px 0 var(--accent); outline:1px solid var(--accent); outline-offset:-1px; padding-left:8px; }
[data-activity="review"] > .session-activity .activity-ring { border-style:dotted; opacity:1; }
[data-activity="unknown"] > .session-activity { border-style:dashed; }
[data-activity="done"] > .session-activity { border-color:var(--accent,#00ff66); color:var(--accent,#00ff66); }
[data-activity="done"] > .session-activity .activity-ring { opacity:1; background:var(--accent,#00ff66); border-color:var(--accent,#00ff66); }
.task-check.task-done-btn { min-width:48px; background:var(--header-bg); border:1px solid var(--accent,#00ff66)!important; color:var(--accent,#00ff66)!important; font:700 10px/1.2 var(--mono-font); padding:2px 4px; text-align:center; cursor:default; opacity:1!important; }
.real-task-row { grid-template-columns:auto minmax(0,1fr)!important; gap:3px 6px; padding:7px 0; }
.real-task-row.task-completed-row { opacity:.92; }
@keyframes session-turn { to { transform:rotate(360deg); } }
@media(prefers-reduced-motion:reduce) { [data-activity="working"] > .session-activity .activity-ring { animation:none; border-style:double; border-right-color:currentColor; } }

/* Real-time System Telemetry Strip */
.system-telemetry-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  padding: 3px 10px;
  font: 10px/1.3 var(--mono-font);
  color: var(--fg);
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
}
.telemetry-item { display: inline-flex; align-items: center; gap: 3px; }
.telemetry-item .t-label { font-weight: 700; color: var(--readable-muted, var(--muted)); font-size: 9.5px; }
.telemetry-item .t-val { font-weight: 600; color: var(--accent, #00aa44); font-size: 10px; }
.telemetry-sep { opacity: 0.35; margin: 0 1px; }

/* Research & Intelligence Work Area View */
.research-tab-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 2px 20px;
}
.research-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
}
.research-heading h2 { margin: 0; font: 700 15px var(--title-font, var(--body-font)); }
.research-heading span { font: 11px var(--mono-font); color: var(--readable-muted, var(--muted)); }
.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}
.research-card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.research-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
}
.research-card-header strong { font-size: 13px; font-weight: 700; }
.research-card p { font-size: 12px; line-height: 1.45; margin: 0; }
.research-card ul { margin: 0; padding-left: 16px; font-size: 11.5px; line-height: 1.45; }
.research-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.research-tag {
  background: var(--header-bg);
  border: 1px solid var(--line);
  padding: 2px 6px;
  font: 10px var(--mono-font);
  font-weight: 600;
  border-radius: 3px;
}
.research-tag.tag-accent { border-color: var(--accent, #00aa44); color: var(--accent, #00aa44); }

/* ── 3D MESH TOPOLOGY & TESSERACT WORKSPACE TAB ────────────────── */
.tesseract-tab-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 480px;
  flex: 1;
  background: var(--bg);
  overflow: hidden;
}
.tesseract-tab-header {
  height: 36px;
  min-height: 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  font: 11px var(--mono-font);
  user-select: none;
}
.tesseract-tab-title { display: flex; align-items: center; gap: 8px; }
.mesh-badge {
  background: var(--surface);
  border: 1px solid var(--accent, #00aa44);
  color: var(--accent, #00aa44);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}
.tesseract-tab-controls { display: flex; align-items: center; gap: 8px; }
.mesh-transit-stats { font-size: 10px; opacity: 0.8; }
.voice-btn {
  background: #003318 !important;
  border-color: #00aa44 !important;
  color: #00ff66 !important;
  font-weight: 700 !important;
}
.voice-btn:hover {
  background: #005528 !important;
  color: #fff !important;
}
.tesseract-tab-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  min-height: 420px;
  height: calc(100% - 36px);
  overflow: hidden;
}
.mesh-tesseract-canvas-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 380px;
  background: #040810;
  overflow: hidden;
}
#mesh-tesseract-canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.mesh-canvas-hint {
  position: absolute;
  bottom: 8px;
  left: 12px;
  font: 10px var(--mono-font);
  color: #6688aa;
  pointer-events: none;
}
.mesh-transit-log-panel {
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
.transit-log-title {
  padding: 6px 10px;
  font: 700 11px var(--mono-font);
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
}
.transit-log-stream {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  font: 10.5px/1.4 var(--mono-font);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.transit-entry {
  border-bottom: 1px dashed var(--line);
  padding-bottom: 4px;
}
.transit-entry .tr-time { color: var(--readable-muted, var(--muted)); }
.transit-entry .tr-from { color: #ffcc00; font-weight: 700; }
.transit-entry .tr-arrow { color: #00ff66; margin: 0 3px; }
.transit-entry .tr-to { color: #33aaff; font-weight: 700; }
.transit-entry .tr-subj { color: var(--fg); opacity: 0.88; }
.transit-entry .tr-ok { color: #00ff66; font-weight: 700; }
.transit-entry .tr-bad { color: #ff3344; font-weight: 700; }

/* ── COMPACT AGENT RELAY LIVE TICKER (BOTTOM) ─────────────────── */
.aos-relay-ticker-bar {
  height: 28px;
  min-height: 28px;
  background: var(--header-bg);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  font: 10.5px var(--mono-font);
  flex-shrink: 0;
  z-index: 40;
}
.ticker-label {
  font-weight: 700;
  color: #ffcc00;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
  white-space: nowrap;
}
.ticker-content {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  opacity: 0.9;
}
.ticker-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 12px;
  white-space: nowrap;
  font-size: 10px;
}
.mini-btn {
  padding: 1px 6px;
  font-size: 9.5px;
  line-height: 1.2;
}

@media (max-width: 900px) {
  .tesseract-tab-body { grid-template-columns: 1fr; }
  .mesh-transit-log-panel { display: none; }
}

/* ── ULTRA MOBILE FORESIGHT & TOUCH OPTIMIZATION (<= 600px) ───── */
@media (max-width: 600px) {
  /* 1. Header Compaction: Clean single 44px titlebar */
  #aos-topbar {
    padding: 0 8px;
    gap: 6px;
    min-height: 44px;
    height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap !important;
    background: var(--titlebar-bg, var(--header-bg));
  }
  .session-badge,
  .theme-picker-wrap,
  .status-chip#sync-indicator,
  .topbar-center,
  .topbar-right > #btn-mode-ankle,
  .topbar-right > #btn-mode-scratch,
  .topbar-right > a.aos-btn,
  .topbar-right > #btn-reset {
    display: none !important;
  }
  .topbar-left {
    display: flex !important;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }
  .topbar-title {
    display: inline-block !important;
    font-size: 11.5px !important;
    font-weight: 700;
    white-space: nowrap !important;
  }
  .topbar-right {
    gap: 4px;
    display: flex !important;
    align-items: center;
    flex-shrink: 0;
  }
  #btn-gemini-voice {
    min-height: 32px !important;
    height: 32px !important;
    padding: 2px 8px !important;
    font-size: 10px !important;
    white-space: nowrap;
  }

  /* 2. Telemetry Bar: Clean horizontal touch scroll */
  .system-telemetry-bar {
    padding: 4px 10px;
    gap: 8px;
    font-size: 10px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* 3. Mobile Navigation Segment Bar */
  .mobile-desk-nav {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .mobile-desk-nav button {
    min-height: 44px !important;
    font-size: 12px !important;
    font-weight: 700;
    padding: 0 6px;
  }

  /* 4. Touch Target Parity (Apple HIG 44px) */
  .aos-btn,
  .tab-btn,
  .task-check,
  button,
  input,
  select {
    min-height: 44px !important;
  }

  /* 5. Smooth Horizontally Swipeable Work Area Tabs */
  .work-area-tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding: 4px 6px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
  }
  .work-area-tabs .tab-btn {
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 0 12px !important;
    font-size: 11px !important;
  }

  /* 6. Channel Selector & Context Header */
  .channel-selector-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 8px;
  }
  .chat-target-select {
    width: 100%;
    min-height: 44px !important;
  }

  /* 7. Input Form & Send Touch Button */
  .dialogue-input-form {
    padding: 6px 8px;
    gap: 6px;
  }
  .dialogue-input-form input {
    min-height: 44px !important;
    font-size: 14px !important; /* Prevents iOS auto-zoom on focus */
    padding: 0 12px !important;
  }
  .dialogue-input-form button {
    min-height: 44px !important;
    min-width: 58px !important;
    padding: 0 14px !important;
  }

  /* 8. Dialogue Container Height */
  .dialogue-container {
    height: 380px !important;
    min-height: 380px !important;
  }
}


/* Conversation / work-area splitter inherits the selected OS skin. */
#col-workspace .dialogue-container {
  height: var(--aos-chat-height, 48%) !important;
  min-height: 0 !important;
  flex: 0 0 auto;
  border-bottom: 0;
}
#col-workspace .active-work-area { min-height: 140px; }
#col-workspace .channel-selector-bar,
#col-workspace .dialogue-input-form,
#col-workspace #chat-feedback { flex-shrink: 0; }
.workspace-row-splitter {
  height: 12px;
  flex: 0 0 12px;
  position: relative;
  cursor: row-resize;
  touch-action: none;
  user-select: none;
  background: var(--header-bg, var(--panel));
  border-block: 1px solid var(--line);
  z-index: 25;
}
.workspace-row-splitter::after {
  content: '';
  position: absolute;
  width: 48px;
  height: 4px;
  left: calc(50% - 24px);
  top: calc(50% - 2px);
  border-block: 1px solid var(--fg);
}
.workspace-row-splitter:hover::after,
.workspace-row-splitter.dragging::after { background: var(--fg); }
.workspace-row-splitter:focus-visible { outline: 2px solid var(--fg); outline-offset: -2px; }
body.workspace-row-resizing { cursor: row-resize; user-select: none; }
@media (max-width: 900px) {
  .workspace-row-splitter { height: 44px; flex-basis: 44px; }
  #col-workspace .active-work-area { min-height: 240px; }
}
