* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --orange: #ff6b35;
  --orange-light: #ff8c42;
  --page-bg: #e8ebf0;
  --surface: #f4f5f7;
  --border: #d5dae1;
  --text-muted: #5f6368;
  --radius: 10px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 8px 24px rgba(255, 107, 53, 0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--page-bg);
  min-height: 100vh;
  padding: 16px;
  color: #202124;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.07);
  overflow: hidden;
  border: 1px solid var(--border);
}

.app-header {
  padding: 24px 20px 18px;
  text-align: center;
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
  color: #fff;
}

.app-header h1 {
  font-size: 1.65rem;
  font-weight: 700;
}

.accent {
  font-weight: 800;
}

.subtitle {
  margin-top: 6px;
  font-size: 0.92em;
  opacity: 0.95;
}

.stats-bar {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  font-size: 0.78em;
}

.stat-chip {
  background: rgba(255, 255, 255, 0.28);
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.toolbar-sticky {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.toolbar {
  padding: 14px 16px 10px;
}

.search-wrap {
  position: relative;
  margin-bottom: 10px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 10px 36px 10px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1em;
  background: var(--surface);
}

.search-input:focus {
  outline: none;
  border-color: var(--orange-light);
  box-shadow: 0 0 0 3px rgba(255, 140, 66, 0.2);
  background: #fff;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.filters-scroll {
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.filter-section {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.filter-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  width: 100%;
  margin-bottom: 4px;
}

.filter-section-facets {
  flex-direction: column;
  margin-top: 8px;
}

.filter-section-label {
  flex-shrink: 0;
  font-size: 0.72em;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  padding-top: 7px;
  min-width: 2.8em;
}

.filter-section-facets .filter-section-label {
  padding-top: 0;
}

.filter-section-hint {
  font-size: 0.72em;
  color: var(--text-muted);
  opacity: 0.85;
}

.sort-label {
  font-size: 0.78em;
  color: var(--text-muted);
  margin-right: 4px;
  white-space: nowrap;
}

.category-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  padding-bottom: 4px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85em;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.tab-count {
  opacity: 0.85;
  font-size: 0.9em;
}

.sort-select {
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
}

.status {
  margin-top: 8px;
  font-size: 0.82em;
  color: var(--text-muted);
}

.status.status-error {
  color: #b42318;
}

.asset-grid {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.view-comfortable {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.asset-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

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

.thumb-wrap {
  aspect-ratio: 4 / 3;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.thumb-missing,
img.thumb-missing {
  object-fit: contain;
  background: var(--surface);
  opacity: 0.45;
}

.thumb-ext {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--ext-bg, #64748b);
  color: var(--ext-fg, #fff);
  overflow: hidden;
}

.thumb-ext::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 28%;
  height: 28%;
  background: rgba(255, 255, 255, 0.18);
  border-bottom-left-radius: 6px;
}

.ext-glyph {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: clamp(0.72rem, 3.5vw, 1.05rem);
  text-transform: uppercase;
  z-index: 1;
}

.thumb-ext[data-ext="psd"],
.thumb-ext[data-ext="psb"] { --ext-bg: #6d28d9; }
.thumb-ext[data-ext="ai"],
.thumb-ext[data-ext="eps"] { --ext-bg: #ea580c; }
.thumb-ext[data-ext="svg"] { --ext-bg: #059669; }
.thumb-ext[data-ext="mp3"],
.thumb-ext[data-ext="wav"],
.thumb-ext[data-ext="aac"],
.thumb-ext[data-ext="m4a"] { --ext-bg: #2563eb; }
.thumb-ext[data-ext="pdf"] { --ext-bg: #dc2626; }
.thumb-ext[data-ext="md"],
.thumb-ext[data-ext="txt"],
.thumb-ext[data-ext="log"] { --ext-bg: #475569; }
.thumb-ext[data-ext="json"],
.thumb-ext[data-ext="yaml"],
.thumb-ext[data-ext="yml"],
.thumb-ext[data-ext="jsonl"] { --ext-bg: #0d9488; }
.thumb-ext[data-kind="creative"]:not([data-ext="ai"]):not([data-ext="eps"]) { --ext-bg: #7c3aed; }
.thumb-ext[data-kind="vector"] { --ext-bg: #059669; }
.thumb-ext[data-kind="audio"] { --ext-bg: #2563eb; }
.thumb-ext[data-kind="document"] { --ext-bg: #64748b; }
.thumb-ext[data-kind="video"] { --ext-bg: #1e293b; }

.view-compact .ext-glyph {
  font-size: clamp(0.62rem, 3vw, 0.82rem);
}

.card-body {
  padding: 10px 12px 12px;
}

.card-title {
  font-size: 0.88em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.badge {
  font-size: 0.72em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.badge-conf {
  background: #e8f5e9;
  border-color: #c8e6c9;
}

.badge-muted {
  color: var(--text-muted);
}

.badge-quality {
  background: #e3f2fd;
  border-color: #bbdefb;
  color: #1565c0;
}

.badge-warn {
  background: #fff3e0;
  border-color: #ffe0b2;
  color: #e65100;
}

.quality-chips {
  margin-top: -4px;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.empty-state-text {
  margin-bottom: 12px;
}

.empty-state-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.88em;
  cursor: pointer;
  min-height: 44px;
}

.empty-state-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}


.main-layout {
  display: block;
}

.toolbar-top {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.toolbar-top .search-wrap {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
}

.filter-toggle-btn {
  display: none;
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.88em;
  font-weight: 600;
  cursor: pointer;
}

.filter-toggle-btn[aria-expanded="true"] {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.filter-panel {
  border: none;
}

.filter-panel-body {
  padding-top: 4px;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.active-filters-label {
  font-size: 0.72em;
  color: var(--text-muted);
  font-weight: 600;
}

.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--orange);
  background: #fff5f0;
  color: var(--orange);
  border-radius: 999px;
  padding: 3px 8px 3px 10px;
  font-size: 0.76em;
  cursor: pointer;
  max-width: 100%;
}

.active-filter-chip:hover {
  background: rgba(255, 107, 53, 0.15);
}

.active-filter-clear {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76em;
  cursor: pointer;
  padding: 4px 8px;
  text-decoration: underline;
}

.content-area {
  min-width: 0;
}

.grid-loading .asset-card {
  pointer-events: none;
}

.skeleton-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.skeleton-thumb {
  aspect-ratio: 4 / 3;
  background: linear-gradient(90deg, #eef0f3 25%, #f8f9fa 50%, #eef0f3 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-line {
  height: 10px;
  margin: 10px 12px 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, #eef0f3 25%, #f8f9fa 50%, #eef0f3 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-line.short {
  width: 55%;
  margin-bottom: 12px;
}

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

.card-date {
  font-size: 0.72em;
  color: var(--text-muted);
  margin-top: 4px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 40;
}

.drawer-ext-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 12px;
  border-radius: var(--radius);
  overflow: hidden;
}

.app-header.is-compact {
  padding: 10px 16px 8px;
}

.app-header.is-compact h1 {
  font-size: 1.15rem;
}

.app-header.is-compact .subtitle {
  display: none;
}

.app-header.is-compact .stats-bar {
  margin-top: 4px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}

#lightbox-img {
  max-width: min(92vw, 1200px);
  max-height: 70vh;
  object-fit: contain;
}

.lightbox-caption {
  color: #fff;
  margin-top: 12px;
  font-size: 0.9em;
  word-break: break-all;
  text-align: center;
}

.lightbox-actions {
  margin-top: 12px;
}

.lightbox-btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--orange);
  color: #fff;
  cursor: pointer;
  font-size: 0.9em;
}

@media (max-width: 640px) {
  .view-comfortable {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* Gate */
.login-page {
  padding: 0;
}

.login-page .gate--auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top))
           max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom))
           max(16px, env(safe-area-inset-left));
}

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-panel {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.07);
  border: 1px solid var(--border);
  overflow: hidden;
  text-align: center;
}

.gate-header {
  background: linear-gradient(135deg, var(--orange) 0%, var(--orange-light) 100%);
}

.gate-title {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  color: #fff;
  padding: clamp(20px, 5vw, 28px) 20px 8px;
  background: transparent;
}

.gate-subtitle {
  padding: 0 20px clamp(18px, 4vw, 24px);
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  font-size: clamp(0.85rem, 2.5vw, 0.95rem);
  line-height: 1.45;
}

.gate-body {
  padding: clamp(20px, 5vw, 28px) clamp(16px, 4vw, 24px) clamp(24px, 5vw, 32px);
  text-align: left;
}

.gate-body-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 10px;
  text-align: center;
}

.gate-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
  margin-bottom: 20px;
  text-align: center;
}

.gate-message {
  font-size: 0.92rem;
  line-height: 1.55;
  margin-bottom: 16px;
  text-align: center;
}

.gate-message--error {
  color: #c62828;
}

.github-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  background: #24292f;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.github-login-btn:hover {
  background: #1b1f23;
}

.github-login-btn:active {
  transform: scale(0.98);
}

.github-login-btn--secondary {
  background: var(--orange);
}

.github-login-btn--secondary:hover {
  background: #e85a28;
}

.github-login-icon {
  flex-shrink: 0;
}

.gate-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.gate-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1em;
}

.gate-submit {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--orange);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.gate-error {
  color: #c62828;
  font-size: 0.85em;
  min-height: 1.2em;
}

.logout-btn {
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.15);
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.8em;
}

.header-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 2;
}

.upload-entry-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.8em;
  min-height: 32px;
}

.upload-entry-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.upload-entry-icon {
  font-weight: 700;
}

.upload-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 120;
}

.upload-panel {
  position: fixed;
  z-index: 130;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.upload-panel.hidden,
.upload-backdrop.hidden {
  display: none;
}

.upload-panel-inner {
  width: min(560px, 92vw);
  max-height: min(90vh, 760px);
  overflow: auto;
  background: var(--surface);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  padding: 20px;
}

.upload-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.upload-panel-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.upload-panel-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.upload-login-cta {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: #fff8f0;
}

.upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 14px;
  min-height: 100px;
}

.upload-dropzone.is-dragover {
  border-color: var(--orange);
  background: #fff6ef;
}

.upload-dropzone-title {
  margin: 0 0 6px;
  font-weight: 600;
}

.upload-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.upload-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85em;
}

.upload-field-full {
  margin-bottom: 10px;
}

.upload-input,
.upload-textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}

.upload-queue {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  max-height: 180px;
  overflow: auto;
}

.upload-queue li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85em;
}

.upload-queue li.is-error {
  color: #c62828;
}

.upload-progress-wrap {
  margin-bottom: 10px;
}

.upload-progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0;
  background: var(--orange);
  transition: width 0.15s linear;
}

.upload-progress-text {
  margin: 6px 0 0;
  font-size: 0.8em;
}

.upload-error {
  color: #c62828;
  font-size: 0.85em;
  margin-bottom: 10px;
}

.upload-results {
  margin-bottom: 12px;
}

.upload-result-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.upload-result-card img {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--border);
}

.upload-panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.github-login-btn--compact {
  display: inline-flex;
  padding: 8px 14px;
  font-size: 0.9em;
}

.app-header {
  position: relative;
}

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

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.view-btn {
  border: none;
  background: var(--surface);
  padding: 8px 10px;
  font-size: 0.75em;
  cursor: pointer;
}

.view-btn.active {
  background: var(--orange);
  color: #fff;
}

.filters-row-2 {
  margin-top: 8px;
}

.category-tabs-secondary .tab-btn {
  font-size: 0.8em;
}

.facet-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.facet-groups {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.facet-group-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.facet-group-label {
  flex-shrink: 0;
  font-size: 0.72em;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 2.2em;
}

.facet-chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78em;
  cursor: pointer;
}

.facet-chip.active {
  background: #fff5f0;
  border-color: var(--orange);
  color: var(--orange);
  font-weight: 600;
}

.facet-chip.active::before {
  content: "✓ ";
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.quick-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78em;
  cursor: pointer;
}

.quick-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.view-compact {
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.view-compact .card-body {
  padding: 6px 8px;
}

.view-compact .card-title {
  font-size: 0.75em;
}





.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 92vw);
  height: 100vh;
  height: 100dvh;
  background: #fff;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  z-index: 50;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.detail-drawer.is-open {
  transform: translateX(0);
}

.drawer-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
}

.drawer-title {
  font-size: 1.1rem;
  margin-bottom: 8px;
  padding-right: 24px;
}

.drawer-path {
  font-size: 0.82em;
  color: var(--text-muted);
  word-break: break-all;
  margin-bottom: 12px;
}

.drawer-desc {
  font-size: 0.9em;
  line-height: 1.5;
  margin-bottom: 12px;
}

.drawer-badges,
.drawer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.lightbox-btn-outline {
  background: transparent;
  border: 1px solid var(--orange);
  color: var(--orange);
}

.drawer-hint.muted {
  font-size: 0.82em;
  color: var(--text-muted);
}

#lightbox-video {
  max-width: min(92vw, 1200px);
  max-height: 70vh;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  border: none;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  width: 44px;
  height: 56px;
  border-radius: 8px;
  cursor: pointer;
}

.lightbox-nav-prev {
  left: 12px;
}

.lightbox-nav-next {
  right: 12px;
}

.lightbox-nav:hover {
  background: rgba(255, 107, 53, 0.85);
}

.library-status-panel {
  margin: 0 16px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.library-status-summary {
  cursor: pointer;
  padding: 10px 14px;
  font-size: 0.9em;
  font-weight: 600;
  color: #3c4043;
  list-style: none;
}

.library-status-summary::-webkit-details-marker {
  display: none;
}

.library-status-body {
  padding: 0 14px 12px;
  display: grid;
  gap: 10px;
}

.library-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.library-stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.library-stat-label {
  font-size: 0.75em;
  color: var(--text-muted);
}

.library-stat-value {
  font-size: 1.05em;
  font-weight: 600;
  margin-top: 2px;
}

.library-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.library-progress-bar {
  height: 8px;
  background: #e8eaed;
  border-radius: 999px;
  overflow: hidden;
}

.library-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-light));
  border-radius: 999px;
}

.library-status-note {
  font-size: 0.82em;
  color: var(--text-muted);
  line-height: 1.4;
}

.banner-dismiss {
  float: right;
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
  line-height: 1;
  padding: 0 4px;
}

.analysis-banner {
  margin: 0 16px 0;
  padding: 10px 14px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  color: #6d4c00;
  font-size: 0.88em;
  line-height: 1.45;
}

.thumb-wrap {
  position: relative;
}

.video-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.75em;
  padding: 2px 7px;
  border-radius: 4px;
}

.drawer-video,
.drawer-preview-img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.drawer-meta {
  font-size: 0.85em;
  margin-bottom: 6px;
}

.badge-warn-inline {
  color: #b45309;
}

.badge-quality-inline {
  color: #047857;
  font-weight: 600;
}

.drawer-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.drawer-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85em;
  color: var(--text-muted);
}

.drawer-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  color: inherit;
  background: #fff;
}

.drawer-textarea {
  resize: vertical;
  min-height: 72px;
}

.drawer-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: inherit;
}

.drawer-checkbox input {
  width: auto;
}

.drawer-form-error {
  color: #b91c1c;
  font-size: 0.85em;
  margin: 0;
}

.quality-hint {
  margin: 8px 0 0;
  padding: 8px 12px;
  font-size: 0.84em;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.folder-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 0.86em;
}

.breadcrumb-link {
  background: none;
  border: none;
  color: var(--orange);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.breadcrumb-link:hover {
  background: rgba(255, 107, 53, 0.08);
}

.breadcrumb-current {
  color: #202124;
  font-weight: 600;
  cursor: default;
}

.breadcrumb-sep {
  color: var(--text-muted);
}

.folder-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.folder-shortcuts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.folder-shortcuts .folder-chip.active,
.folder-nav .folder-chip.active {
  border-color: var(--orange);
  background: rgba(255, 107, 53, 0.1);
  color: var(--orange);
}

.folder-nav-label {
  font-size: 0.78em;
  color: var(--text-muted);
  margin-right: 4px;
}

.folder-chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.82em;
  cursor: pointer;
}

.folder-chip:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.load-sentinel {
  height: 24px;
  margin: 8px 0 16px;
}

@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .login-page {
    padding: 0;
  }

  .login-page .gate--auth {
    align-items: stretch;
    padding: max(12px, env(safe-area-inset-top))
             max(12px, env(safe-area-inset-right))
             max(12px, env(safe-area-inset-bottom))
             max(12px, env(safe-area-inset-left));
  }

  .login-page .gate-panel {
    max-width: none;
    min-height: min(100%, calc(100dvh - 24px));
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: 12px;
  }

  .gate {
    padding: 12px;
    align-items: stretch;
  }

  .gate-panel {
    max-width: none;
  }

  .toolbar {
    padding: 10px 12px 8px;
  }

  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .sort-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
  }

  .sort-select {
    flex: 1;
    min-width: 0;
  }

  .view-toggle {
    flex: 1;
    display: flex;
  }

  .view-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.72em;
  }

  .filter-section-label {
    min-width: 2.4em;
    padding-top: 6px;
  }

  .facet-group-label {
    width: 100%;
    min-width: 0;
  }



  .filter-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .filter-panel:not([open]) .filter-panel-body {
    display: none;
  }

  .filter-panel > summary {
    display: none;
  }

  .library-status-panel:not([open]) {
    margin-bottom: 0;
  }

  .login-page .gate-panel {
    min-height: auto;
    justify-content: flex-start;
    padding-top: max(24px, env(safe-area-inset-top));
  }

  .detail-drawer {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .detail-drawer.is-open {
    transform: translateY(0);
  }

  .app-header {
    padding: 16px 14px 12px;
  }

  .app-header h1 {
    font-size: 1.35rem;
  }

  .asset-grid.view-comfortable {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
}

@media (min-width: 1025px) {
  .main-layout {
    display: grid;
    grid-template-columns: minmax(260px, 300px) 1fr;
    align-items: start;
  }

  .toolbar-sticky {
    position: sticky;
    top: 0;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    border-right: 1px solid var(--border);
    border-bottom: none;
  }

  .toolbar-top .search-wrap {
    margin-bottom: 0;
  }

  .filter-toggle-btn {
    display: none !important;
  }

  .filter-panel,
  .filter-panel[open] {
    display: block;
  }

  .filter-panel > summary {
    display: none;
  }

  .view-comfortable {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .view-comfortable {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .upload-entry-label {
    font-size: 0.85em;
  }
}

@media (max-width: 640px) {
  .upload-panel {
    align-items: flex-end;
    padding: 0;
  }

  .upload-panel-inner {
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }

  .upload-dropzone {
    min-height: 120px;
  }

  .upload-form-grid {
    grid-template-columns: 1fr;
  }

  .upload-panel-actions button {
    min-height: 44px;
  }

  .upload-entry-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

