* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  width: 100vw; height: 100vh;
  background: #0b0e14;
  color: #cdd6f4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               Arial, "Liberation Sans", sans-serif;
  font-size: 14px;
  overflow: hidden;
}
.screen { width: 100vw; height: 100vh; display: flex; }
.screen[hidden] { display: none !important; }

/* ----- loading + auth ----- */
#loading { align-items: center; justify-content: center; color: #6c7086; }

#auth-screen { align-items: center; justify-content: center; }
.panel {
  width: min(420px, 92vw);
  background: #11141c;
  border: 1px solid #1e2230;
  border-radius: 8px;
  padding: 28px 28px 22px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
}
.panel h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: .04em; }
.panel .muted { color: #6c7086; margin: 4px 0 18px; }
.panel button {
  display: inline-block;
  border: 1px solid #313244;
  background: #1e2030;
  color: #cdd6f4;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.panel button:hover { background: #262838; }
.panel button.primary { background: #5876b6; border-color: #5876b6; color: #fff; }
.panel button.primary:hover { background: #6688c8; }
.panel button.ghost { background: transparent; }

.panel input {
  width: 100%;
  background: #1a1d28;
  border: 1px solid #313244;
  color: #cdd6f4;
  padding: 8px 10px;
  border-radius: 6px;
  margin-top: 4px;
  font-family: inherit;
  font-size: 13px;
}
.panel label { display: block; margin: 12px 0 6px; font-size: 12px; color: #9399b2; }

.panel details {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #1e2230;
}
.panel summary { cursor: pointer; color: #9399b2; user-select: none; }
.panel summary:hover { color: #cdd6f4; }

.panel .msg { margin-top: 12px; font-size: 13px; color: #f38ba8; min-height: 18px; }
.panel .msg.ok { color: #a6e3a1; }

#blob-output {
  width: 100%;
  background: #0b0e14;
  color: #cdd6f4;
  border: 1px solid #313244;
  border-radius: 6px;
  padding: 8px;
  font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  margin-top: 10px;
  resize: vertical;
}
#blob-instructions {
  margin-top: 8px;
  background: #0b0e14;
  border: 1px solid #313244;
  border-radius: 6px;
  padding: 8px;
  color: #a6adc8;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ----- main app layout ----- */
#app { flex-direction: row; }

#machine-list {
  width: 220px;
  flex-shrink: 0;
  background: #0c0f17;
  border-right: 1px solid #1e2230;
  display: flex;
  flex-direction: column;
}
#machine-list header {
  padding: 12px 14px;
  font-size: 11px;
  text-transform: uppercase;
  color: #6c7086;
  letter-spacing: .08em;
  border-bottom: 1px solid #1e2230;
}
#machines {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  flex: 1;
  overflow-y: auto;
}
#machines li {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  cursor: pointer;
  color: #cdd6f4;
  transition: background .15s;
  user-select: none;
}
#machines li:hover { background: #1a1d28; }
#machines li .label { flex: 1; font-weight: 500; }
#machines li .id    { color: #6c7086; font-size: 11px; margin-left: 8px; }
#machines li .new   {
  background: transparent;
  border: 1px solid #313244;
  color: #9399b2;
  width: 22px; height: 22px;
  border-radius: 4px;
  margin-left: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 18px;
}
#machines li .new:hover { color: #cdd6f4; border-color: #585b70; }
#machine-list footer {
  padding: 10px 14px;
  border-top: 1px solid #1e2230;
}
#logout-btn {
  width: 100%;
  background: transparent;
  border: 1px solid #313244;
  color: #9399b2;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
#logout-btn:hover { color: #cdd6f4; }

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#tab-bar {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  height: 36px;
  background: #0c0f17;
  border-bottom: 1px solid #1e2230;
  overflow-x: auto;
  flex-shrink: 0;
}
.tab {
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-right: 1px solid #1e2230;
  cursor: pointer;
  color: #9399b2;
  font-size: 12px;
  background: transparent;
  user-select: none;
  white-space: nowrap;
  max-width: 220px;
  position: relative;
}
.tab:hover { background: #11141c; color: #cdd6f4; }
.tab.active { background: #0b0e14; color: #cdd6f4; box-shadow: inset 0 2px 0 #5876b6; }
.tab .name { overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.tab .close {
  margin-left: 10px;
  color: #6c7086;
  background: transparent;
  border: 0;
  width: 18px; height: 18px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 14px;
  line-height: 14px;
  font-family: inherit;
  padding: 0;
}
.tab .close:hover { color: #f38ba8; background: #1e2030; }
.tab .status {
  display: inline-block;
  width: 6px; height: 6px;
  background: #6c7086;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}
.tab .status.ok       { background: #a6e3a1; }
.tab .status.error    { background: #f38ba8; }
.tab .status.connecting { background: #f9e2af; }

#terminal-container {
  flex: 1;
  position: relative;
  background: #0b0e14;
  min-height: 0;
}
.term-pane {
  position: absolute;
  inset: 0;
  padding: 6px;
  background: #0b0e14;
}
.term-pane[hidden] { display: none; }
.term-pane .xterm,
.term-pane .xterm-viewport,
.term-pane .xterm-screen { width: 100% !important; height: 100% !important; }

/* ----- search bar ----- */
#search-bar {
  position: absolute;
  top: 8px;
  right: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #11141c;
  border: 1px solid #313244;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
#search-bar[hidden] { display: none; }
#search-input {
  width: 320px;
  background: #0b0e14;
  border: 1px solid #1e2230;
  border-radius: 4px;
  color: #cdd6f4;
  padding: 4px 8px;
  font: inherit;
  outline: none;
}
#search-input:focus { border-color: #89b4fa; }
#search-count { font-size: 12px; color: #6c7086; }

/* xterm viewport must allow the search bar to overlay it. */
main { position: relative; }
