* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, var(--glow-a), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 0%, var(--glow-b), transparent 45%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 40%, var(--bg-end));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.35s ease, color 0.25s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
}
.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.brand span { color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: center; }
.nav a { color: var(--muted); font-weight: 500; }
.nav a:hover { color: var(--ink); }
.theme-picker { margin: 0; display: inline-flex; align-items: center; }
.theme-picker select {
  width: auto; max-width: 9.5rem; margin: 0; padding: 0.35rem 0.5rem;
  font-size: 0.85rem; border-radius: 6px;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.inline-form { display: inline; margin: 0; }
.link-btn {
  background: none; border: none; color: var(--muted); font: inherit; cursor: pointer; padding: 0;
}
.link-btn:hover { color: var(--ink); }

.site-main { flex: 1; width: min(1120px, 100%); margin: 0 auto; padding: 1.5rem; }
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
}
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }

.hero {
  display: grid;
  gap: 1.25rem;
  padding: 2.5rem 0 2rem;
  animation: rise 0.7s ease both;
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin: 0;
  max-width: 14ch;
}
.hero p { color: var(--muted); font-size: 1.15rem; max-width: 42ch; margin: 0; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--btn-ink); font-weight: 700;
  border: none; border-radius: 999px; padding: 0.7rem 1.25rem; cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { background: var(--accent-hover); color: var(--btn-ink); transform: translateY(-1px); }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.9rem; }
.btn-ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-danger { background: var(--danger); color: #1a0505; }

.flash {
  padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  animation: rise 0.35s ease both;
}
.flash.ok { background: color-mix(in srgb, var(--accent) 18%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.flash.err { background: color-mix(in srgb, var(--danger) 18%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.panel h1, .panel h2 { font-family: var(--display); margin-top: 0; }

label { display: block; margin: 0.75rem 0 0.35rem; color: var(--muted); font-size: 0.9rem; }
input[type=text], input[type=email], input[type=password], input[type=file], select, textarea {
  width: 100%; max-width: 420px;
  background: var(--bg0); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 0.65rem 0.75rem; font: inherit;
}
textarea { max-width: 100%; min-height: 100px; }
.checkbox { display: flex; gap: 0.5rem; align-items: center; margin: 0.75rem 0; color: var(--muted); }
.checkbox input { width: auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
}
.tile {
  display: block; position: relative; overflow: hidden; border-radius: 10px;
  aspect-ratio: 1; background: var(--bg2); border: 1px solid var(--line);
  transition: transform 0.2s ease, border-color 0.2s ease;
  animation: rise 0.5s ease both;
}
.tile:hover { transform: translateY(-3px); border-color: var(--accent-dim); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .meta {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0.4rem 0.5rem; font-size: 0.75rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff;
}

.pager { display: flex; gap: 0.75rem; align-items: center; margin-top: 1.25rem; color: var(--muted); }

.meter {
  height: 8px; background: var(--bg0); border-radius: 999px; overflow: hidden; margin-top: 0.4rem;
}
.meter > span { display: block; height: 100%; background: var(--accent); }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; }

pre.mono {
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.45;
}
.legal h1 { font-family: var(--display); }
.legal h2 { margin-top: 1.75rem; font-size: 1.15rem; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; word-break: break-all; }

.copy-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.copy-row input { max-width: 100%; flex: 1; min-width: 200px; }

.img-hero {
  max-width: 100%; border-radius: var(--radius); border: 1px solid var(--line);
  animation: fade 0.6s ease both;
}

.ad-slot {
  margin: 0.75rem 0 1rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.65rem;
  background: color-mix(in srgb, var(--bg0) 60%, transparent);
}
.ad-label {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.ad-placeholder {
  min-height: 90px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  justify-content: center;
  align-items: flex-start;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.5rem;
}

/* Theme picker */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.theme-card {
  text-align: left;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: inherit;
  font: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.theme-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.theme-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.theme-swatch {
  height: 72px;
  display: flex;
  align-items: flex-end;
  padding: 0.5rem;
  gap: 0.35rem;
}
.theme-swatch i {
  width: 18px; height: 18px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
}
.theme-meta { padding: 0.85rem 1rem 1rem; }
.theme-meta strong { display: block; font-family: var(--display); margin-bottom: 0.25rem; }
.theme-meta span { color: var(--muted); font-size: 0.85rem; }

[data-theme="jarvis"] .site-header {
  border-bottom-color: rgba(79, 210, 255, 0.25);
  box-shadow: 0 0 24px rgba(79, 210, 255, 0.06);
}
[data-theme="jarvis"] .brand span {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(79, 210, 255, 0.45);
}
[data-theme="jarvis"] .btn {
  border-radius: 4px;
  box-shadow: 0 0 16px rgba(79, 210, 255, 0.25);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .hero { padding-top: 1.5rem; }
}
