:root {
  color-scheme: dark;
  --bg: #101318;
  --panel: #181d24;
  --panel-2: #1f2630;
  --line: #303945;
  --text: #edf2f7;
  --muted: #9aa6b2;
  --accent: #41b883;
  --accent-2: #2c7be5;
  --danger: #e55353;
  --warn: #f0ad4e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.locked-input {
  opacity: 0.72;
  cursor: not-allowed;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: #141920;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 10, 14, 0.86);
}

.login-box {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-error {
  min-height: 20px;
  color: #ffb4b4;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 16px;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
}

.status-pill {
  min-width: 112px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
}

.status-pill.online {
  border-color: rgba(65, 184, 131, 0.5);
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(460px, 1fr);
  gap: 16px;
  padding: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.controls,
.command,
.screen,
.bot-chat,
.inventory,
.logs,
.overview,
.client-launcher,
.desktop-view,
.chest-shop,
.profiles,
.schematics {
  padding: 16px;
}

.chest-shop[data-tab-panel="chestshop"] {
  grid-column: 1 / -1;
}

.controls {
  grid-row: span 2;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.command-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-status {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.action-status.ok {
  color: var(--accent);
}

.action-status.error {
  color: #ffb4b4;
}

.head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11161d;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 150px;
  margin-top: 12px;
  padding: 10px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
}

.toggles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 14px;
}

.toggles label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggles input {
  width: 16px;
  height: 16px;
}

.upload {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}

.file-button input {
  display: none;
}

.file-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.file-button:hover {
  border-color: var(--accent-2);
}

.primary {
  background: var(--accent);
  color: #08120d;
  border-color: transparent;
  font-weight: 700;
}

.danger {
  background: rgba(229, 83, 83, 0.16);
  border-color: rgba(229, 83, 83, 0.45);
  color: #ffb4b4;
}

.ghost {
  background: transparent;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
}

.stats span {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.bot-list {
  display: grid;
  gap: 10px;
}

.bot-list.empty {
  color: var(--muted);
}

.bot-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151a21;
}

.bot-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.bot-status {
  padding: 2px 8px;
  border-radius: 999px;
  background: #2a323d;
  color: var(--muted);
  font-size: 12px;
}

.bot-status.spawned {
  background: rgba(65, 184, 131, 0.15);
  color: var(--accent);
}

.bot-status.error,
.bot-status.kicked {
  background: rgba(229, 83, 83, 0.15);
  color: #ffb4b4;
}

.bot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.command-stack {
  display: grid;
  gap: 12px;
}

.command-row {
  display: grid;
  gap: 10px;
  align-items: end;
}

.chat-row {
  grid-template-columns: 1fr 110px 110px;
}

.goto-row {
  grid-template-columns: repeat(3, minmax(80px, 1fr)) 110px;
}

.follow-row {
  grid-template-columns: minmax(180px, 1fr) 90px 110px 110px 110px;
}

.baritone-box {
  display: grid;
  grid-template-columns: 1fr 110px 110px;
  gap: 10px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.quick-commands {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.quick-commands button {
  min-width: 0;
  padding: 0 8px;
}

.fleet-actions {
  display: flex;
  justify-content: flex-end;
}

.command-row button {
  width: 100%;
}

/*
 * Keep the old class harmless if cached markup is still open in a browser.
 */
.command-grid {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
  align-items: end;
}

.logs {
  grid-column: 2;
}

.screen,
.bot-chat,
.inventory,
.client-launcher,
.profiles,
.schematics,
.client-mods {
  grid-column: 2;
}

.profile-list,
.asset-list {
  display: grid;
  gap: 8px;
}

.profile-list.empty,
.asset-list.empty {
  color: var(--muted);
}

.profile-row,
.asset-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151a21;
}

.profile-actions {
  display: flex;
  gap: 8px;
}

.profile-title {
  font-weight: 700;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.chest-shop-presets {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.chest-shop-preset-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.log-stream {
  height: 310px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1015;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.client-launcher {
  grid-column: 1 / -1;
}

.desktop-view {
  grid-column: 1 / -1;
}

.desktop-frame-wrap {
  height: min(72vh, 760px);
  min-height: 460px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #06080b;
}

#desktopFrame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #06080b;
}

.client-fields {
  margin-bottom: 12px;
}

.client-actions {
  justify-content: flex-start;
}

.client-account-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}

.client-log-stream {
  margin-top: 14px;
}

.client-process-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.client-process-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 160px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151a21;
}

.client-process-row.pending {
  color: var(--muted);
}

.muted-line {
  color: var(--muted);
}

.viewer-status {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.viewer-frame-wrap {
  height: 300px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #06080b;
}

#viewerFrame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #06080b;
}

.bot-chat-stream {
  height: 260px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1015;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.bot-chat-line {
  display: grid;
  grid-template-columns: 78px 74px 1fr;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: #d7dde4;
}

.bot-chat-line.out {
  color: #c2a5ff;
}

.bot-chat-line .chat-kind {
  color: var(--muted);
}

.bot-chat-send,
.auth-actions,
.inventory-actions,
.hand-actions {
  display: grid;
  grid-template-columns: 1fr 110px 110px;
  gap: 10px;
  margin-top: 10px;
}

.inventory-actions {
  grid-template-columns: repeat(3, minmax(110px, auto)) 150px 90px 110px;
  align-items: end;
}

.auth-actions {
  grid-template-columns: 110px 110px 110px 110px;
  justify-content: end;
}

.hand-actions {
  grid-template-columns: repeat(5, minmax(100px, auto)) 90px;
}

.inventory-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(54px, 1fr));
  gap: 6px;
  max-height: 390px;
  overflow: auto;
  margin-top: 10px;
}

.inventory-grid.empty {
  display: block;
  color: var(--muted);
}

.slot-button {
  min-width: 0;
  min-height: 58px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11161d;
  color: var(--text);
  display: grid;
  align-content: start;
  gap: 2px;
}

.slot-button.empty-slot {
  color: #53606d;
}

.slot-index {
  font-size: 10px;
  color: var(--muted);
}

.slot-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.slot-count {
  font-size: 11px;
  color: var(--accent);
}

.log-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.log-tools select {
  width: 180px;
}

.log-line {
  display: grid;
  grid-template-columns: 78px 108px 56px 1fr;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: #d7dde4;
}

.level-error {
  color: #ff8e8e;
}

.level-warn {
  color: var(--warn);
}

.level-chat {
  color: #8fd6ff;
}

.level-cmd {
  color: #c2a5ff;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .controls,
  .screen,
  .bot-chat,
  .inventory,
  .client-launcher,
  .desktop-view,
  .profiles,
  .schematics,
  .logs {
    grid-column: auto;
  }

  .command-stack,
  .command-row,
  .baritone-box,
  .quick-commands,
  .bot-chat-send,
  .auth-actions,
  .inventory-actions,
  .hand-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-row label,
  .bot-chat-send input,
  .inventory-actions button:first-child,
  .baritone-box label,
  .follow-row label:first-child,
  .follow-row .ghost {
    grid-column: span 2;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.two,
  .chest-shop-preset-editor,
  .toggles,
  .command-stack,
  .command-row,
  .baritone-box,
  .quick-commands,
  .bot-chat-send,
  .auth-actions,
  .inventory-actions,
  .hand-actions,
  .client-account-head,
  .client-process-row {
    grid-template-columns: 1fr;
  }

  .client-account-head {
    align-items: stretch;
    display: grid;
  }

  .chat-row label,
  .bot-chat-send input,
  .inventory-actions button:first-child,
  .baritone-box label,
  .follow-row label:first-child,
  .follow-row .ghost {
    grid-column: auto;
  }

  .log-line,
  .bot-chat-line {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .inventory-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .viewer-frame-wrap {
    height: 220px;
  }
}
