/* klinik.fun - mobile-first, dark, no build step. */

:root {
  --bg: #0d0d11;
  --surface: #16161c;
  --surface-2: #1f1f27;
  --surface-3: #2a2a34;
  --border: #2b2b36;
  --text: #f4f4f7;
  --muted: #9a9aaa;
  --accent: #5ee6b0;
  --accent-strong: #79f0c2;
  --accent-ink: #062a1e;
  --danger: #ff6b6b;
  --tap: 44px;
  --page-max: 560px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; color-scheme: dark; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll { overflow: hidden; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: var(--safe-top);
  background: rgba(13, 13, 17, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}

.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand span { color: var(--accent); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.user-chip { font-size: 14px; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { color: var(--text); }

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 12px 12px calc(28px + var(--safe-bottom));
}

/* ---------- Calendar ---------- */

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 10px;
}

.cal-title { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.cal-nav { display: flex; gap: 2px; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}

.cal-weekdays span {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  touch-action: pan-y;
  transition: opacity 0.15s;
}

.calendar.loading .cal-grid { opacity: 0.6; }

.day {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  padding: 0;
  overflow: hidden;
  color: var(--text);
  transition: transform 0.12s;
}

.day:active { transform: scale(0.95); }
.day.placeholder { background: transparent; pointer-events: none; }

.day .num {
  position: absolute;
  top: 5px;
  left: 6px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.day.past:not(.has-album) .num { color: var(--muted); }

.day.has-album .num {
  background: rgba(0, 0, 0, 0.62);
  padding: 3px 6px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

.day img { width: 100%; height: 100%; object-fit: cover; }

.day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.day.today .num { color: var(--accent); }

.day .tick {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.day.can-add::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 22px;
  opacity: 0;
  transition: opacity 0.15s;
}

@media (hover: hover) {
  .day.can-add:hover::after { opacity: 0.6; }
  .day:hover { filter: brightness(1.1); }
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 18px 0 0;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, opacity 0.15s;
}

.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: rgba(255, 107, 107, 0.12); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.is-on { background: var(--accent); color: var(--accent-ink); }

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.icon-btn:hover { background: var(--surface-2); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; /* >= 16px stops iOS from zooming on focus */
  outline: none;
  transition: border-color 0.15s;
}

.input:focus { border-color: var(--accent); }
.input::placeholder { color: #6f6f7d; }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.4; }

.counter { align-self: flex-end; font-size: 12px; color: var(--muted); }
.counter.over { color: var(--danger); }

.form-error { color: var(--danger); font-size: 14px; margin: 0 0 12px; }
.form-row { display: flex; gap: 10px; }
.form-row > .field { flex: 1; }

.tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 38px;
  border-radius: 9px;
  font-weight: 600;
}

.tab.active { background: var(--surface); color: var(--text); }

/* ---------- Sheet (bottom sheet on phones, dialog on desktop) ---------- */

.sheet-root { position: fixed; inset: 0; z-index: 50; }

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(100dvh - 32px - var(--safe-top));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-bottom: var(--safe-bottom);
}

.sheet.tall { height: calc(100dvh - 32px - var(--safe-top)); }

.sheet::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  transform: translateX(-50%);
}

.sheet-root.open .backdrop { opacity: 1; }
.sheet-root.open .sheet { transform: translateY(0); }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 18px 8px 8px 16px;
}

.sheet-head.has-back { padding-left: 4px; }
.sheet-titles { flex: 1; min-width: 0; }

.sheet-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-subtitle {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 18px;
}

.sheet-foot {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

@media (min-width: 640px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: 480px;
    max-height: min(85vh, 760px);
    border-radius: 22px;
    padding-bottom: 0;
    opacity: 0;
    transform: translate(-50%, -46%);
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .sheet.tall { height: min(85vh, 760px); }
  .sheet::before { display: none; }
  .sheet-root.open .sheet { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-head { padding-top: 14px; }
}

/* ---------- Album detail ---------- */

.album-hero { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }

.album-cover {
  width: 128px;
  height: 128px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.album-meta { flex: 1; min-width: 0; }

.album-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.album-artist { font-size: 16px; margin: 0 0 8px; overflow-wrap: anywhere; }
.album-sub { font-size: 13px; color: var(--muted); margin: 0 0 2px; }

.album-note {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  margin: 0 0 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.album-note .by { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 8px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 5px 11px; font-size: 14px; }
.chip.me { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.actions-row { display: flex; gap: 10px; }
.actions-row > .btn { flex: 1; min-width: 0; }

/* ---------- Add album ---------- */

.preview {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 10px;
  margin: -4px 0 14px;
  min-height: 64px;
}

.preview img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-3);
  flex-shrink: 0;
}

.preview-text { min-width: 0; font-size: 14px; color: var(--muted); }
.preview-text strong { display: block; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview.error { color: var(--danger); }

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* ---------- Comments ---------- */

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

.comment { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }

.comment-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--muted);
}

.comment-head strong { color: var(--text); font-size: 14px; }

.comment-head .del {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px;
}

.comment-head .del:hover { color: var(--danger); }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }

.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { flex: 1; min-height: var(--tap); max-height: 140px; resize: none; }

.empty { color: var(--muted); text-align: center; padding: 28px 0; margin: 0; }
.note-center { text-align: center; color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Name links (open a profile) ---------- */

.name-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}

.name-link:hover { text-decoration-color: var(--accent); }
.name-link.chip { display: inline-block; text-decoration: none; font-weight: 500; }
.name-link.chip.me { font-weight: 600; }
.user-chip { border: 0; background: none; padding: 4px 2px; color: var(--muted); }
.user-chip:hover strong { color: var(--accent); }

/* ---------- Activity feed ---------- */

.feed { margin-top: 28px; }

.feed-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
}

.feed-list { display: flex; flex-direction: column; gap: 6px; }

.feed-item {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: var(--surface);
  transition: background 0.15s;
}

.feed-item:hover { background: var(--surface-2); }

/* The thumbnail button is stretched over the whole card via ::after. */
.feed-open {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 8px;
  flex-shrink: 0;
}

.feed-open::after { content: ""; position: absolute; inset: 0; border-radius: 14px; }
.feed-open:focus-visible { outline: none; }
.feed-open:focus-visible::after { outline: 2px solid var(--accent); }

.feed-thumb { position: relative; display: block; width: 44px; height: 44px; }
.feed-thumb img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }

.feed-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--surface-3);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  display: grid;
  place-items: center;
}

.feed-album .feed-badge, .feed-listen .feed-badge { background: var(--accent); color: var(--accent-ink); }

.feed-text { position: relative; z-index: 1; min-width: 0; flex: 1; font-size: 14px; line-height: 1.35; pointer-events: none; }
.feed-text .name-link { pointer-events: auto; }
.feed-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.feed-quote {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.feed-meta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-more { margin-top: 10px; }

/* ---------- Profile ---------- */

.profile-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 14px; }

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  color: hsl(var(--hue, 160) 70% 14%);
  background: hsl(var(--hue, 160) 60% 72%);
}

.profile-meta { min-width: 0; }
.profile-name { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 2px; overflow-wrap: anywhere; }

.stats { display: flex; gap: 8px; margin-bottom: 14px; }

.stat {
  flex: 1;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat strong { font-size: 20px; font-weight: 800; line-height: 1; }
.stat span { font-size: 12px; color: var(--muted); }

.rename { margin-bottom: 6px; }
.rename-form { background: var(--surface-2); border-radius: 14px; padding: 12px 12px 12px; }
.rename-form .field { margin-bottom: 10px; }
.rename-form .input { background: var(--surface); }
.profile-feed .feed-item { background: var(--surface-2); }
.profile-feed .feed-item:hover { background: var(--surface-3); }
.profile-feed .feed-badge { border-color: var(--surface-2); }

/* ---------- "Up next" card ---------- */

.feed-item.next-card { box-shadow: inset 0 0 0 1.5px var(--accent); margin-bottom: 22px; }
.next-card .feed-thumb, .next-card .feed-thumb img { width: 56px; height: 56px; }
.next-card .feed-line strong { font-size: 15px; }
.next-artist { color: var(--muted); }
.next-empty { padding: 14px 0 22px; }

/* ---------- Profile actions / Admin ---------- */

.profile-actions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.profile-actions .rename { margin: 0; }
.profile-actions .btn-sm { align-self: flex-start; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
}

.badge-warn { background: rgba(255, 107, 107, 0.15); color: var(--danger); }

.admin-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.admin-user { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.admin-user-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 16px; }
.admin-user-meta { font-size: 13px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.admin-result { margin-top: 10px; background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.admin-pw-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }

code.pw {
  font: 600 16px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2);
  padding: 8px 10px;
  border-radius: 8px;
  user-select: all;
  -webkit-user-select: all;
}

/* ---------- Text links inside forms ---------- */

.form-links { text-align: center; margin: 14px 0 0; font-size: 14px; }
.link-btn { background: none; border: 0; padding: 4px; color: var(--muted); font: inherit; font-size: 14px; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent); }

/* ---------- Hamburger menu ---------- */

.menu-wrap { position: relative; }
.menu-toggle { font-size: 20px; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  z-index: 30;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}

.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }

/* ---------- Member directory ---------- */

.user-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
}

.user-row:hover { background: var(--surface-3); }
.avatar-sm { width: 44px; height: 44px; font-size: 18px; }
.user-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-row-text strong { display: flex; align-items: center; gap: 8px; font-size: 16px; overflow-wrap: anywhere; }
.user-row-meta { font-size: 13px; color: var(--muted); }
.chevron { color: var(--muted); font-size: 22px; line-height: 1; }

/* ---------- Avatars (photo or initial) ---------- */

.avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--user-color, hsl(var(--hue, 160) 60% 72%));
  color: #14141a;
}

.avatar.has-photo { background: var(--surface-3); }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-lg { width: 96px; height: 96px; font-size: 40px; }
.avatar-xs { width: 22px; height: 22px; font-size: 11px; font-weight: 800; }
.avatar-inline { display: inline-grid; vertical-align: -5px; margin-right: 6px; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; }
.chip .avatar-inline { width: 18px; height: 18px; font-size: 10px; vertical-align: -4px; margin-right: 4px; }

/* ---------- Member colour ---------- */

.profile-head {
  background: var(--surface-2);
  border-radius: 18px;
  padding: 14px;
}

.has-color.profile-head,
.edit-profile.has-color .edit-head {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--user-color) 40%, var(--surface)) 0%,
    color-mix(in srgb, var(--user-color) 12%, var(--surface)) 100%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--user-color) 45%, transparent);
}

.comment.has-color {
  background: color-mix(in srgb, var(--user-color) 16%, var(--surface-2));
  box-shadow: inset 3px 0 0 var(--user-color);
}

/* ---------- Edit profile ---------- */

.edit-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  padding: 18px 14px 14px;
  border-radius: 18px;
  background: var(--surface-2);
}

.edit-photo { position: relative; }
.edit-status { margin: 0; min-height: 1em; }

.pencil {
  border: 0;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 16px;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.pencil-photo { position: absolute; right: -4px; bottom: -4px; }
.pencil-inline { width: 30px; height: 30px; font-size: 14px; background: var(--surface-3); color: var(--text); box-shadow: none; }
.pencil-inline:hover { background: var(--accent); color: var(--accent-ink); }

.edit-name { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; min-height: 44px; }
.edit-name .profile-name { margin: 0; }
.edit-name-form { width: 100%; }
.edit-name-form .actions-row { align-items: center; }
.edit-name-form .actions-row .input { flex: 1; min-width: 0; }
.edit-name-form .actions-row .btn { flex: 0 0 auto; }

.edit-colour { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; width: 100%; }

.swatch {
  aspect-ratio: 1;
  width: 100%;
  border: 0;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 2px transparent;
  transition: transform 0.12s, box-shadow 0.12s;
}

.swatch:hover { transform: scale(1.08); }
.swatch.selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch-none { background: var(--surface-3); color: var(--muted); font-size: 20px; line-height: 1; }

/* ---------- Round-3 polish ---------- */

.actions-row > .btn { overflow: hidden; text-overflow: ellipsis; padding: 0 10px; }
.topbar-inner { padding-left: calc(16px + env(safe-area-inset-left, 0px)); padding-right: calc(16px + env(safe-area-inset-right, 0px)); }
.page { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
.sheet { max-height: calc(100vh - 32px - var(--safe-top)); max-height: calc(100dvh - 32px - var(--safe-top)); }
.sheet.tall { height: calc(100vh - 32px - var(--safe-top)); height: calc(100dvh - 32px - var(--safe-top)); }
@media (min-width: 640px) {
  .sheet { max-height: min(85vh, 760px); }
  .sheet.tall { height: min(85vh, 760px); }
}
.sheet:focus { outline: none; }
.form-links-msg { display: block; margin-top: 6px; }

/* ---------- Toggles / admin tools ---------- */

.toggle-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); cursor: pointer; font-size: 15px; }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; margin: 0; }
.admin-tools { margin-bottom: 6px; }
.admin-tools .btn { margin-top: 8px; }

/* ---------- Chips with avatars (listeners) ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 12px 3px 3px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1;
  min-height: 30px;
}

.chip .avatar-inline { width: 24px; height: 24px; font-size: 11px; margin: 0; vertical-align: middle; display: grid; }
.chip.me { background: var(--accent); color: var(--accent-ink); }
.chip.me .avatar { box-shadow: 0 0 0 2px var(--accent); }
.chips { gap: 8px; }

/* ---------- Remove confirm / share ---------- */

.remove-wrap { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.confirm-text { margin: 0; }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #ff8585; }

/* ---------- Listeners: avatar row with hover names ---------- */

.listeners { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 6px; }

.avatar-btn { position: relative; border: 0; background: none; padding: 0; border-radius: 50%; line-height: 0; }
.avatar-btn .avatar-md { width: 42px; height: 42px; font-size: 17px; }
.avatar-btn.me .avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.avatar-btn:hover .avatar { transform: scale(1.06); }
.avatar-btn .avatar { transition: transform 0.12s; }

.avatar-btn::after {
  content: attr(data-name);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 2;
}

.avatar-btn:hover::after, .avatar-btn:focus-visible::after { opacity: 1; }

/* ---------- Ratings ---------- */

.rating-block { margin-top: 4px; }
.stars { display: flex; gap: 4px; margin-top: 4px; }
.star { width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--surface-3); font-size: 22px; line-height: 1; transition: color 0.12s, transform 0.12s; }
.star.on { color: #ffd166; }
.star:hover { transform: scale(1.08); color: #ffd166; }
.rating-pill { align-self: center; flex-shrink: 0; padding: 4px 9px; border-radius: 999px; background: var(--surface-3); color: #ffd166; font-size: 13px; font-weight: 700; }

/* ---------- Comment reactions ---------- */

.comment-actions { display: flex; gap: 6px; margin-top: 8px; }
.react { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 10px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.06); color: var(--muted); font-size: 13px; font-weight: 600; }
.react:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.react.on { color: #ff6b8a; }
.react-count { font-size: 12px; }

/* ---------- Albums archive ---------- */

.archive-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.archive-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 8px; border: 0; border-radius: 14px; background: var(--surface-2); color: var(--text); }
.archive-row:hover { background: var(--surface-3); }
.archive-row img { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--surface-3); flex-shrink: 0; }
.archive-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.archive-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-sub { font-size: 14px; color: var(--text); opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-links { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }

/* ---------- Reaction icon alignment ---------- */

.react { line-height: 1; }
.react svg { display: block; flex-shrink: 0; opacity: 0.55; transition: opacity 0.12s, transform 0.12s; }
.react.on svg { opacity: 1; transform: scale(1.1); }
.react .react-count:empty { display: none; }

/* ---------- Rating voters ---------- */

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 16px 0 8px; }
.section-head .section-title { margin: 0; }
.section-link { font-size: 13px; padding: 0; color: var(--muted); }
.votes { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.vote { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.stars-text { color: #ffd166; font-size: 14px; letter-spacing: 1px; white-space: nowrap; }
