.artifacts-shell [hidden] { display: none !important; }
.artifacts-shell .rail-flyout { visibility: hidden; }
.artifacts-shell .rail-flyout-wrap:is(:hover, :focus-within, .is-open) .rail-flyout { visibility: visible; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 8px 12px; border-radius: 9px; background: var(--espresso); color: white; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.artifacts-main { grid-column: 2; min-width: 0; min-height: 100dvh; }
.artifacts-topbar { height: 56px; display: flex; align-items: center; justify-content: flex-end; padding: 0 16px; }
.artifacts-view-toggle { display: flex; padding: 4px; border: 1px solid var(--border); border-radius: 13px; }
.artifacts-view-toggle button { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; color: var(--muted); transition: background-color 140ms ease; }
.artifacts-view-toggle button.is-active { background: var(--mist); color: var(--cocoa); }
.artifacts-view-toggle button:hover { background: var(--oat); }
.artifacts-view-toggle svg { width: 16px; height: 16px; stroke-width: 1.6; }
.artifacts-content { display: flex; flex-direction: column; width: min(880px, calc(100% - 64px)); min-height: calc(100dvh - 56px); margin: 0 auto; padding: 24px 0 80px; }
.artifacts-header h1 { margin: 0 0 4px; color: var(--espresso); font-size: 24px; font-weight: 500; line-height: 1.35; letter-spacing: -.319px; }
.artifacts-header p { margin: 0; color: var(--muted); font-size: 14px; line-height: 22px; }
.artifacts-search { position: relative; display: flex; align-items: center; height: 36px; flex: 0 0 36px; margin-top: 20px; border: 1px solid var(--border); border-radius: 999px; background: var(--mist); box-shadow: 0 1px 2px rgba(24,15,8,.05); }
.artifacts-search > svg { position: absolute; left: 14px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.artifacts-search input { width: 100%; height: 100%; min-width: 0; padding: 0 40px 0 40px; border: 0; border-radius: inherit; background: transparent; color: var(--espresso); font-size: 14px; appearance: none; }
.artifacts-search input::placeholder { color: var(--muted); opacity: 1; }
.artifacts-search input::-webkit-search-cancel-button { display: none; }
.artifacts-search input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.artifacts-search button { position: absolute; right: 4px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--muted); }
.artifacts-search button:hover { background: var(--sand); }
.artifacts-search button svg { width: 16px; height: 16px; }
.artifacts-filters { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 16px; }
.artifacts-filter { min-height: 32px; padding: 6px 10px; border-radius: 9px; color: var(--muted); font-size: 14px; line-height: 20px; white-space: nowrap; transition: background-color 140ms ease, color 140ms ease; }
.artifacts-filter:hover { background: var(--whisper); color: var(--espresso); }
.artifacts-filter.is-active { background: var(--oat); color: var(--espresso); }
.artifacts-results { display: flex; flex: 1; align-items: center; justify-content: center; min-height: 400px; padding: 80px 0 24px; }
.artifacts-results:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 12px; }
.artifacts-empty { width: 100%; text-align: center; }
.artifacts-empty-icon { width: 44px; height: 44px; margin: 0 auto 32px; color: var(--cocoa); stroke-width: 4; }
.artifacts-empty h2 { margin: 0 0 10px; color: var(--ink); font-size: 16px; line-height: 24px; font-weight: 500; }
.artifacts-empty p { max-width: 440px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 24px; overflow-wrap: anywhere; }
.artifacts-create { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; padding: 8px 12px; border-radius: 12px; background: var(--espresso); color: var(--canvas); font-size: 14px; line-height: 20px; transition: background-color 140ms ease; }
.artifacts-create:hover { background: var(--cocoa); }
.artifacts-create svg { width: 16px; height: 16px; stroke-width: 1.6; }
@media (max-width: 767px) {
  .artifacts-shell, .artifacts-shell[data-sidebar="expanded"] { grid-template-columns: minmax(0, 1fr); }
  .artifacts-main { grid-column: 1; }
  .artifacts-topbar { padding-inline: 16px; }
  .artifacts-view-toggle button { width: 40px; height: 40px; }
  .artifacts-content { width: calc(100% - 32px); padding: 24px 0 40px; }
  .artifacts-header h1 { font-size: 24px; }
  .artifacts-search { height: 44px; flex-basis: 44px; }
  .artifacts-search input { font-size: 16px; line-height: 24px; }
  .artifacts-filter { min-height: 44px; font-size: 14px; padding-inline: 12px; }
  .artifacts-results { min-height: 400px; padding: 64px 0 32px; }
  .artifacts-empty-icon { margin-bottom: 28px; }
  .artifacts-create { min-height: 44px; }
}
@media (max-width: 440px) {
  .artifacts-content { padding-top: 16px; }
  .artifacts-filters { gap: 4px 0; margin-top: 16px; }
  .artifacts-filter { padding-inline: 10px; }
  .artifacts-desktop-break { display: none; }
  .artifacts-results { min-height: 360px; padding-top: 48px; }
}

/* ── Artifact Cards ────────────────────────────────── */
.artifacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  width: 100%;
  padding: 0;
}
.artifacts-results[data-view="list"] .artifacts-grid {
  grid-template-columns: 1fr;
  gap: 6px;
}

.artifacts-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border, #e8e0d9);
  border-radius: 14px;
  background: var(--canvas, #fefdfb);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: box-shadow 140ms ease, border-color 140ms ease;
}
.artifacts-card:hover {
  border-color: var(--sand, #eae2dc);
  box-shadow: 0 4px 16px rgba(24,15,8,.08);
}
.artifacts-card:focus-visible {
  outline: 2px solid var(--primary, #2d8a7f);
  outline-offset: 2px;
}

.artifacts-results[data-view="list"] .artifacts-card {
  flex-direction: row;
  align-items: center;
  border-radius: 10px;
}
.artifacts-results[data-view="list"] .artifacts-card-thumb {
  width: 72px;
  height: 54px;
  flex-shrink: 0;
  border-radius: 8px;
  margin: 6px;
}
.artifacts-results[data-view="list"] .artifacts-card-body {
  padding: 8px 12px;
  flex: 1;
  min-width: 0;
}

/* ── Thumbnails ──────────────────────────────────── */
.artifacts-card-thumb {
  position: relative;
  aspect-ratio: 16/10;
  overflow: hidden;
  background: var(--mist, #f8f5f2);
}
.artifacts-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.artifacts-card-thumb--broken {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted, #9a8a7c);
  background: var(--oat, #ece5df);
}
.artifacts-card-thumb--broken svg {
  width: 28px;
  height: 28px;
  opacity: .5;
}
.artifacts-card-thumb--broken span {
  font-size: 11px;
  opacity: .7;
}

/* ── Play badge ─────────────────────────────────── */
.artifacts-card-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.25);
  opacity: 0;
  transition: opacity 140ms ease;
}
.artifacts-card:hover .artifacts-card-play {
  opacity: 1;
}
.artifacts-card-play svg {
  width: 32px;
  height: 32px;
  color: #fff;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}

/* ── Card body ──────────────────────────────────── */
.artifacts-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.artifacts-card-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--espresso, #180f08);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.artifacts-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 11px;
  color: var(--muted, #9a8a7c);
}
.artifacts-card-type {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--oat, #ece5df);
  color: var(--cocoa, #3d2e24);
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

/* ── Lightbox ────────────────────────────────────── */
.artifacts-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: rgba(24,15,8,.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: artifacts-fade-in 180ms ease;
}
@keyframes artifacts-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.artifacts-lightbox-content {
  position: relative;
  max-width: min(90vw, 900px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.artifacts-lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  color: #fff;
  transition: background 140ms ease;
}
.artifacts-lightbox-close:hover {
  background: rgba(255,255,255,.3);
}
.artifacts-lightbox-close svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}
.artifacts-lightbox-meta {
  text-align: center;
  color: rgba(255,255,255,.85);
}
.artifacts-lightbox-prompt {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  max-width: 600px;
}
.artifacts-lightbox-info {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  opacity: .7;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 767px) {
  .artifacts-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
  .artifacts-lightbox-content {
    max-width: 95vw;
  }
}
@media (max-width: 440px) {
  .artifacts-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

/* ── Results has-cards: remove centering ──────────── */
.artifacts-results:has(.artifacts-grid) {
  align-items: flex-start;
  justify-content: flex-start;
  padding-top: 24px;
}
