:root {
  /* Core Colors */
  --bg: #0b1020;
  --bg-pattern-1: rgba(49, 98, 255, .15);
  --bg-pattern-2: rgba(0, 190, 255, .1);
  --card-bg: #131b2e;
  --card-border: rgba(255, 255, 255, 0.08);

  /* Text Colors */
  --txt: #f1f5f9;
  --txt-dim: #94a3b8;
  --txt-muted: #64748b;

  /* Brand Colors */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-ring: rgba(59, 130, 246, 0.5);

  /* Functional Colors */
  --error: #ef4444;
  --warn: #eab308;
  --success: #22c55e;
  --input-bg: rgba(0, 0, 0, 0.2);
  --input-border: rgba(255, 255, 255, 0.1);
  --code-bg: #0f172a;

  /* Typography */
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;

  /* Metrics */
  --radius: 12px;
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --bg-pattern-1: rgba(59, 130, 246, 0.05);
    --bg-pattern-2: rgba(14, 165, 233, 0.05);
    --card-bg: #ffffff;
    --card-border: #e2e8f0;

    --txt: #0f172a;
    --txt-dim: #475569;
    --txt-muted: #94a3b8;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;

    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --code-bg: #f1f5f9;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  }
}

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

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--txt);
  background:
    radial-gradient(circle at 15% 15%, var(--bg-pattern-1) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, var(--bg-pattern-2) 0%, transparent 40%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Header */
header {
  margin-bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), #06b6d4);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--txt);
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  color: var(--txt-dim);
  font-size: 0.95rem;
}

/* Grid Layout */
.grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: 5fr 7fr;
    gap: 32px;
  }
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.card h2 {
  margin: 0 0 20px 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Forms */
.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--txt-dim);
  margin-bottom: 8px;
}

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

.input-group.stack-mobile {
  flex-wrap: wrap;
}

input[type="text"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--txt);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

textarea {
  font-family: var(--mono);
  font-size: 0.9rem;
  min-height: 120px;
  line-height: 1.4;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--txt-muted);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

input[readonly],
textarea[readonly] {
  opacity: 0.8;
  cursor: default;
  background: var(--code-bg);
  border-color: var(--card-border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  background: var(--primary);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-hover);
}

.btn:active {
  transform: translateY(1px);
}

.btn.secondary {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--txt-dim);
}

.btn.secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.btn.small {
  padding: 4px 12px;
  font-size: 0.8rem;
  height: 28px;
}

/* ISP Selection specific */
.isp-actions {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

#ispSelect {
  flex: 1;
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.2s;
}

#ispSelect.show {
  opacity: 1;
  pointer-events: auto;
  border-color: var(--primary);
}

/* Results Area */
.status-msg {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  display: none;
}

.status-msg.error {
  display: block;
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 0;
  color: var(--txt);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
}

.code-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 9999px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--card-border);
  color: var(--txt-muted);
  font-size: 0.9rem;
}

.footer a {
  color: var(--txt-dim);
  text-decoration: none;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.footer a:hover {
  color: var(--primary);
}