/* The app chrome uses neutral grays so it does not compete with the theme being edited. */
:root {
  --ui-bg: #0f1110;
  --ui-panel: #161917;
  --ui-surface: #1e2220;
  --ui-line: #2c312e;
  --ui-line-strong: #3d4440;
  --ui-text: #e4e7e2;
  --ui-dim: #a7ada6;
  --ui-muted: #7b827b;
  --ui-accent: #ffae2b;
  --ui-accent-ink: #14110a;
  --ui-ok: #4fd18b;
  --ui-warn: #f2c14e;
  --ui-bad: #ff6b5b;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --display: "Space Grotesk", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ui-bg);
  color: var(--ui-text);
  font: 13px/1.45 var(--mono);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
[hidden] { display: none !important; }

/* top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--ui-line);
  background: var(--ui-panel);
  min-height: 46px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  color: var(--ui-dim);
  white-space: nowrap;
}
.brand-mark { width: 28px; height: 28px; flex: none; }
.title-fields { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.name-input, .desc-input {
  background: transparent;
  border: 1px solid transparent;
  padding: 1px 6px;
  min-width: 0;
  width: 100%;
}
.name-input { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--ui-text); }
.desc-input { font-size: 12px; color: var(--ui-muted); }
.name-input:hover, .desc-input:hover { border-color: var(--ui-line); }
.name-input:focus, .desc-input:focus { border-color: var(--ui-line-strong); outline: none; background: var(--ui-bg); }
.actions { display: flex; align-items: center; gap: 6px; }
.save-state { color: var(--ui-muted); font-size: 11px; margin-right: 6px; white-space: nowrap; }
.save-state.dirty { color: var(--ui-warn); }

.btn {
  background: var(--ui-surface);
  border: 1px solid var(--ui-line-strong);
  color: var(--ui-text);
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ui-dim); }
.btn:disabled { opacity: 0.4; cursor: default; border-color: var(--ui-line); }
.btn.primary { background: var(--ui-accent); color: var(--ui-accent-ink); border-color: var(--ui-accent); font-weight: 800; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn.icon { padding: 4px 9px; font-size: 15px; line-height: 1.2; }

.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 250px;
  max-height: 70vh;
  overflow: auto;
  background: var(--ui-panel);
  border: 1px solid var(--ui-line-strong);
  box-shadow: 0 10px 30px rgb(0 0 0 / 45%);
  padding: 4px 0;
}
.menu button {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 7px 12px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--ui-surface); outline: none; }
.menu button small { color: var(--ui-muted); }
.menu hr { border: 0; border-top: 1px solid var(--ui-line); margin: 4px 0; }
.menu .menu-head { padding: 6px 12px 2px; font-size: 10.5px; letter-spacing: 1px; color: var(--ui-muted); }

/* layout */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 300px;
  flex: none;
  border-right: 1px solid var(--ui-line);
  background: var(--ui-panel);
  overflow-y: auto;
}
.panel { padding: 10px 12px 12px; border-bottom: 1px solid var(--ui-line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.new-row { display: flex; gap: 4px; }
.btn.ico { padding: 4px 6px; line-height: 0; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.icon svg { vertical-align: -2px; }
.btn.danger { background: var(--ui-bad); color: var(--ui-accent-ink); border-color: var(--ui-bad); font-weight: 800; }
.btn.danger:hover { filter: brightness(1.08); }
.ask-text { margin: 0; color: var(--ui-dim); }
.history-menu { min-width: 300px; max-width: 360px; }
.history-menu button span { display: flex; align-items: center; gap: 8px; min-width: 0; }
.history-menu button b { font-weight: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-menu .chip { width: 12px; height: 12px; flex: none; border: 1px solid var(--ui-line-strong); }
.history-menu .now { color: var(--ui-accent); font-weight: 700; }
.history-menu .now small { color: var(--ui-accent); }
.history-menu .redo { color: var(--ui-muted); }
.panel h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ui-muted); }

.theme-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.theme-item { display: flex; align-items: center; gap: 4px; }
.theme-item .pick {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  background: none;
  text-align: left;
  cursor: pointer;
}
.theme-item .pick:hover { background: var(--ui-surface); }
.theme-item.active .pick { border-color: var(--ui-line-strong); background: var(--ui-surface); }
.theme-item .tname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-item.active .tname { color: var(--ui-accent); font-weight: 600; }
.stripe { display: flex; height: 6px; }
.stripe i { flex: 1; }
.theme-item .del { background: none; border: 0; color: var(--ui-muted); cursor: pointer; padding: 4px 8px; font-size: 14px; }
.theme-item .del:hover { color: var(--ui-bad); }

.slot-group + .slot-group { margin-top: 12px; }
.slot-group h3 { margin: 0 0 4px; font-size: 11px; font-weight: 400; color: var(--ui-dim); display: flex; align-items: center; justify-content: space-between; }
.slot {
  display: grid;
  grid-template-columns: 30px 1fr 86px;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  margin: 0 -4px;
}
.slot.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgb(255 174 43 / 30%); } to { background: transparent; } }
.swatch {
  position: relative;
  width: 30px;
  height: 26px;
  border: 1px solid var(--ui-line-strong);
  cursor: pointer;
}
.swatch { padding: 0; }
.swatch:hover { border-color: var(--ui-dim); }
.swatch[aria-expanded="true"] { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.slot .meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.slot .nm { font-size: 12px; }
.slot .nm b { font-weight: 600; }
.slot .nm span { color: var(--ui-muted); }
.slot .role { font-size: 10.5px; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .hex {
  width: 100%;
  background: var(--ui-bg);
  border: 1px solid var(--ui-line);
  padding: 3px 6px;
  font-size: 12px;
}
.slot .hex:focus { border-color: var(--ui-dim); outline: none; }
.slot .hex.bad { border-color: var(--ui-bad); }
.slot.pv { background: rgb(255 174 43 / 9%); box-shadow: inset 2px 0 var(--ui-accent); }
.slot.pv .hex { color: var(--ui-accent); }
.slot input:disabled { cursor: default; }

/* color picker */
.picker {
  position: fixed;
  inset: auto;
  margin: 0;
  z-index: 40;
  width: 300px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 10px 12px 12px;
  background: var(--ui-panel);
  color: var(--ui-text);
  border: 1px solid var(--ui-line-strong);
  box-shadow: 0 14px 40px rgb(0 0 0 / 55%);
  flex-direction: column;
  gap: 8px;
}
.picker[open] { display: flex; }
.pk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pk-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.pk-name b { font-family: var(--display); font-size: 14px; }
.pk-name span { font-size: 11px; color: var(--ui-muted); }
.pk-x { background: none; border: 0; color: var(--ui-muted); cursor: pointer; font-size: 16px; padding: 0 4px; line-height: 1; }
.pk-x:hover { color: var(--ui-text); }
.pk-cmp { display: flex; align-items: center; gap: 8px; }
.pk-pair { display: flex; border: 1px solid var(--ui-line-strong); flex: none; }
.pk-pair > * { display: block; width: 28px; height: 26px; }
.pk-was { border: 0; padding: 0; cursor: pointer; }
.pk-was:hover { box-shadow: inset 0 0 0 2px rgb(255 255 255 / 35%); }
.pk-cmp .hex { width: 86px; background: var(--ui-bg); border: 1px solid var(--ui-line); padding: 3px 6px; font-size: 12px; }
.pk-cmp .hex:focus { border-color: var(--ui-dim); outline: none; }
.pk-cmp .hex.bad { border-color: var(--ui-bad); }
.pk-ratio { margin-left: auto; font-size: 11.5px; color: var(--ui-dim); font-variant-numeric: tabular-nums; }
.pk-area { position: relative; height: 132px; border: 1px solid var(--ui-line); cursor: crosshair; touch-action: none; }
.pk-area canvas { display: block; width: 100%; height: 100%; }
.pk-thumb {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 70%), 0 1px 4px rgb(0 0 0 / 50%);
  pointer-events: none;
}
.pk-area:focus-visible { outline-offset: 2px; }
.pk-hue {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 12px;
  margin: 0;
  border: 1px solid var(--ui-line);
  background: linear-gradient(to right, #ed86a7, #f28979, #e6964f, #cba63a, #a0b751, #69c27e, #1dc5ae, #23bfd5, #52b5f4, #8ba6fd, #b897f0, #d98cd2, #ed86a7);
  cursor: pointer;
}
.pk-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 8px; height: 16px; background: #fff; border: 1px solid #000; }
.pk-hue::-moz-range-thumb { width: 6px; height: 14px; background: #fff; border: 1px solid #000; border-radius: 0; }
.pk-read { font-size: 10.5px; color: var(--ui-muted); font-variant-numeric: tabular-nums; margin-top: -2px; }
.pk-sugs { display: flex; flex-direction: column; gap: 8px; }
.pk-sec h4 { margin: 0 0 3px; font-size: 10.5px; font-weight: 400; letter-spacing: 0.8px; text-transform: uppercase; color: var(--ui-muted); }
.pk-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.pk-chip { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 0; background: none; border: 0; cursor: pointer; color: var(--ui-dim); }
.pk-chip i { display: block; width: 100%; height: 22px; border: 1px solid var(--ui-line-strong); }
.pk-chip small { font-size: 9.5px; line-height: 1.2; white-space: nowrap; overflow: hidden; max-width: 100%; }
.pk-chip:hover i, .pk-chip:focus-visible i { border-color: var(--ui-text); }
.pk-chip:focus-visible { outline: none; }
.pk-chip[aria-pressed="true"] i { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.pk-chip[aria-pressed="true"] small { color: var(--ui-accent); }
.pk-sec.contrast .pk-row { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pk-sec.contrast .pk-chip i { height: 26px; display: grid; place-items: center; font: 700 13px/1 var(--display); font-style: normal; }
.pk-sec.contrast .pk-chip[aria-pressed="true"] i { outline: none; }
.pk-sec.ladder .pk-row { gap: 0; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
.pk-sec.ladder .pk-chip i { height: 18px; border-width: 1px 0; }
.pk-sec.ladder .pk-chip:first-child i { border-left-width: 1px; }
.pk-sec.ladder .pk-chip:last-child i { border-right-width: 1px; }
.pk-actions { display: flex; justify-content: flex-end; gap: 6px; }

/* wand */
.wand-btn { padding: 2px 4px; color: var(--ui-dim); }
.wand-btn svg { width: 13px; height: 13px; }
.wand-btn[aria-expanded="true"] { border-color: var(--ui-accent); color: var(--ui-accent); }
.wand-panel { border: 1px solid var(--ui-accent); background: var(--ui-bg); padding: 10px; margin: 4px 0 8px; display: flex; flex-direction: column; gap: 8px; }
.wand-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; }
.wand-card { flex: none; width: 52px; height: 38px; padding: 6px 5px; border: 1px solid var(--ui-line-strong); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.wand-card:hover { border-color: var(--ui-dim); }
.wand-card[aria-selected="true"] { outline: 2px solid var(--ui-accent); outline-offset: 1px; }
.wc-ramp { display: flex; width: 100%; height: 100%; }
.wc-ramp i { flex: 1; }
.wc-dots { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.wc-dots i { width: 8px; height: 8px; border-radius: 50%; }
.wand-sentinel { flex: none; width: 1px; }
.wand-field { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; font-size: 12px; color: var(--ui-dim); }
.wand-field output { color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.wand-field.set output { color: var(--ui-text); }
.wand-field input { grid-column: 1 / -1; accent-color: var(--ui-accent); margin: 2px 0 0; }
.wand-diff { display: flex; flex-wrap: wrap; gap: 6px; }
.wand-sw { display: flex; align-items: center; gap: 0; font-size: 10.5px; color: var(--ui-muted); }
.wand-sw i { width: 14px; height: 14px; display: block; border: 1px solid var(--ui-line-strong); }
.wand-sw i + i { border-left: 0; }
.wand-sw small { margin-left: 4px; font-size: inherit; }
.wand-none { font-size: 11.5px; color: var(--ui-muted); }
.wand-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.wand-actions > span { display: flex; gap: 6px; }
.wand-end { margin-left: auto; }

.contrast { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.contrast li { display: grid; grid-template-columns: 54px 1fr auto auto; gap: 8px; align-items: center; }
.contrast .pair { height: 18px; font-size: 11px; display: flex; align-items: center; justify-content: center; font-weight: 600; border: 1px solid var(--ui-line); }
.contrast .lbl { color: var(--ui-dim); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.contrast .ratio { font-variant-numeric: tabular-nums; }
.badge { font-size: 10px; padding: 0 5px; border: 1px solid currentColor; }
.badge.ok { color: var(--ui-ok); }
.badge.mid { color: var(--ui-warn); }
.badge.bad { color: var(--ui-bad); }

/* main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewtabs { display: flex; gap: 0; padding: 0 14px; border-bottom: 1px solid var(--ui-line); background: var(--ui-panel); }
.viewtabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 6px 14px 5px;
  color: var(--ui-dim);
  cursor: pointer;
}
.viewtabs button[aria-selected="true"] { color: var(--ui-text); border-bottom-color: var(--ui-accent); }
.view { flex: 1; min-height: 0; overflow: auto; }

/* files view */
.files { display: flex; overflow: hidden; }
.app-list { list-style: none; margin: 0; padding: 8px; width: 270px; flex: none; overflow-y: auto; border-right: 1px solid var(--ui-line); }
.app-list button {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  padding: 7px 10px;
  cursor: pointer;
}
.app-list button:hover { background: var(--ui-surface); }
.app-list button[aria-current="true"] { background: var(--ui-surface); border-color: var(--ui-line-strong); }
.app-list .al { font-weight: 600; }
.app-list button[aria-current="true"] .al { color: var(--ui-accent); }
.app-list .ad { font-size: 11px; color: var(--ui-muted); }
.file-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 8px 12px 0; border-bottom: 1px solid var(--ui-line); flex-wrap: wrap; }
.file-tabs { display: flex; flex-wrap: wrap; gap: 2px; }
.file-tabs button {
  background: none;
  border: 1px solid transparent;
  border-bottom: 0;
  padding: 5px 10px;
  color: var(--ui-dim);
  cursor: pointer;
  font-size: 12px;
}
.file-tabs button[aria-selected="true"] { background: var(--ui-bg); color: var(--ui-text); border-color: var(--ui-line); margin-bottom: -1px; }
.file-actions { display: flex; gap: 6px; padding-bottom: 6px; }
.file-actions .btn { display: inline-flex; align-items: center; gap: 5px; }
.file-actions .btn[hidden] { display: none; }
.file-body { flex: 1; overflow: auto; background: var(--ui-bg); }
.file-body pre { margin: 0; padding: 10px 0; font: 12.5px/1.55 var(--mono); counter-reset: ln; }
.file-body .fl { display: block; padding: 0 16px 0 0; white-space: pre; }
.file-body .fl::before {
  counter-increment: ln;
  content: counter(ln);
  display: inline-block;
  width: 52px;
  padding-right: 14px;
  text-align: right;
  color: var(--ui-line-strong);
  user-select: none;
}
.chip { display: inline-block; width: 10px; height: 10px; margin-right: 4px; border: 1px solid rgb(255 255 255 / 25%); vertical-align: -1px; }
.file-note { padding: 10px 16px; color: var(--ui-muted); border-bottom: 1px solid var(--ui-line); }
.asset-grid { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--ui-line); background: var(--ui-panel); }
.asset-grid img { image-rendering: pixelated; background: var(--asset-bg, #151f12); padding: 4px; }

/* dialog */
.dialog { background: var(--ui-panel); color: var(--ui-text); border: 1px solid var(--ui-line-strong); padding: 0; width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgb(0 0 0 / 60%); }
.dialog form { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.dialog h2 { margin: 0; font-family: var(--display); font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; border: 0; padding: 0; margin: 0; }
.field > span, .field legend { font-size: 12px; color: var(--ui-dim); }
.field input:not([type="radio"]):not([type="range"]) { background: var(--ui-bg); border: 1px solid var(--ui-line-strong); padding: 6px 8px; }
.field input[type="range"] { accent-color: var(--ui-accent); }
.seg { flex-direction: row; gap: 16px; }
.seg legend { margin-bottom: 4px; }
.gen-preview { display: grid; grid-template-columns: repeat(11, 1fr); height: 34px; border: 1px solid var(--ui-line); }
.dialog.wide { width: min(720px, calc(100vw - 32px)); }
.preset-filter { background: var(--ui-bg); border: 1px solid var(--ui-line-strong); padding: 6px 8px; }
.preset-list { max-height: min(60vh, 560px); overflow-y: auto; }
.preset-list h3 { margin: 4px 0 6px; font-size: 11px; font-weight: 400; color: var(--ui-dim); }
.preset-list h3 + .preset-grid { margin-bottom: 12px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.preset { display: flex; flex-direction: column; gap: 3px; padding: 8px 9px; border: 1px solid var(--ui-line-strong); text-align: left; cursor: pointer; }
.preset:hover, .preset:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: -1px; }
.preset .pn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset .pb { font-size: 11px; }
.preset .stripe { margin-top: 3px; }
.preset-none { color: var(--ui-muted); margin: 8px 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.drop { position: fixed; inset: 0; z-index: 50; background: rgb(15 17 16 / 85%); display: grid; place-items: center; }
.drop div { border: 2px dashed var(--ui-accent); padding: 40px 60px; font-size: 16px; color: var(--ui-accent); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: var(--ui-surface);
  border: 1px solid var(--ui-line-strong);
  padding: 9px 16px;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--ui-bad); }

/* ---------- preview scene: every color comes from the theme ---------- */
.scene {
  height: 100%;
  min-height: 440px;
  background: var(--bg0);
  color: var(--fg);
  font: 12px/1.5 var(--mono);
  display: flex;
  flex-direction: column;
  tab-size: 4;
}
.scene button { font: inherit; }
.sw-btn { border: 0; padding: 0; cursor: pointer; display: block; box-shadow: inset 0 0 0 1px var(--bg3); }
.sw-btn:hover, .sw-btn:focus-visible { outline: 2px solid var(--fgb); outline-offset: -2px; }

/* i3bar */
.s-bar { height: 24px; flex: none; display: flex; align-items: stretch; justify-content: space-between; background: var(--bg0); }
.s-ws { display: flex; }
.ws { display: flex; align-items: center; padding: 0 10px; background: var(--bg0); color: var(--fgdim); border: 1px solid var(--bg0); cursor: pointer; }
.ws:not(.focused):hover, .ws:not(.focused):focus-visible { background: var(--amber); border-color: var(--amber); color: var(--bg0); outline: none; }
.ws.focused { background: var(--amber); border-color: var(--amber); color: var(--bg0); font-weight: 800; }
.ws.urgent { background: var(--red); border-color: var(--red); color: var(--bg0); font-weight: 800; }
.s-bar .clock { display: flex; align-items: center; padding: 0 12px; color: var(--fg); white-space: nowrap; }

/* tiled windows, as in i3 with gaps */
.s-desk { flex: 1; min-height: 0; display: flex; padding: 8px; }
.tile { display: flex; gap: 8px; min-width: 0; min-height: 0; flex: 1; }
.tile.col { flex-direction: column; }
.w { display: flex; flex-direction: column; min-width: 0; min-height: 0; border: 2px solid var(--bg2); background: var(--bg0); }
.w-title { height: 20px; flex: none; display: flex; align-items: center; padding: 0 8px; background: var(--bg2); color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; }
.w.focused { border-color: var(--green); }
.w.focused .w-title { background: var(--green); color: var(--bg0); font-weight: 800; }
.w:not(.focused):hover .w-title { color: var(--fg); }
.w-hint { margin-left: auto; padding-left: 12px; color: var(--muted); font-weight: 400; }
.w-body { flex: 1; min-height: 0; overflow: hidden; position: relative; }
.w-body.term { padding: 6px 10px; white-space: pre; }
.w-body.term.tight { padding: 4px 8px; }
.w-body.flush { padding: 0; }

/* zsh */
.term .gap { margin-top: 6px; }
.pl { display: flex; align-items: center; }
.pl span { padding: 0 8px; color: var(--bg0); font-weight: 600; }
.pl .pl-a { background: var(--amber); font-weight: 800; }
.pl .pl-b { background: var(--green); }
.pl .pl-c { background: var(--magenta); }
.pl .pl-d { background: var(--bg2); color: var(--yellow); font-weight: 400; }
.t-arrow { color: var(--amber); font-weight: 800; }
.t-cursor { display: inline-block; width: 7px; height: 14px; background: var(--amber); vertical-align: -2px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .t-cursor { animation: none; } .slot.flash { animation: none; } }

/* htop */
.ht { display: flex; flex-direction: column; height: 100%; }
.ht-head { background: var(--green); color: var(--bg0); margin: 4px -8px 0; padding: 0 8px; }
.ht-sel { background: var(--cyan); color: var(--bg0); margin: 0 -8px; padding: 0 8px; }
.ht-fill { flex: 1; }
.ht-keys { display: flex; margin: 0 -8px -4px; overflow: hidden; }
.ht-keys span { color: var(--fg); }
.ht-keys i { font-style: normal; background: var(--cyan); color: var(--bg0); }

/* fastfetch */
.ft-top { display: flex; align-items: center; gap: 14px; margin: 2px 0; }
.ft-logo { width: 64px; height: 64px; flex: none; }
.ft-row { display: flex; gap: 3px; margin: 1px 0; }
.ft-row .sw-btn { width: 40px; height: 20px; }

/* neovim */
.nvim { display: flex; flex-direction: column; height: 100%; background: var(--bg0); }
.nv-tabline { display: flex; flex: none; background: var(--bg1); }
.nv-tabs { display: flex; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nv-tab, .nv-step { background: none; border: 0; padding: 0 3px; color: var(--fgdim); white-space: pre; cursor: pointer; }
.nv-tab { border-left: 1px solid var(--bg3); }
.nv-tab:first-child { border-left: 0; }
.nv-tab[aria-selected="true"] { background: var(--amber); color: var(--bg0); font-weight: 800; }
.nv-tab[aria-selected="false"]:hover, .nv-tab[aria-selected="false"]:focus-visible, .nv-step:hover, .nv-step:focus-visible { background: var(--amber); color: var(--bg0); outline: none; }
.nv-steps { display: flex; flex: none; border-left: 1px solid var(--bg3); }
.nv-step { padding: 0 6px; }
.nv-count { color: var(--muted); padding: 0 6px; white-space: pre; }
.nv-buf { flex: 1; min-height: 0; overflow: auto; padding: 2px 0; scrollbar-width: thin; scrollbar-color: var(--bg3) var(--bg0); }
.nv-row { white-space: pre; display: flex; }
.nv-row.cur { background: var(--bg1); }
.nv-nr { color: var(--bg3); flex: none; }
.nv-row.cur .nv-nr { color: var(--amber); font-weight: 800; }
.nv-code { padding-right: 16px; }
.nv-status { display: flex; flex: none; background: var(--bg1); color: var(--fg); }
.nv-status span { padding: 0 8px; white-space: pre; }
.ll-a { background: var(--amber); color: var(--bg0); font-weight: 800; }
.ll-b { background: var(--green); color: var(--bg0); }
.ll-c { color: var(--fg); }
.ll-fill { flex: 1; }
.nv-cmd { flex: none; padding: 0 8px; color: var(--fg); }

/* syntax groups, as in the Neovim colorscheme */
.c-comment { color: var(--muted); font-style: italic; }
.c-string { color: var(--green); }
.c-char { color: var(--greenb); }
.c-escape { color: var(--magentab); }
.c-number { color: var(--yellow); }
.c-bool { color: var(--yellow); font-weight: 700; }
.c-const { color: var(--orange); }
.c-constb { color: var(--orange); font-weight: 700; }
.c-kw, .c-label { color: var(--magenta); }
.c-kwret { color: var(--magenta); font-weight: 700; }
.c-fn { color: var(--blue); }
.c-fnb, .c-macro, .c-attr, .c-special { color: var(--cyan); }
.c-type, .c-module { color: var(--amber); }
.c-typeb { color: var(--amber); font-style: italic; }
.c-op { color: var(--orange); }
.c-punct { color: var(--fgdim); }
.c-var, .c-prop { color: var(--fg); }
.c-varb { color: var(--red); font-style: italic; }
.c-param { color: var(--fgdim); font-style: italic; }

/* lynx */
.lynx { display: flex; flex-direction: column; height: 100%; padding: 4px 0 0; }
.lx-title { text-align: right; padding: 0 10px; color: var(--fgb); }
.lx-body { flex: 1; min-height: 0; overflow: auto; padding: 0 10px; scrollbar-width: none; }
.lx-h1 { display: block; text-align: center; color: var(--fgb); }
.lx-h2 { display: block; color: var(--fgb); }
.lx-a { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.lx-a:hover, .lx-a:focus-visible { background: var(--amber); color: var(--bg0); outline: none; }
.lx-status { padding: 0 10px; background: var(--bg2); color: var(--fg); display: flex; gap: 10px; }
.lx-pg { background: none; border: 0; padding: 0 4px; color: var(--blue); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.lx-pg:hover { background: var(--amber); color: var(--bg0); }
.lx-pg.on { background: var(--amber); color: var(--bg0); text-decoration: none; }
.lx-pg:focus-visible { outline: 1px solid var(--fgb); }
.lx-help { color: var(--fgdim); padding: 0 10px; overflow: hidden; }

/* irssi */
.irssi { display: flex; flex-direction: column; height: 100%; }
.irc-topic { background: var(--blue); color: var(--bg0); padding: 0 4px; overflow: hidden; }
.irc-log { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 6px; }
.irc-hl { color: var(--amber); }
.irc-bar { background: var(--bg2); color: var(--fg); padding: 0 4px; overflow: hidden; }
.irc-input { padding: 0 4px; }

/* ncmpcpp */
.mp { display: flex; flex-direction: column; height: 100%; padding: 2px 0; }
.mp-top { display: flex; justify-content: space-between; padding: 0 8px; color: var(--fgb); }
.mp-sep { border-top: 1px solid var(--bg3); margin: 3px 0; }
.mp-list { flex: 1; min-height: 0; overflow: hidden; }
.mp-row { display: grid; grid-template-columns: 22% 38% 1fr 6ch; gap: 8px; padding: 0 8px; white-space: pre; overflow: hidden; }
.mp-row span { overflow: hidden; text-overflow: ellipsis; }
.mp-ar { color: var(--fg); }
.mp-ti { color: var(--fgb); }
.mp-al { color: var(--cyan); }
.mp-len { color: var(--magenta); text-align: right; }
.mp-cols span { color: var(--muted); font-weight: 700; }
.mp-row.np span { font-weight: 800; color: var(--green); }
.mp-row.sel { background: var(--bg3); }
.mp-prog { display: flex; height: 3px; margin: 2px 8px 4px; background: var(--bg3); }
.mp-prog i { background: var(--amber); }
.mp-status { display: flex; padding: 0 8px; white-space: pre; }
.mp-fill { flex: 1; }

/* cava */
.cava { display: flex; align-items: stretch; gap: 2px; height: 100%; padding: 8px 10px 6px; }
.cava i { flex: 1; display: flex; flex-direction: column; background: linear-gradient(to top, var(--green), var(--yellow) 60%, var(--red)); }
.cava b { background: var(--bg0); }

/* narrow screens: stack the sidebar above the main area */
@media (max-width: 900px) {
  body { overflow: auto; height: auto; }
  .topbar { flex-wrap: wrap; padding: 8px 16px; }
  .title-fields { order: 3; flex-basis: 100%; }
  .actions { flex-wrap: wrap; }
  .layout { flex-direction: column; }
  .sidebar { width: auto; border-right: 0; overflow: visible; }
  .main { min-height: 80vh; }
  .view { overflow: auto; }
  .files { flex-direction: column; overflow: visible; }
  .app-list { width: auto; max-height: 220px; border-right: 0; border-bottom: 1px solid var(--ui-line); }
  .scene { height: 760px; }
  .tile.row { flex-direction: column; }
  .s-bar .clock { display: none; }
}
