:root {
  --terminal: #1f1e19;
  --terminal-soft: #28261f;
  --terminal-text: #f7f7f4;
  --terminal-muted: #a09c92;
  --line: rgba(247, 247, 244, 0.13);
  --line-strong: rgba(247, 247, 244, 0.24);
  --primary: #f54e00;
  --primary-active: #d04200;
  --danger: #cf2d56;
  --success: #9fc9a2;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  overflow: hidden;
}

body {
  position: fixed;
  inset: 0;
  display: block;
  margin: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--terminal);
  color: var(--terminal-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  min-height: 32px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(247, 247, 244, 0.24);
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(247, 247, 244, 0.36);
  background-clip: padding-box;
}

.hidden {
  display: none !important;
}

.terminal-shell {
  position: fixed;
  inset: 0 0 18px 0;
  width: 100vw;
  max-width: 100vw;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--terminal);
}

.terminal {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 10px 12px;
}

.xterm {
  width: 100% !important;
  max-width: 100% !important;
  height: 100%;
}

.xterm .xterm-screen,
.xterm .xterm-viewport {
  max-width: 100% !important;
}

.xterm .xterm-viewport {
  scrollbar-width: thin;
  scrollbar-color: rgba(247, 247, 244, 0.28) transparent;
}

.drop-overlay {
  position: absolute;
  inset: 12px;
  z-index: 4;
  display: grid;
  place-items: center;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  background: rgba(31, 30, 25, 0.82);
  color: var(--terminal-text);
  font-size: 22px;
  font-weight: 600;
  pointer-events: none;
}

.dialog-backdrop {
  position: fixed;
  inset: 0 0 18px;
  z-index: 30;
  display: grid;
  place-items: center;
  border: 0;
  margin: 0;
  padding: 20px;
  background: rgba(31, 30, 25, 0.32);
  backdrop-filter: blur(4px);
}

.connect-card,
.confirm-card {
  display: grid;
  gap: 14px;
  width: min(390px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(40, 38, 31, 0.96);
  padding: 18px;
}

.connect-card h1,
.confirm-card h2 {
  margin: 0;
  color: var(--terminal-text);
  font-size: 18px;
  font-weight: 600;
}

label {
  display: grid;
  gap: 6px;
  color: var(--terminal-muted);
  font-size: 12px;
  line-height: 1.35;
}

input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: none;
  background: rgba(31, 30, 25, 0.88);
  color: var(--terminal-text);
  padding: 0 10px;
}

input:focus {
  border-color: var(--primary);
}

input[readonly] {
  cursor: text;
}

.host-port-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 600;
}

.primary-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-active);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: rgba(31, 30, 25, 0.74);
  color: var(--terminal-text);
}

.dialog-error {
  border: 1px solid rgba(207, 45, 86, 0.55);
  border-radius: 6px;
  background: rgba(207, 45, 86, 0.14);
  color: #ffb2c2;
  padding: 8px 10px;
  font-size: 12px;
}

.confirm-card p {
  margin: 0;
  color: var(--terminal-muted);
  font-size: 13px;
  line-height: 1.45;
}

.upload-file-list {
  max-height: 118px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  color: var(--terminal-text);
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.upload-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 18px;
  z-index: 12;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(360px, calc(100vw - 28px));
  border-left: 1px solid rgba(247, 247, 244, 0.12);
  background: rgba(25, 24, 20, 0.98);
  box-shadow: -18px 0 42px rgba(0, 0, 0, 0.32);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

body.upload-panel-open .upload-panel {
  transform: translateX(0);
}

.upload-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border-bottom: 1px solid rgba(247, 247, 244, 0.09);
  padding: 12px;
}

.upload-panel-header h2 {
  margin: 0 0 4px;
  color: var(--terminal-text);
  font-size: 13px;
  font-weight: 600;
}

.upload-panel-header p {
  margin: 0;
  max-width: 235px;
  overflow: hidden;
  color: var(--terminal-muted);
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 10px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-pick-button {
  height: 34px;
  margin: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(31, 30, 25, 0.86);
  color: var(--terminal-text);
  font-size: 12px;
  font-weight: 600;
}

.upload-pick-button:hover {
  border-color: var(--primary);
}

.upload-pick-button:disabled {
  border-color: var(--line);
  color: rgba(160, 156, 146, 0.45);
  opacity: 0.74;
}

.upload-items {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding: 0 12px 12px;
}

.upload-empty {
  margin: 10px 0 0;
  color: var(--terminal-muted);
  font-size: 12px;
}

.upload-item {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(31, 30, 25, 0.72);
  padding: 9px;
}

.upload-item-title,
.upload-item-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-item-title {
  color: var(--terminal-text);
  font-size: 12px;
  font-weight: 600;
}

.upload-item-meta {
  color: var(--terminal-muted);
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 10px;
}

.upload-progress {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(247, 247, 244, 0.12);
}

.upload-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 120ms ease;
}

.upload-item[data-status="complete"] .upload-progress-fill {
  background: var(--success);
}

.upload-item[data-status="error"] .upload-progress-fill,
.upload-item[data-status="skipped"] .upload-progress-fill {
  background: var(--danger);
}

.status-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100vw;
  height: 18px;
  min-width: 0;
  overflow: hidden;
  border-top: 1px solid rgba(247, 247, 244, 0.09);
  background: #191814;
  color: var(--terminal-muted);
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 10px;
  line-height: 18px;
  padding: 0 8px;
}

.status-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#connectionStatus {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#connectionStatus[data-state="connected"] {
  color: var(--success);
}

#connectionStatus[data-state="connecting"],
#connectionStatus[data-state="uploading"] {
  color: #dfa88f;
}

#connectionStatus[data-state="error"] {
  color: #ff8aa5;
}

.status-button {
  flex: 0 0 auto;
  height: 16px;
  border: 0;
  background: transparent;
  color: var(--terminal-muted);
  padding: 0;
  font: inherit;
  white-space: nowrap;
}

.status-button:hover,
.status-button[aria-pressed="true"] {
  color: var(--terminal-text);
}

.status-button:disabled,
.status-button:disabled:hover {
  color: rgba(160, 156, 146, 0.38);
}

@media (max-width: 520px) {
  .host-port-row {
    grid-template-columns: 1fr;
  }

  .connect-card,
  .confirm-card {
    padding: 16px;
  }
}
