/* ==========================================================================
   MAIN STYLES
   Uses only variables from tokens.css. To restyle the site, edit tokens.css.
   Sections: base, layout, buttons, forms, avatar, bottom nav, toasts,
             auth, profile, post grid, empty states, post card, song chip,
             mini player, song picker.
   ========================================================================== */

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

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

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

p { margin: 0; }

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); }

img { display: block; max-width: 100%; }

[hidden] { display: none !important; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

.muted { color: var(--color-text-muted); }

/* ---- Layout -------------------------------------------------------------- */
.app {
  max-width: var(--layout-max-width);
  margin-inline: auto;
  min-height: 100dvh;
  position: relative;
}

.page {
  padding: var(--space-5) var(--space-4);
  padding-bottom: calc(var(--nav-space) + var(--space-6) + env(safe-area-inset-bottom));
}

.stack > * + * { margin-top: var(--space-4); }

.form-page__title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-5);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding-top: var(--space-2);
}

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font: inherit;
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-standard),
              color var(--duration-fast) var(--ease-standard);
}

.btn--primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn--primary:hover { background: var(--color-accent-hover); color: var(--color-on-accent); }

.btn--secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}
.btn--secondary:hover { background: var(--color-surface-raised); color: var(--color-text); }

.btn--ghost { background: transparent; color: var(--color-text-muted); }
.btn--ghost:hover { color: var(--color-text); }

.btn--block { width: 100%; }

.btn--danger { color: var(--color-danger); }
.btn--danger:hover { color: var(--color-danger); background: var(--color-surface); }

/* ---- Forms --------------------------------------------------------------- */
.field + .field { margin-top: var(--space-4); }

.field__label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font: inherit;
  transition: border-color var(--duration-fast) var(--ease-standard);
}

.field textarea { resize: vertical; min-height: 5rem; }

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
}

.field input[type="file"] {
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.field input[type="file"]::file-selector-button {
  margin-right: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
}

.field--checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
.field--checkbox input { accent-color: var(--color-accent); width: 1rem; height: 1rem; }

.field__help {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.field__help ul { margin: 0; padding-left: var(--space-5); }

.field--error input,
.field--error textarea { border-color: var(--color-danger); }

.field__error {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-danger);
}

.form-errors {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  color: var(--color-danger);
  font-size: var(--text-sm);
}

/* ---- Avatar -------------------------------------------------------------- */
.avatar {
  --size: var(--avatar-md);
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: calc(var(--size) * 0.42);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar--sm { --size: var(--avatar-sm); }
.avatar--md { --size: var(--avatar-md); }
.avatar--lg { --size: var(--avatar-lg); }
.avatar--xl { --size: var(--avatar-xl); }

.avatar-picker {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

/* ---- Bottom navigation --------------------------------------------------- */
/* Phones: a floating glass bar at the bottom (same style as the top bar). */
.bottom-nav {
  position: fixed;
  bottom: calc(var(--nav-gap) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: calc(min(100vw, var(--layout-max-width)) - var(--nav-gap) * 2);
  height: var(--nav-height);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  justify-items: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bottom-nav { background: var(--color-surface); }
}

.nav-brand { display: none; }
.nav-label { display: none; }
.nav-icon { position: relative; display: grid; place-items: center; }

.bottom-nav__item {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
}
.bottom-nav__item:hover { color: var(--color-text); }
.bottom-nav__item.is-active { color: var(--color-text); }

.nav-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--color-like);
  color: #fff;
  font-size: 11px;
  font-weight: var(--weight-bold);
  line-height: 18px;
  text-align: center;
}

.bottom-nav__item.is-active .avatar {
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-text);
}

/* The "+" button is the one bold element in the nav. */
.bottom-nav__create {
  width: 56px;
  height: 38px;
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: var(--radius-md);
}
.bottom-nav__create:hover,
.bottom-nav__create.is-active {
  background: var(--color-accent-hover);
  color: var(--color-on-accent);
}

/* ---- Computers: nav becomes a glass panel on the left ------------------- */
@media (min-width: 700px) {
  .app { margin-left: var(--column-left); margin-right: 0; }
  .app:has(> .page-auth) { margin-inline: auto; }  /* login/signup: centered, no nav */

  .bottom-nav {
    top: var(--header-gap);
    bottom: var(--header-gap);
    left: var(--shell-left);
    transform: none;
    width: var(--shell-nav);
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-items: initial;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-2);
  }

  .nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    height: 48px;
    margin-bottom: var(--space-3);
    color: var(--color-accent);
  }
  .nav-brand:hover { color: var(--color-accent-hover); }
  .nav-brand__name { display: none; }

  .bottom-nav__item { flex-shrink: 0; }
  .bottom-nav__create { order: 10; margin-top: var(--space-3); width: 48px; height: 48px; border-radius: var(--radius-full); }
}

@media (min-width: 1100px) {
  .bottom-nav { align-items: stretch; padding: var(--space-4) var(--space-3); }

  .nav-brand { padding: 0 var(--space-3); }
  .nav-brand__name {
    display: inline;
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
    color: var(--color-text);
  }

  .bottom-nav__item {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    gap: var(--space-4);
    padding: 0 var(--space-3);
    border-radius: var(--radius-full);
  }
  .bottom-nav__item:hover { background: var(--color-surface-raised); }
  .nav-label { display: inline; font-size: var(--text-base); font-weight: var(--weight-medium); }
  .bottom-nav__item.is-active .nav-label { font-weight: var(--weight-bold); }
  .bottom-nav__profile .avatar { --size: 26px; }

  .bottom-nav__create {
    width: 100%;
    height: 48px;
    justify-content: center;
    gap: var(--space-2);
  }
  .bottom-nav__create:hover { background: var(--color-accent-hover); }
  .bottom-nav__create .nav-label { font-weight: var(--weight-bold); }
}

/* ---- Right column (wide screens): search + who to follow ---------------- */
.sidebar { display: none; }
@media (min-width: 1100px) {
  .sidebar {
    position: fixed;
    top: var(--header-gap);
    left: calc(var(--column-left) + var(--layout-max-width) + var(--shell-gap));
    width: var(--sidebar-width);
    max-height: calc(100dvh - var(--header-gap) * 2);
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: var(--space-4);
    z-index: 5;
  }
  .page-auth ~ .sidebar { display: none; }
}
.sidebar__search {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
}
.sidebar__search input {
  flex: 1;
  min-width: 0;
  height: 44px;
  background: none;
  border: 0;
  color: var(--color-text);
  font: inherit;
}
.sidebar__search input:focus, .sidebar__search input:focus-visible { outline: none; box-shadow: none; }
.sidebar__box {
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.sidebar__title { font-size: var(--text-lg); margin-bottom: var(--space-2); }
.sidebar__box .person .follow-btn { min-height: 32px; padding-inline: var(--space-4); }
.sidebar__more { display: inline-block; margin-top: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-semibold); }

/* ---- Docked player and messages follow the middle column on computers -- */
@media (min-width: 700px) {
  .mini-player {
    left: var(--column-left);
    transform: none;
    bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  }
  .toasts { left: calc(var(--column-left) + var(--layout-max-width) / 2); }
}

/* ---- Toast messages ------------------------------------------------------ */
.toasts {
  position: fixed;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: calc(100% - var(--space-6));
  max-width: calc(var(--layout-max-width) - var(--space-6));
  pointer-events: none;
}

.toast {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  animation: toast-out var(--duration-base) var(--ease-standard) 4.5s forwards;
}
.toast + .toast { margin-top: var(--space-2); }
.toast--success { border-color: var(--color-success); }
.toast--error   { border-color: var(--color-danger); }

@keyframes toast-out { to { opacity: 0; visibility: hidden; } }

/* ---- Auth pages (login / signup) ---------------------------------------- */
.page-auth .page {
  min-height: 100dvh;
  display: grid;
  align-items: center;
  padding-bottom: var(--space-6);
}

.auth { width: 100%; }

.wordmark {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.wordmark:hover { color: var(--color-text); }

.auth__tagline {
  margin-top: var(--space-2);
  margin-bottom: var(--space-6);
  color: var(--color-text-muted);
}

.auth__form .btn { margin-top: var(--space-5); }

.auth__switch {
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

/* ---- Profile ------------------------------------------------------------- */
.profile__header {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.profile__username {
  font-size: var(--text-xl);
  word-break: break-word;
}
.profile__name-row { display: flex; align-items: center; gap: var(--space-2); }
.profile__private { display: inline-grid; color: var(--color-text-muted); }
.profile__menu-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  color: var(--color-text);
  cursor: pointer;
}
.profile__menu-btn:hover { background: var(--color-surface); }

.profile-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: var(--space-5) calc(var(--space-4) * -1) 0;
  border-bottom: 1px solid var(--color-border);
}
.profile-tabs__tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.profile-tabs__tab:hover { color: var(--color-text); }
.profile-tabs__tab.is-active { color: var(--color-text); border-bottom-color: var(--color-text); }
.profile-tabs + .post-grid { margin-top: 2px; }
.post-grid--page { margin-top: 0; }

.private-note {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
  padding: var(--space-6) var(--space-4);
  border-top: 1px solid var(--color-border);
  text-align: center;
}
.private-note__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px solid var(--color-text);
  border-radius: 50%;
}
.private-note__title { font-weight: var(--weight-semibold); }

/* Settings */
.settings-group { margin-bottom: var(--space-6); }
.settings-group__title {
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
}
.setting__row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.setting__text { display: grid; gap: var(--space-1); flex: 1; }
.setting__label { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-semibold); }
.setting__help { font-size: var(--text-sm); color: var(--color-text-muted); }
.switch {
  appearance: none;
  flex-shrink: 0;
  position: relative;
  width: 48px;
  height: 28px;
  margin: 0;
  border-radius: var(--radius-full);
  background: var(--color-border);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-standard);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-text);
  transition: transform var(--duration-fast) var(--ease-standard);
}
.switch:checked { background: var(--color-accent); }
.switch:checked::after { transform: translateX(20px); background: var(--color-on-accent); }
.switch:focus-visible { box-shadow: var(--focus-ring); }
.settings-links { display: grid; }
.setting__link {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-4);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.setting__link:hover { color: var(--color-text); background: var(--color-surface); }
.setting__link--danger { color: var(--color-danger); border-bottom: 0; }

/* Your comments */
.my-comments { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: grid; gap: var(--space-3); }
.my-comment {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
}
.my-comment:hover { color: var(--color-text); border-color: var(--color-accent); }
.my-comment__meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.my-comment__meta strong { color: var(--color-text); }
.my-comment__text { overflow-wrap: anywhere; }
.my-comment__post {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.my-comment__post img { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; }

/* Follow requests in notifications */
.notification__requests { display: flex; gap: var(--space-2); flex-shrink: 0; }
.notification__requests .btn { min-height: 32px; padding-inline: var(--space-3); }
.notification__done { flex-shrink: 0; font-size: var(--text-sm); color: var(--color-text-muted); }
.menu-option--admin svg { color: var(--color-accent); }
a.menu-option { color: var(--color-text); }
a.menu-option:hover { color: var(--color-text); }

.profile__identity { flex: 1; min-width: 0; }

.profile__stats {
  display: flex;
  gap: var(--space-5);
  margin-top: var(--space-2);
}

.stat {
  display: grid;
  color: var(--color-text);
  line-height: var(--leading-tight);
}
a.stat:hover { color: var(--color-text); }
a.stat:hover .stat__label { color: var(--color-text); }
.stat__num { font-weight: var(--weight-semibold); }
.stat__label { font-size: var(--text-xs); color: var(--color-text-muted); }

.profile__bio {
  margin-top: var(--space-4);
  max-width: 60ch;
  white-space: normal;
}

.profile__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.profile__actions > a,
.profile__actions > .follow-btn { flex: 1; }

.follow-btn { min-height: 36px; padding-inline: var(--space-5); }

/* ---- Post grid (Instagram-style, 3 columns) ----------------------------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: var(--space-5) calc(var(--space-4) * -1) 0;  /* edge to edge */
}

/* Grid tile: album cover, darkened, with the start of the post text */
.grid-tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--color-surface-raised);
  color: var(--color-text);
}
.grid-tile:hover { color: var(--color-text); }

.grid-tile__cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.45) saturate(1.1);
  transition: filter var(--duration-base) var(--ease-standard);
}
.grid-tile:hover .grid-tile__cover { filter: brightness(0.6) saturate(1.1); }

.grid-tile__text {
  position: absolute;
  inset: auto 0 0 0;
  padding: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-tight);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Empty states -------------------------------------------------------- */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  margin-top: var(--space-7);
  text-align: center;
  color: var(--color-text-muted);
}
.empty--full { min-height: 60dvh; align-content: center; margin-top: 0; }

/* ---- One-time notice (Spotify login) ----------------------------------- */
.notice {
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.notice__text { font-size: var(--text-sm); }
.notice__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* ---- Post card ----------------------------------------------------------- */
.post-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: var(--space-4);
  padding: var(--card-padding);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  transition: border-color var(--duration-base) var(--ease-standard);
}

.post-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.post-card__author {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text);
  min-width: 0;
}
.post-card__author:hover { color: var(--color-text); }

.post-card__who {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

/* "· Follow" / "· You" next to the username */
.post-card__follow,
.post-card__tag {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.post-card__follow::before,
.post-card__tag::before {
  content: "·";
  color: var(--color-text-muted);
}
.post-card__follow { color: var(--color-accent); cursor: pointer; min-height: 32px; }
.post-card__follow:hover { color: var(--color-accent-hover); }
.post-card__follow.is-following { color: var(--color-text-muted); }
.post-card__tag { color: var(--color-text-muted); font-weight: var(--weight-medium); }

.post-card__username {
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-card__time { flex-shrink: 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.post-card__time:hover { color: var(--color-text); }

.post-card__text p {
  font-size: var(--text-lg);
  line-height: var(--leading-normal);
  overflow-wrap: anywhere;
}
.post-card__text--long p  { font-size: var(--text-base); }
.post-card__text--xlong p { font-size: var(--text-sm); }

/* Picture: cropped to --media-aspect in the card, full size in the lightbox */
.post-card__media {
  display: flex;
  justify-content: center;
  min-height: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: var(--radius-md);
  cursor: zoom-in;
}
.post-card__media img {
  width: 100%;
  height: auto;
  aspect-ratio: var(--media-aspect);
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
}

.post-page__owner { margin-top: var(--space-6); }

/* ---- Post list (scrolling) --------------------------------------------- */
html:has(.post-feed) {
  overflow-anchor: none;              /* JS keeps the position when posts load above */
  scroll-snap-type: y mandatory;      /* one post per swipe */
  scroll-padding-top: calc(var(--header-gap) + var(--header-height) + var(--space-3));
}

.page:has(.feed-header) { padding-top: 0; }  /* the floating bar brings its own top gap */

/* Floating glass bar: stays at the top of the screen, posts blur through it */
.feed-header {
  position: sticky;
  top: var(--header-gap);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--header-height);
  margin: var(--header-gap) 0 var(--space-3);
  padding: 0 var(--space-2);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
}
/* Browsers without blur support: make the bar solid so text stays readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .feed-header { background: var(--color-surface); }
}

.feed-header__back {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--color-text);
  border-radius: var(--radius-full);
}
.feed-header__back:hover { color: var(--color-text); background: var(--color-surface); }

.feed-header__title {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}
.feed-header__sub { font-size: var(--text-xs); color: var(--color-text-muted); }

.post-feed__items {
  display: grid;
  grid-template-columns: minmax(0, 1fr);  /* cards never grow wider than the screen */
  gap: var(--card-gap);
}
.post-feed .post-card.is-active { border-color: var(--card-active-border); }

/* Full-screen cards: author on top, text in the middle, song at the bottom */
.post-feed .post-card {
  display: flex;
  flex-direction: column;
  height: var(--feed-card-height);
  min-height: 320px;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.post-feed .post-card__text {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  min-height: 0;
  overflow-y: auto;
}
.post-feed .post-card__text p { font-size: var(--text-xl); line-height: var(--leading-tight); }
.post-feed .post-card__text--long p  { font-size: var(--text-lg); line-height: var(--leading-normal); }
.post-feed .post-card__text--xlong p { font-size: var(--text-base); line-height: var(--leading-normal); }

/* With a picture: text sits on top, picture takes the remaining space */
.post-feed .post-card--has-media .post-card__text {
  flex: 0 1 auto;
  align-items: flex-start;
  max-height: 40%;
}
.post-feed .post-card--has-media .post-card__text p { font-size: var(--text-lg); line-height: var(--leading-normal); }
.post-feed .post-card--has-media .post-card__text--long p  { font-size: var(--text-base); }
.post-feed .post-card--has-media .post-card__text--xlong p { font-size: var(--text-sm); }

.post-feed .post-card__media {
  flex: 1 1 0;
  min-height: 120px;
}
.post-feed .post-card__media img {
  width: auto;
  max-width: 100%;
  height: 100%;
}

.post-feed .post-card__footer { flex-shrink: 0; margin-top: auto; }

.post-feed__sentinel { height: 1px; }

.post-feed__status {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}
.post-feed__status:empty { display: none; }

/* ---- Post footer: like/comment row + song --------------------------------- */
.post-card__footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);  /* never wider than the card, so the player fits too */
  gap: var(--space-2);
  min-width: 0;
  container-type: inline-size;            /* lets the row below adapt to the card's width */
}

.post-actions {
  display: flex;
  gap: var(--space-1);
  min-width: 0;
  margin-left: calc(var(--space-2) * -1);
}

.action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: var(--space-1) var(--space-2);
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.action:hover { background: var(--color-surface-raised); }

/* "Starts at 1:38" and "Use song", right above the player */
.post-actions { align-items: center; }
.post-actions__end {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}
.post-actions__start {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-highlight);
}

.action--like.is-liked,
.comment-like.is-liked { color: var(--color-like); }
.action--like.is-liked path,
.comment-like.is-liked path { fill: currentColor; }
.action--like.is-liked svg { animation: like-pop var(--duration-base) var(--ease-standard); }

.action--repost.is-liked { color: var(--color-repost); }
.action--save.is-liked { color: var(--color-highlight); }
.action--save.is-liked path { fill: currentColor; }
.action--static { cursor: default; color: var(--color-text-muted); }
.action--static:hover { background: none; }

.hashtag { color: var(--color-accent); font-weight: var(--weight-semibold); }

/* Narrower cards (phones): "Starts at 0:16" → "♫ 0:16", "+ Use song" → "+", tighter buttons.
   Based on the card's own width, so it works on every phone and in every layout. */
@container (max-width: 480px) {
  .post-actions__start-label { display: none; }
  .post-actions__end .use-song { width: 30px; padding: 0; justify-content: center; flex-shrink: 0; }
  .use-song__label { display: none; }
}
@container (max-width: 360px) {
  .post-actions { gap: 0; }
  .post-actions .action { gap: 4px; padding-inline: 6px; }
  .post-actions .action svg { width: 22px; height: 22px; }
  .post-actions__end { gap: var(--space-1); }
}

@keyframes like-pop {
  50% { transform: scale(1.25); }
}

/* ---- Song chip (the song attached to a post) ---------------------------- */
.song-slot {
  --chip-bg: var(--color-bg);
  display: flex;
  align-items: center;
  height: var(--player-height);
  min-width: 0;
  background: var(--chip-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.song-slot:has(.is-playing),
.song-slot:has(.needs-tap) { border-color: var(--color-accent); }

/* When the player lives inside posts, every song slot is an empty space:
   the Spotify player fades into the active one. (If the player can't load,
   these rules don't apply and the song cards show as a fallback.) */
html.player-visible.player-overlay .song-slot {
  background: transparent;
  border-color: transparent;
}
html.player-visible.player-overlay .song-slot > * {
  visibility: hidden;
}

.song-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: var(--space-2);
  background: none;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.song-chip:hover { background: var(--color-surface-raised); }

.song-chip__cover {
  width: var(--cover-md);
  height: var(--cover-md);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-surface-raised);
}

.song-chip__text { display: grid; min-width: 0; flex: 1; }

.song-chip__title,
.song-chip__artist {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-chip__title { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.song-chip__artist { color: var(--color-text-muted); font-size: var(--text-xs); }
.song-chip__start { color: var(--color-highlight); }

.song-chip__state { color: var(--color-accent); display: grid; }

.song-chip__hint {
  display: none;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-accent);
  white-space: nowrap;
}
.song-chip.needs-tap .song-chip__hint { display: inline; }
.song-chip .icon-pause { display: none; }
.song-chip.is-playing .icon-play { display: none; }
.song-chip.is-playing .icon-pause { display: block; }

/* Spotify attribution + link back to the song, required by Spotify's rules */
.song-slot__spotify {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin-right: var(--space-2);
  border-radius: var(--radius-full);
  color: var(--color-spotify);
}
.song-slot__spotify:hover { color: var(--color-spotify); background: var(--color-surface-raised); }

/* ---- Mini player (one shared Spotify embed above the nav) --------------- */
.mini-player {
  display: none;
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-space) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 15;
  width: 100%;
  max-width: var(--layout-max-width);
  height: var(--player-height);
  padding: 0 var(--space-2);
  background: var(--color-bg);
}
html.player-visible .mini-player { display: block; }
.page-auth ~ .mini-player { bottom: env(safe-area-inset-bottom); }  /* no nav on login/signup */
.mini-player iframe { display: block; border-radius: var(--radius-md); }

/* Shown on top of a post's song slot (position set by app.js) */
html.player-overlay .mini-player {
  bottom: auto;
  max-width: none;
  padding: 0;
  transform: none;
  background: transparent;
  transition: opacity var(--duration-base) var(--ease-standard);
}
html.player-overlay.player-moving .mini-player,
html.player-overlay.player-offscreen .mini-player {
  opacity: 0;
  pointer-events: none;
}
.mini-player__note { padding-right: 40px; }
.mini-player__note-close {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  cursor: pointer;
}
.mini-player__note-close:hover { color: var(--color-text); }

/* The preview note can't sit above the player here (it would cover the post), so pin it near the top */
html.player-overlay .mini-player__note {
  position: fixed;
  top: calc(env(safe-area-inset-top) + var(--space-2));
  left: 50%;
  right: auto;
  bottom: auto;
  width: min(calc(100% - var(--space-6)), calc(var(--layout-max-width) - var(--space-6)));
  transform: translateX(-50%);
  z-index: 11;
}
html.player-overlay:has(.feed-header) .mini-player__note {
  top: calc(env(safe-area-inset-top) + var(--header-gap) + var(--header-height) + var(--space-2));
}

.mini-player__note {
  position: absolute;
  left: var(--space-2);
  right: var(--space-2);
  bottom: calc(100% + var(--space-2));
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

html.player-visible .page {
  padding-bottom: calc(var(--nav-space) + var(--player-space) + var(--space-6) + env(safe-area-inset-bottom));
}

/* ---- Song picker (new post page) ---------------------------------------- */
.field__counter {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: right;
}
.field__counter.is-low { color: var(--color-highlight); }

.song-picker { margin-top: var(--space-5); }

.song-picker__search {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text);
  font: inherit;
}
.song-picker__search:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--focus-ring);
}

.song-picker__status {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.song-picker__status:empty { display: none; }

.song-results {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
}

.song-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2);
  background: none;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.song-result:hover { background: var(--color-surface); }

.song-result__cover {
  width: var(--cover-sm);
  height: var(--cover-sm);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-surface-raised);
}

.song-result__text { display: grid; min-width: 0; }
.song-result__title,
.song-result__artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-result__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.song-result__artist { font-size: var(--text-xs); color: var(--color-text-muted); }

.song-picked {
  gap: var(--space-3);
  padding: var(--space-2);
}
.song-picked__cover {
  width: var(--cover-md);
  height: var(--cover-md);
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-surface-raised);
}
.song-picked__text { display: grid; min-width: 0; }
.song-picked__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.song-picked__artist { font-size: var(--text-xs); color: var(--color-text-muted); }

.song-picker__start-label {
  display: block;
  margin-top: var(--space-5);
  font-size: var(--text-sm);
}
.song-picker__start-label strong { color: var(--color-highlight); font-weight: var(--weight-semibold); }

.song-picker__note {
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.song-picker__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* Start-time slider: the filled part shows the skipped section of the song */
.start-slider {
  --fill: 0%;
  width: 100%;
  margin-top: var(--space-3);
  height: 28px;
  background: transparent;
  appearance: none;
  cursor: pointer;
}
.start-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(to right,
    var(--color-surface-raised) var(--fill),
    var(--color-border) var(--fill));
}
.start-slider::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(to right,
    var(--color-surface-raised) var(--fill),
    var(--color-border) var(--fill));
}
.start-slider::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--color-highlight);
  border: 3px solid var(--color-bg);
}
.start-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-highlight);
  border: 3px solid var(--color-bg);
}
.start-slider:focus-visible { box-shadow: none; }
.start-slider:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring); }
.start-slider:focus-visible::-moz-range-thumb { box-shadow: var(--focus-ring); }

/* ---- Picture field (new post) ------------------------------------------ */
.picture-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.picture-field:has(input[type="file"]:focus-visible) [data-picture-pick] { box-shadow: var(--focus-ring); }

.picture-field__preview {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
}
.picture-field__preview img {
  width: 160px;
  aspect-ratio: var(--media-aspect);
  object-fit: cover;
  border-radius: var(--radius-md);
}

/* ---- Lightbox (full-size picture) --------------------------------------- */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: var(--space-4);
  border: 0;
  background: var(--color-scrim);
}
.lightbox::backdrop { background: var(--color-scrim); }
.lightbox[open] { display: grid; place-items: center; }

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.lightbox__close {
  position: fixed;
  top: calc(var(--space-4) + env(safe-area-inset-top));
  right: var(--space-4);
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--color-surface-raised);
  border: 0;
  border-radius: var(--radius-full);
  color: var(--color-text);
  cursor: pointer;
}

/* ---- Home tabs: Following | FYP ------------------------------------------- */
.feed-header--tabs { justify-content: center; }

.feed-tabs {
  display: flex;
  gap: var(--space-5);
}
.feed-tabs__tab {
  position: relative;
  padding: var(--space-2) 0;
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-text-muted);
}
.feed-tabs__tab:hover { color: var(--color-text); }
.feed-tabs__tab.is-active { color: var(--color-text); }
.feed-tabs__tab.is-active::after {
  content: "";
  position: absolute;
  left: 25%;
  right: 25%;
  bottom: 0;
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--color-text);
}

.page-feed-empty .page { padding-top: 0; }

/* ---- Tabs (followers / following) ----------------------------------------- */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 calc(var(--space-4) * -1) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.tabs__tab {
  padding: var(--space-3);
  text-align: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs__tab:hover { color: var(--color-text); }
.tabs__tab.is-active { color: var(--color-text); border-bottom-color: var(--color-text); }

/* ---- People list ----------------------------------------------------------- */
.people { list-style: none; margin: 0 0 var(--space-4); padding: 0; }

.person {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}
.person__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
  color: var(--color-text);
}
.person__link:hover { color: var(--color-text); }
.person__text { display: grid; min-width: 0; }
.person__name { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.person__bio {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Comments panel (bottom sheet) ------------------------------------------ */
.sheet {
  width: 100%;
  max-width: var(--layout-max-width);
  height: var(--sheet-height);
  max-height: var(--sheet-height);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--color-surface);
  color: var(--color-text);
}
.sheet::backdrop { background: var(--color-backdrop); }
.sheet[open] { animation: sheet-up var(--duration-base) var(--ease-standard); }

@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

.sheet__panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sheet__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-bottom: 1px solid var(--color-border);
}
.sheet__title { font-size: var(--text-base); }
.sheet__count { color: var(--color-text-muted); font-weight: var(--weight-medium); }

.sheet__close {
  position: absolute;
  right: var(--space-2);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  color: var(--color-text);
  cursor: pointer;
}
.sheet__close:hover { background: var(--color-surface-raised); }

.sheet__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-3) var(--space-4);
}

.sheet__status {
  padding: var(--space-6) 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.sheet__status:empty { display: none; }

.sheet__form {
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.sheet__replying {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.sheet__replying strong { color: var(--color-text); }
.sheet__cancel-reply {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--color-text-muted);
  font: inherit;
  cursor: pointer;
}

.sheet__input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
}
.sheet__input-row .avatar { margin-bottom: 6px; }
.sheet__input-row textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: var(--space-2) var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  resize: none;
}
.sheet__input-row textarea:focus { outline: none; border-color: var(--color-accent); }

.sheet__send {
  min-height: 40px;
  padding: 0 var(--space-2);
  background: none;
  border: 0;
  color: var(--color-accent);
  font: inherit;
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.sheet__send:disabled { opacity: 0.5; }

/* ---- Comments ----------------------------------------------------------------- */
.comment {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}
.comment__main { flex: 1; min-width: 0; }
.comment__meta { font-size: var(--text-xs); }
.comment__author { color: var(--color-text); font-weight: var(--weight-semibold); }
.comment__author:hover { color: var(--color-text); }
.comment__time { color: var(--color-text-muted); margin-left: var(--space-1); }
.comment__text { font-size: var(--text-sm); overflow-wrap: anywhere; }

.comment__actions { display: flex; gap: var(--space-3); margin-top: var(--space-1); }
.comment__action,
.comment__toggle {
  padding: 0;
  background: none;
  border: 0;
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.comment__action:hover,
.comment__toggle:hover { color: var(--color-text); }

.comment__toggle { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); }
.comment__toggle::before { content: ""; width: 24px; border-top: 1px solid var(--color-border); }

.comment__replies { margin-top: var(--space-1); }
.comment--reply .avatar { --size: 24px; }

.comment-like {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 2px;
  min-width: 32px;
  padding-top: var(--space-1);
  background: none;
  border: 0;
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}

/* "Use song": make your own post with this song */
.use-song {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 30px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.use-song:hover { color: var(--color-text); background: var(--color-surface-raised); }
.use-song svg { flex-shrink: 0; }


/* ---- Notifications --------------------------------------------------------- */
.page-title-bar { margin-bottom: var(--space-2); }
.page-title-bar__title { font-size: var(--text-xl); }

.notification-list { list-style: none; margin: var(--space-2) 0 0; padding: 0; }

.notification {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  margin: 0 calc(var(--space-2) * -1);
  border-radius: var(--radius-md);
}
.notification.is-unread { background: var(--color-surface); }

.notification__body {
  flex: 1;
  min-width: 0;
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
.notification__body:hover { color: var(--color-text); }
.notification__quote { color: var(--color-text-muted); overflow-wrap: anywhere; }
.notification__time { color: var(--color-text-muted); margin-left: var(--space-1); white-space: nowrap; }

.notification__thumb {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-raised);
}
.notification__thumb img { width: 100%; height: 100%; object-fit: cover; }
.notification .follow-btn { flex-shrink: 0; min-height: 32px; padding-inline: var(--space-4); }

/* ---- Post editor (bold / italic / underline / strikethrough) ------------- */
.editor {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-standard);
}
.editor:focus-within { border-color: var(--color-accent); box-shadow: var(--focus-ring); }
.field--error .editor { border-color: var(--color-danger); }

.editor__toolbar {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-1);
  border-bottom: 1px solid var(--color-border);
}
.editor__btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 32px;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font: inherit;
  font-size: var(--text-base);
  cursor: pointer;
}
.editor__btn:hover { color: var(--color-text); background: var(--color-surface-raised); }
.editor__btn.is-on { color: var(--color-on-accent); background: var(--color-accent); }

.editor__area {
  min-height: 7rem;
  max-height: 40vh;
  overflow-y: auto;
  padding: var(--space-3) var(--space-4);
  color: var(--color-text);
  line-height: var(--leading-normal);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  outline: none;
}
.editor__area.is-empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-muted);
  pointer-events: none;
}
.editor__area:focus-visible { box-shadow: none; }

/* Formatting inside posts */
.post-card__text b { font-weight: var(--weight-bold); }
.post-card__text s { text-decoration-thickness: 2px; }

/* ---- @mentions ------------------------------------------------------------- */
.mention { color: var(--color-accent); font-weight: var(--weight-semibold); }
.mention:hover { color: var(--color-accent-hover); text-decoration: underline; }

.mention-box {
  position: fixed;
  z-index: 60;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--glass-shadow);
}
.mention-box__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.mention-box__item[aria-selected="true"], .mention-box__item:hover { background: var(--color-surface); }
.mention-box__item .avatar { --size: 32px; }
.mention-box__name { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.mention-box__tag { margin-left: auto; font-size: var(--text-xs); color: var(--color-text-muted); }

/* ---- Mute ------------------------------------------------------------------ */
.mute-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: auto;
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  cursor: pointer;
}
.mute-btn:hover { color: var(--color-text); background: var(--color-surface); }
.mute-btn .mute-btn__off { display: none; }
html.is-muted .mute-btn { color: var(--color-highlight); }
html.is-muted .mute-btn .mute-btn__on { display: none; }
html.is-muted .mute-btn .mute-btn__off { display: block; }

/* (.feed-header is sticky, which also anchors the mute button) */
.feed-header--tabs .mute-btn { position: absolute; right: var(--space-2); top: 50%; transform: translateY(-50%); }
.post-page__bar { display: flex; justify-content: flex-end; margin: calc(var(--space-3) * -1) 0 var(--space-2); }

/* Muted: posts show their song cards; only the post you tapped holds the player. */
html.is-muted.player-overlay .song-slot {
  background: var(--chip-bg);
  border-color: var(--color-border);
}
html.is-muted.player-overlay .song-slot > * { visibility: visible; }
html.is-muted.player-visible.player-overlay:not(.player-moving):not(.player-offscreen) .song-slot.is-under-player {
  background: transparent;
  border-color: transparent;
}
html.is-muted.player-visible.player-overlay:not(.player-moving):not(.player-offscreen) .song-slot.is-under-player > * {
  visibility: hidden;
}

/* ---- Close friends --------------------------------------------------------- */
.post-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.cf-badge {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-close-friends) 18%, transparent);
  color: var(--color-close-friends);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.post-card.is-close-friends .cf-badge { display: inline-flex; }
.post-card.is-close-friends { border-color: color-mix(in srgb, var(--color-close-friends) 45%, var(--card-border)); }
.post-feed .post-card.is-close-friends.is-active { border-color: var(--color-close-friends); }
@media (max-width: 380px) { .cf-badge__label { display: none; } }

.post-card__menu {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-right: calc(var(--space-2) * -1);
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  cursor: pointer;
}
.post-card__menu:hover { color: var(--color-text); background: var(--color-surface-raised); }

.grid-tile__cf {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-close-friends);
  color: var(--color-bg);
}

.btn--cf { flex: 0 0 auto !important; padding-inline: var(--space-4); color: var(--color-close-friends); }
.btn--cf:hover { color: var(--color-close-friends); }

.cf-toggle { flex: 0 0 auto; }
.cf-toggle.is-close {
  border-color: var(--color-close-friends);
  color: var(--color-close-friends);
}

.cf-intro { font-size: var(--text-sm); margin-bottom: var(--space-4); }
.cf-search { margin-bottom: var(--space-3); }
.cf-search input {
  flex: 1;
  min-width: 0;
  height: 44px;
  background: none;
  border: 0;
  color: var(--color-text);
  font: inherit;
}
.cf-search input:focus, .cf-search input:focus-visible { outline: none; box-shadow: none; }
.cf-count { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-2); }

.cf-check {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: none;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-border);
  cursor: pointer;
}
.cf-check.is-close {
  background: var(--color-close-friends);
  border-color: var(--color-close-friends);
  color: var(--color-bg);
}

/* Audience choice on the "+" page */
.audience-field { margin: var(--space-5) 0 0; padding: 0; border: 0; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  padding: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
}
.segmented__option { position: relative; cursor: pointer; }
.segmented__option input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__option span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 38px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
}
.segmented__option input:checked + span { background: var(--color-surface-raised); color: var(--color-text); }
.segmented__option--cf input:checked + span { background: var(--color-close-friends); color: var(--color-bg); }
.segmented__option input:focus-visible + span { box-shadow: var(--focus-ring); }

/* Post options sheet */
.sheet.sheet--menu { height: fit-content; max-height: var(--sheet-height); }
/* Computers: menus are a centered box instead of a bottom sheet */
@media (min-width: 700px) {
  .sheet.sheet--menu {
    width: min(400px, calc(100vw - var(--space-6)));
    margin: auto;
    border-radius: var(--radius-lg);
  }
}
.sheet--menu .sheet__panel { padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); gap: var(--space-1); }
.sheet__menu-title { font-size: var(--text-sm); color: var(--color-text-muted); padding: 0 var(--space-2) var(--space-2); }
.menu-options { display: grid; gap: var(--space-1); }
.menu-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-3);
  background: none;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font: inherit;
  font-weight: var(--weight-semibold);
  text-align: left;
  cursor: pointer;
}
.menu-option:hover { background: var(--color-surface-raised); }
.menu-option__check { margin-left: auto; visibility: hidden; color: var(--color-accent); }
.menu-option.is-selected .menu-option__check { visibility: visible; }
.menu-option--cf svg { color: var(--color-close-friends); }
.menu-option--cf.is-selected .menu-option__check { color: var(--color-close-friends); }
.menu-delete { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--color-border); }
.menu-option--danger { color: var(--color-danger); }
.menu-option--cancel { justify-content: center; color: var(--color-text-muted); }

/* ---- Search page ---------------------------------------------------------- */
.search-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  gap: var(--space-3);
  margin: calc(var(--space-5) * -1) calc(var(--space-4) * -1) var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-3);
  background: var(--color-bg);
}

.search-bar__field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
}
.search-bar__field:focus-within { border-color: var(--color-accent); box-shadow: var(--focus-ring); }
.search-bar__field input {
  flex: 1;
  min-width: 0;
  height: 44px;
  background: none;
  border: 0;
  color: var(--color-text);
  font: inherit;
}
.search-bar__field input:focus,
.search-bar__field input:focus-visible { outline: none; box-shadow: none; }

.chips { display: flex; gap: var(--space-2); }
.chip {
  padding: var(--space-1) var(--space-4);
  min-height: 34px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.chip[aria-pressed="true"] {
  background: var(--color-text);
  border-color: var(--color-text);
  color: var(--color-bg);
}

.search-status {
  padding: var(--space-5) 0;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.search-status:empty { display: none; }

/* Sections of results / suggestions */
.result-section { margin-top: var(--space-4); }
.result-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-1);
}
.result-section__title { font-size: var(--text-base); }
.result-section__action {
  padding: var(--space-1) 0;
  background: none;
  border: 0;
  color: var(--color-accent);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}
.result-list { list-style: none; margin: 0; padding: 0; }

/* Song rows (Search page and "+" page) */
.song-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius-md);
}
.song-row.is-playing { background: var(--color-surface); }
.song-row.is-playing .song-row__title { color: var(--color-accent); }

.song-row__main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
  padding: var(--space-2);
  background: none;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.song-row__main:hover { background: var(--color-surface); }
.song-row__cover {
  width: var(--cover-sm);
  height: var(--cover-sm);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--color-surface-raised);
}
.song-row__text { display: grid; min-width: 0; }
.song-row__title,
.song-row__artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-row__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.song-row__artist { font-size: var(--text-xs); color: var(--color-text-muted); }
.song-row__post { min-height: 32px; padding-inline: var(--space-4); flex-shrink: 0; }
.song-row .song-slot__spotify { margin-right: 0; }

/* Recent search words */
.query-row { display: flex; align-items: center; }
.query-row__main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
  padding: var(--space-3) var(--space-2);
  background: none;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.query-row__main:hover { background: var(--color-surface); }
.query-row__main svg { color: var(--color-text-muted); flex-shrink: 0; }

.row-remove {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: none;
  border: 0;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  cursor: pointer;
}
.row-remove:hover { color: var(--color-text); background: var(--color-surface); }

/* ---- Page-change progress bar ------------------------------------------- */
html.is-navigating::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  height: 3px;
  width: 100%;
  background: var(--color-accent);
  transform-origin: left;
  animation: nav-progress 1.2s var(--ease-standard) forwards;
}
@keyframes nav-progress { from { transform: scaleX(0); } to { transform: scaleX(0.85); } }

/* ---- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; }
  .sheet[open], .action--like.is-liked svg { animation: none; }
}

/* ---- Reports ---------------------------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.report-form { gap: var(--space-2); }
.report-reasons { display: grid; gap: 2px; margin: 0 0 var(--space-4); padding: 0; border: 0; }
.report-reason {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.report-reason:hover { background: var(--color-surface-raised); }
.report-reason:has(input:checked) { background: var(--color-surface-raised); }
.report-reason input { accent-color: var(--color-accent); width: 18px; height: 18px; margin: 0; }
.report-details {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font: inherit;
  resize: vertical;
}
.report-done { display: grid; gap: var(--space-3); padding: var(--space-4) var(--space-2); text-align: center; }
.report-done__title { font-family: var(--font-display); font-size: var(--text-lg); font-weight: var(--weight-bold); }

/* ---- Legal pages & links -------------------------------------------------------- */
.legal { max-width: 65ch; line-height: 1.65; }
.legal h2 { margin: var(--space-6) 0 var(--space-2); font-size: var(--text-lg); }
.legal p, .legal ul { margin: 0 0 var(--space-3); }
.legal ul { padding-left: var(--space-5); }
.legal li + li { margin-top: var(--space-2); }
.legal__updated { color: var(--color-text-muted); font-size: var(--text-sm); }
.legal-links { margin-top: var(--space-5); font-size: var(--text-xs); color: var(--color-text-muted); text-align: center; }
.legal-links a { color: var(--color-text-muted); }
.legal-links a:hover { color: var(--color-text); }
.sidebar .legal-links { margin-top: 0; text-align: left; padding-left: var(--space-2); }

/* ---- Danger zone ------------------------------------------------------------------ */
.danger-note {
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  color: var(--color-text);
}
.btn--danger-solid { background: var(--color-danger); color: #fff; }
.btn--danger-solid:hover { background: var(--color-danger); color: #fff; filter: brightness(1.1); }
.settings-warning {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-highlight);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.field--checkbox label a { text-decoration: underline; }
.field--checkbox { align-items: flex-start; }
.field--checkbox input { margin-top: 3px; flex-shrink: 0; }
.error-code { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--color-text); }


/* ---- Admin accounts: browse and moderate only (the server blocks the rest too) ---- */
.is-admin-account :is(.bottom-nav__create, [data-follow-url], [data-close-friend-url], [data-report-type],
  .use-song, .song-row__post, [data-reply], .profile__actions .btn--cf) { display: none !important; }
.is-admin-account :is([data-like-url]) { pointer-events: none; }
.sheet__admin-note { font-size: var(--text-sm); text-align: center; }
.is-admin-account .bottom-nav { grid-template-columns: repeat(4, 1fr); }
@media (min-width: 700px) { .is-admin-account .bottom-nav { grid-template-columns: none; } }
