@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ─── Reset & Base ────────────────────────────────────────────────────────── */

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

:root {
  --bg: #09090b;
  --surface: #131316;
  --surface-2: #1a1a1f;
  --border: #27272a;
  --border-light: #3f3f46;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent: #10b981;
  --accent-dim: #059669;
  --accent-glow: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-lg: 16px;
  --font: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html { background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ──────────────────────────────────────────────────────────────── */

.page { max-width: 520px; margin: 0 auto; padding: 3rem 1.5rem; }
.page-wide { max-width: 640px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ─── Landing Header ─────────────────────────────────────────────────────── */

.hero { text-align: center; margin-bottom: 3rem; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-glow);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 100px;
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.75rem;
}

.hero h1 span { color: var(--accent); }

.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 400px;
  margin: 0 auto;
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.card-header {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

/* ─── Forms ───────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-dim); }

.form-input-mono {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dim);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--border-light);
  color: var(--text);
  background: var(--surface-2);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-chatgpt {
  background: #1a1a1f;
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
  padding: 12px 20px;
}

.btn-chatgpt:hover {
  background: var(--surface-2);
  border-color: var(--border-light);
}

.btn-chatgpt svg { flex-shrink: 0; }

.btn-block { width: 100%; }

.btn-sm { font-size: 0.8rem; padding: 7px 14px; }

/* ─── Switch Link ─────────────────────────────────────────────────────────── */

.switch-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 1.25rem;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  text-align: center;
}

/* ─── Steps ───────────────────────────────────────────────────────────────── */

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 3rem; }

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
}

.step-num {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.step-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.step-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ─── Nav ─────────────────────────────────────────────────────────────────── */

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.topnav-brand {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
}

.topnav-email { color: var(--text-dim); }

/* ─── Status Banner ───────────────────────────────────────────────────────── */

.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-weight: 500;
  font-size: 0.9rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-running {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--accent);
}

.status-running .status-dot {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.status-stopped {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.status-stopped .status-dot { background: var(--text-dim); }

.status-starting {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.status-starting .status-dot {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

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

.status-error .status-dot { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── URL Box ─────────────────────────────────────────────────────────────── */

.url-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.url-box code {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

/* ─── Section ─────────────────────────────────────────────────────────────── */

.section {
  margin-bottom: 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  cursor: pointer;
  user-select: none;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.section-toggle {
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: transform 0.2s;
}

/* ─── Key Status ──────────────────────────────────────────────────────────── */

.key-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  margin-bottom: 8px;
}

.key-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.key-dot.active { background: var(--accent); }
.key-dot.inactive { background: var(--text-dim); }

.key-name { color: var(--text-muted); }
.key-value { color: var(--text-dim); font-family: var(--mono); font-size: 0.75rem; }

/* ─── Deploy Controls ─────────────────────────────────────────────────────── */

.deploy-row {
  display: flex;
  gap: 8px;
  margin-top: 1.5rem;
}

.deploy-row .btn { flex: 1; }

/* ─── Divider ─────────────────────────────────────────────────────────────── */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 1.25rem 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}

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

/* ─── Save status ─────────────────────────────────────────────────────────── */

.save-msg {
  font-size: 0.8rem;
  margin-top: 8px;
  min-height: 1.2em;
}

.save-msg.success { color: var(--accent); }
.save-msg.error { color: var(--danger); }

/* ─── Footer ──────────────────────────────────────────────────────────────── */

.footer {
  text-align: center;
  padding: 3rem 0 2rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ─── Animations ──────────────────────────────────────────────────────────── */

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

.fade-up {
  animation: fadeUp 0.5s ease both;
}

.fade-up-1 { animation-delay: 0.05s; }
.fade-up-2 { animation-delay: 0.1s; }
.fade-up-3 { animation-delay: 0.15s; }
.fade-up-4 { animation-delay: 0.2s; }
.fade-up-5 { animation-delay: 0.25s; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 520px) {
  .hero h1 { font-size: 2rem; }
  .steps { grid-template-columns: 1fr; }
  .page { padding: 2rem 1rem; }
  .deploy-row { flex-direction: column; }
}

/* ─── Overlay / Modal ─────────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.overlay-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  animation: fadeUp 0.3s ease both;
}

.overlay-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.overlay-close:hover { color: var(--text); }

.overlay-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.overlay-step {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ─── Device Code ─────────────────────────────────────────────────────────── */

.device-code-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.25rem;
}

.device-code-box code {
  flex: 1;
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.15em;
  text-align: center;
}

.device-status {
  text-align: center;
  font-size: 0.82rem;
  padding: 8px;
  border-radius: var(--radius);
}

.device-status.polling {
  color: var(--warning);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.15);
  animation: pulse 2s infinite;
}

.device-status.success {
  color: var(--accent);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.device-status.error {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.device-success-icon {
  text-align: center;
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

/* ─── Hidden utility ──────────────────────────────────────────────────────── */
[hidden] { display: none !important; }
