:root,
[data-theme="light"] {
  --bg: #eef1f6;
  --bg-accent: rgba(99, 102, 241, 0.06);
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #dde2ea;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-2: #06b6d4;
  --live: #059669;
  --live-bg: rgba(5, 150, 105, 0.1);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 8px 24px rgba(15, 23, 42, 0.1), 0 20px 48px rgba(79, 70, 229, 0.08);
  --header: rgba(238, 241, 246, 0.82);
  --toggle-track: #cbd5e1;
  --toggle-thumb: #fff;
  --grid-line: rgba(79, 70, 229, 0.05);
}

[data-theme="dark"] {
  --bg: #0b0f17;
  --bg-accent: rgba(99, 102, 241, 0.08);
  --surface: #131925;
  --surface-2: #1a2230;
  --border: #243044;
  --text: #e8edf5;
  --muted: #8b9bb0;
  --accent: #818cf8;
  --accent-2: #22d3ee;
  --live: #34d399;
  --live-bg: rgba(52, 211, 153, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 12px 32px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.35), 0 20px 48px rgba(99, 102, 241, 0.12);
  --header: rgba(11, 15, 23, 0.88);
  --toggle-track: #334155;
  --toggle-thumb: #f1f5f9;
  --grid-line: rgba(129, 140, 248, 0.06);
}

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

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s, color 0.3s;
  position: relative;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 20%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand__mark {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 8px;
}

.brand__name {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
}

.theme-toggle__input { position: absolute; opacity: 0; width: 0; height: 0; }

.theme-toggle__track {
  width: 44px;
  height: 24px;
  background: var(--toggle-track);
  border-radius: 999px;
  position: relative;
  transition: background 0.25s;
}

.theme-toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--toggle-thumb);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle__input:checked + .theme-toggle__track { background: var(--accent); }
.theme-toggle__input:checked + .theme-toggle__track .theme-toggle__thumb { transform: translateX(20px); }
.theme-toggle__input:focus-visible + .theme-toggle__track { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-toggle__label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  min-width: 2.75rem;
}

.main {
  flex: 1;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 4rem;
  position: relative;
  z-index: 1;
}

.hero { margin-bottom: 2.75rem; max-width: 620px; }

.hero__tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--bg-accent);
  border: 1px solid var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}

.hero__title {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.hero__lead {
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--muted);
}

.projects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.375rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  min-height: 200px;
}

a.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.card--soon {
  opacity: 0.55;
  cursor: default;
  background: var(--surface-2);
}

.card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card__num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
}

.card__status {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.card__status--live {
  color: var(--live);
  background: var(--live-bg);
  border-color: transparent;
}

.card__title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.card__desc {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--muted);
  flex: 1;
  margin-bottom: 1.25rem;
}

.card__url {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  font-family: ui-monospace, 'Cascadia Code', monospace;
}

.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 1.25rem;
  text-align: center;
}

.footer p { font-size: 0.8125rem; color: var(--muted); }

/* Portal auth & admin */
.header__inner { gap: 1rem; }
.header__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.user-menu__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.user-menu__name {
  font-size: 0.8125rem;
  color: var(--muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-sm { padding: 0.35rem 0.7rem; }
.btn-google {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
.btn-google:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-admin {
  background: var(--accent);
  color: #fff;
}
.btn-admin:hover { opacity: 0.9; color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-danger {
  background: #dc2626;
  color: #fff;
  border: none;
}
.card__status--private {
  color: #9333ea;
  background: rgba(147, 51, 234, 0.1);
  border-color: transparent;
}
.flash-wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 0;
  position: relative;
  z-index: 5;
}
.flash {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
}
.flash--success { border-color: #059669; color: #059669; }
.flash--error { border-color: #dc2626; color: #dc2626; }
.admin-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .admin-grid { grid-template-columns: 320px 1fr; }
}
.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.admin-panel--wide { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .admin-panel--wide { grid-column: 2; grid-row: 1 / span 2; }
}
.admin-panel__title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.admin-form label,
.admin-project-row label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.65rem;
}
.admin-form input,
.admin-form textarea,
.admin-form select,
.admin-project-row input,
.admin-project-row textarea,
.admin-project-row select {
  font-size: 0.875rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
.admin-project-row {
  margin-bottom: 0.5rem;
}
.admin-project-row__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.admin-project-row__fields input { flex: 1; min-width: 120px; }
.admin-check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.35rem !important;
  margin: 0 !important;
}
.admin-delete-form { margin: -0.25rem 0 1rem; }
.admin-divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

@media (max-width: 520px) {
  .main { padding: 2.5rem 1rem 3rem; }
  .projects { grid-template-columns: 1fr; }
}
