/* =============================================
   FRAMES — PFP Archive
   Aesthetic: Dark industrial, stark minimal
   Fonts: Geist (UI) + IBM Plex Mono (labels)
   ============================================= */

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

:root {
  --bg:       #0d0d0c;
  --surface:  #141413;
  --card:     #1a1918;
  --border:   #2a2927;
  --border2:  #333230;
  --text:     #e8e6e1;
  --text-2:   #9b9790;
  --muted:    #5a5855;
  --accent:   #e8e6e1;
  --red:      #d64c4c;
  --red-dim:  rgba(214,76,76,0.12);

  --r:        8px;
  --r-sm:     5px;
  --t:        150ms ease;

  --font:     'Syne', sans-serif;
  --mono:     'DM Mono', monospace;
  --serif:    'Syne', sans-serif;

  --sidebar-w: 210px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  padding: 24px 16px 24px;
  flex-shrink: 0;
}

.logo { margin-bottom: 32px; padding: 0 4px; }

.logo-word {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  font-style: normal;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text);
}

.side-section { margin-bottom: 24px; }

.side-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0 4px;
}

.side-link {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  padding: 7px 10px;
  cursor: pointer;
  transition: background var(--t), color var(--t);
  margin-bottom: 2px;
}

.side-link:hover { background: var(--card); color: var(--text); }
.side-link.active { background: var(--surface); color: var(--text); font-weight: 500; }

.filter-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-2);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  padding: 6px 10px;
  cursor: pointer;
  transition: background var(--t), color var(--t);
  margin-bottom: 1px;
}

.filter-btn:hover { color: var(--text); background: var(--card); }
.filter-btn.active { color: var(--text); font-weight: 500; }
.filter-btn.active::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  background: var(--text);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  margin-bottom: 1px;
}

.stats {
  display: flex;
  gap: 18px;
  margin-bottom: 16px;
  padding: 0 4px;
}

.stat { display: flex; flex-direction: column; }
.stat-n { font-family: var(--mono); font-size: 20px; font-weight: 500; color: var(--text); line-height: 1; }
.stat-l { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

.btn-main {
  width: 100%;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--bg);
  background: var(--text);
  border: none;
  border-radius: var(--r);
  padding: 10px;
  cursor: pointer;
  transition: opacity var(--t);
}
.btn-main:hover { opacity: 0.88; }

/* ===================== MAIN ===================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ---- TOPBAR ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13,13,12,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
}

.search {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  outline: none;
  width: 280px;
  transition: border-color var(--t);
}
.search::placeholder { color: var(--muted); }
.search:focus { border-color: var(--border2); }

.topbar-right { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.icon-btn:hover { background: var(--card); color: var(--text-2); }
.icon-btn.active { background: var(--surface); border-color: var(--border); color: var(--text); }

/* ---- SELECTION BAR ---- */
.sel-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  gap: 12px;
}

.sel-count {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
}

.sel-actions { display: flex; gap: 6px; }

.sel-btn {
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 14px;
  cursor: pointer;
  transition: background var(--t);
}
.sel-btn:hover { background: var(--border2); }
.sel-btn.muted { color: var(--text-2); }

/* ---- VIEWS ---- */
.view { display: none; }
.view.active { display: block; }

/* ---- GALLERY ---- */
.gallery {
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.gallery.list-view {
  grid-template-columns: 1fr;
  gap: 0;
}

/* ---- CARD ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: border-color var(--t), transform var(--t);
  animation: fadeUp 0.25s ease both;
}
.card:hover { border-color: var(--border2); transform: translateY(-1px); }
.card.selected { border-color: var(--text-2); }
.card.selected .card-check { opacity: 1; }

.card-check {
  position: absolute;
  top: 8px; left: 8px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text);
  border: none;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity var(--t);
  z-index: 2;
  pointer-events: none;
}
.card-check svg { color: var(--bg); }

.card-img {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface);
}
.card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}
.card:hover .card-img img { transform: scale(1.03); }

.card-body {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.card-user {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-cat {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 7px;
}

.tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 6px;
}

/* LIST VIEW CARD */
.gallery.list-view .card {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}
.gallery.list-view .card:hover { transform: none; background: var(--surface); padding-left: 12px; padding-right: 12px; border-radius: var(--r-sm); }
.gallery.list-view .card-img { width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0; aspect-ratio: unset; }
.gallery.list-view .card-img img { border-radius: 50%; }
.gallery.list-view .card-body { border-top: none; padding: 0; flex: 1; display: flex; align-items: center; gap: 20px; }
.gallery.list-view .card-cat { margin-top: 0; }
.gallery.list-view .card-tags { margin-top: 0; }

/* ---- STATES ---- */
.state-block {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 80px 0;
  color: var(--muted);
  font-size: 13px;
}
.s-title { font-size: 16px; font-weight: 600; color: var(--text-2); }

.spinner {
  width: 20px; height: 20px;
  border: 1.5px solid var(--border2);
  border-top-color: var(--text-2);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===================== COLLECTIONS ===================== */
.view-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.view-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 24px;
}

.col-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  cursor: pointer;
  transition: border-color var(--t);
}
.col-card:hover { border-color: var(--border2); }

.col-card-name {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.col-card-desc {
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 12px;
  min-height: 18px;
}

.col-card-count {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.col-thumb-row {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.col-thumb {
  width: 44px;
  height: 44px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ===================== MODALS ===================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  width: 100%;
  max-width: 460px;
  animation: slideUp 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}
.modal.sm { max-width: 360px; }
.modal.lg { max-width: 720px; }

.modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 0;
  margin-bottom: 16px;
}
.modal-hd h3 { font-family: var(--font); font-size: 15px; font-weight: 700; color: var(--text); }
.modal-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

.close-x {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t);
  flex-shrink: 0;
}
.close-x:hover { background: var(--card); }

.drop-zone {
  margin: 0 22px 16px;
  border: 1px dashed var(--border2);
  border-radius: var(--r);
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}
.drop-zone.drag-over { border-color: var(--text-2); background: var(--card); }

.drop-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
  font-size: 13px;
  padding: 20px;
}
.drop-link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.drop-hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.drop-prev {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
}
.hidden-input { display: none; }

.modal-body { padding: 0 22px 16px; display: flex; flex-direction: column; gap: 12px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 5px; }

.field label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.field label em {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 4px;
}

.field input,
.field select {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  outline: none;
  appearance: none;
  transition: border-color var(--t);
}
.field input::placeholder { color: var(--muted); }
.field input:focus,
.field select:focus { border-color: var(--border2); }

.field-note { font-size: 13px; color: var(--text-2); margin-bottom: 10px; }

.modal-ft {
  border-top: 1px solid var(--border);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.st-msg {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
  flex: 1;
}
.st-msg.err { color: var(--red); }

.btn-primary {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--bg);
  background: var(--text);
  border: none;
  border-radius: var(--r-sm);
  padding: 9px 20px;
  cursor: pointer;
  transition: opacity var(--t);
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 16px;
  cursor: pointer;
  transition: border-color var(--t), color var(--t);
}
.btn-ghost:hover { border-color: var(--border2); color: var(--text); }

.btn-danger {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--red);
  border: none;
  border-radius: var(--r-sm);
  padding: 9px 20px;
  cursor: pointer;
  transition: opacity var(--t);
}
.btn-danger:hover { opacity: 0.85; }

.btn-sm {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 14px;
  cursor: pointer;
  transition: background var(--t);
}
.btn-sm:hover { background: var(--border2); }

/* ---- Collection picker ---- */
.col-picker { padding: 0 22px; max-height: 260px; overflow-y: auto; }

.col-pick-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: color var(--t);
}
.col-pick-item:last-child { border-bottom: none; }
.col-pick-item:hover { color: var(--text); }
.col-pick-name { font-size: 13.5px; color: var(--text); }
.col-pick-count { font-family: var(--mono); font-size: 10px; color: var(--muted); }

/* ---- Collection detail grid ---- */
.col-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  padding: 20px 22px;
  max-height: 60vh;
  overflow-y: auto;
}

.col-thumb-card {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card);
}
.col-thumb-card img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ===================== RADIO ===================== */
.radio-list { display: flex; flex-direction: column; gap: 6px; }

.radio-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  transition: background var(--t), color var(--t);
}
.radio-opt:hover { background: var(--card); color: var(--text); }
.radio-opt input[type="radio"] { accent-color: var(--text); }

/* ===================== LIGHTBOX ===================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  animation: fadeIn 0.2s ease;
}

.lb-close {
  position: absolute;
  top: 20px; right: 20px;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t);
}
.lb-close:hover { background: rgba(255,255,255,0.12); }

.lb-wrap {
  display: flex;
  align-items: flex-end;
  gap: 32px;
  max-width: 820px;
  width: 100%;
}

.lb-img {
  width: clamp(200px, 46vw, 460px);
  height: clamp(200px, 46vw, 460px);
  object-fit: cover;
  border-radius: var(--r);
  display: block;
  border: 1px solid rgba(255,255,255,0.08);
}

.lb-info { flex: 1; padding-bottom: 4px; }

.lb-top { margin-bottom: 24px; }

.lb-user {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 3px;
}

.lb-cat {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  margin-bottom: 14px;
}

.lb-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }

.lb-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 3px;
  padding: 3px 8px;
}

.lb-date {
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(255,255,255,0.25);
}

.lb-btns { display: flex; flex-direction: column; gap: 7px; }

.lb-btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border-radius: var(--r-sm);
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: background var(--t), color var(--t);
  width: 100%;
  display: block;
}
.lb-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.lb-btn.primary { background: #fff; color: #000; border-color: transparent; }
.lb-btn.primary:hover { opacity: 0.9; }
.lb-btn.danger { color: var(--red); border-color: rgba(214,76,76,0.2); background: var(--red-dim); }
.lb-btn.danger:hover { background: rgba(214,76,76,0.2); }

/* ===================== UTILS ===================== */
.hidden { display: none !important; }

/* ---- Sidebar bottom links ---- */
.sidebar-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.sidebar-txt-btn {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: color var(--t);
}
.sidebar-txt-btn:hover { color: var(--text-2); }

.sidebar-sep {
  font-size: 10px;
  color: var(--border2);
  user-select: none;
}

/* ---- Modal md size ---- */
.modal.md { max-width: 540px; }

/* ---- Guide modal ---- */
.guide-body {
  padding: 0 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 70vh;
  overflow-y: auto;
}

.guide-intro {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.65;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.guide-section { display: flex; flex-direction: column; gap: 5px; }

.guide-heading {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.guide-text {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.65;
}

.guide-link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.guide-link:hover { color: var(--text-2); }

/* ---- field-note ---- */
.field-note { font-size: 13px; color: var(--text-2); margin-bottom: 4px; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 720px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .gallery { padding: 16px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .topbar { padding: 10px 16px; }
  .lb-wrap { flex-direction: column; align-items: center; }
  .lb-img { width: min(300px, 85vw); height: min(300px, 85vw); }
}
