/* Hub Layout */
.hub-layout { max-width: 1500px; margin: 0 auto; padding: 0 24px 100px; }

/* Gliim feed — wide masonry of cards (shared by XpLoRe and profile) */
.blog-feed { column-gap: 24px; }

@media (min-width: 1600px) { .blog-feed { column-count: 4; } }
@media (min-width: 1200px) and (max-width: 1599px) { .blog-feed { column-count: 3; } }
@media (min-width: 768px) and (max-width: 1199px) { .blog-feed { column-count: 2; } }
@media (max-width: 767px) { .blog-feed { column-count: 1; column-gap: 16px; } }

/* Spacing for non-.blog-card kinds (audiolites/books/bundles) in this fallback */
.blog-feed > article { margin-bottom: 24px; break-inside: avoid; }

.blog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  break-inside: avoid;
  display: inline-block;
  width: 100%;
  box-sizing: border-box;
}

.blog-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.blog-cover { width: 100%; height: 300px; background-size: cover; background-position: center; background-color: var(--bg-tertiary); }
.blog-content { padding: 24px; }
.blog-meta { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.blog-category { font-size: 11px; font-weight: 700; color: var(--brand-primary); background: var(--brand-primary-light); padding: 4px 10px; border-radius: 20px; text-transform: uppercase; }
.blog-date { font-size: 12px; color: var(--text-muted); }
.blog-title { font-size: 24px; font-weight: 800; color: var(--text-primary); margin-bottom: 12px; line-height: 1.3; letter-spacing: -0.5px; }
.blog-desc { font-size: 15px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 24px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.blog-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding-top: 16px; }
.blog-author { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--text-primary); }
[data-theme="light"] .blog-author { color: #000; }
.blog-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--gradient-primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; object-fit: cover; }
.blog-stats { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* Tier icons are styled in dashboard.css */

/* Theme-Adaptive Modal Background */
[data-theme="light"] .modal-overlay { background: rgba(255, 255, 255, 0.98) !important; }
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, 0.95) !important; }

/* Read View Layout */
.read-view-overlay { padding: 40px 16px; overflow: hidden !important; display: flex; justify-content: center; align-items: flex-start; }
.read-view-content {
  max-width: 800px;
  width: 100%;
  padding: 0;
  overflow: hidden;
  margin: auto;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-2xl);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  position: relative;
}

/* Top Right Menu (Isolated) */
.read-top-bar {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 30;
}
.hub-menu-wrapper { position: relative; }
.hub-menu-btn {
  background: rgba(0,0,0,0.3);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.hub-menu-btn:hover { background: rgba(0,0,0,0.5); }

.hub-read-menu {
  display: none;
  position: absolute;
  top: 120%;
  right: 0;
  left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 1000;
  overflow: hidden;
}
.hub-read-menu.active {
  display: block;
}
.hub-read-menu-item {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hub-read-menu-item:last-child { border-bottom: none; }
.hub-read-menu-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.hub-read-menu-item.danger { color: var(--error); }
.hub-read-menu-item.danger:hover { background: var(--error-light); }

.read-scroll-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.read-cover { width: 100%; height: 400px; background-size: cover; background-position: center; background-color: var(--bg-tertiary); }
.read-body { padding: 40px; }
.read-title { font-size: 32px; font-weight: 800; color: var(--text-primary); margin: 12px 0 24px; line-height: 1.2; letter-spacing: -0.5px; }
/* The dek under the title — the same description the bundle card shows. */
.read-desc { font-size: 17px; color: var(--text-secondary); line-height: 1.55; margin: -12px 0 24px; }
@media (max-width: 768px) {
  .read-desc { font-size: 15px; }
}

/* Read View Blocks */
.read-block-title { font-size: 28px; font-weight: 800; color: var(--text-primary); margin: 32px 0 16px; }
.read-block-subtitle { font-size: 22px; font-weight: 700; color: var(--text-primary); margin: 24px 0 12px; }
.read-block-text { font-size: 18px; color: var(--text-primary); line-height: 1.8; margin-bottom: 24px; }
.read-block-list { font-size: 18px; color: var(--text-primary); line-height: 1.8; margin-bottom: 24px; padding-left: 0; }
.read-block-list-item { display: block; }
.read-block-media { width: 100%; max-width: 600px; max-height: 500px; border-radius: 12px; margin: 0 auto 24px; display: block; border: 1px solid var(--border); object-fit: contain; }
.read-block-audio-wrapper { background: var(--bg-tertiary); padding: 16px; border-radius: 12px; margin-bottom: 24px; }
.read-audio-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.read-audio-head .lib-eq { height: 22px; margin: 0; }
.read-audio-title { margin: 0; font-size: 14px; font-weight: 700; color: var(--text-primary); }
.read-audio-min { margin-left: auto; flex: none; display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-secondary); cursor: pointer; }
.read-audio-min:hover { background: var(--bg-secondary); color: var(--text-primary); }
.read-block-audio { display: none; }
/* Modern audio card — custom chrome over the hidden <audio> element. */
.read-audio-card { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 10px 14px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px; }
.rap-play { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border: none; border-radius: 50%; background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark, var(--brand-primary))); color: var(--text-inverse, #fff); cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); transition: transform 0.15s ease; }
.rap-play:hover { transform: scale(1.06); }
.rap-play:active { transform: scale(0.96); }
.rap-timeline { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rap-seek { width: 100%; accent-color: var(--brand-primary); cursor: pointer; }
.rap-time { font-size: 11px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.rap-mute { flex: none; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: none; border-radius: 50%; background: transparent; color: var(--text-secondary); cursor: pointer; }
.rap-mute:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.rap-vol { width: 70px; accent-color: var(--brand-primary); cursor: pointer; }
@media (max-width: 640px) { .rap-vol { display: none; } }

/* Custom video player in the read view: poster-style big play button and a
   slim gradient control bar instead of the browser's default chrome. */
.read-video-player { position: relative; margin: 0 auto 24px; border-radius: 12px; overflow: hidden; background: #000; max-width: 600px; max-height: 500px; }
.read-video-player video { display: block; width: 100%; max-height: 500px; object-fit: contain; }
.rvp-big { position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: opacity .2s; }
.rvp-big:hover { background: rgba(0,0,0,.7); }
.rvp-big.hidden { opacity: 0; pointer-events: none; }
.rvp-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: linear-gradient(transparent, rgba(0,0,0,.72)); color: #fff; }
.rvp-bar button { background: none; border: none; color: #fff; cursor: pointer; display: flex; padding: 0; }
.rvp-bar button:hover { opacity: .85; }
.rvp-bar input[type=range] { flex: 1; accent-color: var(--brand-primary); height: 4px; cursor: pointer; }
.rvp-time { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; opacity: .9; }

/* Audiolite square card: solid cover_color (or theme surface when none) with
   the title left-aligned on it; text shade is chosen for contrast in JS. */
.audiolite-card {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  padding: 18px;
  border-radius: 16px;
  cursor: pointer;
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
  break-inside: avoid;
}
.audiolite-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.audiolite-card.ambassador-card { border: 1.5px solid currentColor; }
.audiolite-card .blog-meta { margin-bottom: auto; border-top: none; }
.audiolite-kind { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; opacity: .75; }
.audiolite-kind svg { flex-shrink: 0; }
.audiolite-play { width: 30px; height: 30px; border-radius: 50%; background: rgba(127,127,127,.22); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.audiolite-spacer { flex: 1; }
.audiolite-title { font-size: 19px; font-weight: 800; line-height: 1.25; margin: 10px 0 14px; text-align: left; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.audiolite-card .blog-footer { border-top-color: rgba(127,127,127,.25); }

.audiolite-card .audiolite-center-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: color-mix(in srgb, #000000 50%, #868686bd);
  color: #fff;
  box-shadow: var(--shadow-md);
  z-index: 1;
}
.audiolite-center-icon svg { width: 28px; height: 28px; }
.audiolite-center-icon + .audiolite-title {
  margin: auto 0 0;
  -webkit-line-clamp: 2;
  color: inherit;
}
[data-theme="light"] .audiolite-cover-card .audiolite-title { color: #000; text-shadow: 0 1px 4px rgba(255,255,255,.4); }
[data-theme="dark"] .audiolite-cover-card .audiolite-title { color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.6); }

/* Book cover card: JUST the cover image as a square — no title, no author, no stats.
   Only the draft badge is shown in the corner. */
.book-cover-card {
  position: relative;
  aspect-ratio: 3 / 4;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-tertiary);
  border-radius: 16px;
  cursor: pointer;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
  break-inside: avoid;
}
.book-cover-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.book-cover-card.ambassador-card { border: 1.5px solid var(--text-primary); }
[data-theme="dark"] .book-cover-card.ambassador-card { border-color: var(--text-inverse); }

.book-cover-badges {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

/* Bundle card: plain surface, cover on top, kind + title + creator below.
   No scrim or overlay at all — every colour comes from the theme tokens, which
   is what keeps it legible in both light and dark. */
.bundle-card .bundle-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-tertiary);
}
.bundle-card .blog-content { padding: 16px 18px 18px; }
.bundle-card .blog-meta { margin-bottom: 10px; }
.bundle-card .blog-title { font-size: 17px; margin-bottom: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bundle-card .blog-author { font-size: 13px; min-width: 0; }
.bundle-card .blog-author span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Audiolite with cover image: same gradient treatment as bundle/book cards. */
.audiolite-cover-card {
  background-size: cover;
  background-position: center;
  color: #fff;
}
.audiolite-cover-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgb(255 255 255 / 76%) 0%, rgb(204 198 198 / 0%) 40%, rgb(0 0 0 / 10%) 100%);
  border-radius: inherit;
  pointer-events: none;
}
[data-theme="dark"] .audiolite-cover-card::before {
  background: linear-gradient(to top, rgb(0 0 0 / 61%) 0%, rgb(204 198 198 / 0%) 40%, rgb(0 0 0 / 10%) 100%);
}
.audiolite-cover-card > * { position: relative; z-index: 1; }
.audiolite-cover-card .blog-footer { border-top-color: rgba(255,255,255,.2); color: rgba(255,255,255,.85); }
.audiolite-cover-card .blog-stat { color: rgba(255,255,255,.8); }
.audiolite-cover-card .audiolite-kind { color: #fff; }

/* PDF block in the read view: price label + open/download link (label-only
   for now — checkout is a later pass). */
.read-block-pdf { display: flex; align-items: center; gap: 12px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 24px; }
.read-pdf-price { font-size: 13px; font-weight: 800; color: #B45309; background: rgba(245, 158, 11, 0.15); padding: 4px 10px; border-radius: 999px; flex-shrink: 0; }
.read-pdf-price.read-pdf-free { color: var(--success); background: rgba(16, 185, 129, 0.14); }
.read-pdf-link { font-size: 14px; font-weight: 600; color: var(--brand-primary); text-decoration: none; }
.read-pdf-link:hover { text-decoration: underline; }

/* Fixed Bottom Action Bar */
.read-bottom-bar {
  flex-shrink: 0;
  background: var(--surface);
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  z-index: 20;
  display: flex;
  gap: 32px;
  justify-content: center;
}
.action-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; transition: color 0.2s ease; padding: 4px; }
.action-btn:hover { color: var(--brand-primary); }

/* Icon Sizing and Contrast */
img.action-icon-img { width: 24px !important; height: 24px !important; transition: all 0.2s ease; }

[data-theme="dark"] img.action-icon-img { filter: brightness(0) invert(1) !important; opacity: 0.9 !important; }
[data-theme="dark"] .action-btn:hover img.action-icon-img { opacity: 1 !important; }
[data-theme="dark"] .like-btn.liked img.action-icon-img {
  filter: invert(40%) sepia(90%) saturate(3000%) hue-rotate(315deg) brightness(150%) !important;
  opacity: 1 !important;
}

[data-theme="light"] img.action-icon-img { filter: brightness(0) !important; opacity: 0.7 !important; }
[data-theme="light"] .action-btn:hover img.action-icon-img { opacity: 1 !important; }
[data-theme="light"] .like-btn.liked img.action-icon-img {
  filter: invert(20%) sepia(90%) saturate(3000%) hue-rotate(315deg) brightness(150%) !important;
  opacity: 1 !important;
}

.support-btn:hover { color: var(--gold); }
.support-btn:hover svg { stroke: var(--gold); }

/* Comment Section */
.comment-section { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 24px; }
.comment-section h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.comment-input-wrapper { display: flex; gap: 12px; margin-bottom: 24px; position: relative; }
.comment-input-wrapper .input { flex: 1; }
.comment-send-btn { background: var(--brand-primary); color: white; border: none; border-radius: 12px; width: 46px; height: 46px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s ease; }
.comment-send-btn:hover { background: var(--brand-primary-hover); }
.mention-picker { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); max-height: 240px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); display: none; z-index: 30; }
.mention-picker.active { display: block; }
.mention-option { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.mention-option:last-child { border-bottom: none; }
.mention-option:hover, .mention-option.active { background: var(--bg-tertiary); }
.mention-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--bg-tertiary); color: var(--text-secondary); }
.mention-option-name { flex: 1; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.mention-option-gp { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.comment-list { display: flex; flex-direction: column; gap: 16px; }
.comment-item { display: flex; gap: 12px; position: relative; padding: 8px; border-radius: 8px; transition: background 0.2s; }
.comment-item:hover { background: var(--bg-tertiary); }
.comment-item.comment-highlight { background: var(--brand-primary-light); transition: background 0.3s ease; }
.comment-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-tertiary); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; object-fit: cover; cursor: pointer; }
.comment-content-wrap { flex: 1; padding-right: 24px; }
.comment-author { font-weight: 600; color: var(--text-primary); margin-right: 8px; font-size: 14px; }
.comment-text { font-size: 14px; color: var(--text-secondary); line-height: 1.5; display: inline; }
.comment-tag { color: var(--brand-primary); font-weight: 600; background: var(--brand-primary-light); padding: 0 4px; border-radius: 4px; cursor: pointer; }

/* User Profile Click Menu */
.context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 120px;
  overflow: hidden;
}
.ctx-item { padding: 10px 16px; font-size: 14px; cursor: pointer; transition: background 0.2s; }
.ctx-item:hover { background: var(--bg-tertiary); }

/* Topbar Actions (Isolated Classes) */
#topbar-right-actions { display: flex; align-items: center; gap: 8px; }

.hub-filter-bar {
  display: flex;
  justify-content: flex-end;
  padding: 0 0 12px 0;
}

.hub-filter-wrapper { position: relative; }
.hub-filter-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 12px; height: 38px; padding: 0 14px; cursor: pointer; color: var(--text-secondary); font-family: var(--font-sans); font-size: 13px; font-weight: 600; transition: all 0.2s ease; }
.hub-filter-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.hub-filter-btn svg { flex-shrink: 0; }
.hub-filter-label { white-space: nowrap; }

.hub-filter-menu {
  display: none;
  position: absolute;
  top: 120%;
  right: 0;
  left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 1000;
  overflow: hidden;
}
.hub-filter-menu.active {
  display: block;
}
.hub-filter-item {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.hub-filter-item:last-child { border-bottom: none; }
.hub-filter-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.hub-filter-item.active { color: var(--brand-primary); background: var(--brand-primary-light); font-weight: 600; }

/* ============================================
   GLIIM STUDIO — publish canvas
   A document, not a form: masthead, a discreet settings row, then the blocks
   with their handles fading in on hover (tap to reveal on touch).
   ============================================ */
.gliim-builder { max-width: 760px; max-height: 90vh; overflow-y: auto; }
.publish-composer {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-8);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}
.doc-canvas { display: flex; flex-direction: column; gap: var(--space-5); }

/* Masthead: title, standfirst, cover */
.doc-masthead { display: flex; flex-direction: column; gap: var(--space-2); }
.doc-title {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-sans);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-primary);
}
.doc-title::placeholder { color: var(--text-muted); font-weight: 800; }
.doc-standfirst {
  width: 100%;
  padding: 0 0 var(--space-3);
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  outline: none;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.doc-standfirst::placeholder { color: var(--text-muted); }

/* Cover slot — hidden attributes drive the empty/filled states, so make sure
   the display rules below cannot win against them. */
.doc-cover { position: relative; }
.doc-cover [hidden] { display: none !important; }
.doc-cover-picker {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  width: 100%;
  /* Without this the masthead cover is ~400px tall on desktop and dwarfs the body. */
  max-height: 300px;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.doc-cover-picker:hover { border-color: var(--brand-primary); }
.doc-cover-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.doc-cover-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--space-4);
  text-align: center;
  color: var(--text-secondary);
}
.doc-cover-empty svg { color: var(--text-muted); }
.doc-cover-empty strong { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.doc-cover-empty small { font-size: 12.5px; color: var(--text-muted); }
.doc-cover-clear {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.62);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.doc-cover-clear:hover { background: var(--error); }
.mast-cover-status { display: block; margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.mast-cover-status:empty { display: none; }
.doc-cover.needs-cover .doc-cover-picker { border-color: var(--error); border-style: solid; background: var(--error-light); }
.doc-cover.needs-cover .doc-cover-empty strong,
.doc-cover.needs-cover .doc-cover-empty small { color: var(--error-text); }
.doc-cover.needs-cover { animation: cover-nudge 0.35s ease; }
@keyframes cover-nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Collapsible details row (category, tags, hashtags) */
.doc-settings {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  overflow: hidden;
}
.doc-settings-summary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 12px 14px;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  color: var(--text-secondary);
  cursor: pointer;
}
.doc-settings-summary:hover { color: var(--text-primary); }
.doc-settings-chevron { flex-shrink: 0; color: var(--text-muted); transition: transform 0.2s ease; }
.doc-settings.open .doc-settings-chevron { transform: rotate(180deg); }
.doc-settings-body { display: none; padding: var(--space-4) 14px 14px; border-top: 1px solid var(--border); }
.doc-settings.open .doc-settings-body { display: block; }
.doc-settings-body .form-group:last-child { margin-bottom: 0; }

/* Blocks */
.doc-blocks { display: flex; flex-direction: column; }
.builder-block {
  position: relative;
  padding: 34px 14px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: transparent;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.builder-block:hover,
.builder-block:focus-within { background: var(--bg-secondary); border-color: var(--border); }
.builder-block.is-open { background: var(--bg-secondary); border-color: var(--border-strong); }
.builder-block.is-dragging { opacity: 0.45; }
.builder-block.drag-above { box-shadow: 0 -2px 0 0 var(--brand-primary); }
.builder-block.drag-below { box-shadow: 0 2px 0 0 var(--brand-primary); }

/* Handle strip occupies the reserved 34px above the block content */
.block-tools {
  position: absolute;
  top: 5px;
  left: 8px;
  right: 8px;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.builder-block:hover .block-tools,
.builder-block:focus-within .block-tools,
.builder-block.is-open .block-tools { opacity: 1; }
.block-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: grab;
}
.block-drag-handle:active { cursor: grabbing; }
.block-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.block-kind-aa { min-width: 16px; text-align: center; font-size: 11px; font-weight: 800; letter-spacing: 0.04em; }

/* Trash button sits at the far end of the handle strip */
.block-remove-btn {
  margin-left: auto;
  background: transparent;
  color: var(--text-muted);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.block-remove-btn:hover { background: var(--error-light); color: var(--error); }

/* "+ Insert" caret between blocks. It is the only way to add a block to an
   existing document, so it stays visible: a hover-revealed control is
   invisible on touch and undiscoverable on the first read of the page. */
.block-insert-bar { position: relative; height: 20px; display: flex; align-items: center; justify-content: center; }
.block-insert-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.block-insert-btn:hover,
.block-insert-btn:focus-visible,
.block-insert-bar.open .block-insert-btn {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.block-insert-menu {
  position: absolute;
  top: calc(100% - 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.block-insert-bar.open .block-insert-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.block-insert-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  color: var(--text-secondary);
  cursor: pointer;
}
.block-insert-option:hover { background: var(--brand-primary-light); color: var(--brand-primary); }

.doc-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.block-style-select { margin-bottom: 8px; }

.custom-file-upload { display: flex; align-items: center; gap: 8px; background: var(--bg-tertiary); border: 1px solid var(--border); padding: 12px 16px; border-radius: 12px; cursor: pointer; font-size: 14px; color: var(--text-secondary); font-weight: 500; transition: all 0.2s ease; }
.custom-file-upload:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.upload-icon-img { width: 18px !important; height: 18px !important; max-width: 18px !important; max-height: 18px !important; object-fit: contain; }
.block-file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

/* Dark Mode Paperclip Fix */
[data-theme="dark"] .upload-icon-img { filter: brightness(0) invert(1); }

/* Touch screens: no hover, so handles appear on tap and the insert caret is
   always reachable. The .is-open rule must stay last — it ties with the hover
   selectors and wins on order. */
@media (hover: none) {
  .builder-block:hover .block-tools,
  .builder-block:focus-within .block-tools { opacity: 0; }
  .builder-block.is-open .block-tools { opacity: 1; }
  .block-insert-btn { opacity: 0.75; }
}

@media (max-width: 640px) {
  .publish-composer { padding: var(--space-4) var(--space-3) var(--space-6); border-radius: 0; border-left: none; border-right: none; }
  .doc-title { font-size: 22px; }
  .doc-standfirst { font-size: 14px; }
  .doc-cover-picker { aspect-ratio: 4 / 3; }
  .builder-block { padding: 32px 8px 12px; }
  .block-insert-menu { grid-template-columns: 1fr 1fr; min-width: 240px; }
  .doc-actions .btn-primary,
  .doc-actions .btn-secondary { flex: 1; }
}

/* Pool (poll) blocks in the composer and the read view */
.poll-block { border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin: 20px 0; }
.poll-options-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.poll-option-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-tertiary);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.15s ease;
}
.poll-option-row:hover { border-color: var(--brand-primary); }
.poll-option-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--brand-primary) 55%, transparent), color-mix(in srgb, var(--brand-secondary) 45%, transparent));
  transition: width 0.4s ease;
  z-index: 0;
}
.poll-option-row.poll-option-lead .poll-option-fill {
  background: linear-gradient(90deg, color-mix(in srgb, var(--brand-primary) 80%, transparent), color-mix(in srgb, var(--brand-secondary) 70%, transparent));
}
.poll-option-label, .poll-option-meta { position: relative; z-index: 1; }
.poll-option-label { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.poll-option-meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.poll-option-row.poll-option-mine { border-color: var(--brand-primary); box-shadow: inset 0 0 0 1px var(--brand-primary); }
.poll-option-row.poll-option-mine .poll-option-label::after { content: ' · Your pick'; font-size: 11px; font-weight: 500; color: var(--brand-primary); }
.poll-total { margin-top: 12px; font-size: 12px; color: var(--text-muted); text-align: right; }

/* Poll style inside a text block — composer only */
.poll-builder .poll-options { display: flex; flex-direction: column; gap: 8px; }
.poll-builder-row { display: flex; gap: 8px; align-items: center; }
.poll-builder-row .poll-option-input { flex: 1; }
.poll-option-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 18px;
  line-height: 1;
}
.poll-option-remove:hover { color: var(--error); }

/* Mobile: the feed is a single column of cards */
@media (max-width: 768px) {
  .hub-layout { padding-left: 12px; padding-right: 12px; }
  .blog-feed { column-gap: 16px; }
  .blog-card { margin-bottom: 16px; border-radius: 12px; max-width: 100%; box-sizing: border-box; }
  .blog-content { padding: 16px; box-sizing: border-box; }
  .blog-cover { height: 180px; }
  .blog-title { font-size: 19px; margin-bottom: 8px; }
  .blog-desc { font-size: 14px; margin-bottom: 16px; -webkit-line-clamp: 2; }
  .blog-footer { padding-top: 12px; flex-wrap: wrap; gap: 8px; }

  /* Filter button collapses to a square icon on small screens */
  .hub-filter-btn { width: 38px; padding: 0; justify-content: center; }
  .hub-filter-label { display: none; }

  /* Dropdown for the filter menu on mobile */
  .hub-filter-menu {
    top: 120%;
    bottom: auto;
  }
}

/* ============================================
   MOBILE SPACING (No Horizontal Scroll)
   ============================================ */
@media (max-width: 768px) {
  /* Reduce outer dashboard padding but keep room for the fixed bottom bar.
     The values live in --pad-top/--pad-x so the page header's bleed margins
     in dashboard.css cancel exactly this padding. The bar itself is already
     reserved once by body { padding-bottom: var(--bottom-bar-h) }, so this is
     only the breathing gap above it — 140px here used to double up into ~204px
     of dead space under the last card. */
  .view-container {
    padding: var(--pad-top) var(--pad-x) !important;
    padding-bottom: var(--space-6) !important;
  }

  .blog-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    break-inside: avoid;
    overflow: hidden;
  }
  
  .blog-card * {
    box-sizing: border-box;
  }

  /* Mobile: book-cover-card, audiolite-card, bundle-card sizing */
  .book-cover-card, .audiolite-card, .bundle-card {
    max-width: 100%;
    box-sizing: border-box;
  }
  .audiolite-title {
    font-size: 15px;
  }
  .blog-footer {
    font-size: 12px;
  }
  .blog-author span {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .audiolite-card { padding: 12px; }
  .audiolite-card .audiolite-center-icon { width: 40px; height: 40px; }
  .audiolite-center-icon svg { width: 22px; height: 22px; }
  .audiolite-center-icon + .audiolite-title { font-size: 13px; }
}

/* Comment Time Styling */
.comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.comment-time {
  font-size: 11px;
  color: var(--text-muted);
}
.audio-ts-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  margin: 0 6px 0 0;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  color: var(--brand-primary, #6366f1);
  background: color-mix(in srgb, var(--brand-primary, #6366f1) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand-primary, #6366f1) 25%, transparent);
  border-radius: 10px;
  cursor: pointer;
  line-height: 1.3;
  transition: background 0.15s, border-color 0.15s;
}
.audio-ts-badge:hover {
  background: color-mix(in srgb, var(--brand-primary, #6366f1) 22%, transparent);
  border-color: color-mix(in srgb, var(--brand-primary, #6366f1) 40%, transparent);
}
.audio-ts-badge::before {
  content: '▶';
  font-size: 8px;
}
.comment-text {
  display: block; /* Make text block so it sits below the name/time */
}

/* ============================================
   CARD STATS: eye + comment icons
   ============================================ */
.blog-stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.blog-stat svg { width: 14px; height: 14px; }

/* Clickable author (avatar + name link to portfolio) */
.hub-author-hit { cursor: pointer; }
.hub-author-hit:hover > span { color: var(--brand-primary); }
.hub-author-hit:hover > div > span:first-child { color: var(--brand-primary); }

/* ============================================
   TAG PEOPLE PICKER (Gliim composer)
   ============================================ */
.hub-tag-picker { display: flex; flex-direction: column; gap: 8px; }
.hub-tag-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.hub-tag-chips:empty { display: none; }
.hub-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  padding: 4px 6px 4px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.hub-tag-chip-x {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}
.hub-tag-chip-x:hover { color: var(--error); }

.hub-tag-results {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.hub-tag-results:not(:empty) { display: block; }
.hub-tag-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.hub-tag-result:last-child { border-bottom: none; }
.hub-tag-result:hover { background: var(--bg-tertiary); color: var(--brand-primary); }
.hub-tag-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
}
.hub-tag-empty { padding: 10px 14px; font-size: 13px; color: var(--text-muted); }

/* ============================================
   PDF BLOCK (composer slots + reader tiles)
   ============================================ */
/* Composer: up to two PDFs per block, side by side */
.pdf-slot-row { display: flex; flex-wrap: wrap; gap: 12px; }
.pdf-slot {
  flex: 1 1 220px;
  min-width: 0;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
}
.pdf-slot-title { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.pdf-slot .pdf-price-input { margin-top: 8px; width: 100%; }

/* Composer: Live block session picker */
.live-session-select { width: 100%; }
.live-session-status { font-size: 12px; margin-top: 8px; color: var(--text-muted); }

/* Composer: document block cover thumbnail */
.doc-cover-preview img {
  display: block;
  width: 72px;
  margin-top: 8px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Reader: PDF tiles as small rectangles with cover + price */
.pdf-block-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0; }
.pdf-tile {
  position: relative;
  width: 150px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-tertiary);
}
.pdf-tile:hover { border-color: var(--brand-primary); }
.pdf-tile-cover { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.pdf-tile-blank { display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.pdf-tile-blank svg { width: 28px; height: 28px; }
.pdf-tile-price {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

/* Mobile: exactly two PDF tiles per row */
@media (max-width: 768px) {
  .pdf-block-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pdf-tile { width: 100%; }
}

.hub-hashtag {
  color: var(--brand-primary);
  font-weight: 600;
  text-decoration: none;
}
.hub-hashtag:hover {
  text-decoration: underline;
}

/* Related posts section in reader */
.related-posts-section {
  margin: 40px 0 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.related-posts-grid {
  margin-top: 8px;
}

.related-posts-grid .blog-card,
.related-posts-grid .audiolite-card,
.related-posts-grid .book-cover-card,
.related-posts-grid .bundle-card {
  margin-bottom: 0;
}

/* Post reader header actions */
.post-read-action-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background 0.2s;
}

.post-read-action-btn:hover {
  background: var(--bg-tertiary);
}

/* Comments modal */
.comments-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.comments-modal-content {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2xl);
}

.comments-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.comments-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.comments-modal-close {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: background 0.2s;
}

.comments-modal-close:hover {
  background: var(--bg-tertiary);
}

.comments-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.comments-modal-body .comment-input-wrapper {
  margin-bottom: 20px;
}

.comments-modal-body .comment-list {
  max-height: none;
}
