:root {
  --cape-blue: #00009A;
  --cape-blue-deep: #00006F;
  --cape-blue-tint: #1A1AB0;
  --cape-orange: #FF5A00;
  --cape-orange-hover: #FF7733;
  --white: #FFFFFF;
  --off-white: #F5F5FA;
  --ink: #0A0A1F;
  --muted: rgba(255, 255, 255, 0.65);
  --line: rgba(255, 255, 255, 0.14);
  --card: rgba(255, 255, 255, 0.06);
  --card-hover: rgba(255, 255, 255, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--cape-blue);
  color: var(--white);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-feature-settings: 'ss01', 'cv01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(255, 90, 0, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(26, 26, 176, 0.6), transparent 60%),
    var(--cape-blue);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Dashboard page: cosmic ambient ---------- */

body.dashboard-page {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, #1a0f4e 0%, transparent 60%),
    radial-gradient(ellipse 80% 60% at 50% 110%, #2a0a5e 0%, transparent 60%),
    linear-gradient(180deg, #04001f 0%, #0a0240 35%, #080038 70%, #03001a 100%);
  position: relative;
}

body.dashboard-page > header,
body.dashboard-page > main,
body.dashboard-page > footer {
  position: relative;
  z-index: 2;
}

/* Ambient nebula: no goo, very slow drift, heavily blurred */
body.dashboard-page .blobs {
  filter: none;
  mix-blend-mode: screen;
  opacity: 0.55;
}

body.dashboard-page .blob {
  filter: blur(120px);
  opacity: 0.75;
  animation-duration: 100s !important;
}

body.dashboard-page .blob.b1 {
  width: 540px; height: 540px;
  top: -8%; left: -10%;
  background: #FF5A00;
  animation: d-float-a 110s ease-in-out infinite;
}
body.dashboard-page .blob.b2 {
  width: 640px; height: 640px;
  top: 45%; right: -12%;
  background: #3C1DC9;
  animation: d-float-b 140s ease-in-out infinite;
}
body.dashboard-page .blob.b3 {
  width: 440px; height: 440px;
  top: 25%; left: 45%;
  background: #00B4FF;
  animation: d-float-c 125s ease-in-out infinite;
  opacity: 0.55;
}
body.dashboard-page .blob.b4 {
  width: 380px; height: 380px;
  bottom: -8%; left: 30%;
  background: #FF2D8C;
  animation: d-float-d 135s ease-in-out infinite;
  opacity: 0.5;
}
body.dashboard-page .blob.b5 {
  display: none;
}

@keyframes d-float-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(90px, 70px) scale(1.1); }
}
@keyframes d-float-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-80px, -50px) scale(0.95); }
}
@keyframes d-float-c {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(50px, -70px) scale(1.08); }
}
@keyframes d-float-d {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-70px, 40px) scale(1.05); }
}

/* Tiles on cosmic background: frosted glass + a bit darker for readability */
body.dashboard-page .tile {
  background: rgba(12, 6, 48, 0.42);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-color: rgba(255, 255, 255, 0.12);
}

body.dashboard-page .tile:hover {
  background: rgba(22, 12, 60, 0.58);
  border-color: rgba(255, 255, 255, 0.3);
}

body.dashboard-page .site-header,
body.dashboard-page .footer {
  border-color: rgba(255, 255, 255, 0.08);
}

body.dashboard-page .empty-state {
  background: rgba(12, 6, 48, 0.35);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* Tile description line */
.tile-description {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
  margin-top: -8px;
  max-width: 220px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font-family: inherit; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 48px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand img {
  height: 32px;
  width: auto;
  display: block;
}

.brand-word {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 14px;
  text-transform: uppercase;
  opacity: 0.85;
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.user-chip img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--white);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
  text-decoration: none;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-primary {
  background: var(--cape-orange);
  border-color: var(--cape-orange);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--cape-orange-hover);
  border-color: var(--cape-orange-hover);
}

.btn-danger {
  background: transparent;
  border-color: rgba(255, 120, 120, 0.5);
  color: #FFB4B4;
}

.btn-danger:hover {
  background: rgba(255, 80, 80, 0.15);
  border-color: rgba(255, 120, 120, 0.9);
}

main {
  flex: 1;
  padding: 56px 48px 96px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.hero {
  margin-bottom: 48px;
}

.hero-eyebrow {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cape-orange);
  font-weight: 700;
  margin-bottom: 12px;
}

.hero-title {
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin: 0 0 16px;
}

.hero-subtitle {
  font-size: 17px;
  color: var(--muted);
  max-width: 640px;
  line-height: 1.55;
  margin: 0;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 36px 24px;
  min-height: 220px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--white);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  overflow: hidden;
}

.tile::after {
  content: '';
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 18px;
  height: 2px;
  background: var(--cape-orange);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 200ms ease;
}

.tile:hover {
  background: var(--card-hover);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-3px);
  box-shadow: 0 20px 40px rgba(0, 0, 40, 0.35);
}

.tile:hover::after {
  transform: scaleX(1);
}

.tile-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tile-icon img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  display: block;
}

.tile-icon-fallback {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cape-blue-deep);
  color: var(--white);
  font-weight: 800;
  font-size: 28px;
  border-radius: var(--radius-sm);
}

.tile-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}

.tile-host {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: -10px;
}

.empty-state {
  text-align: center;
  padding: 80px 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty-state h2 {
  font-size: 22px;
  margin: 0 0 8px;
}

.empty-state p {
  color: var(--muted);
  margin: 0 0 20px;
}

.footer {
  padding: 24px 48px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Login page ---------- */

body.login-page {
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, #1a0f4e 0%, transparent 60%),
    radial-gradient(ellipse 80% 60% at 50% 110%, #2a0a5e 0%, transparent 60%),
    linear-gradient(180deg, #04001f 0%, #0a0240 35%, #080038 70%, #03001a 100%);
  overflow: hidden;
  position: relative;
}

.scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.stars {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.goo-defs {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.blobs {
  position: absolute;
  inset: -10%;
  filter: url(#goo);
  mix-blend-mode: screen;
}

.blob {
  position: absolute;
  border-radius: 50%;
  opacity: 1;
  will-change: transform;
}

.blob.b1 {
  width: 420px; height: 420px;
  top: 18%; left: 18%;
  background: #FF5A00;
  animation: float1 22s ease-in-out infinite;
}

.blob.b2 {
  width: 500px; height: 500px;
  top: 38%; right: 12%;
  background: #3C1DC9;
  animation: float2 28s ease-in-out infinite;
}

.blob.b3 {
  width: 360px; height: 360px;
  bottom: 14%; left: 28%;
  background: #00B4FF;
  animation: float3 24s ease-in-out infinite;
}

.blob.b4 {
  width: 320px; height: 320px;
  top: 55%; left: 46%;
  background: #FF2D8C;
  animation: float4 30s ease-in-out infinite;
}

.blob.b5 {
  width: 280px; height: 280px;
  top: 12%; right: 32%;
  background: #FFB400;
  animation: float5 26s ease-in-out infinite;
}

@keyframes float1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(120px, 80px) scale(1.15); }
  50% { transform: translate(-60px, 180px) scale(0.9); }
  75% { transform: translate(80px, -40px) scale(1.05); }
}

@keyframes float2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  30% { transform: translate(-140px, 60px) scale(0.95); }
  60% { transform: translate(60px, -120px) scale(1.1); }
}

@keyframes float3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(100px, -100px) scale(1.2); }
  66% { transform: translate(-80px, -40px) scale(0.85); }
}

@keyframes float4 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40% { transform: translate(-120px, -80px) scale(1.1); }
  80% { transform: translate(160px, 40px) scale(0.95); }
}

@keyframes float5 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(-80px, 120px) scale(1.2); }
  50% { transform: translate(60px, 200px) scale(0.9); }
  75% { transform: translate(-40px, 60px) scale(1.1); }
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 60% at 50% 50%, transparent 40%, rgba(0, 0, 20, 0.55) 100%);
}

.login-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  position: relative;
  z-index: 2;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 52px 44px;
  background: rgba(12, 6, 48, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 28px;
  text-align: center;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    0 30px 80px rgba(0, 0, 30, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: card-breathe 7s ease-in-out infinite;
}

@keyframes card-breathe {
  0%, 100% { transform: translateY(0); box-shadow: 0 30px 80px rgba(0, 0, 30, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
  50% { transform: translateY(-6px); box-shadow: 0 40px 100px rgba(0, 0, 30, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none !important; }
  .login-card { animation: none !important; }
}

.login-logo {
  margin-bottom: 32px;
}

.login-logo img {
  height: 40px;
  width: auto;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

.login-card p.sub {
  color: var(--muted);
  margin: 0 0 32px;
  font-size: 15px;
}

#googleBtn {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  min-height: 44px;
}

.login-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--muted);
}

.login-error {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(255, 90, 90, 0.15);
  border: 1px solid rgba(255, 90, 90, 0.4);
  border-radius: 12px;
  color: #FFB4B4;
  font-size: 13px;
  display: none;
}

.login-error.visible { display: block; }

/* ---------- Admin page ---------- */

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  gap: 24px;
  flex-wrap: wrap;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.admin-row {
  display: grid;
  grid-template-columns: 40px 80px 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 160ms ease, background 160ms ease;
}

.admin-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 0;
}

.admin-fields .admin-description {
  grid-column: 1 / -1;
}

.admin-description {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  color: var(--white);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  width: 100%;
  resize: vertical;
  min-height: 38px;
  max-height: 120px;
  font-family: inherit;
  line-height: 1.4;
}

.admin-description:focus {
  outline: none;
  border-color: var(--cape-orange);
}

.admin-description::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.admin-row.dragging { opacity: 0.5; }
.admin-row.drag-over { border-color: var(--cape-orange); }

.drag-handle {
  cursor: grab;
  color: var(--muted);
  user-select: none;
  font-size: 20px;
  text-align: center;
}

.drag-handle:active { cursor: grabbing; }

.admin-icon {
  width: 64px;
  height: 64px;
  background: var(--white);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.admin-icon img { width: 64px; height: 64px; object-fit: contain; }

.admin-icon-fallback {
  width: 64px;
  height: 64px;
  background: var(--cape-blue-deep);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  border-radius: var(--radius-sm);
}

.admin-input {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  color: var(--white);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  width: 100%;
  transition: border-color 120ms ease;
}

.admin-input:focus {
  outline: none;
  border-color: var(--cape-orange);
}

.admin-actions {
  display: flex;
  gap: 8px;
}

.admin-icon-tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.admin-icon-tools button {
  background: none;
  border: none;
  color: var(--cape-orange);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  text-align: left;
}

.admin-icon-tools button:hover { text-decoration: underline; }

.add-row {
  padding: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.add-row h3 {
  margin: 0 0 16px;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.add-row-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  grid-template-areas:
    "name url button"
    "desc desc button";
  gap: 12px;
  align-items: stretch;
}

.add-row-form #newName { grid-area: name; }
.add-row-form #newUrl { grid-area: url; }
.add-row-form #newDescription { grid-area: desc; }
.add-row-form #addBtn { grid-area: button; align-self: stretch; white-space: nowrap; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
  z-index: 1000;
}

.toast.visible { opacity: 1; }
.toast.error { border-color: rgba(255, 90, 90, 0.5); color: #FFB4B4; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .site-header, main, .footer { padding-left: 24px; padding-right: 24px; }
  .admin-row { grid-template-columns: 64px 1fr auto; }
  .admin-row .drag-handle { display: none; }
  .admin-row .admin-actions { grid-column: 1 / 4; justify-self: end; }
  .admin-fields { grid-template-columns: 1fr; }
  .add-row-form {
    grid-template-columns: 1fr;
    grid-template-areas:
      "name"
      "url"
      "desc"
      "button";
  }
}

@media (max-width: 600px) {
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .tile { min-height: 180px; padding: 24px 16px; }
  .tile-icon, .tile-icon img, .tile-icon-fallback { width: 56px; height: 56px; font-size: 22px; }
  .brand-word { display: none; }
}
