/* ============================================================
   Reset & custom properties
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f0f12;
  --surface:      #1a1a24;
  --border:       #2a2a38;
  --text:         #e8e8f0;
  --muted:        #6b6b80;
  --accent:       #7c6af7;
  --accent-hover: #9180ff;
  --danger:       #f75c5c;
  --radius-sm:    6px;
  --radius-md:    10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

/* ============================================================
   Login page
   ============================================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 48px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  text-align: center;
}

.login-logo {
  font-size: 1.875rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 6px;
}
.login-logo span { color: var(--accent); }

.login-env {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 36px;
}

.btn-github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  background: #24292f;
  color: #fff;
  border: 1px solid #373d44;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-github:hover { background: #2f353b; border-color: #555d65; }
.btn-github svg { width: 20px; height: 20px; flex-shrink: 0; }

.login-note {
  margin-top: 18px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.login-auto-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px 20px;
  font-size: 0.9375rem;
  color: var(--muted);
  font-weight: 500;
}

.login-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.login-error {
  margin-top: 14px;
  font-size: 0.8125rem;
  color: var(--danger);
  background: rgba(247, 92, 92, 0.08);
  border: 1px solid rgba(247, 92, 92, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: left;
  line-height: 1.5;
}

/* ============================================================
   Dashboard layout
   ============================================================ */
.dashboard-page {
  display: grid;
  grid-template-rows: 48px 1fr 216px;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 0.9375rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand .dot  { color: var(--accent); }

.env-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(124, 106, 247, 0.12);
  border: 1px solid rgba(124, 106, 247, 0.3);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: 5px;
}

.url-bar-wrapper {
  display: flex;
  flex: 1;
  gap: 6px;
  min-width: 0;
}

.url-bar {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  outline: none;
  transition: border-color 0.15s;
}
.url-bar:focus { border-color: var(--accent); }

/* Shared button base */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font);
}
.btn:hover { background: var(--border); border-color: var(--muted); }

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

.user-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.user-name { font-size: 0.875rem; }

.logout-link {
  font-size: 0.8125rem;
  color: var(--muted);
  text-decoration: none;
}
.logout-link:hover { color: var(--text); }

/* ── Canvas / workspace ── */
.workspace {
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.canvas-placeholder.hidden { display: none; }

.placeholder-hint {
  font-size: 0.875rem;
  color: var(--muted);
}

#main-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #fff;
}

/* ── Chat panel ── */
.chat-panel {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chat-msg {
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 78%;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  padding: 7px 13px;
  border-radius: 14px 14px 3px 14px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: 14px 14px 14px 3px;
}

.chat-msg.thinking {
  align-self: flex-start;
  color: var(--muted);
  font-style: italic;
  font-size: 0.8125rem;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  height: 38px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--muted); }

/* ============================================================
   Setup wizard
   ============================================================ */
.wizard-page {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  padding: 48px 16px;
}

.wizard-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 44px;
}

.wizard-subtitle {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 28px;
}

/* Step indicators */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.4;
  transition: opacity 0.2s;
}

.wizard-step.active,
.wizard-step.done { opacity: 1; }

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.wizard-step.active .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.wizard-step.done .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.step-label {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.wizard-step-divider {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 10px;
  min-width: 24px;
}

/* Pane */
.wizard-pane-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.wizard-pane-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.wizard-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

.wizard-error {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--danger);
  background: rgba(247, 92, 92, 0.08);
  border: 1px solid rgba(247, 92, 92, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  line-height: 1.5;
}

/* Completion check */
.wizard-done-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(124, 106, 247, 0.15);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

/* ============================================================
   Shared form elements (wizard + manage pages)
   ============================================================ */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input,
.form-select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
}

.form-input:focus,
.form-select:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--muted); }

.form-hint {
  margin-top: 5px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.form-hint-inline {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
}

/* ============================================================
   Manage / subdomain manager page
   ============================================================ */
.manage-page {
  display: grid;
  grid-template-rows: 48px 1fr;
  min-height: 100vh;
}

.manage-main {
  padding: 32px 40px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
}

.manage-title {
  font-size: 1.375rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.manage-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.manage-section {
  margin-bottom: 40px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
}

/* Top nav */
.top-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  padding-left: 8px;
}

.top-nav-link {
  font-size: 0.8125rem;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.top-nav-link:hover,
.top-nav-link.active {
  background: var(--border);
  color: var(--text);
}

/* Add-subdomain form */
.add-subdomain-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group-flex { flex: 1; min-width: 220px; }
.form-group-action { flex-shrink: 0; }

/* DNS instructions */
.dns-instructions {
  background: rgba(124, 106, 247, 0.06);
  border: 1px solid rgba(124, 106, 247, 0.25);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin-bottom: 8px;
}

.dns-title {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent);
}

.dns-instructions p {
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.dns-record-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dns-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.dns-value {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 0.8125rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  color: var(--text);
}

.dns-arrow { color: var(--muted); }

.dns-ttl {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 4px;
}

/* Subdomain list */
.subdomain-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-hint {
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
  padding: 32px 0;
}

.subdomain-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  gap: 12px;
  flex-wrap: wrap;
}

.subdomain-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.subdomain-hostname {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 0.875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subdomain-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Status badges */
.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 4px;
  padding: 2px 7px;
  border: 1px solid transparent;
  flex-shrink: 0;
}

.badge-green  { background: rgba(52, 211, 153, 0.12); color: #34d399; border-color: rgba(52, 211, 153, 0.3); }
.badge-yellow { background: rgba(251, 191, 36, 0.12); color: #fbbf24; border-color: rgba(251, 191, 36, 0.3); }
.badge-blue   { background: rgba(99, 179, 237, 0.12); color: #63b3ed; border-color: rgba(99, 179, 237, 0.3); }
.badge-red    { background: rgba(247, 92, 92, 0.12);  color: #f75c5c; border-color: rgba(247, 92, 92, 0.3); }
.badge-muted  { background: rgba(107, 107, 128, 0.12); color: var(--muted); border-color: var(--border); }

/* Table header row */
.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* Small button variant */
.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 0.8125rem;
}

/* ============================================================
   Modal overlay
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 36px;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-subtitle {
  font-size: 0.8125rem;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  color: var(--accent);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Dev-account notice ─────────────────────────────────────────────────── */
.dev-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 179, 237, 0.08);
  border: 1px solid rgba(99, 179, 237, 0.25);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.8125rem;
  color: #63b3ed;
  margin-bottom: 20px;
}
.dev-notice-badge {
  display: inline-block;
  background: rgba(99, 179, 237, 0.18);
  border: 1px solid rgba(99, 179, 237, 0.3);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Marketing homepage ─────────────────────────────────────────────────── */
.home-page {
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 40px;
  border-bottom: 1px solid var(--border);
}
.home-cta-top { font-size: 0.875rem; padding: 7px 16px; }
.home-main {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 64px 32px 80px;
  width: 100%;
}
.home-hero { text-align: center; margin-bottom: 72px; }
.home-headline {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 20px;
}
.home-subheadline {
  font-size: 1.125rem;
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto 32px;
  line-height: 1.6;
}
.home-hero-btn { font-size: 1rem; padding: 12px 28px; }
.home-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 72px;
}
.home-feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
}
.home-feature-icon { font-size: 1.75rem; margin-bottom: 14px; }
.home-feature-title { font-size: 1rem; font-weight: 700; margin-bottom: 10px; }
.home-feature-desc  { font-size: 0.875rem; color: var(--muted); line-height: 1.6; }
.home-how { margin-bottom: 72px; }
.home-section-title {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 28px;
  text-align: center;
}
.home-steps { list-style: none; display: flex; flex-direction: column; gap: 20px; }
.home-step {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  font-size: 0.9375rem;
  line-height: 1.55;
}
.home-step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(99, 179, 237, 0.15);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  margin-top: 1px;
}
.home-footer {
  border-top: 1px solid var(--border);
  padding: 20px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-size: 0.8125rem;
  color: var(--muted);
}
.home-footer-link { color: var(--accent); text-decoration: none; }
.home-footer-link:hover { text-decoration: underline; }

/* ── Subdomain preview page (404.html) ──────────────────────────────────── */
.subdomain-page {
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.subdomain-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.subdomain-loading { display: flex; justify-content: center; }
.subdomain-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}
.subdomain-name {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
  word-break: break-all;
}
.subdomain-claim-text {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 16px 0 20px;
  line-height: 1.5;
}
.subdomain-claim-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.subdomain-wide-btn { width: 100%; justify-content: center; }
.subdomain-divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.8125rem;
  margin: 2px 0;
}
.subdomain-msg {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 14px;
  line-height: 1.5;
}
.subdomain-msg-muted { color: var(--muted); opacity: 0.7; }
.subdomain-hint {
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.6;
  margin-top: 8px;
}
.subdomain-link { color: var(--accent); text-decoration: none; }
.subdomain-link:hover { text-decoration: underline; }
