/* Tools Engine — shared diagnostic shell */
.te-wrap {
  --te-accent: #00c8b5;
  --te-accent-dim: rgba(0, 200, 181, 0.15);
  --te-bg: #0a0a0a;
  --te-card: #141414;
  --te-border: rgba(255, 255, 255, 0.08);
  --te-text: #ffffff;
  --te-muted: #8a8f98;
  --te-danger: #f87171;
  --te-success: #34d399;
  max-width: 720px;
  margin: 0 auto 48px;
  padding: 0 16px;
  font-family: inherit;
}

.te-shell {
  background: var(--te-bg);
  border-radius: 12px;
  padding: 28px 24px 32px;
  color: var(--te-text);
  border: 1px solid var(--te-border);
}

.te-head {
  text-align: center;
  margin-bottom: 24px;
}

.te-head h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}

.te-head p {
  margin: 0;
  font-size: 13px;
  color: var(--te-muted);
  line-height: 1.6;
}

.te-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border: none;
  border-radius: 8px;
  background: var(--te-accent);
  color: #0a0a0a;
  font-size: 14px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.te-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  opacity: 0.92;
}

.te-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.te-btn--ghost {
  background: transparent;
  color: var(--te-accent);
  border: 1px solid rgba(0, 200, 181, 0.4);
}

.te-btn--danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--te-danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.te-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--te-border);
  border-radius: 8px;
  background: var(--te-card);
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.te-input:focus {
  border-color: var(--te-accent);
}

.te-input::placeholder {
  color: var(--te-muted);
}

.te-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--te-muted);
  font-size: 12px;
}

.te-divider::before,
.te-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--te-border);
}

.te-server-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--te-card);
  border: 1px solid var(--te-border);
  border-radius: 10px;
}

.te-flag {
  width: 28px;
  height: 21px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}

.te-server-info {
  flex: 1;
  min-width: 0;
}

.te-server-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.te-server-city {
  font-size: 12px;
  color: var(--te-muted);
  margin-top: 2px;
}

.te-link-btn {
  border: none;
  background: none;
  color: #4da3ff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

.te-link-btn:hover {
  text-decoration: underline;
}

.te-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #fca5a5;
  font-size: 13px;
  text-align: center;
  display: none;
}

.te-error.visible {
  display: block;
}

.te-server-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 480px;
  width: calc(100% - 32px);
  background: #141414;
  color: #fff;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.te-server-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.te-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--te-border);
}

.te-dialog-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.te-dialog-close {
  border: none;
  background: none;
  color: var(--te-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.te-server-list {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px 0;
}

.te-server-group-title {
  padding: 10px 20px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--te-muted);
  letter-spacing: 0.05em;
}

.te-server-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 20px;
  border: none;
  background: none;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  text-align: right;
  cursor: pointer;
  transition: background 0.15s;
}

.te-server-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.te-server-option.selected {
  background: var(--te-accent-dim);
}

.te-server-option-name {
  flex: 1;
  font-weight: 600;
}

.te-server-option-city {
  font-size: 12px;
  color: var(--te-muted);
}

@media (max-width: 560px) {
  .te-shell {
    padding: 20px 16px 24px;
  }

  .te-server-bar {
    flex-wrap: wrap;
  }
}

/* Light theme (ping page) */
.te-wrap.te-light {
  --te-accent: #0093e9;
  --te-accent-dim: rgba(0, 147, 233, 0.1);
  --te-bg: #ffffff;
  --te-card: #f8fafc;
  --te-border: rgba(67, 86, 163, 0.14);
  --te-text: #1e293b;
  --te-muted: #64748b;
  --te-danger: #dc2626;
  --te-success: #059669;
}

.te-wrap.te-light .te-shell {
  box-shadow: 0 4px 24px rgba(67, 86, 163, 0.08);
}

.te-wrap.te-light .te-head h2 {
  color: #4356a3;
}

.te-wrap.te-light .te-btn {
  background: linear-gradient(135deg, #4356a3, #0093e9);
  color: #fff;
}

.te-wrap.te-light .te-link-btn {
  color: #4356a3;
}

.te-wrap.te-light .te-error {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.25);
  color: #b91c1c;
}

.te-wrap.te-light .te-server-dialog {
  background: #fff;
  color: var(--te-text);
  box-shadow: 0 24px 64px rgba(67, 86, 163, 0.18);
}

.te-wrap.te-light .te-server-dialog::backdrop {
  background: rgba(30, 41, 59, 0.35);
}

.te-wrap.te-light .te-server-option {
  color: var(--te-text);
}

.te-wrap.te-light .te-server-option:hover {
  background: rgba(67, 86, 163, 0.06);
}

.te-wrap.te-light .te-server-option.selected {
  background: var(--te-accent-dim);
}

.te-wrap.te-light .te-input {
  color: #1e293b;
  background: #fff;
  border-color: rgba(67, 86, 163, 0.22);
  -webkit-text-fill-color: #1e293b;
}

.te-wrap.te-light .te-input::placeholder {
  color: #94a3b8;
  opacity: 1;
}

.te-wrap.te-light .te-input:focus {
  border-color: var(--te-accent);
  box-shadow: 0 0 0 3px rgba(0, 147, 233, 0.12);
}

.te-wrap.te-light .te-btn--ghost {
  background: #fff;
  color: #4356a3;
  border: 1px solid rgba(67, 86, 163, 0.35);
}
