:root {
  --bg: #05050a;
  --panel: #101018;
  --panel-2: #15151f;
  --border: #232333;
  --text: #f2f2f7;
  --muted: #8a8a9a;
  --primary: #4f7df3;
  --primary-dark: #3a63d1;
  --error: #ff6b6b;
  --ok: #35d07f;
  --pink: #ff4fd8;
  --purple: #c9a2ff;
  --blue: #4fa0ff;
}

* { box-sizing: border-box; }

/* Any class below this line can set its own `display`, which would
   otherwise out-specificity the browser's default `[hidden] { display:
   none }` rule and make the element show up even while hidden (this bit
   the modal backdrops and the ip-mode field grid). This wins over
   everything else in this file except an explicit !important. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

.page {
  width: min(94vw, 420px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 0 16px;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ---- Neon rotating avatar (ported from NeonRotatingAvatar) ---- */

.avatar-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 40px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.avatar-glow, .avatar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--pink), var(--purple), var(--blue), var(--pink));
  animation: spin 5s linear infinite;
}

.avatar-glow {
  filter: blur(16px);
  opacity: 0.6;
}

.avatar-ring { padding: 4px; }
.avatar-ring::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--bg);
}

.avatar-img {
  position: relative;
  z-index: 2;
  width: 192px;
  height: 192px;
  border-radius: 50%;
  object-fit: cover;
}

/* ---- Host input + login button ---- */

.input-row {
  width: 100%;
  display: flex;
  gap: 8px;
}

input[type="text"], input[type="password"], input[type="number"], input[type="email"], select, textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  min-width: 0;
  background: var(--panel);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.icon-btn {
  border: none;
  border-radius: 10px;
  width: 48px;
  min-width: 48px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover { background: var(--primary-dark); }
.icon-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.status {
  min-height: 18px;
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 0;
  text-align: center;
}
.status.ok { color: var(--ok); }
.status.error { color: var(--error); }

/* ---- Action row (Serial REPL / Serial config / Firmware update) ---- */

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

.ghost-icon-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #8a97a6;
}

.ghost-icon-btn:hover { background: linear-gradient(135deg, var(--pink), var(--blue)); color: white; }
.ghost-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; background: none !important; }

/* ---- Font Awesome (vendored locally at app/static/vendor/fontawesome) ---- */

.icon-btn i { font-size: 17px; }
.ghost-icon-btn i { font-size: 17px; }
.term-icon-btn i { font-size: 11px; }
.pw-toggle i { font-size: 13px; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: white;
  border-radius: 50%;
  animation: rotate 0.7s linear infinite;
}
@keyframes rotate { to { transform: rotate(360deg); } }

footer {
  position: fixed;
  right: 12px;
  bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  z-index: 5;
}

/* ---- Terminal panel ---- */

.terminal-panel {
  width: 90vw;
  margin-top: 18px;
  background: black;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-height: 0;
  opacity: 0;
  transform: translateY(-10px);
  transition: max-height 280ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 200ms ease, transform 240ms ease, margin-top 280ms ease,
    border-color 280ms ease;
}

.terminal-panel.is-visible {
  max-height: 520px;
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .terminal-panel {
    transition: none;
  }
}

.terminal-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #101010;
  overflow-x: auto;
}

.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--error);
  flex: 0 0 auto;
}
.status-dot.connected { background: var(--ok); }

.terminal-label {
  color: white;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.terminal-toolbar-spacer { flex: 1; }

.term-btn, .term-icon-btn {
  background: transparent;
  border: 1px solid #4a4a4a;
  color: var(--muted);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.term-icon-btn { padding: 3px 6px; }
.term-btn:hover:not(:disabled), .term-icon-btn:hover:not(:disabled) { color: var(--text); border-color: #5a5a5a; }
.term-btn:disabled, .term-icon-btn:disabled { color: #777; border-color: #333; cursor: not-allowed; }

#terminal { height: 260px; padding: 6px; }

/* ---- Modals ---- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  align-items: center; justify-content: center;
  z-index: 50;
  padding: 16px;
}

/* `display: flex` must NOT live on the bare class above: a class selector
   beats the browser's default `[hidden] { display: none }` rule, so the
   backdrop would show even while `hidden` is set. Scope it to the
   not-hidden case instead. */
.modal-backdrop:not([hidden]) {
  display: flex;
}

.modal {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: min(92vw, 460px);
  max-height: 88vh;
  overflow-y: auto;
}

.modal h2 { margin: 0 0 12px; font-size: 18px; }
.modal p { font-size: 13px; color: var(--muted); line-height: 1.5; }

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}
.modal-grid-span { grid-column: 1 / -1; }

.modal-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.pw-row { display: flex; gap: 6px; }
.pw-toggle {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  width: 40px;
  cursor: pointer;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.primary:disabled { background: #3a3f55; cursor: not-allowed; }
.btn.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--border); }

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
  margin: 16px 0 10px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pink), var(--blue));
  transition: width 0.2s ease;
}

.hint.error { color: var(--error); }


/* ---- Serial port picker ---- */

.port-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.port-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1.5px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}
.port-item:hover { border-color: var(--primary); }
.port-item i { font-size: 18px; color: var(--muted); }
.port-item.likely i { color: var(--ok); }

.port-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.port-item-device { font-weight: 700; }
.port-item-desc { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.port-item-badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ok);
  border: 1px solid var(--ok);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.port-list-empty { color: var(--muted); font-size: 13px; padding: 12px 2px; }
.xterm-rows{
  font-size: 12px;
}