/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #F5F7FA;
  --surface:     #FFFFFF;
  --border:      #E2E6ED;
  --border-s:    #CDD3DC;
  --text:        #1A1D23;
  --text-2:      #5A6271;
  --text-3:      #8C95A6;
  --accent:      #2563EB;
  --accent-bg:   #EEF3FF;
  --accent-text: #1D4ED8;
  --success:     #16A34A;
  --success-bg:  #F0FDF4;
  --success-bd:  #BBF7D0;
  --danger:      #DC2626;
  --danger-bg:   #FFF1F1;
  --danger-bd:   #FECACA;
  --radius:      8px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:        'Fira Mono', 'Consolas', 'Menlo', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 2.5rem 1rem 4rem;
  line-height: 1.5;
}

/* ── Page layout ──────────────────────────────────────── */
.page {
  max-width: 600px;
  margin: 0 auto;
}

/* ── Brand header ─────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.75rem;
}
.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.brand-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}
.brand-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Card ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

/* ── Section label ────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}

/* ── Divider ──────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ── Fields ───────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.field:last-of-type { margin-bottom: 0; }

label:not(.radio-option):not(.toggle-row) {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.label-hint {
  font-weight: 400;
  color: var(--text-3);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--text-3); }

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

select {
  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='%238C95A6' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

#port-custom {
  margin-top: 6px;
}

/* ── Rows ─────────────────────────────────────────────── */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.row .field { margin-bottom: 12px; }
.row-host { grid-template-columns: 1fr 160px; }

/* ── Encryption radio group ───────────────────────────── */
.radio-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.radio-option {
  cursor: pointer;
}
.radio-option input[type="radio"] {
  display: none;
}
.radio-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color .15s, background .15s;
  height: 100%;
}
.radio-option input:checked + .radio-box {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.radio-dot {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-s);
  border-radius: 50%;
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
  position: relative;
}
.radio-dot::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity .15s;
}
.radio-option input:checked + .radio-box .radio-dot {
  border-color: var(--accent);
}
.radio-option input:checked + .radio-box .radio-dot::after {
  opacity: 1;
}
.radio-text strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.radio-text small {
  font-size: 11px;
  color: var(--text-3);
}
.radio-option input:checked + .radio-box .radio-text strong {
  color: var(--accent-text);
}

/* ── Auth toggle ──────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #FAFBFC;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 12px;
  user-select: none;
  transition: background .15s;
}
.toggle-row:hover { background: #F5F7FA; }
.toggle-info {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
}
.toggle-info svg { color: var(--text-3); }
.toggle-hint {
  font-weight: 400;
  color: var(--text-3);
}
.toggle {
  width: 34px;
  height: 20px;
  background: var(--border-s);
  border-radius: 10px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle-knob {
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on .toggle-knob { transform: translateX(14px); }

.no-auth-notice {
  font-size: 13px;
  color: var(--text-3);
  padding: 9px 12px;
  background: #FAFBFC;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── Run button ───────────────────────────────────────── */
.run-btn {
  width: 100%;
  height: 42px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 1.25rem;
  transition: background .15s, opacity .15s;
}
.run-btn:hover:not(:disabled) { background: #1D4ED8; }
.run-btn:disabled { opacity: .6; cursor: not-allowed; }
.run-btn.loading svg { animation: spin .8s linear infinite; }

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

/* ── Result card ──────────────────────────────────────── */
#result-wrap { margin-top: 1rem; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.result-header {
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.result-header.success { background: var(--success-bg); border-bottom-color: var(--success-bd); }
.result-header.error   { background: var(--danger-bg);  border-bottom-color: var(--danger-bd);  }

.result-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  letter-spacing: .04em;
}
.result-badge.success { background: var(--success); color: #fff; }
.result-badge.error   { background: var(--danger);  color: #fff; }

.result-title {
  font-size: 14px;
  font-weight: 500;
}
.result-title.success { color: var(--success); }
.result-title.error   { color: var(--danger);  }

/* ── Log ──────────────────────────────────────────────── */
.result-log {
  padding: 1rem;
  background: #FAFBFC;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.9;
}

.log-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.log-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}
.log-dot.ok    { background: var(--success); }
.log-dot.error { background: var(--danger);  }

.log-text      { color: var(--text-2); }
.log-text.ok   { color: var(--success); }
.log-text.error{ color: var(--danger);  }

/* ── Tip ──────────────────────────────────────────────── */
.result-tip {
  font-size: 13px;
  color: var(--text-2);
  padding: .75rem 1rem;
  border-top: 1px solid var(--danger-bd);
  background: var(--danger-bg);
  line-height: 1.6;
}
.result-tip strong { color: var(--danger); }

/* ── Shake animation (validation) ────────────────────── */
@keyframes shake {
  0%,100%{ transform: translateX(0); }
  25%    { transform: translateX(-6px); }
  75%    { transform: translateX(6px); }
}
.shake {
  animation: shake .3s ease;
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(220,38,38,.12) !important;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 500px) {
  .row, .row-host { grid-template-columns: 1fr; }
  .radio-group { grid-template-columns: 1fr 1fr; }
}
/* ── FAQ ──────────────────────────────────────────────── */
.faq {
  margin-top: 2rem;
}
.faq-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  letter-spacing: -0.2px;
}
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 8px;
  overflow: hidden;
}
.faq-q {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background .15s;
}
.faq-q:hover { background: #FAFBFC; }
.faq-q::after {
  content: '';
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238C95A6' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: transform .2s;
}
.faq-item.open .faq-q::after { transform: rotate(180deg); }
.faq-item.open .faq-q { color: var(--accent); }
.faq-a {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
  padding: 0 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease, padding .3s ease;
}
.faq-item.open .faq-a {
  max-height: 200px;
  padding: 0 16px 14px;
}