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

:root {
  --bg:        #0c0f14;
  --surface:   #131720;
  --surface2:  #1a2030;
  --border:    rgba(255,255,255,0.08);
  --border2:   rgba(255,255,255,0.14);
  --text:      #e8edf5;
  --muted:     #8a97ad;
  --hint:      #55637a;
  --accent:    #3b82f6;
  --accent-glow: rgba(59,130,246,0.18);
  --accent-dim:  rgba(59,130,246,0.08);
  --success:   #22c55e;
  --mono:      'IBM Plex Mono', monospace;
  --sans:      'IBM Plex Sans', sans-serif;
  --radius:    10px;
  --radius-lg: 14px;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

/* Фонова сітка */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(59,130,246,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.wrapper {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  animation: fadeUp 0.5s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-dim);
  border: 1px solid rgba(59,130,246,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo svg { width: 22px; height: 22px; color: var(--accent); }

.header-text h1 { font-size: 19px; font-weight: 500; color: var(--text); }
.header-text p { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

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

.card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--hint);
  display: block;
}

.console-launch {
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.console-launch:hover {
  border-color: rgba(59,130,246,0.45);
  background: #20293a;
}

.console-launch:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.console-launch:disabled {
  border-color: var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--hint);
  box-shadow: none;
  cursor: not-allowed;
}

/* Grid Layout */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.meta-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  padding: 12px 14px;
}

.meta-block p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.release-downloads {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.release-downloads-label {
  color: var(--hint);
}

.release-download-link {
  color: #9ec5ff;
  text-decoration: none;
  border-bottom: 1px dashed rgba(158,197,255,0.45);
  padding-bottom: 1px;
}

.release-download-link:hover {
  color: #c3ddff;
  border-bottom-color: rgba(195,221,255,0.8);
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

select {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a97ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.15s;
}

select:focus { border-color: var(--accent); }

esp-web-install-button { display: block; }

.connect-button {
  height: 42px;
  min-width: 120px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.connect-button:hover {
  border-color: rgba(59,130,246,0.45);
  background: #20293a;
}

.connect-button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

esp-web-install-button[active] .connect-button,
esp-web-install-button[disabled] .connect-button {
  border-color: var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--hint);
  box-shadow: none;
  pointer-events: none;
  cursor: not-allowed;
}

/* Console Styles & Rest */
.console-modal { position: fixed; inset: 0; z-index: 40; background: rgba(6,10,16,0.78); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; padding: 20px; }
.console-modal.visible { display: flex; }
.console-dialog { width: min(940px, 100%); background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-lg); box-shadow: 0 16px 40px rgba(0,0,0,0.38); padding: 18px; display: flex; flex-direction: column; gap: 12px; }

.console-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.console-header-info h2 { font-size: 16px; font-weight: 600; letter-spacing: 0.02em; }
.console-status { font-size: 12px; color: var(--muted); margin-top: 2px; }
.console-status.error { color: #f87171; }

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

.baud-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.console-select-sm {
  height: 34px;
  width: 140px;
  font-size: 13px;
  background-position: right 8px center;
  padding: 0 28px 0 10px;
}

.console-input-row {
  display: flex;
  gap: 8px;
}

.console-log { width: 100%; height: min(58vh, 540px); background: #0a0f19; border: 1px solid var(--border); border-radius: var(--radius); color: #d4dde8; font-family: var(--mono); font-size: 12px; line-height: 1.45; padding: 10px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console-input { height: 36px; min-width: 0; border: 1px solid var(--border2); border-radius: var(--radius); background: #0a0f19; color: var(--text); font-family: var(--mono); font-size: 13px; padding: 0 12px; outline: none; }
.console-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.console-btn { height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--border2); background: var(--surface2); color: var(--text); font-family: var(--sans); font-size: 13px; cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.console-btn:hover { border-color: rgba(59,130,246,0.45); background: #20293a; }
.console-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.console-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.console-controls .console-btn { flex: 1; min-width: 140px; justify-content: center; }

@media (max-width: 580px) {
  .console-top { flex-direction: column; align-items: flex-start; }
  .console-actions-top { width: 100%; justify-content: space-between; }
  .controls { grid-template-columns: 1fr; }
}
