:root {
  --bg-canvas: #000000;
  --tui-bg-canvas: var(--bg-canvas);
  --bg-selection: #211915;
  --bg-highlight: #161314;
  --border-dim: #343044;
  --border: #4b4562;
  --border-active: #65708b;
  --text-faint: #706b80;
  --text-dim: #9b93a7;
  --text-muted: #c3b8a3;
  --text: #d4c7aa;
  --text-bright: #f0dfb9;
  --amber: #f1a55f;
  --amber-dim: #c37b3e;
  --amber-glow: #ffbd7b;
  --chat-body: #d6ccb3;
  --chat-author: #96bd68;
  --mention: #d9c6a2;
  --success: #a6bf77;
  --error: #d26d5f;
  --bot: #a878d7;
  --bonsai-sprout: #99bf68;
  --bonsai-leaf: #a7c877;
  --bonsai-canopy: #b999cf;
  --bonsai-bloom: #e7d5f2;
  --badge-bronze: #bd8954;
  --badge-silver: #c9c9ce;
  --badge-gold: #d5b85b;
}

:root[data-static-background] {
  --tui-bg-canvas: #000000;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: #111827;
  color: var(--text);
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

.designer-shell {
  --picker-width: minmax(300px, 330px);
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--picker-width) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  background: #0d1117;
  transition: grid-template-columns 180ms ease;
}

.designer-shell.is-picker-collapsed {
  --picker-width: 0;
}

.terminal-stage {
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  container-type: inline-size;
  display: grid;
  place-items: center;
}

.terminal {
  position: relative;
  width: min(1900px, 100%, calc((100dvh - 36px) * 1.649));
  aspect-ratio: 16 / 9.7;
  min-height: min(700px, calc(100dvh - 220px));
  max-height: 100%;
  padding: 10px 12px 12px;
  background: var(--tui-bg-canvas);
  border: 1px solid #3d3d3d;
  border-radius: 8px;
  box-shadow: 0 22px 70px rgb(0 0 0 / 65%);
  overflow: hidden;
}

.terminal::before {
  content: "sshlate";
  position: absolute;
  inset: 0 0 auto;
  height: 26px;
  display: grid;
  place-items: center;
  color: #b9b9b9;
  background: #383838;
  font: 700 12px/1 system-ui, sans-serif;
}

.terminal::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff6b57;
  box-shadow: 18px 0 #ffbd5a, 36px 0 #55c763;
  z-index: 2;
}

.terminal[data-isolating-token] {
  border-color: #111111;
}

.terminal[data-isolating-token]::before {
  color: #282828;
  background: #141414;
}

.terminal[data-isolating-token]::after {
  background: #30140f;
  box-shadow: 18px 0 #30240f, 36px 0 #143018;
}

.frame {
  --rail-column: 230px;
  --sidebar-column: 238px;
  position: absolute;
  inset: 34px 6px 6px;
  padding: 18px 10px 22px;
  border: 1px solid var(--border-active);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 3%);
}

.titlebar {
  position: absolute;
  top: -10px;
  left: 12px;
  right: 278px;
  height: 20px;
  display: flex;
  align-items: center;
  gap: 9px;
  overflow: hidden;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
}

.titlebar > span {
  flex: 0 0 auto;
  background: var(--tui-bg-canvas);
}

.titlebar-hud {
  position: absolute;
  top: -10px;
  right: 12px;
  height: 20px;
  padding-inline: 5px;
  background: var(--tui-bg-canvas);
  font-size: 16px;
  line-height: 20px;
  white-space: nowrap;
}

.frame-footer {
  position: absolute;
  bottom: -10px;
  height: 20px;
  padding-inline: 6px;
  background: var(--tui-bg-canvas);
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
}

.footer-help {
  left: 12px;
}

.footer-sponsor {
  right: 12px;
}

.brand {
  padding-inline: 4px;
}

.room-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab.active {
  color: var(--bg-selection) !important;
  background: var(--amber);
  padding: 0 2px;
}

.content-grid {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--rail-column) minmax(0, 1fr) var(--sidebar-column);
  gap: 0;
  overflow: hidden;
}

.room-rail {
  min-width: 0;
  min-height: 0;
  padding: 2px 10px 0 2px;
  border-right: 1px solid var(--border-dim);
  overflow: hidden;
  font-size: 15px;
  line-height: 1.14;
}

.rail-section + .rail-section {
  margin-top: 14px;
}

.rail-label {
  margin: 0 0 5px 2px;
  font-style: italic;
}

.rail-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) max-content;
  gap: 4px;
  padding: 1px 4px;
  white-space: nowrap;
}

.rail-row > :nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 98px 122px 24px minmax(0, 1fr);
  gap: 0;
  padding: 0 10px;
  overflow: hidden;
}

.home-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.18;
}

.home-box {
  min-width: 0;
  padding: 0 10px 0 8px;
  display: grid;
  grid-template-rows: repeat(4, 1fr);
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
}

.online-box {
  grid-template-rows: repeat(5, 1fr);
}

.home-box > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inline-label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}

.inline-label > :first-child {
  font-style: italic;
}

.vertical-rule {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.vertical-rule::before {
  content: "│";
}

.wire-strip {
  min-width: 0;
  padding: 0;
  display: grid;
  grid-template-rows: 20px 24px 28px 28px 28px;
  align-items: center;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.2;
}

.wire-strip > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wire-rule {
  display: flex;
  align-items: center;
}

.wire-fill {
  flex: 1 1 auto;
  min-width: 24px;
  border-bottom: 1px solid var(--border-dim);
  transform: translateY(-1px);
}

.wire-bottom {
  align-self: center;
  border-bottom: 1px solid var(--border-dim);
}

.pinned-row {
  min-width: 0;
  height: 22px;
  display: flex;
  gap: 6px;
  align-items: center;
  padding-inline: 8px;
  border-top: 1px solid var(--border-dim);
  border-bottom: 1px solid var(--amber-dim);
  overflow: hidden;
  white-space: nowrap;
  font-size: 15px;
}

.tui-block {
  position: relative;
  border: 1px solid currentColor;
  color: var(--border);
  background: transparent;
}

.block-title {
  position: absolute;
  top: -10px;
  left: 10px;
  padding-inline: 5px;
  color: currentColor;
  background: var(--tui-bg-canvas);
  font-weight: 700;
  line-height: 18px;
  white-space: nowrap;
}

.key {
  font-weight: 800;
}

.chat-card {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 152px 152px;
  grid-template-rows: minmax(0, 1fr) 48px;
  gap: 6px;
  padding: 0 0 8px;
  font-size: 15px;
  line-height: 1.16;
}

.chat-log {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 4px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.bonsai-preview-dock {
  grid-column: 2 / 4;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  align-self: end;
}

.bonsai-preview {
  min-width: 0;
  height: 276px;
  padding: 16px 6px 7px;
  overflow: visible;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: end;
  text-align: center;
  font-size: 14px;
  line-height: 1;
}

.bonsai-preview pre {
  display: inline-block;
  align-self: end;
  justify-self: center;
  margin: 0 0 8px;
  font: inherit;
  line-height: 1;
  text-align: left;
}

.bonsai-preview div:not(.block-title) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.message {
  padding: 1px 4px;
  white-space: normal;
}

.message.grouped {
  margin-top: 12px;
}

.message.selected {
  margin-inline: -3px;
  padding-inline: 7px;
}

.meta {
  white-space: nowrap;
}

.author,
.bright,
.label,
strong {
  font-weight: 800;
}

.quote {
  font-style: italic;
}

.shout {
  text-transform: uppercase;
}

.composer {
  grid-column: 1 / -1;
  grid-row: 2;
  height: 46px;
  margin-top: 0;
  padding: 16px 12px 8px;
  color: var(--border);
  overflow: visible;
  background: var(--tui-bg-canvas);
  z-index: 1;
  white-space: nowrap;
}

.composer > span {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.composer .block-title {
  left: 10px;
  padding-inline: 4px;
  background: var(--tui-bg-canvas);
}

.sidebar-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.16;
}

.sidebar-rule {
  position: absolute;
  inset: 0 auto 0 0;
  width: 1px;
  background: var(--border-dim);
}

.sidebar-content {
  height: 100%;
  min-height: 0;
  padding-left: 10px;
  padding-right: 4px;
  display: grid;
  grid-template-rows: 22px 20px 82px 20px 188px 20px 112px 20px minmax(0, 1fr);
  overflow: hidden;
}

.sidebar-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  white-space: nowrap;
}

.horizontal-rule {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  align-self: center;
}

.horizontal-rule::before {
  content: "────────────────────────";
}

.visualizer {
  display: grid;
  min-height: 0;
  overflow: hidden;
}

.viz-bars {
  height: 100%;
  display: flex;
  align-items: end;
  gap: 7px;
  padding: 8px 8px 0;
}

.viz-bars span {
  width: 9px;
  background: currentColor;
}

.audio-pairing,
.now-playing,
.active-tables {
  min-width: 0;
  overflow: hidden;
  display: grid;
  align-content: start;
  gap: 3px;
  white-space: nowrap;
}

.audio-pairing {
  grid-template-rows: repeat(4, max-content);
  gap: 6px;
  padding-top: 6px;
}

.sidebar-spacer {
  height: 4px;
}

.now-playing > *,
.audio-pairing > *,
.active-tables > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vote-inline {
  display: grid;
  gap: 1px;
  margin-top: 3px;
}

.room-hint {
  float: right;
}

.bonsai {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: end;
  text-align: center;
  overflow: hidden;
}

.bonsai pre {
  display: inline-block;
  align-self: end;
  justify-self: center;
  margin: 2px 0 6px;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  text-align: left;
}

.bonsai div {
  font-size: 14px;
}

.theme-panel {
  min-width: 0;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overflow: hidden;
  color: #cccccc;
  background: #1e1e1e;
  border: 1px solid #3c3c3c;
  box-shadow: 0 18px 54px rgb(0 0 0 / 40%);
  opacity: 1;
  transition: opacity 140ms ease;
}

.designer-shell.is-picker-collapsed .theme-panel {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.theme-panel-surface {
  width: min(330px, calc(100vw - 36px));
  height: calc(100vh - 36px);
  height: calc(100dvh - 36px);
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
}

.palette-restore {
  position: fixed;
  left: 18px;
  top: 18px;
  z-index: 10;
  width: 42px;
  height: 48px;
  border: 1px solid #3c3c3c;
  border-radius: 6px;
  background: #252526;
  color: #d4d4d4;
  cursor: pointer;
  box-shadow: 0 12px 32px rgb(0 0 0 / 45%);
}

.palette-restore[hidden] {
  display: none;
}

.export-dialog {
  position: fixed;
  inset: 50% auto auto 50%;
  width: min(720px, calc(100vw - 40px));
  max-height: min(760px, calc(100vh - 56px));
  padding: 0;
  margin: 0;
  border: 1px solid #3c3c3c;
  background: #1e1e1e;
  color: #cccccc;
  transform: translate(-50%, -50%);
  box-shadow: 0 30px 100px rgb(0 0 0 / 75%);
}

.export-dialog::backdrop {
  background: transparent;
}

.dialog-surface,
.export-surface {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}

.dialog-header,
.dialog-footer {
  padding: 14px 16px;
  border-bottom: 1px solid #333333;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.theme-panel .dialog-header {
  display: grid;
  justify-content: stretch;
  gap: 8px;
}

.theme-panel-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: end;
  gap: 8px;
}

.dialog-header h1 {
  margin: 0;
  color: #e7e7e7;
  font-size: 18px;
  line-height: 1.2;
}

.dialog-header p {
  margin: 4px 0 0;
  color: #969696;
  font-size: 13px;
}

.preset-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: #b8b8b8;
  font-size: 13px;
}

.preset-field select {
  min-width: 0;
  width: 100%;
  border: 1px solid #3c3c3c;
  padding: 4px 6px;
  background: #111827;
  color: #e7e7e7;
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid #3c3c3c;
  background: #252526;
  color: #d7ba7d;
  cursor: pointer;
}

.command-button {
  border: 1px solid #4f87c8;
  padding: 7px 12px;
  background: #0e639c;
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.command-button.secondary {
  border-color: #5a5a5a;
  background: #2d2d30;
  color: #e7e7e7;
}

.token-list {
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.token-row {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 66px 82px;
  gap: 5px;
  align-items: center;
  min-height: 52px;
  border-bottom: 1px solid #2d2d2d;
}

.token-tools {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.token-info {
  position: relative;
  inline-size: 14px;
  block-size: 14px;
  border: 1px solid #5a5a5a;
  border-radius: 50%;
  padding: 0;
  background: #252526;
  color: #d7ba7d;
  font-size: 10px;
  font-weight: 800;
  line-height: 12px;
  text-align: center;
  cursor: help;
}

.token-info::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 22px;
  top: 50%;
  z-index: 5;
  width: 246px;
  padding: 8px 10px;
  border: 1px solid #4a4a4a;
  background: #111827;
  color: #e7e7e7;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  text-align: left;
  white-space: normal;
  box-shadow: 0 10px 32px rgb(0 0 0 / 55%);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-3px);
  transition:
    opacity 80ms ease,
    transform 80ms ease;
}

.token-info:hover::after,
.token-info:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.token-isolate {
  inline-size: 16px;
  block-size: 16px;
  border: 1px solid #4a4a4a;
  border-radius: 3px;
  padding: 0;
  background: #1b1b1b;
  color: #969696;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  cursor: pointer;
}

.token-isolate:hover,
.token-isolate:focus-visible,
.token-isolate.is-active {
  border-color: #4f87c8;
  color: #ffffff;
  background: #0e639c;
}

.token-name {
  color: #d4d4d4;
  min-width: 0;
}

.token-desc {
  display: block;
  color: #858585;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-row input[type="color"] {
  inline-size: 64px;
  block-size: 32px;
  padding: 0;
  border: 1px solid #3c3c3c;
  background: #111827;
}

.hex-input {
  width: 82px;
  border: 1px solid #3c3c3c;
  padding: 5px 6px;
  background: #111827;
  color: #e7e7e7;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid #333333;
  border-bottom: 0;
}

.footer-options {
  display: grid;
  gap: 7px;
  flex: 0 0 auto;
  margin-right: auto;
}

.background-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  color: #d4d4d4;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.background-toggle span {
  white-space: nowrap;
}

.background-toggle input {
  inline-size: 16px;
  block-size: 16px;
  margin: 0;
  accent-color: #0e639c;
}

.dialog-footer .command-button {
  padding-inline: 10px;
}

.export-preview {
  width: calc(100% - 32px);
  min-height: 420px;
  margin: 16px;
  resize: vertical;
  border: 1px solid #3c3c3c;
  padding: 12px;
  background: #111827;
  color: #d4d4d4;
}

.export-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid #333333;
}

#copyStatus,
#importStatus {
  color: #969696;
}

.hover-info {
  position: fixed;
  z-index: 30;
  min-width: 168px;
  max-width: min(320px, calc(100vw - 16px));
  border: 1px solid #4a4a4a;
  padding: 7px 9px;
  background: #111827;
  color: #e7e7e7;
  box-shadow: 0 14px 36px rgb(0 0 0 / 60%);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
  white-space: nowrap;
}

.hover-info[hidden] {
  display: none;
}

[data-token="bg_canvas"] { color: var(--bg-canvas); }
[data-token="bg_selection"] { color: var(--bg-selection); }
[data-token="bg_highlight"] { color: var(--bg-highlight); }
[data-token="border_dim"] { color: var(--border-dim); }
[data-token="border"] { color: var(--border); }
[data-token="border_active"] { color: var(--border-active); }
[data-token="text_faint"] { color: var(--text-faint); }
[data-token="text_dim"] { color: var(--text-dim); }
[data-token="text_muted"] { color: var(--text-muted); }
[data-token="text"] { color: var(--text); }
[data-token="text_bright"] { color: var(--text-bright); }
[data-token="amber"] { color: var(--amber); }
[data-token="amber_dim"] { color: var(--amber-dim); }
[data-token="amber_glow"] { color: var(--amber-glow); }
[data-token="chat_body"] { color: var(--chat-body); }
[data-token="chat_author"] { color: var(--chat-author); }
[data-token="mention"] { color: var(--mention); }
[data-token="success"] { color: var(--success); }
[data-token="error"] { color: var(--error); }
[data-token="bot"] { color: var(--bot); }
[data-token="bonsai_sprout"] { color: var(--bonsai-sprout); }
[data-token="bonsai_leaf"] { color: var(--bonsai-leaf); }
[data-token="bonsai_canopy"] { color: var(--bonsai-canopy); }
[data-token="bonsai_bloom"] { color: var(--bonsai-bloom); }
[data-token="badge_bronze"] { color: var(--badge-bronze); }
[data-token="badge_silver"] { color: var(--badge-silver); }
[data-token="badge_gold"] { color: var(--badge-gold); }

[data-token-bg="bg_canvas"] { background: var(--tui-bg-canvas); }
[data-token-bg="bg_selection"] { background: var(--bg-selection); }
[data-token-bg="bg_highlight"] { background: var(--bg-highlight); }
[data-token-bg="amber"] { background: var(--amber); }

@container (max-width: 1180px) {
  .frame {
    --rail-column: 0;
    --sidebar-column: 190px;
  }

  .terminal {
    min-height: 650px;
  }

  .titlebar {
    right: 182px;
    gap: 6px;
    font-size: 14px;
  }

  .titlebar-hud {
    font-size: 14px;
  }

  .footer-help {
    font-size: 12px;
  }

  .content-grid {
    grid-template-columns: minmax(0, 1fr) var(--sidebar-column);
  }

  .room-rail {
    display: none;
  }

  .dashboard-pane {
    grid-template-rows: 102px 122px 22px minmax(0, 1fr);
  }

  .sidebar-content {
    grid-template-rows: 22px 20px 76px 20px 172px 20px minmax(0, 1fr);
  }

  .active-tables,
  .active-tables + .horizontal-rule {
    display: none;
  }

  .home-strip {
    grid-template-columns: 1fr;
  }

  .home-strip .vertical-rule,
  .home-strip .home-box:nth-of-type(n + 2),
  .footer-sponsor {
    display: none;
  }
}
