:root {
  --bg-main: #07090e;
  --bg-card: rgba(14, 20, 32, 0.75);
  --bg-card-hover: rgba(20, 28, 46, 0.85);
  --bg-input: rgba(8, 12, 22, 0.85);
  --border-card: rgba(0, 240, 255, 0.15);
  --border-focus: #00f0ff;
  
  --primary: #00f0ff;
  --primary-glow: rgba(0, 240, 255, 0.35);
  --accent-blue: #2563eb;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b;
  --danger: #ef4444;

  --text-main: #f3f4f6;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow-x: hidden;
  padding: 1.5rem 1rem;
}

/* Background Atmosphere */
.background-decorations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.25;
  animation: pulse-glow 8s ease-in-out infinite alternate;
}

.orb-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #00f0ff 0%, #2563eb 100%);
  top: -100px;
  right: -50px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #7928ca 0%, #0070f3 100%);
  bottom: -150px;
  left: -100px;
  animation-delay: -4s;
}

.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
                    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

@keyframes pulse-glow {
  0% { transform: scale(0.9) translate(0, 0); opacity: 0.2; }
  100% { transform: scale(1.1) translate(20px, 20px); opacity: 0.35; }
}

/* Main Container */
.container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 1;
}

/* Header */
.app-header {
  text-align: center;
  padding: 1rem 0;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 1px;
  margin-bottom: 0.75rem;
  backdrop-filter: blur(8px);
}

.status-dot {
  width: 6px;
  height: 6px;
  background-color: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary);
}

.app-title {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.4rem;
}

.app-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
  border-color: rgba(0, 240, 255, 0.35);
  box-shadow: 0 16px 40px rgba(0, 240, 255, 0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.25);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #ffffff;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Badge */
.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.connection-badge.connected {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--success);
  color: #34d399;
}

.connection-badge.connecting {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--warning);
  color: #fbbf24;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* BLE Search & Actions */
.ble-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.ble-search-inline {
  flex: 1;
}

.ble-search-inline input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
}

.ble-search-inline input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 12px var(--primary-glow);
}

.device-banner {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(0, 240, 255, 0.05);
  border: 1px dashed rgba(0, 240, 255, 0.3);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
}

.device-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.meta-val {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
}

/* Form Styles */
.config-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.form-group-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(0, 240, 255, 0.3), transparent);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  height: 44px;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font-size: 0.95rem;
  color: #ffffff;
  font-family: var(--font-sans);
  transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 12px var(--primary-glow);
  background: rgba(12, 18, 32, 0.95);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon input {
  padding-right: 42px;
}

.field-btn {
  position: absolute;
  right: 8px;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.field-btn:hover {
  color: var(--primary);
  background: rgba(0, 240, 255, 0.1);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-family: var(--font-sans);
}

.btn-primary {
  background: linear-gradient(135deg, #00f0ff 0%, #0070f3 100%);
  color: #000000;
}

.btn-glow:hover:not(:disabled) {
  box-shadow: 0 0 20px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  height: 50px;
  font-size: 1.05rem;
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.btn-text:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

/* Console Section */
.console-section {
  padding: 1.25rem;
}

.console-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.console-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.terminal-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--primary);
}

.log-container {
  height: 160px;
  background: #04060a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
}

.log-line {
  word-break: break-all;
}

.log-info { color: #94a3b8; }
.log-success { color: #34d399; }
.log-warn { color: #fbbf24; }
.log-error { color: #f87171; }

/* Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem 0;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* 响应式适配：手机与小屏幕设备 (Mobile Responsive) */
@media (max-width: 640px) {
  body {
    padding: 1rem 0.75rem;
  }

  .app-title {
    font-size: 1.7rem;
  }

  .glass-card {
    padding: 1.15rem 1rem;
    border-radius: var(--radius-md);
  }

  .ble-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .ble-search-inline {
    width: 100%;
  }

  .btn {
    width: 100%;
  }

  .input-row {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  /* 移动端保证输入框字号至少16px，防止iOS聚焦时网页强行缩放 */
  input[type="text"],
  input[type="password"] {
    font-size: 16px;
  }

  .device-banner {
    flex-direction: column;
    gap: 8px;
  }
}
