:root {
  --bg: #0a0b0d;
  --bg-2: #111316;
  --fg: #f4f5f6;
  --fg-dim: #9aa0a6;
  --line: #1c1f24;
  --accent: #323333;
  --accent-soft: ##32333322;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

/* Wispy, very subtle #425870 atmosphere. A fixed, blurred pseudo-element
   sits behind everything so the patches smear into soft clouds. */
body::before {
  content: '';
  position: fixed;
  inset: -10vmax;       /* overshoot so the blur edges fall off-screen */
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(50vmax 36vmax at  6% 42%, rgba(66,88,112,0.18), transparent 65%),
    radial-gradient(42vmax 30vmax at 96% 70%, rgba(66,88,112,0.13), transparent 65%),
    radial-gradient(34vmax 26vmax at 62% 14%, rgba(66,88,112,0.08), transparent 70%),
    radial-gradient(30vmax 24vmax at 72% 92%, rgba(66,88,112,0.07), transparent 70%);
  /* Turbulence-driven displacement turns the soft circles into wispy nebula
     cloud shapes; the blur then smears the displaced edges. The opacities
     above are intentionally higher than they look — much of the brightness
     is lost to displacement spreading the pixels around. */
  filter: url(#nebula) blur(40px) saturate(110%);
}

.hidden { opacity: 0; }

.card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  opacity: 1;
  transition: opacity 600ms ease;
}

.avatar {
  width: 120px; height: 120px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-2);
  border: 1px solid var(--line);
  display: block;
  margin: 0 auto 20px;
}
.avatar:not([src]), .avatar[src=""] { visibility: hidden; }

.name {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.tagline {
  color: var(--fg-dim);
  margin: 0 0 28px;
  font-size: 14px;
}

.links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.link:active { transform: translateY(0); }
.link svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: 0.85; }

.icon-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}
.link.icon-only {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  flex: 0 0 42px;
}
.link.icon-only svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: 1; }

.audio-controls {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
}
.audio-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-2);
  /* Resting state: faint accent tint on icon + border, well under full accent. */
  color: rgba(31, 111, 122, 0.55);
  border: 1px solid rgba(31, 111, 122, 0.28);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.audio-btn.primary { width: 38px; height: 38px; }
.audio-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.audio-btn:active { transform: scale(0.94); }
.audio-btn[data-playing="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

/* admin */
.admin-shell {
  width: 100%;
  max-width: 720px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  text-align: left;
}
.admin-shell h1 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.admin-shell .sub { color: var(--fg-dim); font-size: 13px; margin: 0 0 22px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.field input, .field textarea, .field select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--fg);
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* prevents iOS Safari from zooming the viewport on focus */
  outline: none;
  transition: border-color 120ms ease;
  width: 100%;
  min-width: 0;
}
.link-row input, .link-row select { font-size: 16px; min-width: 0; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }

.row { display: flex; gap: 10px; align-items: stretch; }
.row > * { flex: 1; }
.row > .grow-2 { flex: 2; }

.btn {
  background: var(--accent);
  color: var(--fg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: filter 120ms ease;
}
.btn:hover { filter: brightness(1.15); }
.btn.secondary { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--accent); filter: none; }
.btn.danger { background: transparent; color: #d9534f; border-color: #3a1f1f; }

.link-row {
  display: grid;
  grid-template-columns: 130px 1fr 1fr 32px 32px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.link-row:last-child { border-bottom: none; }
.link-row .iconpick { padding: 8px 10px; }
.link-row .x {
  width: 28px; height: 28px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line); color: var(--fg-dim);
  cursor: pointer; display: grid; place-items: center;
}
.link-row .x:hover { color: #d9534f; border-color: #3a1f1f; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: #111;
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, -6px); }
.toast.err { border-color: #3a1f1f; color: #f4baba; }

.section-title {
  font-size: 12px; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 24px 0 8px;
}

.login {
  width: 100%; max-width: 360px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}
.login h1 { margin: 0 0 18px; font-size: 16px; font-weight: 600; text-align: center; }
.login .err { color: #f4baba; font-size: 13px; min-height: 18px; margin-top: 4px; }

@media (max-width: 560px) {
  body { padding: 16px 12px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }

  .admin-shell { padding: 18px 16px; border-radius: 12px; }
  .admin-shell h1 { font-size: 16px; }
  .login { padding: 22px 18px; }

  /* Avatar row: image on top, buttons stay side-by-side underneath. */
  .row { flex-direction: column; align-items: stretch; }
  .row > * { flex: initial; width: 100%; }

  /* Link rows: collapse the ↑/↓ controls, keep icon picker + fields + delete. */
  .link-row {
    grid-template-columns: 96px 1fr 32px;
    grid-template-areas: "icon label rm" "icon url rm";
    gap: 6px;
  }
  .link-row .iconpick { grid-area: icon; }
  .link-row .lbl { grid-area: label; }
  .link-row .url { grid-area: url; }
  .link-row .x { grid-area: rm; align-self: start; }
  .link-row .up, .link-row .dn { display: none; }

  /* Audio rows reuse .link-row; the audio element goes full-width below the index label. */
  .link-row audio { width: 100%; }

  .section-title { margin-top: 18px; }
  .btn { padding: 12px 16px; min-height: 44px; }
  .btn.secondary { min-height: 44px; }

  /* Bigger tap targets on the public links. */
  .link { padding: 14px 16px; }
  .audio-btn { width: 38px; height: 38px; }
  .audio-btn.primary { width: 44px; height: 44px; }
}
