/* UI helpers shared across pages */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--surface-border);
}

.logo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
}

.logo-link .logo-img {
  display: inline-flex;
}

.logo-link img {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  object-fit: contain;
  padding: 6px;
  border: none;
  box-shadow: none;
  background: transparent;
}

.inline-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-block {
  width: 100%;
  display: inline-flex;
  justify-content: center;
}

.page-header h1 {
  margin: 0 0 0.25rem;
}

.page-content {
  padding: 1.5rem;
  padding-bottom: calc(1.5rem + 4.25rem);
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-auth-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.card {
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--surface) 100%);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.3rem;
}

.guest-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  box-shadow: none;
}

.guest-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1rem;
  align-items: center;
}

.guest-hero-text {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.guest-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.guest-title-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-strong) 92%, var(--primary) 8%);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.guest-title-icon {
  width: 20px;
  height: 20px;
  display: block;
}

.guest-title-action:hover,
.guest-title-action:focus-visible {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--surface-strong) 88%, var(--primary) 12%);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.guest-title {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.guest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.guest-actions a {
  font-size: 0.95rem;
  font-weight: 700;
}

.guest-actions-row {
  grid-column: 1 / -1;
  justify-content: center;
  padding-top: 0.2rem;
  gap: 0.5rem;
}

.guest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill-quiet {
  background: color-mix(in srgb, var(--surface-strong) 92%, var(--primary) 8%);
  border: 1px solid var(--surface-border);
  box-shadow: none;
}

.guest-hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  padding: 0;
  min-height: 0;
}

.guest-hero-img {
  max-width: 360px;
  width: 100%;
  height: auto;
  display: block;
}

.guest-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
  align-items: stretch;
}

.guest-feature {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.6rem;
  border: 1px dashed var(--surface-border);
  border-radius: calc(var(--radius) - 6px);
}

.guest-feature-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: transparent;
  border: none;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
}

.guest-feature-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.guest-steps {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.guest-steps-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.guest-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.guest-step {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  border: 1px dashed var(--surface-border);
  border-radius: calc(var(--radius) - 6px);
  padding: 0.75rem 0.85rem;
  background: color-mix(in srgb, var(--surface-strong) 94%, var(--primary) 6%);
}

.guest-step-num {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--surface-border));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--primary);
  flex: 0 0 auto;
  background: var(--surface);
}

.home-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.3rem;
}

#home-guest > .card {
  margin-bottom: 1.25rem;
}

#home-guest > .card:last-child {
  margin-bottom: 0;
}

.home-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 25% 20%, color-mix(in srgb, var(--primary) 22%, transparent) 0%, transparent 32%), radial-gradient(circle at 80% 0%, color-mix(in srgb, var(--accent-warm) 20%, transparent) 0%, transparent 34%);
  opacity: 0.4;
  pointer-events: none;
}

.home-hero > * {
  position: relative;
  z-index: 1;
}

.home-hero-copy {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.home-hero-title {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.15rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 38%, var(--surface-border));
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.home-hero-panel {
  display: flex;
  align-items: stretch;
}

.home-panel-card {
  width: 100%;
  background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 14%, var(--surface-strong)) 0%, var(--surface) 100%);
  border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--surface-border));
  border-radius: calc(var(--radius) - 2px);
  padding: 1rem 1.05rem 1.1rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.home-checklist {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0.4rem;
  display: grid;
  gap: 0.45rem;
}

.home-checklist li {
  position: relative;
  padding-left: 1.35rem;
  color: var(--muted);
  line-height: 1.5;
}

.home-checklist li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 800;
  color: var(--primary);
}

.home-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-title {
  margin: 0.1rem 0 0.2rem;
  letter-spacing: -0.01em;
}

.home-feature-section {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.home-feature-grid {
  margin-top: 0.2rem;
}

.home-feature {
  background: color-mix(in srgb, var(--surface) 88%, var(--primary) 10%);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--surface-border));
  border-radius: calc(var(--radius) - 4px);
  padding: 1rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.14);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.16s ease;
}

.home-feature:hover,
.home-feature:focus-within {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.16);
}

.home-feature-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--surface-border));
  border-radius: 12px;
  font-size: 1.2rem;
}

.home-steps {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.home-steps-list {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0.2rem 0 0;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.home-steps-list li {
  counter-increment: step;
  position: relative;
  padding: 0.95rem 3.1rem 0.9rem 0.9rem;
  border: 1px dashed var(--surface-border);
  border-radius: calc(var(--radius) - 6px);
  background: color-mix(in srgb, var(--surface) 86%, var(--primary) 8%);
  color: var(--muted);
  line-height: 1.45;
  min-height: 100%;
}

.home-steps-list li::before {
  content: counter(step);
  position: absolute;
  top: 0.8rem;
  right: 0.85rem;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--surface-border));
  background: var(--surface-strong);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.95rem;
}

.home-steps-list strong {
  color: var(--text);
  display: block;
  margin-bottom: 0.15rem;
}

@media (max-width: 900px) {
  .home-hero {
    grid-template-columns: 1fr;
  }
  .home-hero-title {
    font-size: 1.35rem;
  }
  .guest-hero {
    grid-template-columns: 1fr;
  }
  .guest-hero-visual {
    min-height: 180px;
  }
}

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

.small {
  font-size: 0.9rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(480px, 100%);
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--surface) 100%);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem 1.6rem;
}

.auth-header h1 {
  margin: 0 0 0.35rem;
}

.auth-header p {
  margin: 0;
}

.auth-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.form-shell {
  gap: 1rem;
}

.form-section {
  border: 1px solid var(--surface-border);
  border-radius: calc(var(--radius) - 4px);
  background: color-mix(in srgb, var(--surface) 94%, var(--surface-strong) 8%);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.section-title {
  margin: 0;
  font-size: 1.05rem;
}

.section-subtitle h4 {
  margin: 0;
}

.section-subtitle p {
  margin: 0.1rem 0 0;
}

.option-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.option-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  position: relative;
}

.option-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.option-chip span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.option-chip:hover span,
.option-chip:focus-visible span {
  border-color: var(--surface-border-strong);
  background: var(--surface-strong);
}

.option-chip:focus-within span {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.option-chip input:checked + span {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.18);
}

.helper-text {
  min-height: 1.2em;
  color: var(--muted);
  margin: 0;
}

.input-with-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
}

.input-with-toggle input[type="password"],
.input-with-toggle input[type="text"] {
  flex: 1 1 auto;
  padding-right: 3rem;
}

.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-65%);
  z-index: 3;
  border: none;
  background: transparent;
  box-shadow: none;
  outline: none;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  margin: 0;
  line-height: 0;
  min-height: 0;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  pointer-events: auto;
  transition: none;
  appearance: none;
}

.password-toggle-btn:hover,
.password-toggle-btn:focus-visible {
  color: var(--primary);
  background: transparent;
  outline: none;
  box-shadow: none;
  transform: translateY(-65%);
}

.password-toggle-btn:focus,
.password-toggle-btn:active {
  outline: none;
  box-shadow: none;
  transform: translateY(-65%);
}

.password-toggle-btn svg {
  display: block;
  pointer-events: none;
  width: 18px;
  height: 18px;
  overflow: visible;
  transform: translateX(1px) scale(0.94);
  transform-origin: center;
}

.auth-footer {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--surface-border);
  box-shadow: none;
}

.ghost-secondary {
  background: var(--surface-strong);
  border-color: var(--surface-border);
  color: var(--text);
}
.ghost-secondary:hover,
.ghost-secondary:focus-visible {
  background: var(--surface);
  color: var(--text);
  border-color: var(--surface-border-strong);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  background: var(--primary);
  color: #fff;
  border-radius: calc(var(--radius) - 6px);
  border: 1px solid var(--primary);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  min-height: 42px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.18);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.link-btn:hover {
  background: var(--primary-strong);
  color: #fff;
  border-color: var(--primary-strong);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);
  transform: translateY(-1px);
}
.link-btn:active {
  transform: translateY(0);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}
.link-btn:disabled {
  background: var(--primary);
  color: rgba(255, 255, 255, 0.78);
  opacity: 0.6;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn-load-more {
  min-height: 2.4rem;
  padding: 0.5rem 1rem;
  margin-top: 0.25rem;
}

.feed-sentinel {
  width: 100%;
  height: 1px;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.post-tabs {
  display: inline-flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.post-tab {
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.post-tab:hover,
.post-tab:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
  outline: none;
}

.post-tab.active {
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.18);
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  background: var(--primary);
  color: #fff;
  border-radius: calc(var(--radius) - 6px);
  border: 1px solid var(--primary);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.18);
}

.primary-quiet {
  background: transparent;
  color: var(--text);
  border-color: var(--surface-border);
  box-shadow: none;
  font-weight: 700;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.primary-quiet:hover,
.primary-quiet:focus-visible {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22);
  transform: translateY(-1px);
}

.primary-quiet:active {
  transform: translateY(0);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.floating-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem 0.55rem;
  background: var(--surface);
  border-top: 1px solid var(--surface-border);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.16);
  z-index: 999;
  flex-wrap: nowrap;
  border-radius: 0;
}

.floating-nav-fixed {
  position: fixed;
}

.floating-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 0.3rem 0.5rem 0.25rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.72rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 56px;
  line-height: 1.2;
}

.floating-nav a:hover {
  border-color: var(--surface-border);
  background: var(--surface-strong);
}

.floating-nav a.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
}

.floating-nav .nav-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.floating-nav .nav-icon img {
  width: 22px;
  height: 22px;
  display: block;
}

.floating-nav .nav-label {
  font-size: 0.72rem;
  line-height: 1.2;
}

:root[data-theme="dark"] .floating-nav .nav-icon img {
  filter: brightness(1.35) contrast(1.25) saturate(1.2);
}

:root[data-theme="dark"] img[src*="assets/icons/"],
:root[data-theme="dark"] .guest-feature-icon img,
:root[data-theme="dark"] .home-feature-icon img {
  filter: brightness(1.35) contrast(1.25) saturate(1.2);
}

:root[data-theme="dark"] img[src*="assets/icons/guest/hero-"] {
  filter: brightness(1.5) contrast(1.32) saturate(1.25);
}

.floating-nav .theme-toggle {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 50px;
  height: 50px;
  border-radius: 16px;
}

/* Bio modal trigger */
.bio-button-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  margin: 0.35rem 0 0.2rem;
}

.bio-open-btn {
  background: transparent;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  padding: 0.45rem 1rem;
  box-shadow: none;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.bio-open-btn:hover,
.bio-open-btn:focus-visible {
  border-color: var(--primary);
  transform: translateY(-1px);
}

#bio-modal .modal-dialog {
  max-width: 520px;
}

.bio-modal-body {
  text-align: left;
  gap: 0.6rem;
}

#bio-modal p {
  text-align: left;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.floating-nav::before,
.floating-nav::after {
  display: none;
}

.floating-nav.nav-dragging {
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

:root:not([data-nav-state="logged-in"]) .floating-nav {
  display: none !important;
}

:root[data-nav-state="logged-in"] #nav-auth {
  display: none !important;
}
:root[data-nav-state="logged-in"] #nav-profile,
:root[data-nav-state="logged-in"] #nav-settings {
  display: inline-flex !important;
}
:root[data-nav-state="logged-out"] #nav-profile,
:root[data-nav-state="logged-out"] #nav-settings {
  display: none !important;
}
:root[data-nav-state="logged-out"] #nav-auth {
  display: inline-flex !important;
}
:root[data-nav-state="pending"] #nav-auth,
:root[data-nav-state="pending"] #nav-profile,
:root[data-nav-state="pending"] #nav-settings {
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}

.top-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.top-nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.top-nav a:hover {
  border-color: var(--surface-border);
  background: var(--surface-strong);
}

.top-nav-inline {
  align-items: center;
}

.result-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: stretch;
  position: relative;
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--surface) 100%);
  border: 1px solid var(--surface-border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.85rem 1rem 0.95rem;
  box-shadow: var(--shadow);
  overflow: visible;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.18s ease;
}

.result-card:hover,
.result-card:focus-within {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
}

.result-card.ad-card {
  gap: 0.35rem;
  padding: 0.6rem 0.9rem 0.7rem;
  border-color: #7c3aed;
  background: linear-gradient(180deg, color-mix(in srgb, #7c3aed 10%, var(--surface-strong)) 0%, var(--surface) 100%);
}

.result-card.ad-card:hover,
.result-card.ad-card:focus-within {
  border-color: #6d28d9;
  box-shadow: 0 10px 28px rgba(124, 58, 237, 0.16);
}

.ad-card .ad-header {
  align-items: center;
  gap: 0.4rem;
  padding-right: 2rem;
}

.ad-card .ad-title {
  font-weight: 700;
  font-size: 0.98rem;
}

.ad-card .ad-meta {
  margin: 0;
}

.ad-card .card-menu-wrapper {
  position: absolute;
  top: 0.15rem;
  right: 0;
}

.ad-card .ad-body {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  justify-content: center;
}

.ad-card .adsbygoogle {
  display: block;
  min-height: 70px;
  width: 100%;
}

.ad-card .ad-placeholder {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.badge-ads {
  background: #7c3aed;
  border-color: #6d28d9;
  color: #f3e8ff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.result-card .inline-header {
  align-items: flex-start;
}

.post-header-row {
  position: relative;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding-right: 2.6rem;
  z-index: 1;
}

.post-header-row > div:nth-child(1) {
  min-width: 0;
}

.post-header-row .card-menu-wrapper {
  position: absolute;
  top: 0.05rem;
  right: 0;
  margin: 0;
  z-index: 20000;
}

.post-author {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  position: relative;
  z-index: 3;
}

.post-avatar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
  z-index: 4;
  pointer-events: auto;
}

.post-author-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  position: relative;
  z-index: 3;
}

.post-author-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  position: relative;
  z-index: 1;
  flex: 1;
}

.post-author-name {
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  margin: 0;
  letter-spacing: -0.01em;
}

.post-author-name-link {
  color: inherit;
  text-decoration: none;
  display: inline-block;
  width: fit-content;
  position: relative;
  z-index: 4;
  pointer-events: auto;
}

.post-author-name:hover {
  text-decoration: underline;
}

.post-author-city {
  margin: 0;
  color: var(--muted);
}

.post-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  border: 1px solid var(--surface-border);
  background: var(--surface-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  text-decoration: none;
}

.post-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-avatar .avatar-fallback {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 800;
  font-size: 1rem;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface-strong));
}

.result-title {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.result-title:hover {
  text-decoration: underline;
}

.result-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-info-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: center;
}

.result-title-top {
  margin: 0 0 0.4rem;
}

.avatar-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.4rem;
}

.avatar-placeholder img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-avatar-link {
  display: inline-flex;
  align-items: center;
}

.result-title {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 0.25rem;
}

.result-title:hover {
  text-decoration: underline;
}

.result-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-main-instrument {
  font-weight: 700;
  color: var(--text);
}

.result-instruments {
  color: var(--muted);
}

.profile-header {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 1.1rem;
  row-gap: 0.2rem;
}

.avatar-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 84px;
  flex-shrink: 0;
}

.profile-top-block {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 1rem;
  row-gap: 0.2rem;
  width: 100%;
}

.profile-cta-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
  margin-bottom: 0.35rem;
  width: 100%;
}

.profile-cta-row button {
  flex: 1 1 0;
  width: 100%;
  height: 44px;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  box-sizing: border-box;
}

.profile-cta-row .rates-btn {
  margin-top: 0;
  min-height: 44px;
}

.profile-cta-row .cta-half {
  flex: 1 1 calc(50% - 0.25rem);
  max-width: calc(50% - 0.25rem);
}

.profile-cta-row .cta-full {
  flex: 1 1 100%;
  max-width: 100%;
}

.profile-name-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-self: center;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 84px;
}

.profile-name-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.profile-settings-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  padding: 4px;
  box-shadow: none;
  transition: none;
}

.profile-fav-toggle,
.profile-fav-open,
.profile-like-toggle {
  padding: 0.3rem;
  border-radius: 8px;
  border: none !important;
  background: transparent !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none !important;
  transition: none;
  vertical-align: middle;
  margin-top: -2px;
  outline: none;
}

.profile-fav-toggle.is-active,
.profile-like-toggle.is-active {
  background: transparent !important;
}

.profile-settings-link:hover,
.profile-settings-link:focus-visible {
  transform: none;
}

.profile-fav-toggle:hover,
.profile-fav-toggle:focus-visible,
.profile-like-toggle:hover,
.profile-like-toggle:focus-visible,
.profile-fav-open:hover,
.profile-fav-open:focus-visible {
  transform: none;
  outline: none;
  box-shadow: none;
  background: transparent !important;
}

.profile-fav-toggle img,
.profile-like-toggle img,
.profile-fav-open img {
  display: block;
}

.profile-like-toggle img,
.likes-icon img {
  opacity: 1;
  transition: transform 0.2s ease;
}

.profile-fav-open img,
.profile-fav-toggle img,
.profile-like-toggle img,
.likes-icon img {
  filter: none !important;
}

.profile-fav-toggle.fav-bounce,
.profile-fav-toggle.fav-bounce img,
.profile-fav-open.fav-bounce,
.profile-fav-open.fav-bounce img,
.profile-settings-link.fav-bounce,
.profile-settings-link.fav-bounce img {
  animation: fav-bounce 320ms ease;
  transform-origin: center;
}

.profile-like-toggle.like-bounce,
.profile-like-toggle.like-bounce img,
.likes-icon.like-bounce img {
  animation: fav-bounce 320ms ease;
  transform-origin: center;
}

.fav-toast {
  position: fixed;
  padding: 0.4rem 0.7rem;
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.18);
  font-size: 0.86rem;
  line-height: 1.3;
  z-index: 9999;
  transform: translate(-50%, -4px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.fav-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 6px) scale(1);
}

.fav-toast::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 7px solid var(--surface-strong);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
  margin-top: 0.9rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.2rem;
}

.video-card {
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.video-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  font-weight: 700;
  padding: 0.15rem 0;
}

.video-title-input {
  flex: 1;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 0.28rem 0.55rem;
  font-weight: 700;
  background: var(--surface);
  min-height: 36px;
}

.video-delete-btn {
  flex: 0 0 auto;
  padding: 0.25rem 0.6rem;
  min-height: 36px;
}

.video-card video {
  width: 100%;
  max-height: min(320px, 50vh);
  border-radius: 10px;
  background: #000;
  object-fit: contain;
}

.video-empty {
  grid-column: 1 / -1;
  margin: 0.25rem 0;
}

.video-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.5rem;
  gap: 0.5rem;
  position: sticky;
  bottom: 0;
  padding: 0.3rem 0 0.1rem;
  background: var(--surface);
}

.likes-icon {
  padding: 0.2rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

@keyframes fav-bounce {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.15);
  }
  70% {
    transform: scale(0.92);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 640px) {
  .profile-header {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .profile-name-block {
    align-items: flex-start;
    min-height: auto;
  }
}

.profile-avatar {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--surface-border);
  background: var(--surface-strong);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.avatar-fallback {
  font-size: 2rem;
  color: var(--muted);
}

.avatar-menu-toggle {
  position: absolute;
  bottom: -6px;
  right: -6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  text-shadow: 0 0 6px rgba(0,0,0,0.35);
}
.avatar-menu-toggle:hover,
.avatar-menu-toggle:focus {
  background: transparent;
}

.avatar-change-link {
  display: block;
  width: 100%;
  font-size: 0.7rem;
  line-height: 1.1;
  color: var(--muted);
  text-align: center;
  margin-top: 0.3rem;
  padding: 0.1rem 0.2rem;
  border: none;
  background: transparent;
  box-shadow: none;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.avatar-change-link:hover,
.avatar-change-link:focus-visible {
  color: var(--text);
  text-decoration: underline;
  outline: none;
}

.avatar-settings {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: nowrap;
  width: 100%;
}

.profile-avatar.small {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  flex-shrink: 0;
}

.avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  justify-content: center;
  flex: 1;
  min-width: 0;
}

.avatar-helpers {
  width: 100%;
  margin-top: 0.35rem;
}

.avatar-helpers p {
  margin: 0;
}

@media (max-width: 640px) {
  .avatar-settings {
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex-wrap: wrap;
  }
  .avatar-actions,
  .avatar-buttons {
    width: 100%;
    align-items: center;
  }
  .avatar-buttons {
    flex-direction: column;
  }
  .avatar-helpers {
    text-align: center;
  }
}

@media (min-width: 641px) {
  .avatar-settings {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
  }
  .avatar-actions {
    align-items: flex-start;
    justify-content: center;
  }
}

.avatar-buttons {
  display: flex;
  gap: 0.5rem;
  flex-direction: column;
  width: 100%;
}

.avatar-buttons > * {
  width: 100%;
}

.danger-text {
  color: #ef4444;
  border-color: #ef4444;
}

.success-text {
  color: #16a34a;
  border-color: #16a34a;
}

.btn-block {
  width: 100%;
  display: inline-flex;
  justify-content: center;
}
.autocomplete.with-clear input {
  padding-right: 2rem;
}

.autocomplete-list {
  max-height: 240px;
  overflow-y: auto;
}

.clear-input {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%) scale(1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0;
  line-height: 1;
  width: 1.6rem;
  height: 1.6rem;
  min-height: 0;
  border-radius: 999px;
  box-shadow: none;
  transition: color 0.12s ease, background-color 0.12s ease, transform 0.12s ease;
}
.clear-input:hover,
.clear-input:focus-visible {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  outline: none;
  transform: translateY(-50%) scale(1.08);
}
.clear-input:active {
  transform: translateY(-50%) scale(0.98);
  box-shadow: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
}

.badge-success {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

.badge-floating {
  position: absolute;
  top: -0.55rem;
  left: -0.55rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
  pointer-events: none;
  transform-origin: center;
}

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 1.4rem;
  position: relative;
}

.badge-type {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  border: 1px solid var(--surface-border);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  vertical-align: middle;
}

.badge-type.badge-seeking {
  background: #facc15;
  border-color: #eab308;
  color: #7a5c00;
}

.badge-type.badge-offering {
  background: #fb923c;
  border-color: #f97316;
  color: #5f2a00;
}

.badge-anim-in {
  animation: badge-bounce-in 440ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.badge-anim-out {
  animation: badge-bounce-out 360ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes badge-bounce-in {
  0% {
    opacity: 0;
    transform: scale(0.35);
  }
  55% {
    opacity: 1;
    transform: scale(1.18);
  }
  75% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes badge-bounce-out {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  35% {
    transform: scale(1.08);
  }
  100% {
    opacity: 0;
    transform: scale(0.35);
  }
}

.kebab-btn,
.fav-menu-btn,
.thread-menu-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.2rem 0.35rem;
  margin: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: color 0.12s ease, transform 0.12s ease;
  box-shadow: none;
  appearance: none;
}

.kebab-btn:hover,
.kebab-btn:focus-visible,
.fav-menu-btn:hover,
.fav-menu-btn:focus-visible,
.thread-menu-btn:hover,
.thread-menu-btn:focus-visible {
  color: var(--text);
  background: transparent !important;
  box-shadow: none !important;
  outline: none;
  transform: none !important;
}

.card-menu-wrapper,
.thread-menu-wrapper,
.fav-menu-wrapper {
  position: relative;
  margin-left: auto;
  z-index: 20000;
}

.card-menu,
.thread-menu,
.fav-menu {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
  display: none;
  z-index: 20010;
  padding: 0.1rem 0;
  flex-direction: column;
}

.card-menu.open,
.thread-menu.open,
.fav-menu.open {
  display: block;
}

.card-menu button,
.thread-menu button,
.fav-menu button {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.45rem 0.65rem;
  text-align: left;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
}

.card-menu button:hover,
.card-menu button:focus-visible,
.thread-menu button:hover,
.thread-menu button:focus-visible,
.fav-menu button:hover,
.fav-menu button:focus-visible {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.card-menu button:disabled,
.thread-menu button:disabled,
.fav-menu button:disabled {
  color: var(--muted);
  cursor: default;
}

.post-resolved {
  border-color: color-mix(in srgb, #16a34a 35%, var(--surface-border));
}

.field-hint {
  margin: 0.1rem 0 0.2rem;
}

.xsmall {
  font-size: 0.8rem;
}

.avatar-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  box-shadow: none;
  padding: 0.35rem 0.45rem;
  display: none;
  flex-direction: column;
  gap: 0.15rem;
}

.avatar-menu button {
  background: transparent;
  color: var(--text);
  border: none;
  padding: 0.2rem 0.3rem;
  text-align: left;
  font-size: 0.9rem;
}

.avatar-menu button:hover {
  background: var(--surface-strong);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal .modal-backdrop {
  display: block;
  position: absolute;
  background: transparent;
  z-index: 0;
  pointer-events: none;
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 0.5rem;
  max-width: 90vw;
  max-height: 90vh;
  transform: scale(0.92);
  opacity: 0;
  transition: transform 0.26s ease, opacity 0.26s ease;
}

.modal-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 12px;
  object-fit: contain;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent !important;
  border: none !important;
  color: var(--text);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  box-shadow: none !important;
  transition: none;
}

.modal-close:hover,
.modal-close:focus,
.modal-close:focus-visible,
.modal-close:active {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  outline: none;
  color: var(--text);
}

.modal-backdrop.active .modal-content {
  transform: scale(1.04);
  opacity: 1;
}

.modal[aria-hidden="false"] .modal-content,
.modal.open .modal-content {
  transform: scale(1.04);
  opacity: 1;
}

.filter-stack {
  gap: 1rem;
}

.filter-section {
  border: 1px solid var(--surface-border);
  border-radius: calc(var(--radius) - 4px);
  padding: 0.75rem 0.85rem;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
}

.filter-grid {
  gap: 0.9rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.filter-type-btn {
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-type-btn.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.15);
}

.filter-level-btn {
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-level-btn.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.15);
}

.section-label {
  margin: 0 0 0.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.range-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.6rem;
  align-items: center;
}

.range-row input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

/* ============================================================
   Messaggi
   ============================================================ */
.messages-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  align-items: stretch;
}

.threads-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.threads-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.thread-item {
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  color: var(--text);
  cursor: pointer;
  transition: none;
}

.thread-item:hover,
.thread-item:focus-visible {
  border-color: var(--surface-border);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.thread-item.active {
  border-color: var(--surface-border);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.thread-name {
  margin: 0;
  font-weight: 700;
}

.thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.thread-menu-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.thread-menu-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 1.05rem;
  line-height: 1;
  box-shadow: none;
  transition: none;
}

.thread-menu-btn:hover,
.thread-menu-btn:focus-visible {
  color: var(--primary);
  transform: none;
}

.thread-menu {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
  display: none;
  z-index: 50;
  padding: 0;
  overflow: hidden;
}

.thread-menu.open {
  display: block;
}

.thread-menu button {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  text-align: left;
  cursor: pointer;
}

.thread-menu button:hover,
.thread-menu button:focus-visible {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.thread-name {
  margin: 0;
  font-weight: 700;
  font-size: 1.02rem;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-back-btn {
  display: none;
  border: 1px solid var(--surface-border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--text);
  border-radius: 10px;
  padding: 0.35rem 0.7rem;
  font-weight: 600;
  cursor: pointer;
}

.thread-preview {
  margin: 0.1rem 0 0.15rem;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--muted);
}

.thread-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.8rem;
  min-height: 60vh;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.chat-history {
  min-height: 260px;
  max-height: calc(100vh - 280px);
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: color-mix(in srgb, var(--surface) 98%, transparent);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
}

.msg-row {
  display: flex;
}

.msg-row.incoming {
  justify-content: flex-start;
}

.msg-row.outgoing {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: min(440px, 80%);
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.msg-in {
  background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
  border: 1px solid var(--surface-border);
}

.msg-out {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 50%, var(--surface-border));
}

.msg-text {
  margin: 0;
  white-space: pre-wrap;
}

.msg-time {
  align-self: flex-end;
  font-size: 0.82rem;
  color: var(--muted);
}

.chat-input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
}

.chat-input textarea {
  flex: 1;
  height: 84px;
  min-height: 84px;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid var(--surface-border);
  padding: 0.55rem 0.85rem;
  line-height: 1.35;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.chat-input button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 1rem;
  border-radius: 10px;
  width: 100%;
}

/* ============================================================
   Preferiti
   ============================================================ */
.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.favorite-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.favorite-section-title {
  margin: 0;
  font-size: 1.05rem;
}

.favorite-table {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.favorite-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 0.6rem 0.95rem;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  position: relative;
}

.favorite-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1 1 0;
  min-width: 0;
}

.favorite-avatar {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--surface-border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
}

.favorite-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.favorite-avatar-link {
  display: inline-flex;
}

.favorite-info {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  justify-content: center;
  line-height: 1.2;
}

.favorite-name {
  margin: 0;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  line-height: 1.15;
}

.fav-msg-to {
  margin: 0.1rem 0 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.favorite-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.2;
}

.favorite-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}

.favorite-actions .ghost {
  padding: 0.45rem 0.75rem;
}

.chat-name-link {
  cursor: pointer;
  color: var(--primary);
}

.chat-name-link:hover,
.chat-name-link:focus-visible {
  text-decoration: underline;
}

@media (max-width: 720px) {
  .favorite-row {
    flex-direction: column;
    align-items: flex-start;
    padding-right: 2.6rem;
    gap: 0.65rem;
  }
  .favorite-actions {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-left: 0;
    flex-shrink: 0;
  }
  .favorite-actions .ghost {
    width: 100%;
    justify-content: center;
  }
  .fav-menu-wrapper {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
  }
  .favorite-left {
    width: 100%;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.75rem;
  }
}

@media (max-width: 900px) {
  .messages-layout {
    grid-template-columns: 1fr;
  }
  .messages-layout .chat-panel {
    display: none;
  }
  .messages-layout.mobile-list .chat-panel {
    display: none;
  }
  .messages-layout.mobile-chat .threads-panel {
    display: none;
  }
  .messages-layout.mobile-chat .chat-panel {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 0.8rem;
    min-height: 70vh;
  }
  .chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .messages-layout.mobile-chat .chat-history {
    max-height: calc(100vh - 220px);
    min-height: 52vh;
  }
}

@media (max-width: 640px) {
  html {
    font-size: 15px;
  }
  body {
    font-size: 0.95rem;
  }
  .messages-layout {
    grid-template-columns: 1fr;
  }
  .chat-history {
    max-height: none;
    min-height: 260px;
  }
  h1 {
    font-size: 1.85rem;
  }
  h2 {
    font-size: 1.2rem;
  }
  h3 {
    font-size: 1.05rem;
  }
  .page-header {
    padding: 1.1rem;
  }
  .page-content {
    padding: 1.05rem;
    padding-bottom: calc(1.05rem + 4.25rem);
  }
  .card {
    padding: 1rem 1.05rem;
  }
  .floating-nav {
    bottom: 0;
    gap: 0.35rem;
    padding: 0.32rem 0.45rem 0.48rem;
  }
  .floating-nav a {
    padding: 0.28rem 0.4rem 0.22rem;
    font-size: 0.72rem;
    min-width: 54px;
  }
  .theme-toggle {
    padding: 0.22rem 0.3rem;
    width: auto;
    height: 44px;
  }
}

@media (max-width: 720px) {
  .floating-nav {
    right: 0;
    bottom: 0;
    gap: 0.3rem;
    padding: 0.28rem 0.4rem 0.4rem;
    max-width: 100%;
    flex-wrap: nowrap;
  }
  .floating-nav a {
    padding: 0.24rem 0.35rem 0.18rem;
    font-size: 0.7rem;
    min-width: 52px;
  }
  .floating-nav .theme-toggle {
    padding: 0.24rem 0.3rem;
    width: auto;
    height: 42px;
  }
}
