/* ============================================================
   Ephemeral Workspace — project layer over Quiet UI.
   Only what the kit cannot know: the accent, the column plan,
   the terminal stage and the log view. Everything else is tokens.
   ============================================================ */

/* One accent — brand Peacock instead of the stock blue.
   Changed via the token, as the kit prescribes; there is no second accent. */
:root,
[data-theme='light'] {
  --accent: #20808d;
  --accent-fill: rgba(32, 128, 141, 0.1);
}
[data-theme='dark'] {
  --accent: #2fa3b2;
  --accent-fill: rgba(47, 163, 178, 0.16);
}

/* ── machines: column plan ────────────────────────────────── */
#view-machines {
  --grid: minmax(150px, 1.1fr) 136px minmax(112px, 0.9fr) 104px 76px 84px 36px;
}

/* ── terminal: stage without scrolling ────────────────────── */
/* Geometry lives in custom properties: --pad is the stage inset, --tbar-h the
   height of the panel's own terminal bar (tabs + layout), --top where the
   terminal area starts. Frames are absolutely positioned by data-pane so
   they never move in the DOM (moving an iframe reloads it). */
.term-stage {
  --pad: var(--s3);
  --tbar-h: 34px;
  --gap: var(--s2);
  --top: calc(var(--pad) + var(--tbar-h));
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  background: var(--field);
  padding: var(--s3);
}
.term-stage[data-multi='false'] {
  --tbar-h: 0px;
}
/* Off view: still laid out (frames keep a real viewport), just not shown.
   display:none would give loading terminal pages no size to measure, and a
   page that boots that way can stay blank (seen in Firefox). */
.content {
  position: relative;
}
.term-stage.off {
  position: absolute;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
}
.term-stage iframe.off {
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
}
.term-stage iframe {
  position: absolute;
  top: var(--top);
  left: var(--pad);
  right: var(--pad);
  bottom: var(--pad);
  /* a replaced element does not stretch between top and bottom: size it */
  width: calc(100% - 2 * var(--pad));
  height: calc(100% - var(--top) - var(--pad));
  border: 0;
  border-radius: var(--r-lg);
  /* Matches the terminal page's own background (Light Owl / Night Owl) so the
     corners never flash a different colour while the iframe loads. */
  background: #fbfbfb;
  box-shadow: 0 0 0 0.5px var(--hairline);
  transition: box-shadow var(--dur) linear;
}
[data-theme='dark'] .term-stage iframe {
  background: #101317;
}
/* two panes: side by side / stacked */
.term-stage[data-mode='cols'] iframe[data-pane='0'],
.term-stage[data-mode='cols'] iframe[data-pane='1'] {
  width: calc((100% - 2 * var(--pad) - var(--gap)) / 2);
}
.term-stage[data-mode='cols'] iframe[data-pane='0'] { right: auto; }
.term-stage[data-mode='cols'] iframe[data-pane='1'] { left: auto; }
.term-stage[data-mode='rows'] iframe[data-pane='0'],
.term-stage[data-mode='rows'] iframe[data-pane='1'] {
  height: calc((100% - var(--top) - var(--pad) - var(--gap)) / 2);
}
.term-stage[data-mode='rows'] iframe[data-pane='0'] { bottom: auto; }
.term-stage[data-mode='rows'] iframe[data-pane='1'] { top: auto; }
/* the pane that has the keyboard, only meaningful when there are two */
.term-stage:not([data-mode='single']) iframe[data-focus='true'] {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent);
}

/* ── terminal bar: tabs on the left, layout on the right ─── */
.tbar {
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  right: var(--pad);
  height: var(--tbar-h);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
  z-index: 1;
}
.ttabs {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  flex: 1;
  height: 26px;
  overflow: hidden;
}
.ttab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 4px 0 10px;
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
  transition: background var(--dur) linear, color var(--dur) linear;
}
.ttab:hover {
  color: var(--fg);
  background: var(--fill-quiet);
}
.ttab[data-on='true'] {
  color: var(--fg);
  background: var(--fill-quiet);
}
.ttab[data-focus='true'] {
  background: var(--bg);
  box-shadow: 0 0 0 0.5px var(--hairline-strong);
  font-weight: 600;
}
[data-theme='dark'] .ttab[data-focus='true'] {
  background: var(--fill-active);
  box-shadow: none;
}
.ttab-pane {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  color: var(--fg-3);
  background: var(--fill-active);
}
.ttab[data-focus='true'] .ttab-pane {
  color: var(--bg);
  background: var(--accent);
}
.ttab-x {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  color: var(--fg-3);
  opacity: 0;
  transition: opacity var(--dur) linear, background var(--dur) linear;
}
.ttab-x .ic { width: 11px; height: 11px; }
.ttab:hover .ttab-x,
.ttab[data-focus='true'] .ttab-x {
  opacity: 1;
}
.ttab-x:hover {
  color: var(--fg);
  background: var(--fill-active);
}
.ttab-add {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-md);
  color: var(--fg-3);
}
.ttab-add:hover {
  color: var(--fg);
  background: var(--fill-quiet);
}
.ttab-add .ic { width: 13px; height: 13px; }
.tlayout { flex: none; }
.tlayout .seg {
  display: grid;
  place-items: center;
  width: 30px;
  padding: 0;
}
.tlayout .seg .ic { width: 14px; height: 14px; }

/* The right-hand switches share one row; the tabs give up width first. */
.tbar > .segmented + .segmented { margin-left: var(--s2); }

/* Loading veil: covers a pane until its terminal page reports live, so a
   stalled or blank load never looks like a hung panel. Positioned exactly
   like the iframe of the same pane (see the data-pane rules above). */
.term-veil {
  position: absolute;
  top: var(--top);
  left: var(--pad);
  right: var(--pad);
  bottom: var(--pad);
  width: calc(100% - 2 * var(--pad));
  height: calc(100% - var(--top) - var(--pad));
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-lg);
  background: #fbfbfb;
  box-shadow: 0 0 0 0.5px var(--hairline);
  z-index: 2;
}
[data-theme='dark'] .term-veil {
  background: #101317;
}
.term-stage[data-mode='cols'] .term-veil[data-pane='0'],
.term-stage[data-mode='cols'] .term-veil[data-pane='1'] {
  width: calc((100% - 2 * var(--pad) - var(--gap)) / 2);
}
.term-stage[data-mode='cols'] .term-veil[data-pane='0'] { right: auto; }
.term-stage[data-mode='cols'] .term-veil[data-pane='1'] { left: auto; }
.term-stage[data-mode='rows'] .term-veil[data-pane='0'],
.term-stage[data-mode='rows'] .term-veil[data-pane='1'] {
  height: calc((100% - var(--top) - var(--pad) - var(--gap)) / 2);
}
.term-stage[data-mode='rows'] .term-veil[data-pane='0'] { bottom: auto; }
.term-stage[data-mode='rows'] .term-veil[data-pane='1'] { top: auto; }
.term-veil .conn-card {
  width: min(400px, calc(100% - 2 * var(--s6)));
  padding: var(--s6);
  border-radius: var(--r-xl);
  background: var(--bg);
  box-shadow: 0 0 0 0.5px var(--hairline), 0 12px 32px rgb(0 0 0 / 0.18);
}
.term-veil .title {
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.term-veil .hint {
  margin-top: var(--s3);
}
.term-veil code {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: var(--fs-1);
}
.term-veil .conn-actions {
  display: flex;
  gap: var(--s3);
  margin-top: var(--s4);
}
.term-veil .spin {
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--fill-active);
  border-top-color: var(--fg-2);
  animation: connspin 0.8s linear infinite;
}
@keyframes connspin {
  to { transform: rotate(360deg); }
}

/* Boot steps — a card on the field, state dots inside. */
.boot {
  margin: auto;
  width: min(380px, 100%);
  padding: var(--s6);
  border-radius: var(--r-xl);
  background: var(--bg);
}
.boot .title {
  margin-bottom: var(--s4);
}
.bstep {
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: 30px;
  font-size: var(--fs-2);
  color: var(--fg-3);
}
.bstep .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-4);
  flex: none;
}
.bstep[data-st='active'] {
  color: var(--fg);
}
.bstep[data-st='active'] .dot {
  background: var(--accent);
}
.bstep[data-st='done'] {
  color: var(--fg-2);
}
.bstep[data-st='done'] .dot {
  background: var(--ok);
}

/* ── log ──────────────────────────────────────────────────── */
#view-log .row {
  grid-template-columns: 76px minmax(0, 1fr);
  height: auto;
  min-height: 32px;
  padding-block: 5px;
  cursor: default;
}
#view-log .row:hover {
  background: none;
}
.log-t {
  font-family: var(--mono);
  font-size: var(--fs-1);
  color: var(--fg-4);
}
.log-m {
  font-size: var(--fs-2);
  color: var(--fg-2);
  overflow-wrap: anywhere;
}
.row[data-kind='warn'] .log-m {
  color: var(--warn);
}
.row[data-kind='error'] .log-m {
  color: var(--crit);
}

/* ── details ──────────────────────────────────────────────── */
.mark-gloss {
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
#view-machines .cell-mark {
  min-width: 0;
}
.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Narrow screen: a few lines per machine — name and status; the rest lives in the terminal. */
@media (max-width: 900px) {
  #view-machines .row {
    grid-template-areas: 'lead act' 'mark mark' 'addr addr';
    align-items: center;
  }
  #view-machines .row > .cell-lead {
    grid-area: lead;
  }
  #view-machines .row > .cell-mark {
    grid-area: mark;
  }
  #view-machines .row > .cell-act {
    grid-area: act;
  }
  #view-machines .row > .cell {
    display: none;
  }
  #view-machines .row > :nth-child(3) {
    display: flex;
    grid-area: addr;
    min-width: 0;
  }
  /* No hover on touch screens — the actions button is always visible. */
  .row-more {
    opacity: 1;
  }
  .term-stage {
    --pad: 0px;
    --gap: 2px;
    padding: 0;
  }
  .term-stage iframe {
    border-radius: 0;
  }
  .tbar {
    padding: 0 var(--s2);
  }
}

@media (max-width: 520px) {
  #sb-hub,
  #sb-month,
  .statusbar .sep-month {
    display: none;
  }
  /* The uikit hides optional toolbar switches on phones; the layout switcher
     is the only way back from a split, so it stays (icon-only, compact). */
  .tbar .segmented.tlayout {
    display: inline-flex;
  }
}

/* ── login ──────────────────────────────────────────────────
   A full-screen gate rather than a sheet: until the password is entered there
   is nothing behind it, and the panel must not look half-loaded. */
.login-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: var(--s6);
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 21rem;
  padding: var(--s6);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  background: var(--bg-sidebar);
  box-shadow: var(--shadow-pop);
}
.login-card .mark {
  width: 1.75rem;
  height: 1.75rem;
  color: var(--accent);
}
.login-title {
  margin: var(--s3) 0 var(--s2);
  font-size: var(--fs-3);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.login-sub {
  margin: 0 0 var(--s5);
  color: var(--fg-3);
  font-size: var(--fs-1);
  line-height: 1.5;
}
.login-msg {
  min-height: 1.25rem;
  margin: var(--s2) 0 var(--s3);
  color: var(--crit);
  font-size: var(--fs-1);
}
.login-card .act-btn { width: 100%; justify-content: center; }

/* A quiet verb next to a field label: measuring the regions is an action the
   form offers, not a control competing with the inputs. */
.lbl-btn {
  border: 0;
  background: none;
  padding: 0;
  margin-left: 8px;
  font: inherit;
  font-size: var(--fs-1);
  font-weight: 450;
  color: var(--accent);
  cursor: pointer;
}
.lbl-btn:hover { text-decoration: underline; }
.lbl-btn[disabled] { color: var(--fg-4); cursor: default; text-decoration: none; }

/* ── usage ────────────────────────────────────────────────── */
#view-usage {
  --grid: 132px minmax(96px, 0.5fr) minmax(90px, 0.6fr) 64px 110px 72px minmax(110px, 0.7fr);
}
#view-usage .row {
  height: auto;
  min-height: 36px;
  padding-block: 6px;
  cursor: default;
  font-size: var(--fs-2);
}
#view-usage .row:hover {
  background: none;
}
#view-usage .row[data-live='true'] {
  color: var(--fg);
}
#view-usage .row .dot {
  display: inline-block;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--ok);
}
.usage-sum {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s3);
  padding: var(--s3) var(--s3) var(--s2);
}
.us-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  min-width: 0;
}
.us-v {
  font-size: var(--fs-4);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.us-l {
  font-size: var(--fs-1);
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.usage-chart {
  padding: var(--s3) var(--s3) var(--s4);
}
.ub-bars {
  display: grid;
  grid-template-columns: repeat(30, minmax(0, 1fr));
  gap: 3px;
  height: 72px;
  align-items: end;
}
.ub {
  position: relative;
  height: 100%;
  border-radius: 3px;
  background: var(--fill-quiet);
  overflow: hidden;
}
.ub i {
  position: absolute;
  inset: auto 0 0;
  display: block;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height var(--dur) var(--ease);
}
.ub[data-today='true'] {
  outline: 1px solid var(--hairline-strong);
  outline-offset: -1px;
}
.ub:hover {
  background: var(--fill-hover);
}
.ub-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: var(--fs-1);
  color: var(--fg-4);
}

/* ── files drawer (the inspector column) ─────────────────── */
.fi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  height: 44px;
  padding: 0 var(--s3) 0 var(--s5);
  border-bottom: 1px solid var(--hairline);
  flex: none;
}
.fi-title {
  font-weight: 600;
  font-size: var(--fs-2);
}
.fi-acts {
  display: inline-flex;
  gap: 2px;
}
.fi-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: var(--s2) var(--s4);
  font-size: var(--fs-1);
  color: var(--fg-3);
  border-bottom: 1px solid var(--hairline);
  flex: none;
}
.fi-crumb {
  padding: 2px 5px;
  border-radius: var(--r-sm);
  color: var(--fg-3);
  font: inherit;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fi-crumb:hover {
  background: var(--fill-hover);
  color: var(--fg);
}
.fi-crumb[aria-current='true'] {
  color: var(--fg);
}
.fi-sep {
  color: var(--fg-4);
}
.fi-scroll {
  padding: var(--s2) var(--s2) var(--s4);
}
.fi-row {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--r-md);
}
.fi-row:hover {
  background: var(--fill-hover);
}
.fi-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 32px;
  padding: 0 var(--s2) 0 var(--s3);
  text-align: left;
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-2);
  border-radius: var(--r-md);
}
.fi-main svg {
  flex: none;
  color: var(--fg-3);
}
.fi-row[data-type='dir'] .fi-main svg {
  color: var(--accent);
}
.fi-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fi-meta {
  flex: none;
  font-size: var(--fs-1);
  font-variant-numeric: tabular-nums;
}
.fi-hover {
  display: none;
  align-items: center;
  gap: 2px;
  padding-right: var(--s1);
}
.fi-row:hover .fi-hover,
.fi-row:focus-within .fi-hover {
  display: inline-flex;
}
.fi-row:hover .fi-meta {
  display: none;
}
.fi-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  border-radius: var(--r-sm);
  color: var(--fg-3);
  font: inherit;
  font-size: var(--fs-1);
}
.fi-act:hover {
  background: var(--fill-active);
  color: var(--fg);
}
.fi-act.fi-del {
  color: var(--crit);
  font-weight: 600;
}
.fi-note {
  padding: var(--s3) var(--s3);
  font-size: var(--fs-2);
  line-height: 1.45;
}
.fi-note[data-tone='crit'] {
  color: var(--crit);
}
.fi-jobs {
  flex: none;
  padding: var(--s2) var(--s3);
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.fi-job {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
  padding: 4px 6px 7px;
  font-size: var(--fs-1);
  overflow: hidden;
  border-radius: var(--r-sm);
}
.fi-job-n {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fi-job i {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  transition: width 200ms linear;
}
.fi-job[data-state='done'] i {
  background: var(--ok);
}
.fi-job[data-state='error'] i {
  background: var(--crit);
  width: 100% !important;
}
.fi-foot {
  flex: none;
  padding: var(--s2) var(--s4);
  font-size: var(--fs-1);
  border-top: 1px solid var(--hairline);
  min-height: 30px;
}

/* ── drop target ─────────────────────────────────────────── */
body.dragging .term-stage iframe {
  pointer-events: none;
}
.drop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(2px);
}
.drop-card {
  padding: var(--s5) var(--s7);
  border: 1.5px dashed var(--accent);
  border-radius: var(--r-xl);
  background: var(--bg);
  text-align: center;
  box-shadow: var(--shadow-pop);
}
.drop-t {
  font-size: var(--fs-4);
  font-weight: 600;
}
.drop-s {
  margin-top: 4px;
  font-size: var(--fs-1);
  color: var(--fg-3);
}

@media (max-width: 900px) {
  /* The inspector column collapses on narrow screens; the files drawer
     comes in over the terminal instead. */
  .window[data-inspector='true'] .inspector {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(100vw, 360px);
    z-index: 30;
    box-shadow: var(--shadow-pop);
  }
  #view-usage .row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 'when host' 'dur cost' 'ended ended';
    row-gap: 2px;
  }
  #view-usage .row > :nth-child(1) { grid-area: when; }
  #view-usage .row > :nth-child(2) { grid-area: host; text-align: right; }
  #view-usage .row > :nth-child(3),
  #view-usage .row > :nth-child(4) { display: none; }
  #view-usage .row > :nth-child(5) { grid-area: dur; }
  #view-usage .row > :nth-child(6) { grid-area: cost; text-align: right; }
  #view-usage .row > :nth-child(7) { grid-area: ended; }
  #usage-head { display: none; }
  .usage-sum {
    grid-template-columns: 1fr;
  }
}

/* Toolbar buttons never wrap; the title yields (it has its own ellipsis). */
.tb-right .quiet-btn {
  white-space: nowrap;
}

/* inline rename */
.fi-editing .fi-main {
  cursor: default;
}
.fi-input {
  flex: 1;
  min-width: 0;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--field);
  color: var(--fg);
  font-size: var(--fs-2);
  outline: none;
}

/* ── editor / preview over the terminal frames ───────────── */
/* Same inset as the frames, so it reads as a card that slid over the
   terminal; the frames stay mounted underneath and keep their size. */
.editor {
  position: absolute;
  top: var(--pad);
  left: var(--pad);
  right: var(--pad);
  bottom: var(--pad);
  z-index: 3;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--r-lg);
  background: var(--bg);
  box-shadow: 0 0 0 0.5px var(--hairline);
  overflow: hidden;
}
.editor[hidden] { display: none; }
.term-stage[data-editor='true'] .tbar { visibility: hidden; }
.ed-bar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 40px;
  padding: 0 var(--s2) 0 var(--s2);
  border-bottom: 1px solid var(--hairline);
  flex: none;
  min-width: 0;
}
.ed-back { flex: none; padding-left: var(--s2); }
.ed-back .ic { width: 13px; height: 13px; }
.ed-tabs {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ed-tabs::-webkit-scrollbar { display: none; }
.ed-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 4px 0 10px;
  border-radius: var(--r-md);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
  max-width: 220px;
  flex: none;
}
.ed-tab:hover { background: var(--fill-hover); color: var(--fg); }
.ed-tab[aria-selected='true'] { background: var(--fill-select); color: var(--fg); }
.ed-tab-n { overflow: hidden; text-overflow: ellipsis; }
.ed-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  flex: none;
}
.ed-tab-x {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--r-sm);
  color: var(--fg-4);
}
.ed-tab-x .ic { width: 11px; height: 11px; }
.ed-tab-x:hover { background: var(--fill-active); color: var(--fg); }
.ed-status {
  flex: none;
  font-size: var(--fs-1);
  color: var(--fg-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ed-acts { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.ed-save { height: 26px; padding: 0 var(--s3); font-size: var(--fs-1); }
.ed-save[disabled] { opacity: 0.35; cursor: default; }
.ed-save[hidden] { display: none; }
.ed-msg {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--warn-fill);
  font-size: var(--fs-2);
  border-bottom: 1px solid var(--hairline);
  flex: none;
}
.ed-msg [data-tone='crit'] { color: var(--crit); }
.ed-msg > span { flex: 1; min-width: 0; }
.ed-msg .quiet-btn { white-space: nowrap; flex: none; }
.ed-body { flex: 1; min-height: 0; position: relative; }
.ed-host { position: absolute; inset: 0; overflow: hidden; }
.ed-host[hidden] { display: none; }
.ed-host .cm-editor { height: 100%; font-size: 0.8125rem; }
.ed-host .cm-editor.cm-focused { outline: none; }
.ed-host .cm-scroller { font-family: var(--mono); line-height: 1.5; }
.ed-host .cm-gutters { font-size: 0.75rem; }
.ed-plain {
  width: 100%;
  height: 100%;
  padding: var(--s3) var(--s4);
  border: 0;
  resize: none;
  background: transparent;
  color: var(--fg);
  font-size: 0.8125rem;
  line-height: 1.5;
  outline: none;
  tab-size: 4;
}
.ed-center {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
  overflow: auto;
}
.ed-img { background: repeating-conic-gradient(var(--fill-quiet) 0 25%, transparent 0 50%) 0 0 / 20px 20px; }
.ed-img img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 0 0 0.5px var(--hairline); }
.ed-frame { width: 100%; height: 100%; border: 0; background: var(--field); }
.ed-media { max-width: 100%; max-height: 100%; }
.ed-card {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: var(--s2);
  max-width: 520px;
  margin: 0 auto;
  font-size: var(--fs-2);
  line-height: 1.5;
}
.ed-card p { margin: 0; }
.ed-card [data-tone='crit'] { color: var(--crit); }
.ed-card-t {
  font-family: var(--mono);
  font-weight: 600;
  font-size: var(--fs-3);
  word-break: break-all;
  margin-bottom: var(--s2) !important;
}
.ed-kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--s3);
  padding: 5px 0;
  border-top: 1px solid var(--hairline);
  word-break: break-all;
}
.ed-card-acts { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3) !important; }
.ed-card-acts .quiet-btn { text-decoration: none; }

/* files rows: open-in-editor marker, persistent confirm */
.fi-row[data-open='true'] .fi-name::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
.fi-hover.fi-hover-on { display: inline-flex; }
.fi-row.fi-confirm { background: var(--crit-fill); }

@media (max-width: 720px) {
  .ed-status { display: none; }
  .ed-back span, .ed-back { font-size: 0; gap: 0; padding: 0 var(--s2); }
  .ed-back .ic { width: 15px; height: 15px; }
  .ed-kv { grid-template-columns: 90px 1fr; }
}
/* The editor sits on the panel background in both themes (the bundled
   dark theme brings its own; override so the card reads as one surface). */
.ed-host .cm-editor,
.ed-host .cm-editor .cm-gutters { background: var(--bg); }
.ed-host .cm-editor .cm-gutters { border-right-color: var(--hairline); }

/* ── Windows desktop pane ─────────────────────────────────── */
/* Same box as a terminal frame: below the bar, inset by --pad. The desk is a
   focusable div (the keyboard listener lives on it); the display canvas is
   centred inside and scaled to fit while the machine adopts the new size. */
.term-stage .desk {
  position: absolute;
  top: var(--top);
  left: var(--pad);
  right: var(--pad);
  bottom: var(--pad);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* a desktop is a rectangle: rounded corners would clip Windows' own corners */
  border-radius: 0;
  background: #101317;
  box-shadow: 0 0 0 0.5px var(--hairline);
  outline: none;
  cursor: default;
}
.desk-kb {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  resize: none;
  overflow: hidden;
  pointer-events: none;
}
.term-stage .desk.off {
  visibility: hidden;
  pointer-events: none;
  z-index: -1;
}
.desk-view {
  position: relative;
  line-height: 0;
}
/* the library sizes its own element; keep the browser from adding scroll or select */
.desk-view > div {
  user-select: none;
  -webkit-user-select: none;
}
.desk-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 4px;
  font-size: 0.75rem;
  color: var(--fg-2);
  white-space: nowrap;
}
.desk-title .ic { width: 16px; height: 16px; flex: none; }
.tbar .tdesk .seg:disabled {
  opacity: 0.45;
  cursor: default;
}
.os-badge {
  flex: none;
  margin-left: var(--s2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-2);
  background: var(--fill-quiet);
  box-shadow: 0 0 0 0.5px var(--hairline);
}
.os-seg .seg {
  flex: 1;
  text-align: center;
}

/* ── drag-and-drop in the files drawer ───────────────────── */
/* While files are dragged in from outside, the drawer rises above the
   full-window overlay so a folder row or a breadcrumb can take the drop. */
body.dragging .inspector {
  z-index: 41;
}
@media (min-width: 901px) {
  body.dragging .inspector { position: relative; }
}
.fi-row[draggable='true'] { cursor: default; }
.fi-row.fi-dragging { opacity: 0.45; }
.fi-row.fi-over,
.fi-crumb.fi-over {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.inspector.fi-over .fi-scroll {
  box-shadow: inset 0 0 0 1.5px var(--accent);
  border-radius: var(--r-md);
}

/* ── profiles ─────────────────────────────────────────────────
   A profile is text: a manifest one can read and correct. The view is
   therefore a list of documents, not a form - the same reason the editor
   elsewhere in the panel shows files rather than fields. */
#view-profiles {
  padding: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.prow {
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.prow-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s3) var(--s3) var(--s4);
  cursor: pointer;
  min-width: 0;
}
.prow-head:hover {
  background: var(--fill-quiet);
}
.prow-name {
  font-size: var(--fs-2);
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prow-meta {
  font-size: var(--fs-1);
  color: var(--fg-3);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prow-body {
  border-top: 1px solid var(--hairline);
  padding: var(--s3) var(--s4) var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.prow-body .pname {
  font-family: inherit;
  font-size: var(--fs-2);
  font-weight: 560;
}
.prow-body textarea {
  width: 100%;
  min-height: 220px;
  padding: var(--s3);
  border: 0;
  border-radius: var(--r-md);
  background: var(--field);
  color: var(--fg);
  font-family: var(--mono);
  font-size: var(--fs-1);
  line-height: 1.5;
  resize: vertical;
  tab-size: 2;
}
.prow-body textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.prow-acts {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}
.prow-acts .select-wrap {
  min-width: 170px;
}
.prow-note {
  font-size: var(--fs-1);
  color: var(--fg-3);
  line-height: 1.5;
}
.prow-note[data-tone='crit'] {
  color: var(--crit);
}
.prow-note[data-tone='ok'] {
  color: var(--ok);
}
.pver {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--fs-1);
  color: var(--fg-2);
}
.pver-on {
  color: var(--fg);
  font-weight: 560;
}

/* files: multi-selection (Ctrl/Shift-click, Ctrl+A) and its footer bar */
.fi-row.fi-picked,
.fi-row.fi-picked:hover {
  background: var(--accent-fill);
}
.fi-row.fi-picked .fi-main svg { color: var(--accent); }
.fi-foot.fi-foot-pick {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding-top: 3px;
  padding-bottom: 3px;
  color: var(--fg-2);
}
.fi-pick-n { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.fi-pick-acts { display: inline-flex; align-items: center; gap: 4px; }
.fi-pick-acts .quiet-btn { height: 24px; padding: 0 var(--s2); font-family: var(--mono); font-weight: 500; }
.fi-pick-acts .quiet-btn[data-fip='clear'] { padding: 0 5px; font-family: inherit; }
.fi-pick-acts .quiet-btn[data-fip='rm'] { font-family: inherit; }
.fi-pick-acts .fi-pick-del { color: var(--crit); background: var(--crit-fill); }
