:root {
  --bg: #f7f6fb;
  --text: #181124;
  --muted: #645c75;
  --accent: #6f3dde;
  --accent-ink: #f7f2ff;
  --card: #ffffff;
  --line: #e5def5;
  --shadow: 0 14px 24px -22px rgba(28, 15, 61, 0.55);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #ebe0ff 0%, transparent 30%),
    radial-gradient(circle at bottom right, #e2edff 0%, transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

.site-nav-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  backdrop-filter: blur(8px);
  background: linear-gradient(to bottom, rgba(247, 246, 251, 0.95), rgba(247, 246, 251, 0.78));
  border-bottom: 1px solid var(--line);
}

.site-nav,
main {
  width: min(1500px, 98vw);
  margin: 0 auto;
}

.site-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-nav h1 {
  margin: 0 6px 0 0;
  font-family: "DM Serif Display", serif;
  font-weight: 400;
  font-size: clamp(1.8rem, 2.4vw, 2.3rem);
  letter-spacing: 0.02em;
}

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

.brand-logo {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
}

.nav-chip,
.topic-pill,
.tab-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  background: #ece5ff;
  color: #36215d;
  font-weight: 600;
}

.nav-chip.active,
.topic-pill.active,
.tab-btn.active {
  background: var(--accent);
  color: #fff;
}

.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 12px 16px;
  font: inherit;
}

.profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: #2c2141;
  border-radius: 999px;
  padding: 5px 10px 5px 6px;
  cursor: pointer;
}

.profile-btn img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #e7dcff;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0 12px;
}

.filter-select {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #36215d;
  padding: 8px 12px;
}

.auth-message,
.setup-message {
  margin: 3px 0;
  color: #5d42a3;
  font-size: 0.92rem;
}

.setup-message {
  color: #7d223d;
}

.feed-shell,
.profile-section {
  margin: 14px 0 40px;
}

.empty-state {
  padding: 16px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.profile-avatar-large {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #dfd0ff;
}

.profile-header h2 {
  margin: 0;
}

.profile-meta {
  margin: 4px 0 0;
  color: var(--muted);
}

.profile-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.profile-block {
  margin-top: 14px;
}

.profile-block h3 {
  margin: 0 0 8px;
}

.insights-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.insight-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.insight-card strong {
  display: block;
  font-size: 1.1rem;
}

.masonry-feed {
  columns: 6 240px;
  column-gap: 16px;
}

.card {
  break-inside: avoid;
  margin-bottom: 16px;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.card.skeleton {
  min-height: 250px;
  background: linear-gradient(110deg, #f3eefc 8%, #ece4fc 18%, #f3eefc 33%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.1s linear infinite;
}

.card-image-wrap {
  position: relative;
}

.card img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  border-radius: 12px;
}

.card-actions {
  position: absolute;
  inset: 10px 10px auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: calc(100% - 20px);
}

.save-btn,
.delete-btn {
  opacity: 0;
  transform: translateY(-3px);
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  color: #fff;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}

.save-btn {
  background: var(--accent);
}

.delete-btn {
  background: #1f1630;
}

.card:hover .save-btn,
.card:hover .delete-btn,
.save-btn.saved,
.delete-btn.visible {
  opacity: 1;
  transform: translateY(0);
}

.card-body {
  padding: 8px 2px 0;
}

.card h3 {
  margin: 0;
  font-size: 0.97rem;
  line-height: 1.3;
  min-height: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.description {
  display: none;
}

.meta {
  display: none;
}

.author-link {
  color: #4b2ea0;
  text-decoration: none;
  font-weight: 600;
}

.author-link:hover {
  text-decoration: underline;
}

button,
input,
textarea {
  font: inherit;
}

.btn-primary,
.btn-ghost {
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  cursor: pointer;
  text-decoration: none;
}

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

.btn-ghost {
  background: #ede8f8;
  color: #3f286e;
}

.composer-dialog {
  border: none;
  border-radius: 18px;
  width: min(520px, calc(100vw - 24px));
  padding: 0;
  box-shadow: 0 25px 40px -20px rgba(0, 0, 0, 0.45);
}

.composer-dialog::backdrop {
  background: rgba(14, 8, 31, 0.44);
  backdrop-filter: blur(4px);
}

.composer {
  display: grid;
  gap: 10px;
  padding: 22px;
}

.composer h3 {
  margin: 0 0 4px;
}

.composer input,
.composer textarea {
  border: 1px solid #ddd3f1;
  border-radius: 12px;
  padding: 10px 12px;
}

.composer textarea {
  resize: vertical;
  min-height: 90px;
}

.field-counter {
  display: block;
  margin-top: -4px;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.photo-dialog {
  border: none;
  border-radius: 18px;
  width: min(980px, calc(100vw - 24px));
  padding: 0;
}

.photo-dialog::backdrop {
  background: rgba(14, 8, 31, 0.6);
  backdrop-filter: blur(4px);
}

.photo-view {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  background: #fff;
}

.photo-view img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-height: 82vh;
}

.photo-view-body {
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.photo-view-body h3,
.photo-view-body p {
  margin: 0;
}

.board-row {
  display: flex;
  gap: 8px;
}

.comments {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.comments h4 {
  margin: 0 0 8px;
}

.comments-list {
  display: grid;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
}

.comment-item {
  font-size: 0.86rem;
  padding: 7px 8px;
  background: #f6f2ff;
  border-radius: 8px;
}

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.comment-form input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
}

.toast-stack {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 200;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 20px));
}

.toast {
  background: #241341;
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 18px 30px -18px rgba(15, 8, 33, 0.7);
  font-size: 0.9rem;
}

.toast.error {
  background: #7f1d41;
}

@keyframes skeleton-loading {
  to {
    background-position-x: -200%;
  }
}

@media (max-width: 960px) {
  .photo-view {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .site-nav {
    grid-template-columns: 1fr;
  }

  .nav-right {
    flex-wrap: wrap;
  }

  .filter-select {
    width: 100%;
  }

  .masonry-feed {
    columns: 3 220px;
  }
}

@media (max-width: 640px) {
  .masonry-feed {
    columns: 2 170px;
  }
}
