/* Forge Hub Control · v2 (Plan 3) */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Serif:wght@500;600&display=swap');

body {
  background: #0a0a0a;
  margin: 0;
  min-height: 100vh;
  padding: 24px;
  /* leave room for the sticky prompt-bar at the bottom */
  padding-bottom: 88px;
}

.page {
  max-width: 1600px;
  margin: 0 auto;
}

.v4 {
  --bg-deep: #0a0a0a;
  --bg-surface: #141414;
  --bg-card: #1f1f1f;
  --bg-card-hi: #262626;
  --bg-inset: #0f0f0f;
  --bevel-top: rgba(255,255,255,0.04);
  --line: #2c2c2c;
  --line-hi: #3a3a3a;
  --text-primary: #f4f1ea;
  --text-body: #c9c4ba;
  --text-mute: #8a857c;
  --text-faint: #54514a;
  --copper: #d18142;
  --green: #67b187;
  --amber: #d6a14c;
  --red: #d96658;

  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--bg-deep);
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  color: var(--text-primary);
}

/* shared tokens at :root so prompt-bar / stream-drawer / login can reach them */
:root {
  --bg-deep: #0a0a0a;
  --bg-surface: #141414;
  --bg-card: #1f1f1f;
  --bg-card-hi: #262626;
  --bg-inset: #0f0f0f;
  --bevel-top: rgba(255,255,255,0.04);
  --line: #2c2c2c;
  --line-hi: #3a3a3a;
  --text-primary: #f4f1ea;
  --text-body: #c9c4ba;
  --text-mute: #8a857c;
  --text-faint: #54514a;
  --copper: #d18142;
  --green: #67b187;
  --amber: #d6a14c;
  --red: #d96658;
}

/* ============ THIN STATUSBAR ============ */
.v4-tb {
  height: 38px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  display: flex;
  align-items: stretch;
}
.v4-tb-host {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-right: 1px solid var(--line);
  color: var(--text-primary);
  font-weight: 500;
  letter-spacing: 0.4px;
}
.v4-tb-host .led {
  width: 7px; height: 7px;
  background: var(--green);
}
.v4-tb-host .ip {
  color: var(--text-mute);
  font-size: 10px;
  letter-spacing: 0.3px;
}
.v4-tb-metrics {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.v4-tbm {
  display: flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums;
}
.v4-tbm .lbl {
  color: var(--text-mute);
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}
.v4-tbm .val {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 12px;
  min-width: 50px;
}
.v4-tbm .mini-bar {
  width: 36px; height: 3px;
  background: var(--line);
  position: relative; overflow: hidden;
}
.v4-tbm .mini-bar .fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--green);
  transition: width 600ms ease, background 200ms ease;
}
.v4-tbm.warn .mini-bar .fill { background: var(--amber); }
.v4-tbm.warn .val { color: var(--amber); }
.v4-tbm.crit .mini-bar .fill { background: var(--red); }
.v4-tbm.crit .val { color: var(--red); }
.v4-tbm svg.spark { width: 56px; height: 12px; display: block; }
.v4-tb-clock {
  padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
  border-left: 1px solid var(--line);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.6px;
}
.v4-tb-clock .meta { color: var(--text-mute); font-size: 10px; letter-spacing: 1.2px; }

/* ============ TOK metric (Plan 3) — hover dropdown ============ */
.v4-tbm-tok {
  position: relative;
  cursor: default;
  outline: none;
}
.v4-tbm-tok .val { min-width: 42px; color: var(--copper); }
.v4-tbm-tok::before {
  /* tiny LED dot before the label, signals 'live counter' */
  content: "";
  width: 5px; height: 5px;
  background: var(--copper);
  display: inline-block;
  margin-right: 2px;
}
.v4-tbm-tok__breakdown {
  position: absolute;
  top: calc(100% + 1px);
  right: 0;
  min-width: 220px;
  background: var(--bg-inset);
  border: 1px solid var(--line-hi);
  box-shadow:
    inset 0 1px 0 var(--bevel-top),
    0 8px 24px -8px rgba(0,0,0,0.7);
  padding: 10px 12px;
  z-index: 50;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-body);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 140ms ease, transform 140ms ease;
}
.v4-tbm-tok:hover .v4-tbm-tok__breakdown,
.v4-tbm-tok:focus-within .v4-tbm-tok__breakdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.v4-tbm-tok__breakdown .bd-row {
  display: flex; justify-content: space-between; gap: 24px;
  padding: 3px 0;
}
.v4-tbm-tok__breakdown .bd-k {
  color: var(--text-mute);
  letter-spacing: 1.1px;
  text-transform: uppercase;
  font-size: 10px;
}
.v4-tbm-tok__breakdown .bd-v {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.v4-tbm-tok__breakdown .bd-sep {
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}

/* ============ HEADER ============ */
.v4-head {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line);
  padding: 22px 28px 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}
.v4-crumbs {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.6px;
  color: var(--text-mute);
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 500;
}
.v4-crumbs .sep { color: var(--text-faint); margin: 0 8px; }
.v4-crumbs .here { color: var(--copper); }
.v4-head h1 {
  font-family: 'IBM Plex Serif', serif;
  font-weight: 600;
  font-size: 30px;
  letter-spacing: -0.5px;
  margin: 0;
  color: var(--text-primary);
  line-height: 1;
}
.v4-actions { display: flex; gap: 8px; }
.v4-btn {
  background: transparent;
  border: 1px solid var(--line-hi);
  color: var(--text-body);
  padding: 9px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.3px;
  cursor: pointer;
  text-transform: uppercase;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.v4-btn:hover {
  border-color: var(--copper);
  color: var(--copper);
  background: rgba(209,129,66,0.06);
}
.v4-btn .plus { font-size: 15px; line-height: 1; }

/* ============ BODY GRID ============ */
.v4-body { padding: 24px; background: var(--bg-deep); }
.v4-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

/* MODULE — bevelled card */
.v4-mod {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line-hi);
  cursor: pointer;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
  box-shadow:
    inset 0 1px 0 var(--bevel-top),
    0 2px 0 0 rgba(0,0,0,0.5),
    0 8px 24px -10px rgba(0,0,0,0.6);
  text-decoration: none;
  color: inherit;
}
.v4-mod:hover {
  background: var(--bg-card-hi);
  border-color: var(--copper);
  transform: translateY(-1px);
}
.v4-mod:active { transform: translateY(0); }

.v4-mod .h {
  padding: 16px 18px 14px;
  display: flex; align-items: flex-start; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.v4-mod .icn {
  width: 46px; height: 46px;
  border: 1px solid var(--line-hi);
  background: var(--bg-inset);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
  transition: border-color 200ms ease, color 200ms ease;
}
.v4-mod:hover .icn { border-color: var(--copper); color: var(--copper); }
.v4-mod .icn svg { width: 24px; height: 24px; display: block; }

.v4-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.3px;
  padding: 5px 9px;
  text-transform: uppercase;
  border: 1px solid;
  display: inline-flex; align-items: center; gap: 6px;
}
.v4-tag .d { width: 6px; height: 6px; }
.v4-tag.live { color: var(--green); border-color: rgba(103,177,135,0.5); background: rgba(103,177,135,0.08); }
.v4-tag.live .d { background: var(--green); }
.v4-tag.draft { color: var(--copper); border-color: rgba(209,129,66,0.5); background: rgba(209,129,66,0.08); }
.v4-tag.draft .d { background: var(--copper); }
.v4-tag.idle { color: var(--text-mute); border-color: var(--line-hi); }
.v4-tag.idle .d { background: var(--text-mute); }

.v4-mod .b {
  padding: 14px 18px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.v4-mod .b h3 {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 600;
  font-size: 20px;
  margin: 0 0 6px 0;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.v4-mod .b .desc {
  font-size: 13.5px;
  color: var(--text-body);
  line-height: 1.55;
  margin-bottom: 14px;
}

.viz {
  margin-top: auto;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.viz-tt {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--text-mute);
  text-transform: uppercase;
  margin-bottom: 10px;
  font-weight: 500;
}

.viz-versions { display: flex; align-items: center; gap: 6px; }
.viz-versions .node {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  background: var(--bg-inset);
  border: 1px solid var(--line-hi);
  color: var(--text-body);
}
.viz-versions .node.cur {
  background: rgba(209,129,66,0.10);
  border-color: var(--copper);
  color: var(--copper);
}
.viz-versions .ln {
  flex: 0 0 12px; height: 1px; background: var(--line-hi);
}

.viz-index {
  display: flex; align-items: center; justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
}
.viz-index .num {
  font-size: 22px;
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.viz-index .num .unit { font-size: 11px; color: var(--text-mute); margin-left: 4px; font-weight: 500; }
.viz-index .qry {
  text-align: right;
  color: var(--text-mute);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.viz-index .qry .last { color: var(--text-body); font-size: 11px; text-transform: none; letter-spacing: 0; display: block; margin-top: 2px; }

.viz-stg .seg {
  height: 6px;
  display: flex;
  background: var(--bg-inset);
  border: 1px solid var(--line-hi);
  margin-bottom: 8px;
}
.viz-stg .seg .used { background: var(--copper); }
.viz-stg .seg .free { background: transparent; flex: 1; }
.viz-stg .row {
  display: flex; justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-body);
}
.viz-stg .row .k { color: var(--text-mute); letter-spacing: 1px; text-transform: uppercase; }
.viz-stg .row .v { font-variant-numeric: tabular-nums; font-weight: 500; }

.v4-mod .f {
  padding: 12px 18px;
  background: var(--bg-inset);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-mute);
}
.v4-mod .f .path { letter-spacing: 0.5px; }
.v4-mod .f .open {
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color 200ms ease;
}
.v4-mod:hover .f .open { color: var(--copper); }
.v4-mod .f .open svg { width: 13px; height: 13px; }

/* FOLDER */
.v4-fld {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line-hi);
  cursor: pointer;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
  box-shadow:
    inset 0 1px 0 var(--bevel-top),
    0 2px 0 0 rgba(0,0,0,0.5),
    0 8px 24px -10px rgba(0,0,0,0.6);
}
.v4-fld:hover { background: var(--bg-card-hi); border-color: var(--copper); transform: translateY(-1px); }
.v4-fld .h {
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 500;
}
.v4-fld .h .ttl { display: inline-flex; align-items: center; gap: 8px; color: var(--text-body); }
.v4-fld .h svg { width: 14px; height: 14px; }
.v4-fld .grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
}
.v4-fld .grid .slot {
  background: var(--bg-inset);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 6px;
  padding: 14px;
  transition: background 200ms ease;
}
.v4-fld:hover .grid .slot { background: #131313; }
.v4-fld .grid .slot svg { width: 24px; height: 24px; color: var(--text-body); }
.v4-fld .grid .slot .lbl {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 11px;
  color: var(--text-body);
  font-weight: 500;
}
.v4-fld .f {
  padding: 12px 18px;
  background: var(--bg-inset);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.v4-fld .f .name {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 600;
}
.v4-fld .f .cnt {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 1.2px;
}

/* ADD slot */
.v4-add {
  background: transparent;
  border: 1px dashed var(--line-hi);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px;
  cursor: pointer;
  transition: all 200ms ease;
  color: var(--text-mute);
  min-height: 240px;
}
.v4-add:hover {
  border-color: var(--copper);
  background: rgba(209,129,66,0.04);
  color: var(--copper);
}
.v4-add svg { width: 28px; height: 28px; transition: transform 320ms ease; }
.v4-add:hover svg { transform: rotate(45deg); }
.v4-add .l {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 500;
}

/* ============ PROMPT-BAR (Plan 3) ============ */
.prompt-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  background: var(--bg-inset);
  border-top: 1px solid var(--line-hi);
  box-shadow: 0 -8px 24px -10px rgba(0,0,0,0.7);
  padding: 12px 24px;
}
.prompt-bar__inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-deep);
  border: 1px solid var(--line-hi);
  padding: 8px 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.prompt-bar__inner:focus-within {
  border-color: var(--copper);
  box-shadow:
    inset 0 0 0 1px rgba(209,129,66,0.18),
    0 0 0 1px rgba(209,129,66,0.18);
}
.prompt-bar__chev {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--copper);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  user-select: none;
}
.prompt-bar__input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.2px;
  caret-color: var(--copper);
  padding: 6px 4px;
}
.prompt-bar__input::placeholder {
  color: var(--text-faint);
  letter-spacing: 0.6px;
}
.prompt-bar__input:disabled { opacity: 0.5; cursor: not-allowed; }
.prompt-bar__submit {
  background: transparent;
  border: 1px solid var(--line-hi);
  color: var(--text-body);
  padding: 6px 14px;
  min-width: 44px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.prompt-bar__submit:hover:not(:disabled) {
  border-color: var(--copper);
  color: var(--copper);
  background: rgba(209,129,66,0.06);
}
.prompt-bar__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============ STREAM-DRAWER (Plan 3) ============ */
.stream-drawer {
  position: fixed;
  /* sits directly on top of the prompt-bar (which is ~64px tall) */
  left: 0; right: 0;
  bottom: 64px;
  height: 50vh;
  min-height: 100px;
  max-height: 90vh;
  z-index: 55;
  background: var(--bg-surface);
  border-top: 1px solid var(--line-hi);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 -16px 40px -16px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
}
.stream-drawer[hidden] { display: none; }

.stream-drawer__handle {
  height: 10px;
  cursor: ns-resize;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  user-select: none;
}
.stream-drawer__handle:hover { background: #181818; }
.stream-drawer__handle-grip {
  width: 36px; height: 3px;
  background: var(--line-hi);
  transition: background 160ms ease;
}
.stream-drawer__handle:hover .stream-drawer__handle-grip { background: var(--copper); }

/* while dragging, kill text-selection across the document */
body.stream-drawer-dragging,
body.stream-drawer-dragging * {
  user-select: none !important;
  cursor: ns-resize !important;
}

.stream-drawer__head {
  padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.stream-drawer__prompt {
  display: flex; align-items: center; gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-body);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}
.stream-drawer__chev {
  color: var(--copper);
  font-weight: 600;
  flex: 0 0 auto;
}
.stream-drawer__head-actions {
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto;
}
.stream-drawer__cancel {
  background: transparent;
  border: 1px solid var(--line-hi);
  color: var(--text-body);
  padding: 4px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  cursor: pointer;
  text-transform: uppercase;
  transition: border-color 160ms ease, color 160ms ease;
}
.stream-drawer__cancel:hover {
  border-color: var(--red);
  color: var(--red);
}
.stream-drawer__close {
  background: transparent;
  border: 1px solid var(--line-hi);
  color: var(--text-mute);
  width: 26px; height: 26px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
  padding: 0;
}
.stream-drawer__close:hover {
  border-color: var(--copper);
  color: var(--copper);
}

.stream-drawer__output {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 22px;
  background: var(--bg-deep);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-primary);
}
.stream-drawer__output p {
  margin: 0 0 12px 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.stream-drawer__output p:last-child { margin-bottom: 0; }

.stream-drawer__output::-webkit-scrollbar { width: 8px; }
.stream-drawer__output::-webkit-scrollbar-track { background: var(--bg-inset); }
.stream-drawer__output::-webkit-scrollbar-thumb {
  background: var(--line-hi);
  border: 2px solid var(--bg-inset);
}

.stream__token { /* unused — tokens stream into <p>; kept for future explicit wrapping */ }

.stream__tool {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--green);
  background: rgba(103,177,135,0.05);
  border-left: 2px solid var(--green);
  padding: 6px 10px;
  margin: 6px 0 10px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.stream__done {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--green);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 12px;
}
.stream__done::before { content: "✓ "; }

.stream__error {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--red);
  background: rgba(217,102,88,0.06);
  border-left: 2px solid var(--red);
  padding: 8px 10px;
  margin: 8px 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.stream__error__retry {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 4px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 160ms ease;
}
.stream__error__retry:hover { background: rgba(217,102,88,0.1); }

.stream-drawer__footer {
  padding: 8px 22px;
  background: var(--bg-inset);
  border-top: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-mute);
}

/* ============ LOGIN PAGE ============ */
.login-page {
  background: #0a0a0a;
  min-height: 100vh;
  margin: 0;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--text-primary);
}
.login-shell {
  width: 100%;
  max-width: 440px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 var(--bevel-top),
    0 8px 32px -8px rgba(0,0,0,0.7);
}
/* reuse the v4-tb statusbar idiom inside login */
.login-shell .v4-tb {
  height: 38px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  display: flex;
  align-items: stretch;
}
.login-card {
  padding: 36px 32px 32px;
  background: var(--bg-surface);
}
.login-card .crumbs {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.6px;
  color: var(--text-mute);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.login-card .crumbs .here { color: var(--copper); }
.login-card .crumbs .sep { color: var(--text-faint); margin: 0 8px; }
.login-card h1 {
  font-family: 'IBM Plex Serif', serif;
  font-weight: 600;
  font-size: 26px;
  letter-spacing: -0.4px;
  margin: 0 0 24px 0;
  color: var(--text-primary);
  line-height: 1.1;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field {
  display: flex; flex-direction: column; gap: 6px;
}
.login-field label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--text-mute);
  text-transform: uppercase;
}
.login-input {
  background: var(--bg-deep);
  border: 1px solid var(--line-hi);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  padding: 10px 12px;
  outline: 0;
  caret-color: var(--copper);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.login-input:focus {
  border-color: var(--copper);
  box-shadow: inset 0 0 0 1px rgba(209,129,66,0.2);
}
.login-submit {
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--copper);
  color: var(--copper);
  padding: 11px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.login-submit:hover {
  background: rgba(209,129,66,0.1);
}
.login-error {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--red);
  background: rgba(217,102,88,0.06);
  border-left: 2px solid var(--red);
  padding: 8px 10px;
  margin: 0 0 4px 0;
}
.login-error:empty { display: none; }
.login-foot {
  padding: 12px 32px;
  background: var(--bg-inset);
  border-top: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--text-faint);
  text-transform: uppercase;
  display: flex; justify-content: space-between;
}

/* ============ MANAGED APPS / FOLDERS ============ */
.app-card .app-card__glyph,
.folder-card .folder-card__glyph {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 24px;
  line-height: 1;
}
body.apps-edit-mode .app-card[draggable="true"],
body.apps-edit-mode .folder-card[draggable="true"] {
  cursor: grab;
}
.app-card.dragging,
.folder-card.dragging {
  opacity: 0.45;
  cursor: grabbing;
}
body.apps-edit-mode .app-card,
body.apps-edit-mode .folder-card {
  animation: app-wiggle 0.4s ease-in-out infinite alternate;
  transform-origin: 50% 60%;
}
body.apps-edit-mode .app-card:nth-child(even),
body.apps-edit-mode .folder-card:nth-child(even),
body.apps-edit-mode .folder-expanded__apps .app-card:nth-child(even) {
  animation-direction: alternate-reverse;
}
body.apps-edit-mode .app-card:hover,
body.apps-edit-mode .folder-card:hover {
  transform: none;
}
.app-card.drop-target,
.folder-card.drop-target,
.v4-grid.drop-target {
  outline: 1px dashed var(--copper);
  outline-offset: 4px;
}
.app-card__delete-badge,
.folder-card__delete-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 4;
  width: 18px;
  height: 18px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--copper);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 18px;
  line-height: 18px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
body.apps-edit-mode .folder-card__delete-badge {
  display: flex;
}
body.apps-edit-mode .app-card__delete-badge {
  display: none;
}
.app-card__drag-handle,
.folder-card__drag-handle {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: none;
  grid-template-columns: repeat(3, 3px);
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(209,129,66,0.25);
  background: rgba(12,12,12,0.5);
  opacity: 0.45;
  pointer-events: none;
}
.app-card__drag-handle i,
.folder-card__drag-handle i {
  width: 3px;
  height: 3px;
  background: var(--copper);
  border-radius: 50%;
}
body.apps-edit-mode .app-card__drag-handle,
body.apps-edit-mode .folder-card__drag-handle {
  display: grid;
}
body.apps-edit-mode .app-card:hover .app-card__drag-handle,
body.apps-edit-mode .folder-card:hover .folder-card__drag-handle {
  opacity: 0.9;
}
.apps-edit-mode__reset {
  position: fixed;
  right: 22px;
  bottom: 86px;
  z-index: 70;
  display: none;
  border: 1px solid rgba(209,129,66,0.55);
  background: rgba(15,15,15,0.92);
  color: var(--copper);
  padding: 9px 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 26px -14px rgba(0,0,0,0.9);
}
.apps-edit-mode__reset:hover {
  background: rgba(209,129,66,0.08);
}
.apps-edit-mode__exit-hint {
  position: fixed;
  left: 50%;
  bottom: 86px;
  z-index: 70;
  display: none;
  transform: translateX(-50%);
  color: var(--text-faint);
  background: rgba(15,15,15,0.82);
  border: 1px solid var(--line-hi);
  padding: 7px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  pointer-events: none;
}
body.apps-edit-mode .apps-edit-mode__reset,
body.apps-edit-mode .apps-edit-mode__exit-hint {
  display: block;
}
.app-card .viz-index .num {
  font-size: 18px;
}
.folder-card .folder-card__stack {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  padding: 1px;
  border: 1px solid rgba(209,129,66,0.55);
  background: rgba(209,129,66,0.08);
  color: var(--copper);
}
.folder-card .folder-card__stack span {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-inset);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
}
.folder-card.drop-target .folder-card__stack {
  border-style: dashed;
}
.folder-expanded {
  grid-column: 1 / -1;
  background: var(--bg-card);
  border: 1px solid var(--line-hi);
  box-shadow:
    inset 0 1px 0 var(--bevel-top),
    0 8px 24px -12px rgba(0,0,0,0.7);
  overflow: hidden;
  animation: folder-expand 160ms ease-out;
}
.folder-expanded__head {
  padding: 11px 14px;
  background: var(--bg-inset);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-mute);
}
.folder-expanded__head strong {
  color: var(--copper);
  font-weight: 600;
}
.folder-expanded__apps {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.folder-expanded__apps .app-card {
  min-height: 190px;
}
.folder-expanded__apps .app-card .b h3 {
  font-size: 17px;
}
.folder-expanded__apps .app-card .viz {
  display: none;
}
@keyframes app-wiggle {
  0% { transform: rotate(-1.5deg); }
  100% { transform: rotate(1.5deg); }
}
@keyframes folder-expand {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  body.apps-edit-mode .app-card,
  body.apps-edit-mode .folder-card {
    animation: none;
  }
}

/* ============ PROMPT-BAR CLAUDE AFFORDANCES ============ */
.prompt-bar__panel {
  max-width: 1600px;
  margin: 0 auto;
  background: var(--bg-deep);
  border: 1px solid var(--line-hi);
  border-radius: 4px;
  padding: 8px;
  position: relative;
  transition: border-color 160ms ease, box-shadow 160ms ease, outline-color 160ms ease;
}
.prompt-bar__panel:focus-within {
  border-color: var(--copper);
  box-shadow:
    inset 0 0 0 1px rgba(209,129,66,0.18),
    0 0 0 1px rgba(209,129,66,0.18);
}
.prompt-bar__panel.drag-active {
  outline: 1px dashed var(--copper);
  outline-offset: 4px;
  background: rgba(209,129,66,0.04);
}
.prompt-bar__form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.prompt-bar__btn {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line-hi);
  color: var(--text-body);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.prompt-bar__btn:hover:not(:disabled) {
  border-color: var(--copper);
  color: var(--copper);
  background: rgba(209,129,66,0.06);
}
.prompt-bar__btn--mic.recording {
  border-color: var(--red);
  color: var(--red);
  animation: mic-pulse 1100ms ease-in-out infinite;
}
.prompt-bar__btn--tts.is-on {
  border-color: var(--green);
  color: var(--green);
  background: rgba(103,177,135,0.07);
}
.prompt-bar__files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.prompt-bar__files[hidden] { display: none; }
.prompt-bar__chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  border: 1px solid var(--line-hi);
  background: var(--bg-inset);
  color: var(--text-body);
  padding: 5px 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
}
.prompt-bar__chip-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.prompt-bar__chip-remove {
  border: 0;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.prompt-bar__chip-remove:hover {
  color: var(--copper);
}
.prompt-bar__chip--dragover {
  border-color: var(--copper);
  background: rgba(209,129,66,0.08);
}
.prompt-bar__slash-popover {
  position: absolute;
  left: 48px;
  right: 48px;
  bottom: calc(100% + 10px);
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-inset);
  border: 1px solid var(--line-hi);
  box-shadow:
    inset 0 1px 0 var(--bevel-top),
    0 18px 42px -18px rgba(0,0,0,0.9);
  padding: 6px;
  font-family: 'IBM Plex Mono', monospace;
  z-index: 75;
}
.prompt-bar__slash-popover[hidden] { display: none; }
.slash-row {
  display: flex;
  gap: 16px;
  align-items: baseline;
  padding: 8px 10px;
  color: var(--text-body);
  cursor: pointer;
}
.slash-row .cmd {
  color: var(--copper);
  min-width: 150px;
  font-size: 12px;
}
.slash-row .desc {
  color: var(--text-mute);
  font-size: 11px;
}
.slash-row.active,
.slash-row:hover {
  background: rgba(209,129,66,0.08);
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,102,88,0.0); }
  50% { box-shadow: 0 0 0 3px rgba(217,102,88,0.2); }
}

@media (max-width: 720px) {
  .prompt-bar { padding: 10px 12px; }
  .prompt-bar__slash-popover { left: 8px; right: 8px; }
  .slash-row { flex-direction: column; gap: 2px; }
  .slash-row .cmd { min-width: 0; }
}

/* ============ STREAM-DRAWER modernization (Plan 3.5) ============ */
.stream-drawer {
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  background: rgba(20, 20, 20, 0.85);
  border-radius: 8px 8px 0 0;
}

/* Output area capped at readable width */
.stream-drawer__output,
.stream__output {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 0 1.25rem;
  overflow-y: auto;
  flex: 1 1 auto;
}

/* Copper progress-bar animates while streaming, fills 100% on done */
.stream-drawer__head { position: relative; }
.stream-drawer__progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  background: var(--copper, #c89a6c);
  width: 0;
  transition: width 200ms ease-out;
  pointer-events: none;
}
.stream-drawer.is-streaming .stream-drawer__progress {
  animation: stream-progress 4s ease-in-out infinite;
}
.stream-drawer.is-done .stream-drawer__progress { width: 100%; }
.stream-drawer.is-error .stream-drawer__progress {
  width: 100%;
  background: var(--red, #c34a3b);
}
@keyframes stream-progress {
  0% { width: 0; }
  60% { width: 75%; }
  100% { width: 90%; }
}

/* Stream-md container holds rendered markdown */
.stream__md {
  font-family: var(--font-sans, system-ui), sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text, #d4d4d4);
}

/* Markdown element styles */
.md-h1, .md-h2, .md-h3 {
  font-family: var(--font-sans, system-ui), sans-serif;
  font-weight: 600;
  margin: 1.2em 0 0.5em 0;
  letter-spacing: -0.01em;
}
.md-h1 { font-size: 1.5em; color: var(--copper, #c89a6c); border-bottom: 1px solid var(--line, #2a2a2a); padding-bottom: 0.3em; }
.md-h2 { font-size: 1.25em; color: var(--text-bright, #fff); }
.md-h3 { font-size: 1.05em; color: var(--text-bright, #fff); }

.md-p { margin: 0.8em 0; }
.md-strong { font-weight: 600; color: var(--text-bright, #fff); }
.md-em { font-style: italic; }

.md-code {
  font-family: var(--font-mono, monospace);
  font-size: 0.92em;
  background: rgba(200, 154, 108, 0.12);
  color: var(--copper, #c89a6c);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  border: 1px solid rgba(200, 154, 108, 0.25);
}

.md-pre {
  position: relative;
  background: #0e0e0e;
  border: 1px solid var(--line, #2a2a2a);
  border-radius: 6px;
  padding: 1em 1em 0.8em 1em;
  margin: 1em 0;
  overflow-x: auto;
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  line-height: 1.5;
}
.md-pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text, #d4d4d4);
}
.md-pre__lang {
  position: absolute;
  top: 0.4em;
  right: 3em;
  font-size: 11px;
  color: var(--copper, #c89a6c);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.md-pre__copy {
  position: absolute;
  top: 0.3em;
  right: 0.4em;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line, #2a2a2a);
  color: var(--text-muted, #888);
  font-size: 11px;
  padding: 0.2em 0.5em;
  border-radius: 4px;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.md-pre__copy:hover {
  background: var(--copper, #c89a6c);
  color: #000;
}

.md-ul, .md-ol {
  margin: 0.6em 0;
  padding-left: 1.5em;
}
.md-li { margin: 0.25em 0; }

.md-bq {
  border-left: 3px solid var(--copper, #c89a6c);
  margin: 1em 0;
  padding: 0.2em 0 0.2em 1em;
  color: var(--text-muted, #aaa);
  font-style: italic;
}

.md-link {
  color: var(--copper, #c89a6c);
  text-decoration: underline;
  text-decoration-color: rgba(200, 154, 108, 0.5);
  text-underline-offset: 2px;
}
.md-link:hover { text-decoration-color: var(--copper, #c89a6c); }

.md-hr {
  border: none;
  border-top: 1px solid var(--line, #2a2a2a);
  margin: 1.2em 0;
}

.md-table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13px;
  width: 100%;
}
.md-table th, .md-table td {
  border: 1px solid var(--line, #2a2a2a);
  padding: 0.4em 0.7em;
  text-align: left;
}
.md-table th {
  background: rgba(200, 154, 108, 0.08);
  color: var(--copper, #c89a6c);
  font-weight: 600;
}

/* ============ Claude-app-style chat centering (Plan 3.5 polish) ============ */
/* All drawer content lives in a centered max-width column, like claude.ai */
.stream-drawer__head,
.stream-drawer__output {
  max-width: 820px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  box-sizing: border-box;
}
.stream-drawer__head {
  padding-left: 24px;
  padding-right: 24px;
}
.stream-drawer__output {
  padding: 20px 24px 32px;
}

/* Tool-call / token-stream paragraphs respect the column */
.stream__md, .stream__md > * {
  max-width: 100%;
}

/* Subtle chat bubble feel — own message vs assistant tokens */
.stream-drawer__head .stream-drawer__prompt {
  padding: 8px 14px;
  background: rgba(200, 154, 108, 0.08);
  border-radius: 18px;
  border: 1px solid rgba(200, 154, 108, 0.18);
}

/* Outer drawer surface — claude-style soft edge */
.stream-drawer {
  background: rgba(14, 14, 14, 0.92) !important;
  border-top: 1px solid var(--line, #2a2a2a);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -20px 60px -10px rgba(0,0,0,0.65);
}

/* Close button + cancel-button live to the right of the prompt — keep them inside the column too */
.stream-drawer__head {
  /* Use grid to anchor the action group to the right of the centered column */
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}
.stream-drawer__head-actions {
  justify-self: end;
}

/* Prompt-bar also centered like claude-app — overrides earlier full-width */
.prompt-bar__panel {
  max-width: 820px;
  margin: 0 auto;
}

/* Stream error banner inside output — tighten alignment to match column */
.stream__error {
  border-radius: 8px;
  padding: 12px 16px;
}

/* Wider screens — let the column breathe a bit but don't go ultrawide */
@media (min-width: 1280px) {
  .stream-drawer__head,
  .stream-drawer__output,
  .prompt-bar__panel {
    max-width: 900px;
  }
}

/* Soft animated entry for new tokens (subtle, claude-like) */
.stream__md p,
.stream__md li,
.stream__md pre,
.stream__md blockquote {
  animation: stream-fade 180ms ease-out;
}
@keyframes stream-fade {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .stream__md p, .stream__md li, .stream__md pre, .stream__md blockquote { animation: none; }
}

/* ============ SKILLS EDITOR (FHAS Plan 4 Track C) ============ */
.skills-page {
  min-height: 100vh;
  padding: 24px;
  padding-bottom: 24px;
  box-sizing: border-box;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  display: grid;
  grid-template-rows: 38px auto minmax(0, 1fr);
  gap: 0;
}
.skills-page *,
.skills-page *::before,
.skills-page *::after {
  box-sizing: border-box;
}
.v4-tb--minimal {
  max-width: 1600px;
  width: 100%;
  margin: 8px auto 0;
  border: 1px solid var(--line);
  border-radius: 4px 4px 0 0;
  justify-content: space-between;
  overflow: hidden;
}
.v4-tb--minimal .v4-tb-host {
  border-right: 1px solid var(--line);
}
.v4-tb-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-left: 1px solid var(--line);
  color: var(--text-mute);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.8px;
}
.v4-tb-actions .sep {
  color: var(--text-faint);
}
.v4-tb-actions .user {
  color: var(--text-body);
}
.v4-tb-actions .logout,
.v4-tb-action {
  color: var(--text-body);
  text-decoration: none;
  transition: color 160ms ease;
}
.v4-tb-actions .logout:hover,
.v4-tb-action:hover {
  color: var(--copper);
}
.skills-crumbs {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 28px;
  background: var(--bg-surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-mute);
}
.skills-crumbs .sep {
  color: var(--text-faint);
  margin: 0 8px;
}
.skills-crumbs .here {
  color: var(--copper);
}
.skills-main {
  max-width: 1600px;
  width: 100%;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 300px) minmax(0, 1fr);
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.skills-sidebar {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--bg-inset);
  border-right: 1px solid var(--line);
}
.skills-search {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.skills-search input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--line-hi);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  outline: 0;
  padding: 10px 11px;
  caret-color: var(--copper);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.skills-search input::placeholder {
  color: var(--text-faint);
}
.skills-search input:focus {
  border-color: var(--copper);
  box-shadow: inset 0 0 0 1px rgba(209,129,66,0.18);
}
.skills-list {
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 8px 0;
}
.skills-list::-webkit-scrollbar,
.skills-detail__textarea::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.skills-list::-webkit-scrollbar-track,
.skills-detail__textarea::-webkit-scrollbar-track {
  background: var(--bg-inset);
}
.skills-list::-webkit-scrollbar-thumb,
.skills-detail__textarea::-webkit-scrollbar-thumb {
  background: var(--line-hi);
  border: 2px solid var(--bg-inset);
}
.skills-list li {
  min-height: 42px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 12px 9px 14px;
  border-left: 2px solid transparent;
  color: var(--text-body);
  font-family: 'IBM Plex Mono', monospace;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.skills-list li:hover {
  background: rgba(255,255,255,0.03);
  color: var(--text-primary);
}
.skills-list li.selected {
  background: rgba(209,129,66,0.10);
  border-left-color: var(--copper);
  color: var(--text-primary);
}
.skills-list__icon {
  color: var(--text-mute);
  font-size: 13px;
}
.skills-list li.selected .skills-list__icon {
  color: var(--copper);
}
.skills-list__name,
.skills-list li__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
}
.skills-list__version,
.skills-list li__version {
  color: var(--copper);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.skills-list__empty {
  cursor: default;
  color: var(--text-faint);
}
.skills-list__empty:hover {
  background: transparent;
  color: var(--text-faint);
}
.skills-new {
  margin: 14px;
  background: transparent;
  border: 1px solid var(--line-hi);
  color: var(--text-body);
  padding: 10px 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.skills-new:hover {
  border-color: var(--copper);
  color: var(--copper);
  background: rgba(209,129,66,0.06);
}
.skills-detail {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: 24px;
  gap: 16px;
  background: var(--bg-deep);
}
.skills-detail__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 4px;
}
.skills-detail__title {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-family: 'IBM Plex Serif', serif;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.05;
}
.skills-detail__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.skills-detail__edit,
.skills-detail__delete {
  background: transparent;
  border: 1px solid var(--line-hi);
  color: var(--text-body);
  padding: 8px 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}
.skills-detail__edit:hover {
  border-color: var(--copper);
  color: var(--copper);
  background: rgba(209,129,66,0.06);
}
.skills-detail__delete:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(217,102,88,0.06);
}
.skills-detail__editor {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.skills-detail__editor label {
  color: var(--text-mute);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}
.skills-detail__editor--manifest .skills-detail__textarea {
  min-height: 112px;
  resize: vertical;
}
.skills-detail__editor--manifest .skills-detail__textarea:focus {
  min-height: 220px;
}
.skills-detail__editor--markdown {
  min-height: 0;
}
.skills-detail__editor--markdown .skills-detail__textarea {
  height: 60vh;
  min-height: 320px;
  resize: vertical;
}
.skills-detail__textarea {
  width: 100%;
  background: var(--bg-inset);
  border: 1px solid var(--line-hi);
  color: var(--text-primary);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  line-height: 1.55;
  outline: 0;
  padding: 12px;
  caret-color: var(--copper);
  transition: border-color 160ms ease, box-shadow 160ms ease, min-height 180ms ease;
}
.skills-detail__textarea:focus {
  border-color: var(--copper);
  box-shadow: inset 0 0 0 1px rgba(209,129,66,0.18);
}
.skills-detail__textarea[readonly] {
  color: var(--text-body);
  cursor: default;
}
.skills-detail__footer {
  display: flex;
  justify-content: flex-end;
}
.skills-detail__save {
  background: rgba(209,129,66,0.08);
  border: 1px solid var(--copper);
  color: var(--copper);
  min-width: 128px;
  padding: 11px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, opacity 160ms ease;
}
.skills-detail__save:hover:not(:disabled) {
  background: rgba(209,129,66,0.14);
}
.skills-detail__save:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.skills-empty {
  align-self: start;
  color: var(--text-faint);
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-left: 2px solid var(--copper);
  padding: 14px 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
}
.skills-toast {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 100;
  max-width: min(420px, calc(100vw - 44px));
  background: rgba(15,15,15,0.96);
  border: 1px solid rgba(209,129,66,0.72);
  border-left: 2px solid var(--copper);
  color: var(--text-primary);
  box-shadow: 0 16px 36px -18px rgba(0,0,0,0.9);
  padding: 10px 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  line-height: 1.45;
  animation: skills-toast-in 140ms ease-out;
}
.skills-toast--err {
  border-color: rgba(217,102,88,0.72);
  border-left-color: var(--red);
  color: var(--red);
}
@keyframes skills-toast-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 820px) {
  .skills-page {
    padding: 12px;
    padding-bottom: 12px;
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  .v4-tb--minimal {
    height: auto;
    flex-wrap: wrap;
    margin-top: 0;
  }
  .v4-tb-actions {
    min-height: 38px;
    margin-left: auto;
  }
  .skills-crumbs {
    padding: 14px 16px;
  }
  .skills-main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(210px, 34vh) minmax(0, 1fr);
  }
  .skills-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .skills-detail {
    padding: 16px;
  }
  .skills-detail__head {
    align-items: stretch;
    flex-direction: column;
  }
  .skills-detail__actions {
    justify-content: flex-start;
  }
  .skills-detail__title {
    font-size: 24px;
  }
  .skills-detail__editor--markdown .skills-detail__textarea {
    height: 52vh;
  }
}

/* Plan 4 — markdown image embed (image-gen results) */
.md-img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--line, #2a2a2a);
  margin: 0.6em 0;
  background: rgba(255,255,255,0.02);
}
.md-img-blocked {
  color: var(--red, #c34a3b);
  font-family: var(--font-mono, monospace);
  font-size: 0.875em;
}

/* Plan 4 A1 — Vision-routing badge in stream-drawer */
.stream__vision-badge {
  display: inline-block;
  margin-bottom: 1em;
  padding: 4px 10px;
  font-family: var(--font-mono, monospace);
  font-size: 0.8125rem;
  color: var(--copper, #c89a6c);
  background: rgba(200, 154, 108, 0.08);
  border: 1px solid rgba(200, 154, 108, 0.3);
  border-radius: 12px;
}

/* ============ MOBILE RESPONSIVE APPENDS ============ */
@media (min-width: 769px) {
  .hamburger,
  .sidebar-backdrop {
    display: none;
  }
}

@media (max-width: 768px) {
  .skills-page {
    padding: 8px;
    padding-bottom: 8px;
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow-x: hidden;
  }
  .skills-crumbs {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
  }
  .hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--line-hi);
    background: var(--bg-inset);
    color: var(--copper);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 18px;
    cursor: pointer;
  }
  .skills-crumbs__path {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .skills-main {
    display: block;
    min-height: calc(100vh - 118px);
    overflow: visible;
  }
  .skills-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    z-index: 120;
    width: 80vw;
    max-width: 320px;
    height: 100vh;
    height: 100dvh;
    border-right: 1px solid var(--line-hi);
    border-bottom: 0;
    box-shadow: 18px 0 42px -22px rgba(0,0,0,0.95);
    transform: translateX(0);
    transition: left 180ms ease;
  }
  body.sidebar-open .skills-sidebar {
    left: 0;
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: block;
    background: rgba(0,0,0,0.56);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }
  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .skills-detail {
    width: 100%;
    min-height: calc(100vh - 118px);
    padding: 16px;
  }
  .skills-list li,
  .skills-new,
  .skills-search input,
  .skills-detail__edit,
  .skills-detail__delete,
  .skills-detail__save {
    min-height: 44px;
  }
}

@media (max-width: 640px) {
  body:not(.skills-page):not(.login-page) {
    padding: 6px;
    padding-bottom: 78px;
  }
  body:not(.skills-page) .v4 {
    margin-top: 0;
  }
  body:not(.skills-page) .v4-tb {
    height: auto;
    min-height: 76px;
    flex-wrap: wrap;
    align-items: stretch;
  }
  body:not(.skills-page) .v4-tb-host {
    flex: 1 1 auto;
    min-height: 38px;
    padding: 0 10px;
  }
  body:not(.skills-page) .v4-tb-metrics {
    order: 3;
    flex: 1 0 100%;
    min-height: 38px;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 10px;
    overflow-x: auto;
    border-top: 1px solid var(--line);
  }
  body:not(.skills-page) .v4-tb-metrics .v4-tbm:nth-child(3),
  body:not(.skills-page) .v4-tb-metrics .v4-tbm:nth-child(4),
  body:not(.skills-page) .v4-tb-metrics .v4-tbm:nth-child(5),
  body:not(.skills-page) .v4-tb-metrics .v4-tbm:nth-child(6) {
    display: none;
  }
  body:not(.skills-page) .v4-tbm {
    gap: 6px;
  }
  body:not(.skills-page) .v4-tbm .val {
    min-width: auto;
  }
  body:not(.skills-page) .v4-tbm .mini-bar {
    width: 28px;
  }
  body:not(.skills-page) .v4-tb-clock {
    min-height: 38px;
    padding: 0 10px;
    gap: 8px;
    border-left: 1px solid var(--line);
  }
  body:not(.skills-page) .v4-tb-clock #m-clock-cn,
  body:not(.skills-page) .v4-tb-clock #m-clock-cn + .meta,
  body:not(.skills-page) .v4-tb-clock #m-clock-cn ~ span[style] {
    display: none;
  }
  .v4-crumbs {
    display: none;
  }
  .v4-head {
    padding: 16px 14px;
    gap: 14px;
    align-items: flex-start;
    flex-direction: column;
  }
  .v4-head h1 {
    font-size: 26px;
  }
  .v4-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .v4-btn {
    min-height: 44px;
    padding: 8px 12px;
  }
  .v4-body {
    padding: 12px;
  }
  .v4-grid,
  .folder-expanded__apps {
    grid-template-columns: 1fr;
  }
  .v4-mod,
  .v4-fld,
  .v4-add,
  .app-card,
  .folder-card {
    width: 100%;
    min-height: 200px;
  }
  .v4-mod .h,
  .v4-mod .b,
  .v4-mod .f,
  .v4-fld .h,
  .v4-fld .f {
    padding-left: 14px;
    padding-right: 14px;
  }
  .app-card__delete-badge,
  .folder-card__delete-badge {
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 16px;
  }
  .prompt-bar {
    padding: 6px;
  }
  .prompt-bar__panel {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    box-sizing: border-box;
    padding: 6px;
  }
  .prompt-bar__form {
    gap: 6px;
  }
  .prompt-bar__btn {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }
  .prompt-bar__submit {
    min-width: 38px;
    min-height: 32px;
    padding: 6px 10px;
  }
  .prompt-bar__input {
    min-width: 0;
    font-size: 14px;
  }
  .stream-drawer {
    bottom: 58px;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    border-radius: 10px 10px 0 0;
  }
  .stream-drawer__head {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px 10px;
  }
  .stream-drawer__prompt {
    padding: 7px 10px;
    min-width: 0;
  }
  .stream-drawer__cancel {
    min-height: 28px;
    padding: 3px 8px;
    font-size: 9px;
  }
  .stream-drawer__close {
    width: 24px;
    height: 24px;
    font-size: 15px;
  }
  .stream-drawer__output {
    max-width: none;
    padding: 14px 12px 22px;
    font-size: 14px;
  }
  .apps-edit-mode__reset {
    right: 12px;
    bottom: 72px;
    min-height: 44px;
  }
  .apps-edit-mode__exit-hint {
    bottom: 72px;
    max-width: calc(100vw - 120px);
  }
}

@media (max-width: 480px) {
  body:not(.skills-page) .v4-tb-host > span:not(.ip) {
    display: none;
  }
  .v4-tbm-tok__breakdown {
    position: fixed;
    top: 76px;
    right: 6px;
    left: 6px;
    min-width: 0;
    padding: 8px;
  }
  .prompt-bar__slash-popover {
    left: 0;
    right: 0;
    max-height: 50vh;
  }
  .slash-row {
    min-height: 44px;
  }
  .prompt-bar__btn {
    width: 28px;
    height: 32px;
    flex-basis: 28px;
  }
}
