/* RA Tracker — tracker app */

body.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

body.no-scroll {
  overflow: hidden;
}

.small {
  font-size: 12.5px;
}

.push {
  margin-left: auto;
}

.center {
  justify-content: center;
  text-align: center;
}

.strong {
  font-weight: 600;
  color: var(--text);
}

/* ---- Sidebar ---------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
}

.sidebar > .brand {
  padding: 0 8px;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.side-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.side-nav a.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
}

.side-nav a.active .icon {
  color: var(--brand);
}

.nav-count {
  margin-left: auto;
  font-style: normal;
  font-size: 11.5px;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand);
}

.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 6px;
  padding: 0 12px;
}

.side-label.center {
  padding: 0;
  margin-top: 22px;
}

.side-recent {
  display: flex;
  flex-direction: column;
}

.side-recent a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  text-decoration: none;
}

.side-recent a .icon {
  color: var(--text-3);
}

.side-recent a span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-recent a:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Credits (sidebar box, mobile/settings pill) */
.credit-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  text-decoration: none !important;
  transition: border-color 0.15s ease;
}

.credit-box:hover {
  border-color: var(--border-strong);
}

.credit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}

.credit-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 550;
}

.credit-label .icon {
  color: var(--brand);
}

.credit-expiry {
  color: var(--text-3);
  font-size: 12px;
}

.credit-value {
  font-family: var(--font-figures);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13.5px;
  text-decoration: none !important;
  white-space: nowrap;
}

.credit-pill b {
  font-family: var(--font-figures);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.credit-pill.big {
  height: 38px;
  padding: 0 16px;
  font-size: 16px;
}

:root[data-theme="dark"] .credit-pill {
  color: var(--brand);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .credit-pill {
    color: var(--brand);
  }
}

.credit-box.is-empty .credit-value,
.credit-box.is-empty .credit-label .icon {
  color: var(--c-danger);
}

.credit-pill.is-empty {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

.account-line {
  font-size: 13.5px;
}

/* Apify key (Settings) */
.key-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.key-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.key-form .input-group {
  min-width: 240px;
}

.key-form .btn {
  height: 42px;
}

.input-group > .input:has(~ .input-action) {
  padding-right: 48px;
}

.inline-icon {
  display: inline-block;
  vertical-align: -2px;
  margin-left: 4px;
}

.connect-callout {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--brand-soft);
  background: var(--brand-softer);
  text-align: left;
}

.connect-callout .empty-icon {
  margin: 0;
  flex: none;
}

.connect-callout div {
  flex: 1;
  min-width: 0;
}

.connect-callout strong {
  display: block;
  color: var(--text);
  font-weight: 600;
}

.connect-callout p {
  font-size: 13.5px;
}

@media (max-width: 640px) {
  .connect-callout {
    flex-wrap: wrap;
  }
}

.mobile-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Hide the app until the signed-in check finishes (avoids a flash before redirect). */
.auth-pending .main,
.auth-pending .tabbar {
  visibility: hidden;
}

.side-foot .theme-toggle {
  align-self: flex-start;
}

.mobile-bar,
.tabbar {
  display: none;
}

/* ---- Main ------------------------------------------------------------- */

.main {
  min-width: 0;
  padding: 36px clamp(16px, 4vw, 48px) 80px;
}

.view {
  max-width: 1240px;
  margin-inline: auto;
  animation: view-in 0.25s ease;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.view-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}

.view-head h1 {
  font-size: 30px;
  letter-spacing: -0.03em;
}

.view-head p {
  margin-top: 6px;
  color: var(--text-2);
}

/* ---- Query card ------------------------------------------------------- */

.query-card {
  padding: 18px;
  margin-bottom: 26px;
}

.query-row {
  display: flex;
  gap: 10px;
}

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

.input-xl {
  height: 50px;
  font-size: 16px;
  border-radius: 14px;
  background: var(--bg);
}

.input-xl:focus {
  background: var(--surface);
}

.query-row .btn-lg {
  height: 50px;
  border-radius: 14px;
  min-width: 112px;
}

.btn.is-loading .icon {
  animation: nudge 0.9s ease-in-out infinite;
}

@keyframes nudge {
  50% {
    transform: translateX(3px);
  }
}

.query-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 22px;
  margin-top: 14px;
}

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

.filter-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.select-sm {
  height: 36px;
  font-size: 13.5px;
  width: auto;
  border-radius: var(--radius-pill);
  padding-left: 14px;
}

.select.fit {
  width: auto;
}

/* ---- Meta, tiles, panels --------------------------------------------- */

.meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-2);
}

.meta-line .sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-3);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 18px;
}

/* Right/bottom hairlines; the outer ones are clipped by the container. */
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 20px;
  min-width: 0;
  box-shadow: 1px 0 0 var(--border), 0 1px 0 var(--border);
}

.tile-value,
.asset-stats .mono,
.drawer-stats .mono,
.creator-stats .mono,
.toolbar-count .mono,
.rank-val,
.legend .mono {
  font-family: var(--font-figures);
  font-variant-numeric: tabular-nums;
}

.tile-label {
  font-size: 12.5px;
  color: var(--text-3);
  font-weight: 500;
}

.tile-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.tile-sub {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 30px;
}

.panel {
  padding: 18px 20px 20px;
  min-width: 0;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-height: 32px;
  margin-bottom: 12px;
}

.panel-head h3 {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

.mix-bar {
  display: flex;
  gap: 3px;
  height: 10px;
  margin-bottom: 16px;
}

.mix-bar span {
  width: var(--w);
  min-width: 4px;
  background: var(--c);
  border-radius: 5px;
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend .mono {
  margin-left: auto;
  font-size: 12.5px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
}

/* minmax(0, 1fr) stops long names from widening the column past the card. */
.rank-list {
  list-style: none;
  margin: 0 -8px;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.rank-list > li {
  min-width: 0;
}

.rank-list > li + li {
  border-top: 1px solid var(--border);
}

.rank-row {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  transition: background-color 0.15s ease;
}

.rank-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rank-name {
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.rank-bar {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.rank-bar i {
  display: block;
  height: 100%;
  width: var(--w);
  min-width: 4px;
  border-radius: 2px;
  background: var(--brand);
}

.rank-val {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 56px;
  line-height: 1.25;
}

.rank-val b {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.rank-val small {
  font-size: 11.5px;
  color: var(--text-3);
}

.columns {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 150px;
}

.col {
  flex: 1;
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.col-bar {
  width: 100%;
  max-width: 28px;
  height: var(--h);
  background: var(--brand-soft);
  border-top: 2px solid var(--brand);
  border-radius: 4px 4px 0 0;
  transition: background-color 0.15s ease;
}

.col:hover .col-bar {
  background: var(--brand);
}

.col-val,
.col-label {
  font-size: 10.5px;
  color: var(--text-3);
}

.col-val {
  color: var(--text-2);
}

.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 650;
  font-size: 14px;
  letter-spacing: -0.02em;
}

.avatar.lg {
  width: 64px;
  height: 64px;
  font-size: 22px;
  background: var(--brand);
  color: var(--on-brand);
}

/* ---- Profile ---------------------------------------------------------- */

.profile {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  margin-bottom: 18px;
}

.profile-info {
  min-width: 0;
}

.profile-info h2 {
  font-size: 24px;
  letter-spacing: -0.025em;
}

.profile-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 6px;
  font-size: 13px;
}

.profile-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.profile-meta .icon {
  color: var(--text-3);
}

.profile-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ---- Toolbar ---------------------------------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.toolbar-count {
  font-size: 14px;
}

.toolbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar .segmented button {
  padding: 0 10px;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 550;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.toggle-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-chip:hover {
  border-color: var(--border-strong);
}

.toggle-chip.on {
  background: var(--c-ai-soft);
  border-color: transparent;
  color: var(--c-ai);
}

.toggle-chip:focus-within {
  box-shadow: var(--ring);
}

/* ---- Asset grid ------------------------------------------------------- */

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.asset {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.asset:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 0;
  background: var(--surface-2);
  overflow: hidden;
}

.thumb img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.asset:hover .thumb img {
  transform: scale(1.035);
}

.thumb-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-3);
}

.thumb-badges {
  position: absolute;
  z-index: 2;
  left: 10px;
  top: 10px;
  display: flex;
  gap: 4px;
}

.thumb-badges .badge {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 8%, transparent);
}

.thumb-badges .badge-ai {
  background: var(--c-ai);
  color: #fff;
}

.thumb-badges .badge.rank {
  background: var(--text);
  color: var(--text-invert);
  text-transform: none;
}

.bookmark-btn {
  position: absolute;
  z-index: 3;
  right: 8px;
  top: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--text);
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.asset:hover .bookmark-btn,
.bookmark-btn:focus-visible,
.bookmark-btn[aria-pressed="true"] {
  opacity: 1;
}

.bookmark-btn[aria-pressed="true"] {
  color: var(--brand);
}

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

.asset-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 14px;
  flex: 1;
}

.asset-title {
  font-size: 14px;
  font-weight: 550;
  line-height: 1.4;
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.asset-stats {
  display: grid;
  grid-template-columns: 1.3fr 1fr 0.8fr;
  gap: 8px;
}

.asset-stats div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.asset-stats .mono {
  font-size: 15px;
  color: var(--text);
  line-height: 1.3;
}

.asset-stats .strong {
  font-size: 17px;
}

.asset-stats small {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.heat {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.heat span {
  display: block;
  height: 100%;
  width: var(--w);
  background: var(--brand);
  border-radius: 2px;
}

.asset-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.creator-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

.creator-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.creator-link:hover {
  color: var(--brand);
}

.id-copy {
  margin-left: auto;
  flex: none;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11.5px;
}

.id-copy:hover {
  color: var(--text);
  border-color: var(--border);
}

.profile-meta .id-copy,
.drawer-facts .id-copy {
  margin-left: 0;
}

.no-img .thumb-fallback,
.thumb:not(:has(img)) .thumb-fallback {
  z-index: 1;
}

/* Skeleton */
.skeleton .thumb,
.skeleton i {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}

.skeleton i {
  display: block;
  height: 12px;
  border-radius: 6px;
}

.skeleton i.short {
  width: 55%;
}

.skeleton:hover {
  transform: none;
  box-shadow: none;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.loading-line {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--text);
}

.loading-line p {
  flex: 1;
}

.spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--brand-soft);
  border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- List / table ----------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
}

.asset-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.asset-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.asset-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}

.asset-table tbody tr:last-child td {
  border-bottom: 0;
}

.asset-table tbody tr:hover td {
  background: var(--brand-softer);
}

.asset-table .num {
  text-align: right;
  white-space: nowrap;
}

.t-rank {
  width: 40px;
}

.t-act {
  width: 48px;
}

.t-act .bookmark-btn {
  position: static;
  opacity: 1;
  background: transparent;
  backdrop-filter: none;
}

.row-asset {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  min-width: 260px;
}

.row-thumb {
  width: 56px;
  height: 42px;
  flex: none;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-title > span {
  color: var(--text);
  font-weight: 550;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.row-asset:hover .row-title > span {
  color: var(--brand);
}

.row-title small {
  font-size: 11.5px;
}

.ai-text {
  font-style: normal;
  color: var(--c-ai);
  font-weight: 600;
}

.asset-table td:has(.type-dot),
.asset-table td:has(.link-btn) {
  white-space: nowrap;
}

.type-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  margin-right: 8px;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-link);
  font-weight: 500;
}

.link-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---- Empty / error ---------------------------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 56px 24px;
}

.empty h3 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.empty p {
  max-width: 460px;
}

.empty .chip-row {
  margin-top: 10px;
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: 6px;
}

.empty-icon.err {
  background: var(--c-danger-soft);
  color: var(--c-danger);
}

.small-empty {
  padding: 36px 24px;
  color: var(--text-3);
}

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

.empty .btn-row {
  margin-top: 12px;
}

/* ---- Saved ------------------------------------------------------------ */

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
}

.section-title h2 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.creator-grid + .section-title {
  margin-top: 36px;
}

.creator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.creator-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.creator-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  height: 88px;
  background: var(--surface-2);
}

.creator-thumbs img,
.creator-thumbs span {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface-2);
}

.creator-body {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 0 18px;
  margin-top: -22px;
}

.creator-body .avatar {
  border: 3px solid var(--surface);
  background: var(--brand);
  color: var(--on-brand);
}

.creator-info {
  padding-top: 32px;
  min-width: 0;
}

.creator-info h3 {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.creator-info p {
  font-size: 12px;
}

.creator-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 14px 18px;
}

.creator-stats div {
  display: flex;
  flex-direction: column;
}

.creator-stats .mono {
  font-size: 17px;
  color: var(--text);
  font-weight: 600;
}

.creator-stats small {
  font-size: 11.5px;
  color: var(--text-3);
}

.creator-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ---- Settings --------------------------------------------------------- */

.settings {
  display: grid;
  gap: 16px;
  max-width: 820px;
}

.settings-group {
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 20px 22px;
}

.settings-row + .settings-row {
  border-top: 1px solid var(--border);
}

.settings-row > div:first-child {
  flex: 1;
  min-width: 0;
}

.settings-row h3 {
  font-size: 15px;
  margin-bottom: 3px;
}

.settings-row p {
  font-size: 13.5px;
}

.settings-body {
  display: grid;
  gap: 16px;
  padding: 0 22px 22px;
}

.switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  background: var(--surface-3);
  transition: background-color 0.2s ease;
  pointer-events: none;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.switch input:focus-visible + span {
  box-shadow: var(--ring);
}

/* ---- Drawer ----------------------------------------------------------- */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.drawer {
  position: fixed;
  z-index: 41;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100%);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.3s;
  outline: none;
}

.drawer.open {
  transform: none;
  visibility: visible;
}

.drawer-inner {
  min-height: 100%;
  padding: 18px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drawer-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.drawer-media {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.drawer-media img,
.drawer-media video {
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  margin: 0 auto;
}

.drawer-title {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.drawer-title h2 {
  flex: 1;
  font-size: 20px;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.drawer-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.drawer-stats div {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  background: var(--surface);
}

.drawer-stats .mono {
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
}

.drawer-stats small {
  font-size: 11.5px;
  color: var(--text-3);
}

.drawer-facts {
  margin: 0;
  display: grid;
}

.drawer-facts > div {
  display: flex;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.drawer-facts dt {
  width: 110px;
  flex: none;
  color: var(--text-3);
}

.drawer-facts dd {
  margin: 0;
  color: var(--text);
  min-width: 0;
}

.drawer-kw .panel-head {
  margin-bottom: 10px;
}

.drawer-kw .chip {
  height: 28px;
  font-size: 12.5px;
}

.drawer-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding: 20px 0;
  background: linear-gradient(to bottom, transparent, var(--bg-elevated) 22px);
}

.drawer-actions .btn {
  flex: 1;
}

/* ---- Type badges ------------------------------------------------------ */

.badge.type-photo {
  color: var(--c-photo);
}

.badge.type-illustration {
  color: var(--c-illustration);
}

.badge.type-vector {
  color: var(--c-vector);
}

.badge.type-video {
  color: var(--c-video);
}

.thumb-badges .badge[class*="type-"] {
  color: var(--text);
}

/* ---- Responsive ------------------------------------------------------- */

@media (max-width: 1180px) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  body.app {
    display: block;
    padding-bottom: 72px;
  }

  .sidebar {
    display: none;
  }

  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
    padding: 0 16px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
  }

  .tabbar {
    position: fixed;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
  }

  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    border-radius: 10px;
    color: var(--text-3);
    font-size: 11px;
    font-weight: 550;
    text-decoration: none;
  }

  .tabbar a.active {
    color: var(--brand);
  }

  .main {
    padding: 22px 16px 40px;
  }

  .view-head h1 {
    font-size: 25px;
  }

  .toast-stack {
    bottom: 84px;
  }
}

@media (max-width: 640px) {
  .query-card {
    padding: 14px;
  }

  .query-row .btn-lg {
    min-width: 0;
    padding: 0 16px;
  }

  .query-row .btn-lg span {
    display: none;
  }

  .query-filters {
    gap: 12px;
  }

  .filter {
    width: 100%;
    flex-wrap: wrap;
  }

  .filter .segmented {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .filter .segmented::-webkit-scrollbar {
    display: none;
  }

  .filter:has(select) {
    width: auto;
  }

  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tile:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .tile {
    padding: 14px 16px;
  }

  .tile-value {
    font-size: 22px;
  }

  .panels {
    grid-template-columns: minmax(0, 1fr);
  }

  .profile {
    flex-wrap: wrap;
  }

  .profile-actions {
    margin-left: 0;
    width: 100%;
  }

  .profile-actions .btn {
    flex: 1;
  }

  .toolbar-actions {
    margin-left: 0;
    width: 100%;
  }

  .toolbar-actions .select {
    flex: 1;
  }

  .asset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .asset-body {
    padding: 10px 12px 12px;
    gap: 8px;
  }

  .asset-title {
    font-size: 13px;
  }

  .asset-stats {
    grid-template-columns: 1fr 1fr;
  }

  .asset-stats > div:nth-child(3) {
    display: none;
  }

  .asset-stats .strong {
    font-size: 15px;
  }

  .asset-foot .id-copy {
    display: none;
  }

  .bookmark-btn {
    opacity: 1;
  }

  .t-hide-sm {
    display: none;
  }

  .settings-row {
    flex-wrap: wrap;
    gap: 14px;
  }

  .drawer-inner {
    padding: 14px 16px 0;
  }

  .drawer-facts dt {
    width: 92px;
  }
}

@media (max-width: 380px) {
  .asset-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
