/* ===== Design tokens ===== */
:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface2: #f5f5f4;
  --border: #e7e5e4;
  --border-soft: #f0eeec;
  --text: #1c1917;
  --text2: #57534e;
  --text3: #a8a29e;
  --accent: #1c1917;
  --radius: 14px;
  --radius-tile: 20px;
  --shadow-soft: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
}

/* ===== Base reset ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }

/* ===== Container ===== */
.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 28px 80px;
}

/* ===== Back link ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text2);
  font-size: 14px;
  margin-bottom: 18px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

/* ===== Page title ===== */
.page-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  color: var(--text);
}
.page-title .chev {
  color: var(--text3);
  font-weight: 500;
  margin-left: 2px;
  line-height: 1;
}

/* ===== Search ===== */
.search-row {
  margin-bottom: 14px;
}
.search-input-wrap {
  position: relative;
  width: 100%;
}
.search-input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input::placeholder { color: var(--text3); }
.search-input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(28,25,23,0.06);
}
.search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border: none; background: var(--surface2);
  border-radius: 50%; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  padding: 0; color: var(--text2);
  transition: background 0.15s, color 0.15s;
}
.search-clear:hover { background: var(--border); color: var(--text); }
.search-clear svg { width: 12px; height: 12px; }
.search-input-wrap .search-input { padding-right: 40px; }
.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
}

/* ===== Filters ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.filters-left { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.last-refresh { font-size: 11px; color: var(--text3); white-space: nowrap; letter-spacing: 0.01em; }

/* ===== Filter bar (redesigned) ===== */
.filter-bar {
  display: flex; align-items: flex-end; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text3); padding-left: 4px;
}
.filter-group-controls { display: flex; gap: 6px; align-items: center; }
.filter-arrow {
  color: var(--text3); font-size: 14px; align-self: center; padding: 0 2px;
}
.filter-divider {
  width: 1px; height: 32px; background: var(--border); opacity: 0.5;
  align-self: flex-end; margin-bottom: 4px;
}
.filter-bar-right {
  margin-left: auto; display: flex; align-items: center; gap: 12px;
}
.result-count {
  font-size: 12px; font-weight: 600; color: var(--text2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.filter-clear-all {
  border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  color: var(--text3); padding: 4px 8px; border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  align-self: flex-end; margin-bottom: 4px;
}
.filter-clear-all:hover { color: var(--text); background: var(--surface2); }

/* Sort icon inside chip */
.filter-chip .sort-icon { width: 14px; height: 14px; opacity: 0.5; flex-shrink: 0; }

/* Course popover */
#course-pop { overflow: visible; min-width: 420px; }
.course-pop-inner { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.course-row-pair { display: flex; gap: 8px; align-items: flex-start; }
.course-col { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.course-col-label {
  font-size: 9px; font-weight: 700; color: var(--text3); text-transform: uppercase;
  letter-spacing: 0.06em; padding: 0 0 3px 2px;
}
.course-dd-trigger {
  width: 100%; height: 30px; border: 1px solid var(--border);
  border-radius: 8px; padding: 0 24px 0 8px; font-size: 11px;
  background: var(--surface); color: var(--text);
  cursor: pointer; font-family: inherit; text-align: left;
  display: flex; align-items: center; position: relative;
  transition: border-color 0.15s;
}
.course-dd-trigger:hover { border-color: var(--text3); }
.course-dd-trigger.open { border-color: var(--text3); border-radius: 8px 8px 0 0; }
.course-dd-trigger .dd-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.course-dd-trigger .dd-label.muted { color: var(--text3); }
.course-dd-trigger .dd-chev {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 12px; height: 12px; color: var(--text3);
  transition: transform 0.2s;
}
.course-dd-trigger.open .dd-chev { transform: translateY(-50%) rotate(180deg); }
.course-dd-body {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 8px 8px; background: var(--surface);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  display: none; max-height: 240px; overflow: hidden;
  flex-direction: column;
}
.course-dd-body.open { display: flex; }
.course-dd-search {
  width: 100%; height: 30px; border: none; border-bottom: 1px solid var(--border-soft);
  padding: 0 10px; font-size: 12px; background: var(--surface2);
  color: var(--text); outline: none; font-family: inherit; flex-shrink: 0;
}
.course-dd-list { flex: 1; overflow-y: auto; }
.course-dd-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; font-size: 12.5px; cursor: pointer;
  color: var(--text); transition: background 0.1s;
}
.course-dd-item:hover { background: var(--surface2); }
.course-dd-item .dd-check {
  width: 14px; height: 14px; border: 1.5px solid var(--border);
  border-radius: 3px; flex-shrink: 0; display: flex;
  align-items: center; justify-content: center; transition: all 0.12s;
}
.course-dd-item .dd-check svg { width: 10px; height: 10px; opacity: 0; }
.course-dd-item.included .dd-check { background: var(--accent); border-color: var(--accent); }
.course-dd-item.included .dd-check svg { opacity: 1; color: #fff; }
.course-dd-item .dd-name { flex: 1; }
.course-dd-item .dd-cnt { font-size: 10.5px; color: var(--text3); }
.course-dd-meta {
  display: flex; justify-content: space-between; padding: 5px 10px;
  border-bottom: 1px solid var(--border-soft); font-size: 11px; color: var(--text3);
  flex-shrink: 0;
}
.course-dd-meta a { cursor: pointer; font-weight: 600; color: var(--text2); }
.course-dd-meta a:hover { color: var(--text); }
.course-col .brand-pop-search { padding: 8px 8px 0; }
.course-col .brand-pop-search input { font-size: 11px; height: 28px; padding-left: 28px; }
.course-col .brand-pop-search .bp-search-icon { left: 16px; width: 13px; height: 13px; margin-top: 4px; }
.course-col .brand-pop-item { padding: 5px 8px; font-size: 11.5px; }
.course-col .bp-label { font-size: 11.5px; }
.course-col .bp-checkbox { width: 14px; height: 14px; }
.course-col .brand-pop-meta { font-size: 9px; padding: 3px 8px; }
.course-col .brand-pop-meta .bp-meta-clear { font-size: 9px !important; padding: 1px 0; }
.course-col .brand-pop-meta .bp-meta-count { font-size: 9px; }
.course-col .brand-pop-meta .bp-meta-actions { gap: 6px; }
.course-col .brand-pop-list { max-height: 220px; }
.course-arrow-mid {
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--text3); padding: 18px 2px 0;
  flex-shrink: 0;
}
.course-footer { display: flex; justify-content: space-between; gap: 8px; padding-top: 4px; border-top: 1px solid var(--border-soft); }
.course-footer button {
  border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 8px; transition: background 0.12s;
}
.course-footer .course-reset { color: var(--text3); }
.course-footer .course-reset:hover { background: var(--surface2); color: var(--text2); }
.course-footer .course-apply { background: var(--text); color: var(--surface); }
.course-footer .course-apply:hover { opacity: 0.9; }

/* Spoken-in popover segmented toggle */
.spoken-match-toggle {
  display: flex; background: var(--surface2); border-radius: 8px;
  padding: 3px; margin: 10px 12px 0;
}
.spoken-match-toggle button {
  flex: 1; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  padding: 6px 10px; border-radius: 6px; color: var(--text3);
  transition: background 0.15s, color 0.15s;
}
.spoken-match-toggle button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

/* Spoken-in popover footer */
.spoken-footer {
  display: flex; justify-content: space-between; padding: 8px 12px;
  border-top: 1px solid var(--border-soft);
}
.spoken-footer button {
  border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 8px; transition: background 0.12s;
}
.spoken-footer .spoken-clear { color: var(--text3); }
.spoken-footer .spoken-clear:hover { background: var(--surface2); color: var(--text2); }
.spoken-footer .spoken-apply { background: var(--text); color: var(--surface); }
.spoken-footer .spoken-apply:hover { opacity: 0.9; }

/* Mobile bottom sheet */
.filter-mobile-trigger {
  display: none; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--text);
  cursor: pointer; margin-bottom: 16px;
}
.filter-mobile-trigger .badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--text); color: var(--surface);
  font-size: 10px; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center;
}
.filter-sheet-overlay {
  position: fixed; inset: 0; z-index: 998;
  background: rgba(0,0,0,0.4); display: none;
}
.filter-sheet-overlay.open { display: block; }
.filter-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 999;
  background: var(--surface); border-radius: 20px 20px 0 0;
  max-height: 80vh; overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  padding: 20px 16px 32px;
}
.filter-sheet-overlay.open .filter-sheet { transform: translateY(0); }
.filter-sheet .filter-group { margin-bottom: 20px; }
.filter-sheet .filter-group-controls { flex-wrap: wrap; }
.filter-sheet-handle {
  width: 40px; height: 4px; border-radius: 4px; background: var(--border);
  margin: 0 auto 16px;
}

@media (max-width: 900px) {
  .filter-bar { display: none !important; }
  .filter-mobile-trigger { display: inline-flex; }
}

/* Compact pagination (top of page) */
.pagination-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
}
.pagination-mini .pg-mini-label {
  color: var(--text2);
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pagination-mini .pg-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
}

/* ===== Filter chips ===== */
.filter-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}
.filter-chip:hover { background: var(--surface2); }
.filter-chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.filter-chip .chev-down {
  width: 12px;
  height: 12px;
  opacity: 0.6;
}
.filter-chip select {
  display: none;
}
.filter-chip .chip-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--text);
  color: var(--surface); font-size: 11px; font-weight: 700;
  margin-left: 4px; line-height: 1;
}
.filter-chip.active .chip-badge {
  background: var(--surface); color: var(--text);
}
#lbl-brand {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Filter popover ===== */
.filter-pop {
  position: absolute; top: calc(100% + 8px); left: 0;
  min-width: 180px; max-height: 380px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.04);
  padding: 8px 0; z-index: 100;
  display: none;
  opacity: 0; transform: translateY(-6px) scale(0.98);
  transition: opacity 0.2s cubic-bezier(.4,0,.2,1), transform 0.2s cubic-bezier(.4,0,.2,1);
}
.filter-pop.open { opacity: 1; transform: translateY(0) scale(1); }
.filter-pop-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  font-size: 14px; font-weight: 500; color: var(--text);
  cursor: pointer; transition: background 0.12s;
  user-select: none;
}
.filter-pop-item:hover { background: var(--surface2); }
.filter-pop-item .fp-icon {
  width: 20px; height: 20px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; color: var(--text2);
}
.filter-pop-item .fp-label { flex: 1; }
.filter-pop-item .fp-check {
  width: 18px; height: 18px; flex-shrink: 0;
  color: var(--accent); opacity: 0;
  transition: opacity 0.15s;
}
.filter-pop-item.selected .fp-check { opacity: 1; }
.filter-pop-hint {
  padding: 8px 12px 8px; font-size: 11px; color: var(--text3);
  font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 1px solid var(--border-soft); margin-bottom: 2px;
}
/* Sort pop — buying intent boost toggle */
.sort-pop-boost {
  padding: 10px 12px; border-bottom: 1px solid var(--border-soft);
  cursor: pointer; user-select: none;
  transition: background .12s;
}
.sort-pop-boost:hover { background: var(--surface2); }
.sort-boost-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.sort-boost-label {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.sort-boost-switch {
  width: 32px; height: 18px; border-radius: 9px;
  background: var(--border); position: relative;
  transition: background .15s; flex-shrink: 0;
}
.sort-boost-knob {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: left .15s;
}
.sort-pop-boost.active .sort-boost-switch { background: var(--accent); }
.sort-pop-boost.active .sort-boost-knob { left: 16px; }
.sort-boost-hint {
  display: block; font-size: 11px; color: var(--text3);
  margin-top: 4px; line-height: 1.3;
}
.filter-pop::-webkit-scrollbar { width: 6px; }
.filter-pop::-webkit-scrollbar-track { background: transparent; }
.filter-pop::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.filter-pop::-webkit-scrollbar-thumb:hover { background: var(--text3); }
.filter-pop { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ===== Brand popover ===== */
.brand-pop {
  position: absolute; top: calc(100% + 8px); left: 0;
  min-width: 220px; max-height: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.04);
  padding: 0; z-index: 100;
  display: none; overflow: hidden;
  opacity: 0; transform: translateY(-6px) scale(0.98);
  transition: opacity 0.2s cubic-bezier(.4,0,.2,1), transform 0.2s cubic-bezier(.4,0,.2,1);
}
.brand-pop.open { opacity: 1; transform: translateY(0) scale(1); }
.brand-pop-search {
  position: relative; padding: 12px 12px 0;
}
.brand-pop-search input {
  width: 100%; height: 38px; padding: 0 14px 0 38px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); font-size: 13px; color: var(--text);
  outline: none; transition: border-color 0.15s;
  box-sizing: border-box;
}
.brand-pop-search input::placeholder { color: var(--text3); }
.brand-pop-search input:focus { border-color: var(--text); }
.brand-pop-search input { padding-right: 36px; }
.brand-pop-search .search-clear {
  right: 22px; top: 50%; margin-top: 6px;
  width: 18px; height: 18px;
}
.brand-pop-search .search-clear svg { width: 10px; height: 10px; }
.brand-pop-search .bp-search-icon {
  position: absolute; left: 26px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text3); pointer-events: none;
  margin-top: 6px;
}
.brand-pop-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 8px; font-size: 12.5px;
}
.brand-pop-meta .bp-meta-count { color: var(--text3); font-weight: 500; }
.brand-pop-meta .bp-meta-clear {
  color: var(--text); font-weight: 600; cursor: pointer;
  padding: 2px 0; border: none; background: none; font-size: 12.5px;
}
.brand-pop-meta .bp-meta-clear:hover { text-decoration: underline; }
.brand-pop-meta .bp-meta-actions { display: flex; gap: 10px; }
.brand-pop-list {
  overflow-y: auto; max-height: 280px; padding: 2px 0 6px;
  border-top: 1px solid var(--border-soft);
  overflow-anchor: none;
}
.brand-pop-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  font-size: 14px; font-weight: 500; color: var(--text);
  cursor: pointer; transition: background 0.12s;
  user-select: none; position: relative;
}
.brand-pop-item:hover { background: var(--surface2); }
.brand-pop-item .bp-label { flex: 1; }
.brand-pop-item .bp-count {
  font-size: 12px; color: var(--text3); font-weight: 400;
  margin-left: auto; padding-left: 8px;
}
.brand-pop-item .bp-checkbox {
  width: 20px; height: 20px; flex-shrink: 0;
  border: 2px solid var(--border); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; background: var(--surface);
}
.brand-pop-item .bp-checkbox svg {
  width: 12px; height: 12px; color: #fff; opacity: 0;
  transition: opacity 0.12s;
}
.brand-pop-item.included .bp-checkbox {
  background: var(--text); border-color: var(--text);
}
.brand-pop-item.included .bp-checkbox svg { opacity: 1; }
.brand-pop-list::-webkit-scrollbar { width: 6px; }
.brand-pop-list::-webkit-scrollbar-track { background: transparent; }
.brand-pop-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.brand-pop-list::-webkit-scrollbar-thumb:hover { background: var(--text3); }
.brand-pop-list { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.brand-pop-divider { height: 1px; background: var(--border-soft); margin: 4px 0; }

/* ===== Grid ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  position: relative;
}
@media (max-width: 1280px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1024px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px)  { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 460px)  { .grid { grid-template-columns: 1fr; } }

/* ===== Tile ===== */
.tile {
  position: relative;
  aspect-ratio: 9 / 14;
  border-radius: var(--radius-tile);
  overflow: hidden;
  background: var(--surface2);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  isolation: isolate;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.tile-slide-prev, .tile-slide-next {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 5;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,0.45); border: none; color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
  backdrop-filter: blur(3px);
}
.tile:hover .tile-slide-prev, .tile:hover .tile-slide-next { opacity: 1; }
.tile-slide-prev { left: 6px; }
.tile-slide-next { right: 6px; }
.tile-slide-prev:hover, .tile-slide-next:hover { background: rgba(0,0,0,0.7); }
.tile-slide-dots {
  position: absolute; bottom: 38px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; z-index: 5;
  opacity: 0; transition: opacity 0.15s;
}
.tile:hover .tile-slide-dots { opacity: 1; }
.tile-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,0.4);
}
.tile-dot.active { background: #fff; }
.tile img.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.2s ease;
}
#shared-hover-video {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
  pointer-events: none;
  z-index: 2;
  border-radius: var(--radius-tile);
}
.tile.is-playing img.thumb { opacity: 0; }
.tile .placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3); font-size: 12px;
  background: linear-gradient(135deg, #e7e5e4, #f5f5f4);
}

/* Top-left outlier badge */
.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255,255,255,0.95);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  line-height: 1;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  letter-spacing: -0.01em;
}
.badge { z-index: 3; }

/* Top-right action row */
.actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 3;
}
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.95);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  border: 0;
  cursor: pointer;
  padding: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  transition: transform 0.1s, background 0.15s;
  text-decoration: none;
}
.icon-btn:hover { background: #fff; }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 16px; height: 16px; display: block; }

/* TikTok link */
.icon-btn.tiktok-link {
  background: #000;
  border-radius: 50%;
  border: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.icon-btn.tiktok-link:hover { background: #111; }
.icon-btn.tiktok-link svg { width: 22px; height: 22px; }

/* Brand chip (bottom-left) */
.brand-strip {
  position: absolute;
  left: 12px;
  bottom: 38px;
  display: flex;
  gap: 6px;
  z-index: 2;
  max-width: calc(100% - 24px);
  flex-wrap: wrap;
}
.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7c3aed;
  flex-shrink: 0;
}

/* Bottom overlay with meta */
.tile .overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 22px 14px 10px;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.0) 100%);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 12.5px;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.tile.is-playing .overlay { opacity: 0.55; }
.tile.is-playing:hover .overlay { opacity: 0.55; }
.tile .views { font-weight: 600; }
.tile .when { opacity: 0.85; }

/* Platform link (bottom-right, above overlay) */
.tile-platform-link {
  position: absolute;
  right: 10px;
  bottom: 36px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  z-index: 3;
  text-decoration: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.1s;
}
.tile-platform-link:hover { background: rgba(0,0,0,0.8); }
.tile-platform-link:active { transform: scale(0.92); }
.tile-platform-link svg { width: 14px; height: 14px; display: block; }
.tile.is-playing .tile-platform-link { opacity: 0.6; }
.tile-tiktok-btn svg { width: 16px; height: 16px; }

/* Brand chips fade with the overlay on hover */
.brand-strip { transition: opacity 0.2s ease; }
.tile.is-playing .brand-strip { opacity: 0.55; }

/* Description popover */
.desc-pop {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 44px;
  z-index: 4;
  background: rgba(15, 15, 15, 0.78);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  max-height: 55%;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  letter-spacing: -0.005em;
  word-break: break-word;
}
.tile.show-desc .desc-pop {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.desc-pop:empty { display: none; }
.icon-btn.js-info.active {
  background: var(--text);
  color: #fff;
}
.icon-btn.js-bookmark.active {
  color: #f59e0b;
}

/* Audio-blocked hint */
.audio-pill {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.tile.audio-blocked.is-playing .audio-pill { opacity: 1; }
.audio-pill svg { width: 12px; height: 12px; }

/* ===== Empty / loading / error ===== */
.status {
  grid-column: 1 / -1;
  padding: 48px 16px;
  text-align: center;
  color: var(--text2);
  font-size: 14px;
}
.skeleton {
  aspect-ratio: 9 / 14;
  border-radius: var(--radius-tile);
  background: linear-gradient(110deg, #ececeb 8%, #f5f5f4 18%, #ececeb 33%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer {
  to { background-position-x: -200%; }
}

/* ===== Pagination bar ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 28px 0 8px;
}
.pg-info {
  width: 100%;
  text-align: center;
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 4px;
}
.pg-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pg-btn:hover:not(:disabled):not(.pg-ellipsis) { background: var(--surface2); }
.pg-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.pg-btn.current {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
  cursor: default;
}
.pg-btn.pg-ellipsis {
  border-color: transparent;
  background: transparent;
  cursor: default;
  color: var(--text3);
}
.pg-btn svg { width: 14px; height: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Auth gate ===== */
#auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  transition: opacity 0.3s;
}
#auth-gate.hidden { opacity: 0; pointer-events: none; }
#auth-gate .auth-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
#auth-gate .auth-sub {
  font-size: 14px;
  color: var(--text2);
  margin-top: -12px;
}
#auth-gate .auth-error {
  color: #dc2626;
  font-size: 13px;
  min-height: 18px;
}

/* ===== User pill ===== */
.user-pill {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
  color: var(--text);
}
.user-pill:hover { background: var(--surface2); }
.user-pill img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.user-pill .user-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

/* ===== User menu ===== */
.user-menu {
  position: fixed;
  top: 58px;
  right: 20px;
  z-index: 101;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px;
  min-width: 180px;
  display: none;
}
.user-menu.open { display: block; }
.user-menu-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  background: none;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.user-menu-item:hover { background: var(--surface2); }
.user-menu .user-email {
  padding: 8px 12px 4px;
  font-size: 12px;
  color: var(--text3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Main content area ===== */
.main-content { margin-left: 220px; transition: margin-left 0.2s ease; }
.main-content.sidebar-collapsed { margin-left: 60px; }

/* ===== Sidebar toggle (mobile) ===== */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 250;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
  color: var(--text);
  padding: 0;
}
.sidebar-toggle svg { width: 18px; height: 18px; }

@media (max-width: 768px) {
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 190;
    background: rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }
}

/* ===== Trends view ===== */
.trends-view {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 64px;
}
.trends-view .page-title { margin-bottom: 16px; }
.trends-view .trends-filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 18px;
}
.trends-view .trends-filters-left { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.trends-view .trends-filters-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.trends-search-row { margin-bottom: 14px; }
.trends-search-row .search-input-wrap { max-width: 100%; }
.trends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}
.trend-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
  cursor: default;
}
.trend-tile:hover {
  border-color: var(--text2);
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.trend-thumbs {
  display: flex;
  gap: 2px;
  height: 130px;
  overflow: hidden;
  background: var(--bg);
}
.trend-thumbs img {
  flex: 1;
  min-width: 0;
  object-fit: cover;
  height: 100%;
}
.trend-thumbs .trend-thumb-more {
  flex: 0 0 50px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2); color: var(--text3);
  font-size: 13px; font-weight: 600;
}
.trend-body {
  padding: 14px 16px 16px;
}
.trend-title {
  font-size: 15px; font-weight: 650; color: var(--text);
  line-height: 1.35;
  margin: 0 0 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.trend-hook {
  font-size: 12.5px; color: var(--text3); line-height: 1.4;
  margin: 0 0 12px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: italic;
}
.trend-analytics {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  font-size: 12px; color: var(--text2);
  margin-bottom: 10px;
}
.trend-analytics .ta-item {
  display: flex; align-items: center; gap: 4px;
}
.trend-analytics .ta-label { color: var(--text3); }
.trend-analytics .ta-value { font-weight: 600; color: var(--text); }
.trend-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.sat-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 650;
  letter-spacing: 0.02em;
}
.sat-fresh { background: #dcfce7; color: #166534; }
.sat-growing { background: #fef9c3; color: #854d0e; }
.sat-mature { background: #fed7aa; color: #9a3412; }
.sat-saturated { background: #fecaca; color: #991b1b; }
.trend-status-chip {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  border-radius: 999px; text-transform: capitalize;
}
.trend-status-confirmed { background: var(--surface2); color: var(--text2); }
.trend-status-emerging { background: #dbeafe; color: #1e40af; }
.trend-status-singleton { background: #fef3c7; color: #92400e; }
.trend-see-more {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  text-decoration: none; cursor: pointer; border: none;
  background: none; padding: 0;
}
.trend-see-more:hover { text-decoration: underline; }
.trend-desc-expanded {
  font-size: 13px; color: var(--text2); line-height: 1.5;
  margin: 8px 0 0; padding: 10px 0 0;
  border-top: 1px solid var(--border-soft);
}
@media (max-width: 768px) {
  .trends-grid { grid-template-columns: 1fr; }
  .trend-thumbs { height: 100px; }
}

/* ===== Trend detail modal — redesign ===== */
.trend-modal-overlay {
  --m-panel: #FBFAF5;
  --m-panel2: #F6F2E8;
  --m-card: #FFFFFF;
  --m-ink: #211E18;
  --m-ink2: #6E665A;
  --m-ink3: #A39B8B;
  --m-line: #E7E1D2;
  --m-line2: #EFEADD;
  --m-creator: #B6452C;
  --m-creator-bg: #FAEAE2;
  --m-ai: #106B61;
  --m-ai-bg: #E3EEEA;
  --m-honey: #E9B949;
  --m-shadow: 0 1px 2px rgba(33,30,24,.05), 0 20px 50px rgba(20,16,10,.30), 0 50px 100px rgba(20,16,10,.34);

  position: fixed; inset: 0; z-index: 999;
  background: rgba(29,26,20,0.65);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; transition: opacity 0.2s ease;
  pointer-events: none;
}
.trend-modal-overlay.open { opacity: 1; pointer-events: auto; }

.trend-modal {
  width: 100%; max-width: 1180px;
  height: min(880px, 90vh);
  background: var(--m-panel);
  border-radius: 22px;
  box-shadow: var(--m-shadow);
  display: grid;
  grid-template-columns: minmax(260px,320px) minmax(0,1fr) minmax(280px,350px);
  overflow: hidden;
  position: relative;
  transform: scale(0.96) translateY(12px);
  transition: transform 0.25s cubic-bezier(.4,0,.2,1);
}
.trend-modal-overlay.open .trend-modal { transform: scale(1) translateY(0); }

.trend-modal.no-left-panel {
  grid-template-columns: minmax(0,1fr) minmax(300px,380px);
}
.trend-modal.no-left-panel .col--left { display: none; }

.col { display: flex; flex-direction: column; min-height: 0; }
.col--left { background: var(--m-panel); border-right: 1px solid var(--m-line); overflow-y: auto; }
.col--mid { background: #171410; padding: 10px; gap: 8px; }
.col--right { background: var(--m-panel); border-left: 1px solid var(--m-line); }

.col .scroll { flex: 1; overflow-y: auto; min-height: 0; }
.col .scroll::-webkit-scrollbar { width: 9px; }
.col .scroll::-webkit-scrollbar-thumb { background: var(--m-line); border-radius: 9px; border: 3px solid var(--m-panel); }

/* ===== Left column — trend info ===== */
.tm-crumb {
  padding: 10px 16px 0;
  font-size: 10px; font-weight: 600; letter-spacing: .04em;
  color: var(--m-ink3); text-transform: uppercase;
  display: flex; align-items: center; gap: 5px;
}
.tm-crumb b { color: var(--m-ink2); }

.tm-trendhdr { padding: 12px 16px 14px; border-bottom: 1px solid var(--m-line); }
.tm-kicker {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: #A77B1C; margin-bottom: 6px;
}
.tm-kicker .spark {
  width: 15px; height: 15px; border-radius: 5px; background: var(--m-honey);
  color: #5A3E07; display: flex; align-items: center; justify-content: center; font-size: 9px;
}
.tm-trendhdr h1 {
  font-family: 'Fraunces', Georgia, serif; font-weight: 600;
  font-size: 19px; line-height: 1.2; letter-spacing: -.01em; color: var(--m-ink);
  margin: 0;
}
.tm-source {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 8px;
  background: var(--m-ai-bg); color: var(--m-ai);
  font-size: 11px; font-weight: 600;
  padding: 3px 9px 3px 5px; border-radius: 16px;
}
.tm-source .glyph {
  width: 16px; height: 16px; border-radius: 50%; background: var(--m-ai); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700;
}
.tm-desc {
  font-size: 12px; line-height: 1.5; color: var(--m-ink2); margin-top: 10px;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}

.tm-stats-grid {
  display: flex; flex-wrap: wrap; gap: 0;
  border: 1px solid var(--m-line); border-radius: 10px;
  background: var(--m-card); margin-top: 10px; overflow: hidden;
}
.tm-stat {
  flex: 1 1 33.33%; min-width: 0;
  padding: 7px 8px; border-right: 1px solid var(--m-line2);
  border-bottom: 1px solid var(--m-line2);
}
.tm-stat:nth-child(3n) { border-right: none; }
.tm-stat:last-child { border-right: none; border-bottom: none; }
.tm-stat:nth-last-child(1):nth-child(3n),
.tm-stat:nth-last-child(2):nth-child(3n-1),
.tm-stat:nth-last-child(3):nth-child(3n-2) { border-bottom: none; }
.tm-stat:nth-last-child(1):nth-child(3n) ~ .tm-stat { border-bottom: none; }
.tm-stat:nth-last-child(2):nth-child(3n-1) ~ .tm-stat { border-bottom: none; }
.tm-stat b {
  font-family: 'Fraunces', Georgia, serif; font-size: 14px; font-weight: 600;
  letter-spacing: -.02em; display: block; font-variant-numeric: tabular-nums;
  color: var(--m-ink);
}
.tm-stat span {
  font-size: 8.5px; color: var(--m-ink3); text-transform: uppercase;
  letter-spacing: .05em; margin-top: 1px; display: block;
}
.tm-stat.hot b { color: var(--m-creator); }

.tm-listhdr {
  padding: 12px 16px 6px;
  display: flex; align-items: baseline; gap: 6px;
}
.tm-listhdr h2 {
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; color: var(--m-ink);
  margin: 0;
}
.tm-listhdr .n { font-size: 10.5px; color: var(--m-ink3); font-weight: 500; }

.tm-vlist { padding: 0 8px 12px; }
.tm-vrow {
  display: flex; gap: 8px; padding: 6px 8px; border-radius: 10px;
  cursor: pointer; border: 1.5px solid transparent;
  transition: background .15s, border-color .15s;
}
.tm-vrow:hover { background: var(--m-panel2); }
.tm-vrow.active {
  background: var(--m-card); border-color: var(--m-ai);
  box-shadow: 0 4px 14px rgba(33,30,24,.07);
}
.tm-vthumb {
  width: 42px; height: 54px; border-radius: 7px; flex-shrink: 0;
  position: relative; overflow: hidden; background: var(--m-line2);
}
.tm-vthumb img { width: 100%; height: 100%; object-fit: cover; }
.tm-vthumb .dur {
  position: absolute; left: 4px; bottom: 4px;
  font-size: 9px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.55); padding: 1px 5px; border-radius: 5px;
  backdrop-filter: blur(2px);
}
.tm-vmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.tm-vtitle {
  font-size: 11.5px; font-weight: 600; color: var(--m-ink); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tm-vsub {
  display: flex; align-items: center; gap: 5px; margin-top: 3px;
  font-size: 10.5px; color: var(--m-ink3);
}
.tm-vsub .who { color: var(--m-ink2); font-weight: 600; }
.tm-vsub .src {
  background: var(--m-ai-bg); color: var(--m-ai); font-weight: 600;
  font-size: 9.5px; padding: 1px 6px; border-radius: 5px;
}
.tm-vviews {
  text-align: right; flex-shrink: 0; display: flex; flex-direction: column;
  justify-content: center; gap: 2px;
}
.tm-vviews b { font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--m-ink); }
.tm-vviews span { font-size: 9.5px; color: var(--m-ink3); }

/* ===== Center column — video player ===== */
.tm-player {
  flex: 1; border-radius: 16px; overflow: hidden; position: relative;
  background: #000; display: flex; flex-direction: column;
  min-height: 0;
}
.tm-player video {
  width: 100%; height: 100%; object-fit: contain;
}
.tm-player .tm-placeholder {
  color: #888; font-size: 14px; text-align: center; padding: 40px;
  display: flex; align-items: center; justify-content: center; flex: 1;
}
.tm-actions-row {
  display: flex; gap: 4px; margin-bottom: 4px; justify-content: center;
}
.tm-act {
  cursor: pointer; font-family: inherit; font-size: 9.5px; font-weight: 600;
  padding: 5px 9px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  color: var(--m-ink2);
  background: var(--m-card); border: 1px solid var(--m-line);
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none; white-space: nowrap;
}
.tm-act:hover {
  background: var(--m-panel2); color: var(--m-ink); border-color: var(--m-ink3);
}
.tm-act:active { opacity: .7; }
.tm-act.primary { color: var(--m-ai); border-color: var(--m-ai-bg); background: var(--m-ai-bg); }
.tm-act.primary:hover { background: #d0e8e2; border-color: var(--m-ai); }
.tm-act svg { width: 11px; height: 11px; flex-shrink: 0; }
.tm-act.bookmarked { color: var(--m-honey); border-color: #F5E6B8; background: #FDF8EC; }

/* Nav buttons outside modal */
.tm-nav {
  position: fixed; top: 50%; z-index: 1000;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.8);
  display: none; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, opacity .15s, transform .15s;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transform: translateY(-50%);
}
.trend-modal-overlay.open .tm-nav { display: flex; }
.tm-nav svg { width: 20px; height: 20px; }
.tm-nav:hover { background: rgba(255,255,255,.3); color: #fff; }
.tm-nav.disabled { opacity: .15; pointer-events: none; }
.tm-nav-prev { left: max(8px, calc((100vw - 1180px) / 2 - 52px)); }
.tm-nav-next { right: max(8px, calc((100vw - 1180px) / 2 - 52px)); }

/* ===== Right column — info + transcript ===== */
.tm-rhead {
  padding: 12px 14px 10px; border-bottom: 1px solid var(--m-line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-shrink: 0;
}
.tm-rhead__id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tm-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(150deg,#caa37d,#7d6b4f);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: 0 2px 8px rgba(125,107,79,.35);
  overflow: hidden;
}
.tm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tm-rhead__id b { font-size: 14px; font-weight: 700; color: var(--m-ink); display: block; letter-spacing: -.01em; }
.tm-rhead__id span { font-size: 11.5px; color: var(--m-ink3); }
.tm-closebtn {
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--m-line2); color: var(--m-ink2); font-size: 15px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
}
.tm-closebtn:hover { background: var(--m-line); transform: rotate(90deg); }

.tm-rbody { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }

.tm-caption {
  color: var(--m-ink2); font-size: 12px; line-height: 1.5;
  margin-bottom: 6px;
}
.tm-caption .tag { color: var(--m-ai); font-weight: 600; }

.tm-metricbar { display: flex; gap: 5px; margin-bottom: 4px; }
.tm-mchip {
  flex: 1; background: var(--m-card); border: 1px solid var(--m-line);
  border-radius: 8px; padding: 7px 4px; text-align: center;
}
.tm-mchip b {
  color: var(--m-ink); font-family: 'Fraunces', Georgia, serif; font-size: 14px;
  font-weight: 600; display: block; font-variant-numeric: tabular-nums;
}
.tm-mchip span {
  color: var(--m-ink3); font-size: 8.5px; text-transform: uppercase;
  letter-spacing: .05em; margin-top: 1px; display: block;
}

.tm-seclabel {
  font-size: 11.5px; font-weight: 700; color: var(--m-ink);
  display: flex; align-items: center; gap: 6px; margin-bottom: 7px;
}
.tm-seclabel .count { font-weight: 500; color: var(--m-ink3); font-size: 11.5px; }
.tm-seclabel::after { content: ""; flex: 1; height: 1px; background: var(--m-line2); }
.tm-seclabel.tm-toggle { cursor: pointer; user-select: none; }
.tm-seclabel.tm-toggle:hover { color: var(--m-ai); }
.tm-chevron {
  display: inline-block; width: 14px; height: 14px; flex-shrink: 0;
  transition: transform .2s ease;
}
.tm-chevron::before {
  content: ""; display: block; width: 6px; height: 6px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  margin: 3px auto 0;
}
.tm-collapsible.collapsed .tm-chevron { transform: rotate(-90deg); }
.tm-collapse-body {
  overflow: hidden; max-height: 2000px;
  transition: max-height .3s ease, opacity .2s ease;
  opacity: 1;
}
.tm-collapsible.collapsed .tm-collapse-body {
  max-height: 0; opacity: 0; margin: 0;
}

/* On-screen text cards */
.tm-ost { display: flex; flex-direction: column; gap: 6px; }
.tm-ost__item {
  background: var(--m-card); border: 1px solid var(--m-line);
  border-radius: 11px; padding: 11px 12px 11px 14px; position: relative;
}
.tm-ost__item::before {
  content: ""; position: absolute; left: 0; top: 11px; bottom: 11px; width: 3px;
  background: var(--m-honey); border-radius: 3px;
}
.tm-ost__main { font-size: 11.5px; font-weight: 600; color: var(--m-ink); line-height: 1.4; }
.tm-ost__sub { font-size: 10.5px; color: var(--m-ink3); font-style: italic; margin-top: 2px; }

/* Chat-bubble transcript */
.tm-convo { display: flex; flex-direction: column; gap: 9px; }
.tm-msg { display: flex; gap: 9px; align-items: flex-start; }
.tm-msg.ai { flex-direction: row-reverse; }
.tm-dot {
  width: 27px; height: 27px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.tm-msg.creator .tm-dot { background: var(--m-creator-bg); color: var(--m-creator); }
.tm-msg.ai .tm-dot { background: var(--m-ai); color: #fff; }
.tm-msg.narrator .tm-dot { background: #FFF3E0; color: #E65100; }
.tm-msg.other .tm-dot { background: var(--m-line2); color: var(--m-ink3); }
.tm-bubble {
  max-width: 82%; border-radius: 11px; padding: 6px 9px;
  border: 1px solid var(--m-line); transition: transform .15s, box-shadow .15s;
}
.tm-msg.creator .tm-bubble { background: var(--m-creator-bg); border-color: #F1D8CC; border-bottom-left-radius: 5px; }
.tm-msg.ai .tm-bubble { background: var(--m-ai-bg); border-color: #CFE3DD; border-bottom-right-radius: 5px; }
.tm-msg.narrator .tm-bubble { background: #FFF3E0; border-color: #FFE0B2; border-bottom-left-radius: 5px; }
.tm-msg.other .tm-bubble { background: var(--m-panel2); border-color: var(--m-line); border-bottom-left-radius: 5px; }
.tm-bubble:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(33,30,24,.08); }
.tm-who {
  display: flex; align-items: center; gap: 5px; margin-bottom: 3px;
  font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.tm-msg.ai .tm-who { flex-direction: row-reverse; }
.tm-msg.creator .tm-who { color: var(--m-creator); }
.tm-msg.ai .tm-who { color: var(--m-ai); }
.tm-msg.narrator .tm-who { color: #E65100; }
.tm-msg.other .tm-who { color: var(--m-ink3); }
.tm-lng {
  font-size: 8.5px; letter-spacing: .06em; color: var(--m-ink3);
  border: 1px solid var(--m-line); border-radius: 4px; padding: 0 4px; font-weight: 600;
}
.tm-line { display: flex; flex-direction: column; }
.tm-line.primary { font-size: 11.5px; font-weight: 600; color: var(--m-ink); line-height: 1.4; }
.tm-line.secondary {
  font-size: 10.5px; color: var(--m-ink2); font-style: italic; line-height: 1.4;
  margin-top: 3px; padding-top: 3px; border-top: 1px dashed rgba(110,102,90,.2);
}
.trend-modal[data-trans="off"] .tm-line.secondary { display: none; }

/* Plain transcript fallback */
.tm-plain-transcript {
  font-size: 11px; line-height: 1.55; white-space: pre-wrap; color: var(--m-ink2);
}
.tm-transcript-na {
  font-size: 12.5px; color: var(--m-ink3); font-style: italic;
}

/* Footer — language switcher + translation toggle */
.tm-rfoot {
  border-top: 1px solid var(--m-line); padding: 8px 10px;
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0; flex-wrap: wrap;
}
.tm-seg { display: flex; background: var(--m-line2); border-radius: 7px; padding: 2px; position: relative; flex-wrap: wrap; }
.tm-seg button {
  border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 10px; font-weight: 600; color: var(--m-ink2);
  padding: 4px 8px; border-radius: 6px; position: relative; z-index: 1; transition: color .2s;
}
.tm-seg button.active { color: var(--m-ink); }
.tm-seg__pill {
  position: absolute; top: 3px; left: 3px; height: calc(100% - 6px);
  background: var(--m-card); border-radius: 7px; box-shadow: 0 1px 4px rgba(33,30,24,.12);
  transition: transform .25s cubic-bezier(.3,.8,.3,1), width .25s; z-index: 0;
}
.tm-rfoot__sp { flex: 1; }
.tm-ttoggle {
  display: flex; align-items: center; gap: 5px; cursor: pointer; user-select: none;
  font-size: 10px; font-weight: 600; color: var(--m-ink2);
}
.tm-switch {
  width: 36px; height: 21px; border-radius: 21px; background: var(--m-line);
  position: relative; transition: background .2s; flex-shrink: 0;
}
.tm-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s;
}
.trend-modal[data-trans="on"] .tm-switch { background: var(--m-ai); }
.trend-modal[data-trans="on"] .tm-switch::after { transform: translateX(15px); }

/* Slideshow viewer */
.tm-slideshow {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; background: #000; border-radius: 16px; overflow: hidden;
}
.tm-slide-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
}
.tm-slide-prev, .tm-slide-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(0,0,0,0.5); border: none; color: #fff;
  font-size: 22px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background 0.15s, opacity 0.15s;
  backdrop-filter: blur(4px);
}
.tm-slide-prev { left: 10px; }
.tm-slide-next { right: 10px; }
.tm-slide-prev:hover, .tm-slide-next:hover { background: rgba(0,0,0,0.7); }
.tm-slide-prev.disabled, .tm-slide-next.disabled { opacity: 0.25; pointer-events: none; }
.tm-slide-counter {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.5); color: #fff; font-size: 11px;
  padding: 3px 10px; border-radius: 12px; backdrop-filter: blur(4px);
}

.tm-vid-id-inline {
  font-size: 7.5px; color: var(--m-ink3); opacity: 0.35;
  font-family: monospace; letter-spacing: 0.02em;
  user-select: text; margin-left: auto; align-self: center;
}

/* ===== Comment Analysis (modal left panel) ===== */
.ca-card {
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--m-line);
}

.ca-header { margin-bottom: 10px; }
.ca-kicker {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--m-ai); margin-bottom: 6px;
}
.ca-kicker .ca-spark {
  width: 15px; height: 15px; border-radius: 5px; background: var(--m-ai-bg);
  color: var(--m-ai); display: flex; align-items: center; justify-content: center; font-size: 9px;
}
.ca-title {
  font-family: 'Fraunces', Georgia, serif; font-weight: 600;
  font-size: 16px; line-height: 1.2; letter-spacing: -.01em; color: var(--m-ink);
  margin: 0;
}
.ca-subtitle { font-size: 9.5px; color: var(--m-ink3); margin-top: 4px; }

/* Top metrics — matches tm-stats-grid */
.ca-metrics-row {
  display: flex; flex-wrap: wrap; gap: 0;
  border: 1px solid var(--m-line); border-radius: 10px;
  background: var(--m-card); margin-top: 10px; overflow: hidden;
  margin-bottom: 10px;
}
.ca-metric-block {
  flex: 1 1 33.33%; min-width: 0;
  padding: 7px 8px; text-align: center;
  border-right: 1px solid var(--m-line2);
  border-bottom: 1px solid var(--m-line2);
}
.ca-metric-block:nth-child(3n) { border-right: none; }
.ca-metric-block:last-child { border-right: none; border-bottom: none; }
.ca-metric-block:nth-last-child(1):nth-child(3n),
.ca-metric-block:nth-last-child(2):nth-child(3n-1),
.ca-metric-block:nth-last-child(3):nth-child(3n-2) { border-bottom: none; }
.ca-metric-block:nth-last-child(2):nth-child(3n-1) ~ .ca-metric-block { border-bottom: none; }
.ca-metric-big {
  font-family: 'Fraunces', Georgia, serif; font-size: 14px; font-weight: 600;
  letter-spacing: -.02em; display: block; font-variant-numeric: tabular-nums;
  color: var(--m-ink);
}
.ca-metric-sub {
  font-size: 8.5px; color: var(--m-ink3); text-transform: uppercase;
  letter-spacing: .05em; margin-top: 1px; display: block;
}
.ca-badge {
  display: inline-block; font-size: 8px; font-weight: 600;
  padding: 1px 5px; border-radius: 3px;
  margin-left: 4px; vertical-align: middle;
}
.ca-badge.ca-positive { background: #DCFCE7; color: #166534; }
.ca-badge.ca-negative { background: #FEE2E2; color: #991B1B; }
.ca-badge.ca-mixed { background: #FEF3C7; color: #854D0E; }

/* Analysis summary */
.ca-analysis { margin-top: 10px; }
.ca-analysis-title {
  font-size: 11.5px; font-weight: 700; color: var(--m-ink); margin-bottom: 4px;
}
.ca-analysis-text {
  font-size: 12px; line-height: 1.5; color: var(--m-ink2); margin: 0;
}

/* Breakdowns */
.ca-breakdowns {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 10px;
}
.ca-bd-title {
  font-size: 10px; font-weight: 700; color: var(--m-ink);
  margin-bottom: 8px;
}
.ca-bar-row { margin-bottom: 8px; }
.ca-bar-top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 3px;
}
.ca-bar-label { font-size: 11px; color: var(--m-ink2); }
.ca-bar-val {
  font-size: 10px; color: var(--m-ink3); font-variant-numeric: tabular-nums;
}
.ca-bar-track {
  width: 100%; height: 3px; background: var(--m-line2); border-radius: 2px;
  overflow: hidden;
}
.ca-bar-fill {
  height: 100%; border-radius: 2px; background: #3B82F6;
  transition: width 0.4s cubic-bezier(.4,0,.2,1);
}
.ca-bar-fill.ca-fill-muted { background: #D1D5DB; }
.ca-bar-fill.ca-fill-danger { background: #EF4444; }

/* Footer extras */
.ca-footer {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding-top: 10px; border-top: 1px solid var(--m-line2);
}
.ca-foot-item { font-size: 10.5px; color: var(--m-ink3); }
.ca-foot-item strong { color: var(--m-ink); font-weight: 600; margin-left: 2px; }

/* Info tooltip icon + custom tooltip */
.ca-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid var(--m-line); background: var(--m-card);
  font-size: 7px; font-weight: 700; color: var(--m-ink3); cursor: help;
  vertical-align: middle; margin-left: 2px;
  transition: border-color .15s, color .15s;
  position: relative;
}
.ca-info:hover { border-color: var(--m-ink3); color: var(--m-ink2); }
.ca-tip-bubble {
  position: fixed; z-index: 10000; pointer-events: none;
  background: #1c1917; color: #fff; font-size: 10.5px; font-weight: 500;
  line-height: 1.4; padding: 7px 11px; border-radius: 7px;
  max-width: 210px; white-space: normal;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  opacity: 0; transition: opacity .12s;
}
.ca-tip-bubble.visible { opacity: 1; }

/* Toast */
.trend-modal .tm-toast {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(28,25,23,0.92); color: #fff;
  padding: 8px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  opacity: 0; transition: opacity 0.2s, transform 0.2s;
  pointer-events: none; z-index: 15;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
}
.tm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Modal responsive ===== */
@media (max-width: 768px) {
  .trend-modal-overlay { padding: 0; }
  .trend-modal { grid-template-columns: 1fr !important; height: 100vh; border-radius: 0; }
  .col--left { border-right: none; border-bottom: 1px solid var(--m-line); max-height: 45vh; }
  .col--mid { min-height: 260px; }
  .col--right { border-left: none; border-top: 1px solid var(--m-line); }
}
