/* ============================================================
   Desk UI Kit — workspace shell layout
   Faithful recreation of the real Desk chrome (topbar, app rail,
   sidebar tree, terminal multiplexer, editor & git surfaces).
   Ports the structural classes from the product; all color comes
   from the design tokens in styles.css.
   ============================================================ */

.deskShell {
  position: relative; width: 100%; height: 100vh; padding: 8px; overflow: hidden;
  color: var(--text); font-family: var(--font-mono);
  background:
    radial-gradient(circle at 15% 8%, var(--glow), transparent 26%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-elevated) 54%, var(--bg) 100%);
}
.deskShell *::-webkit-scrollbar { width: 9px; height: 9px; }
.deskShell *::-webkit-scrollbar-thumb { background: var(--line); border: 2px solid transparent; background-clip: padding-box; }
.deskShell *::-webkit-scrollbar-track { background: transparent; }

.terminalFrame {
  position: relative; display: grid; grid-template-rows: 84px minmax(0,1fr) 22px;
  width: 100%; height: 100%; border: 1px solid var(--line); background: var(--bg);
  box-shadow: var(--shadow-inset-bloom);
}

/* ---------- Topbar ---------- */
.workspaceTopbar {
  position: relative; z-index: 1; display: grid; grid-template-rows: 30px 53px;
  padding: 0 10px; border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, var(--surface), var(--surface)),
    repeating-linear-gradient(90deg, var(--glow) 0 1px, transparent 1px 18px);
}
.topbarPrimary { display: grid; grid-template-columns: minmax(220px,1fr) auto auto; gap: 8px; align-items: center; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.brand strong { font-size: 19px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase;
  background: linear-gradient(105deg,transparent 0,transparent 35%,var(--sheen-hi) 44%,var(--line-strong) 50%,var(--sheen-hi) 56%,transparent 65%,transparent 100%),
    linear-gradient(180deg,var(--text) 0,var(--text) 45%,var(--text-dim) 125%);
  background-size: 250% 100%,100% 100%; background-position: 125% 0,0 0;
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 6px var(--glow-strong)); animation: kitSheen 5s ease-in-out infinite; }
@keyframes kitSheen { 0%,18%{background-position:125% 0,0 0} 62%,100%{background-position:-25% 0,0 0} }
.brand span { color: var(--text-dim); }
.topbarPrimary .toolbar { display: flex; gap: 6px; justify-self: end; }
.topbarTelemetry { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(120px,1fr);
  grid-template-columns: minmax(170px,1.2fr); gap: 8px; padding: 4px 0 5px; border-top: 1px solid var(--line); align-items: center; }

.thinButton { display: inline-flex; align-items: center; justify-content: center; height: 24px; gap: 5px;
  padding: 0 8px; border: 1px solid var(--line); border-radius: 2px; background: var(--surface);
  color: var(--text); cursor: pointer; font: inherit; font-size: 11px; }
.thinButton:hover { border-color: var(--accent); color: var(--accent); }
.thinButton.danger { color: var(--error); border-color: var(--error); }

/* ---------- Content: app rail + subsystem ---------- */
.deskContent { position: relative; z-index: 1; display: grid; grid-template-columns: 48px minmax(0,1fr); height: 100%; min-height: 0; }
.appRail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 5px;
  border-right: 1px solid var(--line); background: var(--surface); }
.subsystemButton { position: relative; display: grid; place-items: center; width: 42px; height: 42px;
  border: 0; background: none; color: var(--text-dim); cursor: pointer; transition: color .15s, background-color .15s; }
.subsystemButton:hover { color: var(--text); background: var(--glow); }
.subsystemButton.selected { color: var(--text); }
.subsystemButton.selected .bar { height: 72%; }
.subsystemButton .bar { position: absolute; left: 0; top: 50%; width: 2px; height: 0; translate: 0 -50%;
  background: var(--line-strong); box-shadow: 0 0 7px var(--glow); transition: height .2s; }
.subsystemButton.selected svg { filter: drop-shadow(0 0 7px var(--glow)); }
.subsystemButton.compact::after { content:''; position:absolute; right:3px; bottom:3px; width:5px; height:5px;
  border-radius:50%; background:var(--accent); box-shadow:0 0 8px var(--accent); }

.subsystemPanels { display: grid; grid-template-columns: 264px minmax(0,1fr); min-height: 0; height: 100%; }
.subsystemPanels.single { grid-template-columns: minmax(0,1fr); }

/* ---------- Sidebar ---------- */
.agentsSidebar { display: grid; grid-template-rows: 32px minmax(0,1fr); height: 100%; border-right: 1px solid var(--line); background: var(--surface); min-height: 0; }
.sidebarHeader { display: flex; align-items: center; justify-content: space-between; min-height: 32px;
  padding: 4px 8px; border-bottom: 1px solid var(--line); background: var(--surface); }
.sidebarHeader .railTitle { display: flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text); }
.railTitle svg { color: var(--accent); }
.projectTree { min-height: 0; overflow: auto; padding: 6px; }
.projectNode + .projectNode { margin-top: 8px; }
.treeMain { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 6px;
  height: 24px; padding: 0 6px; border-radius: 2px; cursor: pointer; color: var(--text); font-size: 12px; }
.treeMain:hover { background: var(--glow); }
.projectRow .treeMain { font-weight: 700; }
.treeMain small { color: var(--accent); font-size: 10px; }
.groupBranch, .sessionBranch { margin-left: 8px; padding-left: 7px; border-left: 1px solid var(--line); }
.sessionRow { display: grid; grid-template-columns: 10px minmax(0,1fr); align-items: center; gap: 7px;
  height: 25px; padding: 0 7px; margin-bottom: 3px; border: 1px solid var(--line); border-radius: 2px;
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 12px; }
.sessionRow:hover, .sessionRow.selected { border-color: var(--accent); color: var(--accent); }
.sessionRow span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Surface area ---------- */
.subsystemSurface { display: grid; grid-template-rows: 32px minmax(0,1fr); min-height: 0; height: 100%; background: var(--surface); }
.subsystemHeader { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 10px;
  border-bottom: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
.subsystemHeader .layoutBadge { margin-left: auto; padding: 2px 7px; border: 1px solid var(--line); color: var(--accent); font-size: 10px; }

/* multiplexer grid */
.multiplexerGrid { display: grid; gap: 6px; padding: 6px; min-height: 0; }
.multiplexerGrid.g4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.cellChrome { position: relative; min-height: 0; }
.cellBorder { position: absolute; inset: 0; background: var(--line); clip-path: var(--clip-oct-cell); }
.cellBody { position: absolute; inset: 1px; display: grid; grid-template-rows: 26px minmax(0,1fr);
  background: var(--bg-elevated); clip-path: var(--clip-oct-cell); }
.cellChrome:hover .cellBorder, .cellChrome.focused .cellBorder { background: var(--line-strong); }
.cellChrome.focused { filter: drop-shadow(0 0 7px var(--glow)); }
.cellTabs { display: flex; align-items: center; gap: 4px; padding: 3px 6px; border-bottom: 1px solid var(--line); }
.cellTab { display: inline-flex; align-items: center; gap: 5px; height: 18px; padding: 0 7px; border: 1px solid var(--line);
  border-radius: 2px; background: var(--surface); color: var(--text); font-size: 10px; }
.cellTab.selected { border-color: var(--accent); color: var(--accent); }
.term { padding: 8px 11px; font-size: 11px; line-height: 1.55; color: var(--term-fg); overflow: hidden; background: var(--term-bg); }
.term .ln { white-space: pre-wrap; }
.term .c { color: var(--accent); } .term .g { color: var(--ok); } .term .d { color: var(--text-dim); } .term .r { color: var(--error); }
.term .caret { display:inline-block; width:7px; height:12px; background: var(--accent); vertical-align:-2px; animation: kitCaret 1s steps(1) infinite; }
@keyframes kitCaret { 50%{opacity:0} }
.emptyCell { display: grid; place-items: center; height: 100%; color: var(--text-dim); font-size: 11px; background: var(--term-bg); }

.statusDot2 { width: 7px; height: 7px; border-radius: 50%; }
.statusDot2.run { background: var(--ok); box-shadow: 0 0 7px var(--ok); }
.statusDot2.att { background: var(--accent); box-shadow: 0 0 7px var(--accent); }
.statusDot2.miss { background: var(--error); box-shadow: 0 0 7px var(--error); }

/* ---------- Editor surface ---------- */
.editorWrap { display: grid; grid-template-rows: 30px minmax(0,1fr); min-height: 0; }
.editorTabs { display: flex; align-items: center; gap: 4px; padding: 5px 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.editorTab { position: relative; display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  background: var(--glow); color: var(--text-dim); cursor: pointer; font-size: 12px; }
.editorTab.active { color: var(--text); background: var(--frame-bg); }
.editorTab .tb { position: absolute; left: 6px; right: 6px; top: 0; height: 2px; background: transparent; }
.editorTab.active .tb { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.editorTab .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.codePane { min-height: 0; overflow: auto; padding: 12px 0; background: var(--term-bg); font-size: 12.5px; line-height: 1.6; }
.codeLine { display: grid; grid-template-columns: 42px 1fr; }
.codeLine .gut { text-align: right; padding-right: 14px; color: var(--text-dim); opacity: 0.5; user-select: none; }
.codePane .kw { color: var(--accent); } .codePane .st { color: var(--ok); } .codePane .cm { color: var(--text-dim); font-style: italic; }
.codePane .fn { color: var(--text); font-weight: 700; } .codePane .nm2 { color: var(--line-strong); }

/* file tree */
.fileNode { display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 5px; height: 24px; padding: 0 6px; cursor: pointer; font-size: 12px; }
.fileNode:hover { background: var(--glow); }
.fileNode.active { background: var(--glow); }
.fileNode .fi { color: var(--text-dim); display: inline-grid; place-items: center; }
.fileNode .fi.dir { color: var(--accent); }
.fileBranch { margin-left: 9px; padding-left: 6px; border-left: 1px solid var(--line); }

/* git surface */
.gitChangeRow { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 8px; height: 26px; padding: 0 10px; font-size: 12px; cursor: pointer; }
.gitChangeRow:hover { background: var(--glow); }
.gitBadge { width: 14px; text-align: center; font-weight: 700; }
.gitBadge.m { color: #ffd166; } .gitBadge.a { color: var(--ok); } .gitBadge.d { color: var(--error); }
.gitDir { color: var(--text-dim); font-size: 10px; }
.gitGroupHeader { padding: 8px 10px 3px; color: var(--accent); font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; }
.commitBox { margin: 8px; }
.commitBox textarea { width: 100%; min-height: 46px; resize: vertical; padding: 6px 8px; background: var(--input-bg);
  color: var(--text); border: 1px solid var(--line); border-bottom-color: var(--accent); font: inherit; font-size: 12px; }
.commitBox textarea:focus { outline: none; box-shadow: var(--focus-ring); }
.commitRow { display: grid; grid-template-columns: auto auto minmax(0,1fr) auto; align-items: center; gap: 8px; height: 30px; padding: 0 10px; font-size: 12px; cursor: pointer; }
.commitRow:hover { background: var(--glow); }
.graphNode { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--accent); background: var(--bg); }
.refChip { padding: 0 5px; height: 15px; line-height: 14px; font-size: 9px; border: 1px solid var(--accent); color: var(--accent); }
.refChip.head { background: var(--accent); color: var(--bg); font-weight: 700; }

/* ---------- Status bar ---------- */
.statusBar { position: relative; z-index: 1; display: flex; align-items: stretch; justify-content: space-between;
  padding: 0 6px; border-top: 1px solid var(--line); background: var(--surface); font-size: 10.5px;
  letter-spacing: 0.35px; color: var(--text-dim); }
.statusSeg { display: inline-flex; align-items: center; gap: 5px; padding: 0 9px; white-space: nowrap; }
.statusSeg + .statusSeg { border-left: 1px solid var(--line); }
.statusSeg.ok { color: var(--ok); } .statusSeg.warn { color: var(--accent); }
.statusRight { display: flex; }

/* ---------- Channels (Slack-like agent rooms) ---------- */
.chanRow { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 7px;
  height: 26px; padding: 0 8px; margin-bottom: 2px; border-radius: 2px; cursor: pointer; color: var(--text); font-size: 12px; }
.chanRow:hover { background: var(--glow); }
.chanRow.selected { background: var(--glow); color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.chanRow .hash { color: var(--text-dim); }
.chanRow.selected .hash { color: var(--accent); }
.chanUnread { min-width: 18px; height: 15px; padding: 0 5px; display: grid; place-items: center;
  font-size: 9px; font-weight: 700; color: var(--bg); background: var(--accent); box-shadow: 0 0 8px var(--accent);
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 50%, calc(100% - 4px) 100%, 4px 100%, 0 50%); }
.memberRow { display: grid; grid-template-columns: 10px minmax(0,1fr) auto; gap: 7px; align-items: center;
  height: 24px; padding: 0 8px; font-size: 12px; color: var(--text); }
.memberRow small { color: var(--text-dim); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; }

.chatWrap { display: grid; grid-template-rows: minmax(0,1fr) auto; min-height: 0; }
.chatScroll { min-height: 0; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; background: var(--term-bg); }
.dayDivider { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 4px 0 10px;
  color: var(--text-dim); font-size: 9px; letter-spacing: 2px; text-transform: uppercase; }
.dayDivider::before, .dayDivider::after { content: ""; height: 1px; background: var(--line); }
.chatMsg { display: grid; grid-template-columns: 30px minmax(0,1fr); gap: 9px; padding: 4px 6px; border-radius: 2px; }
.chatMsg:hover { background: var(--glow); }
.chatAva { width: 26px; height: 26px; display: grid; place-items: center; font-size: 9px; font-weight: 800; letter-spacing: 0.5px;
  color: var(--bg); clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px); }
.chatAva.c1 { background: var(--line-strong); }
.chatAva.c2 { background: var(--ok); }
.chatAva.c3 { background: var(--accent); }
.chatAva.c4 { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--line-strong); }
.chatAva.c5 { background: transparent; box-shadow: inset 0 0 0 1px var(--ok); color: var(--ok); }
.chatGutterTime { align-self: start; justify-self: end; padding-top: 2px; font-size: 8.5px; color: var(--text-dim); opacity: 0; }
.chatMsg:hover .chatGutterTime { opacity: 0.75; }
.chatHead { display: flex; align-items: baseline; gap: 8px; }
.chatHead b { font-size: 12px; color: var(--text); }
.chatHead b.human { color: var(--accent); }
.chatHead .agentTag { font-size: 8.5px; letter-spacing: 1px; padding: 1px 4px; border: 1px solid var(--line); color: var(--text-dim); text-transform: uppercase; }
.chatHead time { font-size: 9.5px; color: var(--text-dim); }
.chatBody { font-size: 12px; line-height: 1.55; color: var(--term-fg); white-space: pre-wrap; overflow-wrap: break-word; }
.chatBody .mention { color: var(--accent); background: var(--glow); padding: 0 3px; box-shadow: inset 0 0 0 1px var(--line); }
.chatBody code { font-size: 11px; padding: 0 4px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--line-strong); }
.typingRow { display: flex; align-items: center; gap: 8px; padding: 4px 6px 2px 45px; color: var(--text-dim); font-size: 10.5px; min-height: 20px; }
.typingDots { display: inline-flex; align-items: center; gap: 3px; }
.typingDots i { display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--line-strong); animation: chTyping 1s ease-in-out infinite; }
.typingDots i:nth-child(2) { animation-delay: 0.15s; }
.typingDots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chTyping { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .typingDots i { animation: none; } }
.chatComposer { margin: 8px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 6px; align-items: center;
  padding: 4px 4px 4px 10px; background: var(--input-bg); border: 1px solid var(--line); }
.chatComposer:focus-within { border-color: var(--line-strong); box-shadow: var(--focus-ring); }
.chatComposer input { background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: 12px; height: 24px; min-width: 0; }
.chatComposer input::placeholder { color: var(--text-dim); }

/* ---------- Projects (kanban) ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: 10px;
  min-height: 0; overflow-x: auto; padding: 12px; background: var(--term-bg); }
.kanColumn { display: grid; grid-template-rows: auto 1fr; min-height: 0; min-width: 0;
  background: var(--bg-elevated); box-shadow: inset 0 0 0 1px var(--line); }
.kanColHead { display: flex; align-items: center; gap: 7px; padding: 8px 10px; font-size: 10px;
  letter-spacing: 1.4px; text-transform: uppercase; color: var(--text); border-bottom: 1px solid var(--line); }
.kanColHead small { margin-left: auto; color: var(--text-dim); }
.kanDot { width: 7px; height: 7px; transform: rotate(45deg); flex: none; background: var(--text-dim); }
.kanDot.progress { background: var(--accent); box-shadow: 0 0 7px var(--accent); }
.kanDot.review { background: var(--line-strong); box-shadow: 0 0 7px var(--line-strong); }
.kanDot.done { background: var(--ok); box-shadow: 0 0 7px var(--ok); }
.kanCards { display: flex; flex-direction: column; gap: 8px; padding: 9px; overflow-y: auto; min-height: 0; }
.kanCard { position: relative; padding: 9px 10px; background: var(--surface); cursor: grab;
  box-shadow: inset 0 0 0 1px var(--line), inset 3px 0 0 var(--line-strong);
  transition: box-shadow .16s, transform .12s; }
.kanCard:hover { box-shadow: inset 0 0 0 1px var(--line-strong), inset 3px 0 0 var(--line-strong), 0 6px 18px rgba(0,0,0,.4); transform: translateY(-1px); }
.kanCard.lift { cursor: grabbing; transform: scale(1.02) rotate(-.6deg); box-shadow: inset 0 0 0 1px var(--line-strong), 0 12px 26px rgba(0,0,0,.5); }
.kanCard.tone-ok { box-shadow: inset 0 0 0 1px var(--line), inset 3px 0 0 var(--ok); }
.kanCard.tone-accent { box-shadow: inset 0 0 0 1px var(--line), inset 3px 0 0 var(--accent); }
.kanCardTop { display: flex; align-items: center; justify-content: space-between; font-size: 9px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--text-dim); }
.kanId { color: var(--accent); }
.kanCardTitle { margin: 6px 0 9px; font-size: 12px; line-height: 1.4; color: var(--text); }
.kanCardFoot { display: flex; align-items: center; gap: 6px; }
.kanTag { font-size: 8.5px; letter-spacing: .8px; text-transform: uppercase; padding: 1px 6px;
  color: var(--line-strong); box-shadow: inset 0 0 0 1px var(--line); }
.kanAva { margin-left: auto; width: 21px; height: 21px; display: grid; place-items: center; font-size: 8.5px;
  font-weight: 700; color: var(--bg); background: var(--line-strong);
  clip-path: polygon(4px 0,calc(100% - 4px) 0,100% 4px,100% calc(100% - 4px),calc(100% - 4px) 100%,4px 100%,0 calc(100% - 4px),0 4px); }
.kanAdd { display: flex; align-items: center; gap: 6px; padding: 7px 8px; font-size: 10px; color: var(--text-dim);
  letter-spacing: .6px; cursor: pointer; box-shadow: inset 0 0 0 1px transparent; }
.kanAdd:hover { color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Notes (sidebar + markdown) ---------- */
.noteRow { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 8px; align-items: center;
  padding: 7px 8px; margin-bottom: 2px; border-radius: 2px; cursor: pointer; color: var(--text); }
.noteRow:hover { background: var(--glow); }
.noteRow.selected { background: var(--glow); box-shadow: inset 2px 0 0 var(--accent); }
.noteRow.selected .noteTitle { color: var(--accent); }
.noteRowMeta { display: flex; flex-direction: column; min-width: 0; }
.noteTitle { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.noteRowMeta small { color: var(--text-dim); font-size: 9px; letter-spacing: .8px; text-transform: uppercase; }
.noteDoc { min-height: 0; overflow-y: auto; padding: 20px 26px; background: var(--term-bg); color: var(--term-fg);
  font-size: 13px; line-height: 1.7; max-width: 720px; }
.ndH1 { margin: 0 0 12px; font-size: 19px; font-weight: 700; letter-spacing: .3px; color: var(--text); }
.ndH1::before { content: "# "; color: var(--text-dim); }
.ndH2 { margin: 18px 0 8px; font-size: 14px; font-weight: 600; color: var(--line-strong); }
.ndH2::before { content: "## "; color: var(--text-dim); }
.ndP { margin: 0 0 11px; color: var(--term-fg); }
.ndLi { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin: 0 0 6px; }
.ndBul { color: var(--accent); }
.ndCode { margin: 12px 0; padding: 10px 12px; font-size: 11.5px; color: var(--line-strong);
  background: var(--bg-elevated); box-shadow: inset 0 0 0 1px var(--line), inset 3px 0 0 var(--line-strong); white-space: pre-wrap; }
