/* ============================================================
   PRISM Image CDN — Stylesheet
   Covers: index.php · login.php · media-picker.html
   Link in each page:
     <link rel="stylesheet" href="/prism.css" />
   Then remove the entire <style>…</style> block from each file.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@600;700;800;900&family=DM+Mono:wght@300;400;500&display=swap');


/* ═══════════════════════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════════════════════ */

:root {
  --ink:     #0a0a0f;
  --ink2:    #1a1a26;
  --ink3:    #2a2a3a;
  --muted:   #6b6b85;
  --border:  #2e2e42;
  --surface: #13131e;
  --card:    #18182a;
  --accent:  #7c6dfa;
  --accent2: #f97b6b;
  --green:   #4ade9a;
  --yellow:  #f0d060;
  --cyan:    #60d8f0;
  --paper:   #f5f4f0;
  --glow:    rgba(124, 109, 250, 0.35);
}


/* ═══════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════ */

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

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Mono', monospace;
  background: var(--ink);
  color: var(--paper);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise overlay */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--ink2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.font-display { font-family: 'Syne', sans-serif; }


/* ═══════════════════════════════════════════════════════════
   INDEX — SIDEBAR
═══════════════════════════════════════════════════════════ */

#sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  display: flex; align-items: center; gap: 10px;
  font-family: 'Syne', sans-serif;
  font-weight: 800; font-size: 22px; letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-mark img { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }

.logo-sub {
  font-size: 10px; color: var(--muted);
  letter-spacing: 2px; text-transform: uppercase; margin-top: 2px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; font-size: 12px;
  color: var(--muted); cursor: pointer;
  transition: all .2s; border-left: 2px solid transparent;
  text-transform: uppercase; letter-spacing: 1px;
  font-family: 'Syne', sans-serif; font-weight: 600;
}
.nav-item:hover { color: var(--paper); background: var(--ink2); }
.nav-item.active {
  color: var(--accent); border-left-color: var(--accent);
  background: rgba(124, 109, 250, .08);
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* Sidebar overlay (mobile drawer) */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 99;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.show { display: block; }


/* ═══════════════════════════════════════════════════════════
   INDEX — MAIN / TOPBAR
═══════════════════════════════════════════════════════════ */

#main { margin-left: 220px; min-height: 100vh; }

#topbar {
  position: sticky; top: 0;
  background: rgba(10, 10, 15, .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; gap: 16px;
  z-index: 50;
}

/* Hamburger — hidden on desktop */
#menu-toggle {
  display: none;
  background: none; border: 1px solid var(--border);
  color: var(--paper); width: 34px; height: 34px; border-radius: 8px;
  cursor: pointer; font-size: 18px;
  align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .2s;
}
#menu-toggle:hover { border-color: var(--accent); color: var(--accent); }

.page-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 16px; }

.search-wrap { position: relative; flex: 1; max-width: 380px; }
.search-input {
  width: 100%; background: var(--ink2);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px 8px 36px;
  font-family: 'DM Mono', monospace; font-size: 12px;
  color: var(--paper); outline: none; transition: border-color .2s;
}
.search-input:focus { border-color: var(--accent); }
.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); color: var(--muted); font-size: 14px;
}

.stats-badge {
  font-size: 11px; color: var(--muted);
  background: var(--ink2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 20px; white-space: nowrap;
}

.btn-upload {
  background: linear-gradient(135deg, var(--accent), #9d6dfa);
  color: #fff; border: none; border-radius: 8px;
  padding: 8px 18px; font-family: 'Syne', sans-serif;
  font-size: 12px; font-weight: 700; cursor: pointer;
  letter-spacing: 0.5px; transition: transform .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn-upload:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--glow); }

.view-toggle { display: flex; gap: 4px; }
.view-btn {
  width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.view-btn.active { background: var(--ink2); border-color: var(--accent); color: var(--accent); }


/* ═══════════════════════════════════════════════════════════
   INDEX — UPLOAD
═══════════════════════════════════════════════════════════ */

#upload-zone {
  margin: 28px; border: 2px dashed var(--border);
  border-radius: 16px; padding: 48px 24px;
  text-align: center; cursor: pointer;
  transition: all .25s; background: var(--surface);
  position: relative; overflow: hidden;
}
#upload-zone.dragover {
  border-color: var(--accent); background: rgba(124, 109, 250, .07);
  transform: scale(1.005); box-shadow: 0 0 40px var(--glow);
}
#upload-zone.hidden { display: none; }

.upload-icon { font-size: 48px; margin-bottom: 12px; opacity: .7; }
.upload-title { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.upload-sub { font-size: 11px; color: var(--muted); }
.upload-formats { margin-top: 12px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

.fmt-chip {
  font-size: 10px; padding: 3px 8px; border-radius: 4px;
  background: var(--ink2); border: 1px solid var(--border);
  color: var(--muted); letter-spacing: 1px;
}
#file-input { display: none; }

#upload-queue { margin: 0 28px 28px; display: flex; flex-direction: column; gap: 10px; }
.queue-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
}
.queue-thumb {
  width: 48px; height: 48px; border-radius: 8px;
  object-fit: cover; background: var(--ink2); flex-shrink: 0;
}
.queue-info { flex: 1; min-width: 0; }
.queue-name {
  font-size: 13px; font-family: 'Syne', sans-serif; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.queue-size { font-size: 11px; color: var(--muted); margin-top: 2px; }
.queue-progress-wrap { margin-top: 8px; height: 3px; background: var(--ink2); border-radius: 2px; overflow: hidden; }
.queue-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px; transition: width .3s;
}
.queue-status { font-size: 11px; color: var(--muted); white-space: nowrap; }
.queue-status.done  { color: var(--green); }
.queue-status.error { color: var(--accent2); }


/* ═══════════════════════════════════════════════════════════
   INDEX — IMAGE GRID
═══════════════════════════════════════════════════════════ */

#image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; padding: 0 28px 28px;
}

.grid-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  position: relative;
}
.grid-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  border-color: var(--accent);
}

.grid-thumb-wrap { aspect-ratio: 1; overflow: hidden; background: var(--ink2); position: relative; }
.grid-thumb { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.grid-item:hover .grid-thumb { transform: scale(1.06); }

.grid-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(10, 10, 15, .85) 0%, transparent 55%);
  opacity: 0; transition: opacity .2s;
  display: flex; align-items: flex-end; padding: 10px;
}
.grid-item:hover .grid-overlay { opacity: 1; }
.grid-overlay-text { font-size: 10px; color: var(--paper); font-family: 'Syne', sans-serif; font-weight: 600; }

.grid-meta { padding: 10px 12px; }
.grid-name { font-size: 12px; font-family: 'Syne', sans-serif; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-info { font-size: 10px; color: var(--muted); margin-top: 3px; }
.grid-formats { display: flex; gap: 4px; margin-top: 6px; }
.grid-fmt {
  font-size: 9px; padding: 2px 6px; border-radius: 3px;
  background: var(--ink2); color: var(--muted); border: 1px solid var(--border);
}
.grid-fmt.webp { color: var(--cyan); border-color: rgba(96, 200, 240, .3); }
.grid-fmt.avif { color: #a0e87a; border-color: rgba(160, 232, 122, .3); }

/* List view */
#image-grid.list-view { grid-template-columns: 1fr; }
#image-grid.list-view .grid-item { display: flex; border-radius: 10px; }
#image-grid.list-view .grid-thumb-wrap { aspect-ratio: unset; width: 72px; height: 72px; flex-shrink: 0; border-radius: 8px 0 0 8px; }
#image-grid.list-view .grid-overlay { display: none; }
#image-grid.list-view .grid-meta { display: flex; align-items: center; gap: 24px; flex: 1; padding: 0 16px; }
#image-grid.list-view .grid-info { margin: 0; }


/* ═══════════════════════════════════════════════════════════
   INDEX — EMPTY / PAGINATION
═══════════════════════════════════════════════════════════ */

#empty-state { text-align: center; padding: 80px 24px; display: none; }
#empty-state.show { display: block; }
.empty-icon { font-size: 56px; opacity: .3; margin-bottom: 16px; }
.empty-title { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; color: var(--muted); }
.empty-sub { font-size: 12px; color: var(--muted); margin-top: 6px; opacity: .7; }

#pagination { display: flex; gap: 8px; justify-content: center; padding: 20px 28px 40px; }
.page-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-family: 'DM Mono', monospace; font-size: 12px;
  cursor: pointer; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-btn:disabled { opacity: .3; cursor: not-allowed; }


/* ═══════════════════════════════════════════════════════════
   INDEX — DETAILS PANEL
═══════════════════════════════════════════════════════════ */

#details-panel {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 420px; background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200; transform: translateX(100%);
  transition: transform .3s cubic-bezier(.25, .8, .25, 1);
  display: flex; flex-direction: column; overflow: hidden;
}
#details-panel.open { transform: translateX(0); }

.panel-header {
  padding: 20px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
}
.panel-preview { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--ink2); flex-shrink: 0; }
.panel-title { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; word-break: break-all; }
.panel-dims { font-size: 11px; color: var(--muted); margin-top: 3px; }
.close-btn {
  margin-left: auto; background: none; border: 1px solid var(--border);
  color: var(--muted); width: 30px; height: 30px; border-radius: 7px;
  cursor: pointer; font-size: 16px; transition: all .2s; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.close-btn:hover { border-color: var(--accent2); color: var(--accent2); }
.panel-body { flex: 1; overflow-y: auto; padding: 18px 22px; }

.variant-section { margin-bottom: 20px; }
.variant-section-title {
  font-family: 'Syne', sans-serif; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 2px; color: var(--muted);
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.variant-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.variant-row {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 6px;
  display: flex; align-items: center; gap: 10px;
}
.variant-label {
  font-family: 'Syne', sans-serif; font-size: 11px; font-weight: 700;
  min-width: 80px; text-transform: uppercase; letter-spacing: .5px;
}
.variant-url { flex: 1; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copy-btn {
  background: var(--ink2); border: 1px solid var(--border);
  color: var(--muted); border-radius: 6px; padding: 4px 8px;
  font-size: 10px; cursor: pointer; font-family: 'DM Mono', monospace;
  transition: all .2s; white-space: nowrap; flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: var(--green); color: var(--green); }
.variant-dims { font-size: 10px; color: var(--muted); white-space: nowrap; }

.delete-btn {
  width: 100%; margin-top: 8px;
  background: none; border: 1px solid rgba(249, 123, 107, .3);
  color: var(--accent2); border-radius: 8px; padding: 10px;
  font-family: 'Syne', sans-serif; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: all .2s;
}
.delete-btn:hover { background: rgba(249, 123, 107, .1); border-color: var(--accent2); }

/* Format tabs */
.fmt-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.fmt-tab {
  font-size: 11px; padding: 5px 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--ink2);
  color: var(--muted); cursor: pointer; font-family: 'Syne', sans-serif;
  font-weight: 700; transition: all .15s; text-transform: uppercase;
}
.fmt-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Title editor */
.title-editor-wrap { padding: 14px 22px 0; border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.title-editor-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--muted); font-family: 'Syne', sans-serif; font-weight: 600; margin-bottom: 6px;
}
.title-editor-row { display: flex; gap: 8px; align-items: center; }
.title-input {
  flex: 1; background: var(--ink2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px;
  font-family: 'DM Mono', monospace; font-size: 13px;
  color: var(--paper); outline: none; transition: border-color .2s;
}
.title-input:focus { border-color: var(--accent); }
.title-input::placeholder { color: var(--muted); }
.title-save-btn {
  background: var(--accent); border: none; border-radius: 8px;
  color: #fff; padding: 8px 14px; font-family: 'Syne', sans-serif;
  font-size: 11px; font-weight: 700; cursor: pointer; transition: opacity .15s; white-space: nowrap;
}
.title-save-btn:hover { opacity: .85; }
.title-save-btn:disabled { opacity: .4; cursor: not-allowed; }
.title-saved-msg { font-size: 11px; color: var(--green); display: none; }


/* ═══════════════════════════════════════════════════════════
   INDEX — OVERLAY / TOAST / UTILITIES
═══════════════════════════════════════════════════════════ */

#overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .5);
  z-index: 190; opacity: 0; pointer-events: none; transition: opacity .3s;
  backdrop-filter: blur(2px);
}
#overlay.show { opacity: 1; pointer-events: auto; }

#toast-container {
  position: fixed; bottom: 28px; right: 28px;
  z-index: 500; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 18px;
  font-size: 12px; font-family: 'DM Mono', monospace;
  animation: toastIn .25s ease; max-width: 300px;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--accent2); }
.toast.info    { border-left: 3px solid var(--accent); }

.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
.skeleton {
  background: linear-gradient(90deg, var(--ink2) 25%, var(--ink3) 50%, var(--ink2) 75%);
  background-size: 200%; animation: shimmer 1.5s infinite; border-radius: 8px;
}
.processor-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  background: rgba(124, 109, 250, .15); color: var(--accent);
  border: 1px solid rgba(124, 109, 250, .3); letter-spacing: 1px;
  font-family: 'Syne', sans-serif; font-weight: 700;
}


/* ═══════════════════════════════════════════════════════════
   INDEX — API KEYS
═══════════════════════════════════════════════════════════ */

.api-section { padding: 0 28px 28px; }
.api-section-title { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.api-section-sub { font-size: 11px; color: var(--muted); margin-bottom: 24px; }

.key-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px; margin-bottom: 10px;
}
.key-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.key-name { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px; min-width: 0; }
.key-prefix {
  font-size: 11px; color: var(--accent);
  background: rgba(124, 109, 250, .1); padding: 2px 8px;
  border-radius: 4px; border: 1px solid rgba(124, 109, 250, .25);
  font-family: 'DM Mono', monospace; white-space: nowrap;
}
.key-status {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  font-family: 'Syne', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
}
.key-status.active  { background: rgba(74, 222, 154, .1); color: var(--green); border: 1px solid rgba(74, 222, 154, .25); }
.key-status.revoked { background: rgba(249, 123, 107, .1); color: var(--accent2); border: 1px solid rgba(249, 123, 107, .25); }

.key-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.key-perm { font-size: 10px; padding: 2px 6px; border-radius: 3px; background: var(--ink2); border: 1px solid var(--border); }
.key-perm.upload { color: var(--yellow); border-color: rgba(240, 192, 96, .3); }
.key-perm.read   { color: var(--cyan);   border-color: rgba(96, 200, 240, .3); }
.key-actions { margin-left: auto; display: flex; gap: 6px; }
.key-revoke-btn {
  font-size: 11px; padding: 5px 12px; border-radius: 6px;
  border: 1px solid rgba(249, 123, 107, .3); background: none; color: var(--accent2);
  cursor: pointer; font-family: 'Syne', sans-serif; font-weight: 700; transition: all .15s;
}
.key-revoke-btn:hover { background: rgba(249, 123, 107, .1); }

.new-key-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 20px;
}
.new-key-form-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; margin-bottom: 14px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.form-field { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 140px; }
.form-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--muted); font-family: 'Syne', sans-serif; font-weight: 600;
}
.form-input {
  background: var(--ink2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-family: 'DM Mono', monospace; font-size: 12px;
  color: var(--paper); outline: none; transition: border-color .2s; width: 100%;
}
.form-input:focus { border-color: var(--accent); }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b6b85'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
}
.btn-create-key {
  background: linear-gradient(135deg, var(--accent), #9d6dfa); color: #fff;
  border: none; border-radius: 8px; padding: 9px 20px;
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 12px;
  cursor: pointer; transition: opacity .15s;
}
.btn-create-key:hover { opacity: .85; }

.key-reveal {
  background: var(--ink); border: 1px solid var(--accent);
  border-radius: 10px; padding: 16px; margin-bottom: 16px;
  animation: fadeIn .3s ease;
}
.key-reveal-warn { font-size: 11px; color: var(--accent2); margin-bottom: 8px; }
.key-reveal-val {
  font-family: 'DM Mono', monospace; font-size: 12px; color: var(--green);
  word-break: break-all; background: rgba(74, 222, 154, .05);
  border: 1px solid rgba(74, 222, 154, .2); border-radius: 6px;
  padding: 10px 12px; cursor: pointer; transition: background .15s;
  user-select: all; -webkit-user-select: all;
}
.key-reveal-val:hover { background: rgba(74, 222, 154, .1); }
.key-reveal-hint { font-size: 10px; color: var(--muted); margin-top: 6px; }

.embed-box {
  background: var(--ink2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-family: 'DM Mono', monospace; font-size: 10px;
  color: var(--muted); cursor: pointer; word-break: break-all; margin-top: 8px;
  transition: border-color .15s; white-space: pre-wrap; line-height: 1.6;
  user-select: all; -webkit-user-select: all;
}
.embed-box:hover { border-color: var(--accent); }


/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════════ */

/* login.php needs: html,body { height:100%; } body { display:flex; align-items:center; justify-content:center; } */

.login-wrap {
  position: relative; z-index: 10;
  width: 100%; max-width: 400px; padding: 20px;
}
.login-card {
  background: var(--ink2); border: 1px solid var(--border);
  border-radius: 20px; padding: 44px 40px 40px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6), 0 0 0 1px rgba(124, 109, 250, .08);
  animation: cardIn .4s cubic-bezier(.25, .8, .25, 1) both;
}

.logo-area { text-align: center; margin-bottom: 36px; }
.logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: 20px;
  margin-bottom: 14px;
  box-shadow: 0 8px 32px var(--glow);
  overflow: hidden;
}
.logo-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.logo-name {
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 26px; letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-tagline { font-size: 11px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; margin-top: 4px; }

.field { margin-bottom: 18px; }
.field label {
  display: block; font-size: 10px; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--muted); margin-bottom: 7px;
  font-family: 'Syne', sans-serif; font-weight: 600;
}
.field input {
  width: 100%; background: var(--ink); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 14px;
  font-family: 'DM Mono', monospace; font-size: 13px;
  color: var(--paper); outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 109, 250, .15); }
.field input::placeholder { color: var(--muted); }

.btn-login {
  width: 100%; background: linear-gradient(135deg, var(--accent), #9d6dfa);
  color: #fff; border: none; border-radius: 10px;
  padding: 13px; font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 700;
  cursor: pointer; letter-spacing: 0.5px;
  transition: transform .15s, box-shadow .15s; margin-top: 6px;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 8px 30px var(--glow); }
.btn-login:active { transform: translateY(0); }

.login-error {
  background: rgba(249, 123, 107, .1); border: 1px solid rgba(249, 123, 107, .3);
  color: var(--accent2); border-radius: 8px; padding: 10px 14px;
  font-size: 12px; margin-bottom: 16px; display: none;
}
.login-error.show { display: block; }

.login-footer { text-align: center; margin-top: 24px; font-size: 11px; color: var(--muted); }


/* ═══════════════════════════════════════════════════════════
   MEDIA PICKER
═══════════════════════════════════════════════════════════ */

/* media-picker.html needs: html,body { height:100%; overflow:hidden; }
   body { display:flex; flex-direction:column; } */

/* Topbar */
#topbar.pm-topbar,
media-picker #topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--ink2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.pm-logo {
  display: flex; align-items: center; gap: 7px;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; white-space: nowrap;
}
.pm-logo img { width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; }

.pm-search {
  flex: 1; background: var(--ink3); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 10px 6px 28px;
  font-family: 'DM Mono', monospace; font-size: 11px; color: var(--paper);
  outline: none; transition: border-color .2s;
}
.pm-search:focus { border-color: var(--accent); }
.pm-search-wrap { position: relative; flex: 1; max-width: 260px; }
.pm-search-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 12px; pointer-events: none;
}
.pm-count { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* Body layout */
#body { flex: 1; display: flex; overflow: hidden; }
#grid-wrap { flex: 1; overflow-y: auto; padding: 12px; }
#grid-wrap ::-webkit-scrollbar { width: 4px; }
#pm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }

/* Detail panel */
#detail-panel {
  width: 220px; flex-shrink: 0; background: var(--ink2);
  border-left: 1px solid var(--border); display: flex; flex-direction: column;
  overflow-y: auto; transition: width .2s;
}
#detail-panel.empty { width: 0; border-left: none; overflow: hidden; }

.dp-preview { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--ink3); display: block; }
.dp-preview-wrap { position: relative; }
.dp-deselect {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px;
  background: rgba(10, 10, 15, .8); border: 1px solid var(--border); border-radius: 50%;
  color: var(--muted); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.dp-deselect:hover { background: var(--accent2); color: #fff; border-color: var(--accent2); }

.dp-body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.dp-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 12px; color: var(--paper); word-break: break-word; line-height: 1.4; }
.dp-dims { font-size: 10px; color: var(--muted); }
.dp-section-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--muted); font-family: 'Syne', sans-serif; font-weight: 700; margin-bottom: 4px;
}
.dp-select {
  width: 100%; background: var(--ink3); border: 1px solid var(--border); border-radius: 6px;
  color: var(--paper); font-family: 'DM Mono', monospace; font-size: 11px;
  padding: 6px 24px 6px 8px; outline: none; cursor: pointer; transition: border-color .2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b6b85'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.dp-select:focus { border-color: var(--accent); }
.dp-url-preview {
  font-size: 9px; color: var(--muted); word-break: break-all; line-height: 1.5;
  background: var(--ink3); border: 1px solid var(--border); border-radius: 5px;
  padding: 6px 8px; margin-top: 2px; min-height: 32px;
}
.dp-fmt-row { display: flex; gap: 6px; }
.dp-fmt-btn {
  flex: 1; padding: 5px 0; border-radius: 6px; border: 1px solid var(--border);
  background: var(--ink3); color: var(--muted); font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 10px; cursor: pointer; transition: all .15s; text-align: center;
}
.dp-fmt-btn:hover { border-color: var(--accent); color: var(--accent); }
.dp-fmt-btn.active { background: rgba(124, 109, 250, .15); border-color: var(--accent); color: var(--accent); }
.dp-fmt-btn.unavailable { opacity: .3; cursor: not-allowed; }

/* Grid items */
.pm-item {
  border-radius: 9px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: var(--ink2);
  transition: border-color .15s, transform .15s, box-shadow .15s; position: relative;
}
.pm-item:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(124, 109, 250, .3); }
.pm-item.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 109, 250, .3); }
.pm-thumb-wrap { aspect-ratio: 1; overflow: hidden; background: var(--ink3); }
.pm-thumb { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.pm-item:hover .pm-thumb { transform: scale(1.07); }
.pm-check {
  position: absolute; top: 5px; right: 5px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent); display: none;
  align-items: center; justify-content: center; font-size: 10px; color: #fff; font-weight: bold;
}
.pm-item.selected .pm-check { display: flex; }
.pm-label { padding: 5px 7px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }

/* Picker footer */
#footer.pm-footer,
.pm-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--ink2);
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.pm-selected-preview { font-size: 11px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-btn {
  padding: 7px 18px; border-radius: 8px; border: none;
  font-family: 'Syne', sans-serif; font-weight: 700; font-size: 12px;
  cursor: pointer; transition: opacity .15s;
}
.pm-btn:hover { opacity: .85; }
.pm-btn:disabled { opacity: .35; cursor: not-allowed; }
.pm-btn-cancel { background: var(--ink3); color: var(--muted); border: 1px solid var(--border); }
.pm-btn-insert { background: linear-gradient(135deg, var(--accent), #9d6dfa); color: #fff; }

/* Picker states */
.pm-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.pm-empty-icon { font-size: 40px; opacity: .3; margin-bottom: 10px; }
.pm-empty-txt { font-size: 12px; }
.pm-spinner {
  width: 24px; height: 24px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 60px auto;
}
.pm-error { color: var(--accent2); font-size: 11px; padding: 40px; text-align: center; }

/* Picker pagination */
#pm-pag { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
.pm-pg-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--ink2); color: var(--muted);
  font-size: 11px; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.pm-pg-btn:hover { border-color: var(--accent); color: var(--accent); }
.pm-pg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pm-pg-btn:disabled { opacity: .3; cursor: not-allowed; }

.dp-loading { display: flex; align-items: center; justify-content: center; padding: 40px; }
.dp-spinner {
  width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
}


/* ═══════════════════════════════════════════════════════════
   KEYFRAMES
═══════════════════════════════════════════════════════════ */

@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes shimmer   { to { background-position: -200% 0; } }
@keyframes toastIn   { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn    { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes cardIn    { from { opacity: 0; transform: translateY(20px) scale(.97); } to { opacity: 1; transform: none; } }


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — INDEX (≤768px)
═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.25, .8, .25, 1);
  }
  #sidebar.open { transform: translateX(0); }

  #main { margin-left: 0; }

  #menu-toggle { display: flex; }

  #topbar { padding: 10px 14px; gap: 8px; }
  .page-title { font-size: 14px; }
  .stats-badge { display: none; }
  #search-wrap { max-width: none; flex: 1; }

  .btn-upload { padding: 8px 12px; font-size: 0; }
  .btn-upload::before { content: '+'; font-size: 18px; font-weight: 700; }

  #logout-btn span { display: none; }
  #logout-btn { padding: 8px 10px; }

  #image-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 0 14px 20px; }
  #upload-zone { margin: 14px; padding: 32px 16px; }
  #upload-queue { margin: 0 14px 20px; }

  #details-panel {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%; height: 80vh;
    border-left: none; border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  #details-panel.open { transform: translateY(0); }

  .api-section { padding: 0 14px 20px; }
  .form-row { flex-direction: column; }
  .key-meta { gap: 8px; }
  .key-card-top { flex-wrap: wrap; gap: 8px; }
  .key-actions { width: 100%; justify-content: flex-end; }

  #pagination { padding: 16px 14px 28px; gap: 6px; }
  .page-btn { width: 30px; height: 30px; font-size: 11px; }

  #toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { max-width: none; }
}

@media (max-width: 480px) {
  #image-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .upload-title { font-size: 15px; }
  .upload-sub { font-size: 10px; }
  .view-toggle { display: none; }
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — LOGIN (≤480px)
═══════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  .login-wrap { padding: 12px; }
  .login-card { padding: 28px 20px 24px; border-radius: 16px; }
  .logo-icon { width: 56px; height: 56px; }
  .logo-name { font-size: 22px; }
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — MEDIA PICKER (≤600px)
═══════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  #body { flex-direction: column; }

  #detail-panel {
    width: 100% !important;
    border-left: none; border-top: 1px solid var(--border);
    flex-direction: row; max-height: 180px; overflow: hidden;
  }
  #detail-panel.empty { max-height: 0; border-top: none; }

  .dp-preview-wrap { width: 120px; flex-shrink: 0; }
  .dp-preview { width: 120px; height: 120px; aspect-ratio: unset; }
  .dp-deselect { top: 4px; right: 4px; width: 18px; height: 18px; font-size: 10px; }
  .dp-body { flex-direction: row; flex-wrap: wrap; gap: 6px; padding: 8px; overflow-y: auto; align-content: flex-start; }
  .dp-title { font-size: 11px; width: 100%; }
  .dp-dims { font-size: 9px; }
  .dp-section-label { font-size: 8px; margin-bottom: 2px; }
  .dp-select { font-size: 10px; padding: 4px 24px 4px 6px; }
  .dp-url-preview { display: none; }
  .dp-fmt-row { gap: 4px; }
  .dp-fmt-btn { font-size: 9px; padding: 3px 0; }

  #pm-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 6px; }
  #grid-wrap { padding: 8px; }

  .pm-logo img { width: 18px; height: 18px; }
  .pm-logo { font-size: 12px; }
  #pm-count { display: none; }

  .pm-btn { padding: 6px 12px; font-size: 11px; }
  .pm-selected-preview { font-size: 10px; }
}

@media (max-width: 380px) {
  #pm-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .pm-label { display: none; }
}
