:root {
  color-scheme: dark;
  --bg: #070b13;
  --surface: #0d1421;
  --surface-2: #111a2a;
  --surface-3: #151f31;
  --border: #1d2a3e;
  --border-soft: #172235;
  --text: #f5f8ff;
  --muted: #8995aa;
  --muted-2: #667389;
  --accent: #6d88ff;
  --accent-strong: #5573ff;
  --accent-soft: #19264e;
  --good: #48d597;
  --danger: #ff6477;
  --warning: #f5c266;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font: inherit;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

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

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border-soft);
  background: #090e18;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 26px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent-strong), #795cff);
  box-shadow: 0 8px 24px rgba(85, 115, 255, 0.28);
}

.brand-block strong {
  display: block;
  font-size: 14px;
}

.brand-block span {
  display: block;
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: #8895aa;
  border-radius: 11px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  transition: all .18s ease;
}

.nav-item:hover {
  color: #dce4f4;
  background: #0e1624;
}

.nav-item.active {
  color: #ffffff;
  background: #121c2d;
  border-color: #1e2d45;
}

.nav-icon {
  width: 22px;
  text-align: center;
  color: #8fa3ff;
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.server-status {
  border: 1px solid var(--border-soft);
  background: #0c131f;
  border-radius: 12px;
  padding: 11px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.server-status > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(72, 213, 151, 0.12);
  flex: 0 0 auto;
}

.server-status b, .server-status small {
  display: block;
}

.server-status b {
  font-size: 11px;
  font-weight: 700;
}

.server-status small {
  color: var(--muted-2);
  font-size: 10px;
  margin-top: 2px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px;
  background: #0d1420;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}

.sidebar-user img, .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #182239;
}

.sidebar-user strong, .sidebar-user small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 145px;
}

.sidebar-user strong {
  font-size: 11px;
}

.sidebar-user small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

/* Main Content & Topbar */
.main-content {
  min-width: 0;
  padding: 28px clamp(20px, 4vw, 56px) 60px;
}

.topbar {
  min-height: 62px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 26px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 30px;
  letter-spacing: -.04em;
}

.eyebrow {
  margin: 0;
  color: #7f96fa;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
}

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

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 6px 10px 6px 6px;
}

.user-menu img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.user-menu span {
  font-size: 12px;
  font-weight: 600;
}

.user-menu button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 14px;
}

.user-menu button:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
}

/* Buttons */
.primary-button, .secondary-button, .discord-button, .danger-button, .icon-button, .text-button, .primary-mini, .icon-mini {
  border: 0;
  border-radius: 10px;
  text-decoration: none;
  transition: all .18s ease;
}

.primary-button {
  color: white;
  background: var(--accent-strong);
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13px;
}

.primary-button:hover {
  background: #6782ff;
  transform: translateY(-1px);
}

.secondary-button {
  color: #c9d2e5;
  background: #121c2b;
  border: 1px solid var(--border);
  padding: 9px 13px;
  font-size: 12px;
}

.secondary-button:hover {
  border-color: #314364;
  color: #ffffff;
}

.discord-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: #5865f2;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 13px;
}

.discord-button:hover {
  filter: brightness(1.08);
}

.discord-button.compact {
  width: 100%;
  font-size: 12px;
}

.danger-button {
  color: #ffdce1;
  background: #2a151d;
  border: 1px solid #4a202c;
  padding: 9px 13px;
  font-size: 12px;
}

.danger-button:hover {
  border-color: #7a3040;
  background: #341a24;
}

.text-button {
  background: transparent;
  color: #8da3ff;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
}

.text-button:hover {
  color: #b3c0ff;
}

.icon-button {
  width: 40px;
  height: 40px;
  color: #ffffff;
  background: var(--surface);
  border: 1px solid var(--border);
}

.mobile-only {
  display: none;
}

/* Notice Banner */
.notice-card {
  margin-bottom: 20px;
  border: 1px solid #324672;
  background: #111b30;
  border-radius: 13px;
  padding: 13px 16px;
  color: #cbd6ef;
  font-size: 13px;
  line-height: 1.5;
}

.notice-card.error {
  border-color: #5e2935;
  background: #24141a;
  color: #ffd1d8;
}

/* Views */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.stat-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: 15px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.stat-card strong {
  display: block;
  margin: 10px 0 4px;
  font-size: clamp(24px, 2.5vw, 32px);
  letter-spacing: -.03em;
  color: #ffffff;
}

.stat-card small {
  color: var(--muted-2);
  font-size: 10px;
}

/* Panels */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .85fr);
  gap: 14px;
  margin-bottom: 14px;
}

.lower-grid {
  grid-template-columns: 1fr 1fr;
}

.lower-grid:has(#topUploadersPanel.hidden) {
  grid-template-columns: 1fr;
}

.panel {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: 16px;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
}

.panel-heading h2 {
  margin: 4px 0 0;
  font-size: 17px;
  letter-spacing: -.02em;
}

.soft-badge {
  color: #9cadcf;
  background: #111c2d;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

/* Form Inputs & Selects */
.select-input, .search-box input, .collection-create-form input, .token-row input {
  color: #dbe3f3;
  background: #0b121e;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  font-size: 12px;
}

.select-input {
  padding: 9px 32px 9px 12px;
  max-width: 220px;
  appearance: none;
  -webkit-appearance: none;
  background: #0b121e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238995aa' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") no-repeat right 12px center;
  cursor: pointer;
}

.select-input:focus, .search-box input:focus, .collection-create-form input:focus, .token-row input:focus {
  border-color: #40588e;
}

.upload-options {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.privacy-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

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

.privacy-toggle-label {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b121e;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .18s ease;
}

.privacy-toggle:hover .privacy-toggle-label {
  border-color: #314468;
  color: #dce4f4;
}

.privacy-toggle input:checked + .privacy-toggle-label {
  background: #251a10;
  border-color: #5c3e1e;
  color: #f5c266;
  box-shadow: 0 0 0 1px #5c3e1e inset;
}

/* Dropzone */
.dropzone {
  min-height: 180px;
  border: 1px dashed #2d3c58;
  border-radius: 13px;
  background: #0a111d;
  padding: 24px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  transition: all .18s ease;
  outline: none;
}

.dropzone:hover, .dropzone.dragging, .dropzone:focus-visible {
  border-color: #5973db;
  background: #0d1627;
}

.dropzone.disabled {
  opacity: .55;
  cursor: not-allowed;
}

.upload-icon {
  width: 50px;
  height: 50px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: #9cafef;
  font-size: 23px;
}

.dropzone h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

.dropzone p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.token-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.token-row input {
  padding: 9px 12px;
}

.token-row button {
  border: 0;
  color: #bac7ff;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
}

/* Upload Queue */
.upload-queue {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.queue-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: #0b121d;
}

.queue-file {
  min-width: 0;
}

.queue-file strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.queue-file small {
  display: block;
  color: var(--muted-2);
  margin-top: 3px;
  font-size: 9px;
}

.queue-progress {
  height: 4px;
  border-radius: 99px;
  margin-top: 7px;
  background: #172235;
  overflow: hidden;
}

.queue-progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width .12s linear;
}

.queue-status {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.queue-item.success .queue-status {
  color: var(--good);
}

.queue-item.error .queue-status {
  color: var(--danger);
}

/* Activity Chart */
.activity-chart {
  height: 190px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 8px;
  padding-top: 10px;
}

.chart-column {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  gap: 8px;
}

.chart-bar-wrap {
  flex: 1;
  display: flex;
  align-items: end;
  justify-content: center;
}

.chart-bar {
  width: min(30px, 72%);
  min-height: 4px;
  background: linear-gradient(180deg, #718bff, #445dcb);
  border-radius: 7px 7px 3px 3px;
  position: relative;
}

.chart-bar:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: #182235;
  border: 1px solid #2c3d59;
  border-radius: 7px;
  padding: 5px 8px;
  color: #ffffff;
  font-size: 9px;
  z-index: 4;
  pointer-events: none;
}

.chart-label {
  color: var(--muted-2);
  font-size: 10px;
  text-align: center;
}

/* Lists */
.people-list {
  display: grid;
  gap: 8px;
}

.person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #0b121e;
  border: 1px solid var(--border-soft);
}

.person-row img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.person-row div {
  min-width: 0;
  flex: 1;
}

.person-row strong, .person-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-row strong {
  font-size: 11px;
}

.person-row small {
  color: var(--muted-2);
  font-size: 10px;
  margin-top: 2px;
}

.person-row > span {
  color: #9fb0ff;
  font-size: 10px;
  font-weight: 600;
}

.collection-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.collection-summary-item {
  min-width: 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: #0b121e;
  color: inherit;
  text-align: left;
  transition: border-color .18s ease;
}

.collection-summary-item:hover {
  border-color: #2b3d5b;
}

.collection-summary-item strong {
  display: block;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-summary-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 10px;
}

.empty-inline {
  color: var(--muted-2);
  font-size: 11px;
  padding: 14px 2px;
}

/* Gallery View */
.gallery-toolbar-panel {
  padding: 12px;
  margin-bottom: 14px;
}

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

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 200px;
  min-width: 180px;
  background: #0b121e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding-left: 12px;
  color: var(--muted-2);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 9px 10px 9px 0;
}

.selection-bar {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.selection-bar > span {
  margin-right: auto;
  color: var(--muted);
  font-size: 11px;
}

.gallery-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
  margin: 14px 2px 10px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.image-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: 14px;
  overflow: visible;
  transition: all .18s ease;
}

.image-card:hover {
  border-color: #2b3b58;
  transform: translateY(-1px);
}

.image-card.selected {
  border-color: #6680ef;
  box-shadow: 0 0 0 1px #6680ef inset;
}

.image-card.menu-open {
  z-index: 50;
}

.preview-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #050912;
  border-radius: 13px 13px 0 0;
  overflow: hidden;
  aspect-ratio: 16 / 10;
}

.preview {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform .25s ease;
}

.image-card:hover .preview {
  transform: scale(1.02);
}

.card-body {
  padding: 12px;
  position: relative;
}

.card-topline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.more-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 3px 6px;
  letter-spacing: 1px;
  font-size: 12px;
}

.more-button:hover {
  color: #ffffff;
}

.card-meta {
  min-height: 19px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.dimensions {
  color: var(--muted-2);
  font-size: 10px;
}

.collection-pill {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #9cafef;
  background: #142043;
  border: 1px solid #243563;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 9px;
  font-weight: 600;
}

.privacy-badge {
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f5c266;
  background: #251a10;
  border: 1px solid #4a341e;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 9px;
  font-weight: 600;
}

.uploader-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.uploader-avatar-wrap {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #172235;
  color: #6f7d94;
  font-size: 9px;
  font-weight: 700;
  flex: 0 0 auto;
}

.uploader-avatar-wrap img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

.uploader-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #aeb9cd;
  font-size: 10px;
}

.upload-date {
  color: var(--muted-2);
  font-size: 9px;
  white-space: nowrap;
}

.card-primary-actions {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 7px;
  margin-top: 10px;
}

.primary-mini {
  color: #dce4ff;
  background: #182754;
  border: 1px solid #293f7c;
  padding: 7px 8px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
}

.primary-mini:hover {
  background: #20336c;
}

.icon-mini {
  display: grid;
  place-items: center;
  color: #b8c2d6;
  background: #111a29;
  border: 1px solid var(--border);
  font-size: 12px;
  border-radius: 10px;
}

.icon-mini:hover {
  border-color: #314364;
  color: #ffffff;
}

.card-menu {
  position: absolute;
  right: 8px;
  top: 36px;
  z-index: 60;
  width: 160px;
  padding: 6px;
  border: 1px solid #334466;
  background: #0c1524;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
}

.card-menu button {
  width: 100%;
  border: 0;
  background: transparent;
  color: #c2ccdc;
  padding: 8px 10px;
  border-radius: 7px;
  text-align: left;
  font-size: 11px;
}

.card-menu button:hover {
  background: #182337;
  color: #ffffff;
}

.card-menu .danger-text {
  color: #ff8997;
}

.select-check {
  position: absolute;
  z-index: 6;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  border: 1px solid #425271;
  background: #0c1422;
  border-radius: 7px;
  padding: 4px;
}

.select-check span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

.image-card.selected .select-check span {
  background: var(--accent);
}

.empty-state {
  border: 1px dashed #26364f;
  background: #0a111c;
  border-radius: 15px;
  padding: 55px 20px;
  text-align: center;
  margin: 14px 0;
}

.empty-state > div {
  color: #5870d8;
  font-size: 34px;
}

.empty-state h3 {
  margin: 10px 0 4px;
  font-size: 15px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
}

.pagination button {
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #aeb9cb;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
}

.pagination button.active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #ffffff;
}

.pagination button:disabled {
  opacity: .35;
  cursor: default;
}

/* Collections View */
.collections-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.collections-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.collection-create-form {
  display: flex;
  gap: 8px;
}

.collection-create-form input {
  width: 240px;
  padding: 10px 12px;
}

.collections-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.collection-card {
  padding: 18px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  border-radius: 14px;
}

.collection-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.collection-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #16234a;
  color: #8ea2ff;
  font-size: 16px;
}

.collection-card-head > div:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.collection-card h3 {
  margin: 1px 0 4px;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-card p {
  margin: 0;
  color: var(--muted-2);
  font-size: 10px;
}

.collection-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.collection-card-actions button {
  flex: 1;
}

/* Lightbox & Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(1, 4, 9, 0.88);
  display: grid;
  place-items: center;
  padding: 28px;
}

.lightbox-card {
  width: min(1120px, 100%);
  max-height: 92vh;
  position: relative;
  border: 1px solid #263650;
  background: #0b111c;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.6);
}

.upload-modal-card {
  width: min(680px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #0b111c;
  border: 1px solid #263650;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.7);
}

.rename-modal-card {
  width: min(480px, 100%);
  background: #0b111c;
  border: 1px solid #263650;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-header h3 {
  margin: 2px 0 0;
  font-size: 16px;
  letter-spacing: -.02em;
}

.upload-modal-settings {
  padding: 16px 20px;
  background: #080d16;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.upload-setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.visibility-segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented-option {
  flex: 1;
  min-width: 220px;
  cursor: pointer;
  position: relative;
}

.segmented-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0d1624;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: all .18s ease;
  text-align: center;
}

.segmented-option:hover .segmented-label {
  border-color: #314468;
  color: #dce4f4;
}

.segmented-option input:checked + .segmented-label {
  background: #131f38;
  border-color: #5572d4;
  color: #ffffff;
  box-shadow: 0 0 0 1px #5572d4 inset;
}

.modal-select {
  width: 100%;
  max-width: none;
}

.upload-staged-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 20px 8px;
}

.staged-list-title {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
}

.staged-list-hint {
  font-size: 11px;
  color: var(--muted-2);
}

.upload-staged-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
}

.staged-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  background: #0d1522;
  border: 1px solid var(--border-soft);
}

.staged-item-preview {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #05080e;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.staged-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.staged-name-input {
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  background: #070c14;
  border: 1px solid var(--border);
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  outline: none;
}

.staged-name-input:focus {
  border-color: #5572d4;
}

.staged-item-size {
  font-size: 10px;
  color: var(--muted-2);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  background: #080d16;
}

.modal-body-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-text-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  background: #070c14;
  border: 1px solid var(--border);
  color: #ffffff;
  font-size: 13px;
  outline: none;
}

.modal-text-input:focus {
  border-color: #5572d4;
}

.lightbox-media {
  min-height: 420px;
  max-height: calc(92vh - 86px);
  display: grid;
  place-items: center;
  background: #03060c;
}

.lightbox-media img {
  max-width: 100%;
  max-height: calc(92vh - 110px);
  object-fit: contain;
}

.modal-close {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #344158;
  background: #0c1421;
  color: white;
  font-size: 20px;
  display: grid;
  place-items: center;
}

.lightbox-nav {
  position: absolute;
  z-index: 4;
  top: 45%;
  width: 42px;
  height: 52px;
  border: 1px solid #344158;
  background: #0c1421;
  color: white;
  border-radius: 10px;
  font-size: 30px;
}

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

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

.lightbox-info {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
}

.lightbox-title {
  min-width: 0;
}

.lightbox-title strong, .lightbox-title span {
  display: block;
}

.lightbox-title strong {
  max-width: 620px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.lightbox-title span {
  color: var(--muted);
  margin-top: 4px;
  font-size: 10px;
}

.lightbox-actions {
  display: flex;
  gap: 8px;
}

/* Toast */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  max-width: min(420px, calc(100% - 28px));
  padding: 12px 16px;
  border: 1px solid #2b3b56;
  background: #121c2b;
  border-radius: 11px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: #642c39;
  color: #ffd3d9;
  background: #231218;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.65);
}

/* Responsive Media Queries */
@media (max-width: 1200px) {
  .gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-101%);
    width: 248px;
    transition: transform .2s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-only {
    display: inline-grid;
    place-items: center;
  }
  .dashboard-grid, .lower-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .collections-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .main-content {
    padding: 18px 14px 44px;
  }
  .topbar {
    align-items: center;
    margin-bottom: 18px;
  }
  .topbar h1 {
    font-size: 24px;
  }
  #quickUploadButton {
    display: none;
  }
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .collections-header {
    align-items: stretch;
    flex-direction: column;
  }
  .collection-create-form input {
    width: 100%;
    min-width: 0;
    flex: 1;
  }
  .lightbox-info {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .stats-grid, .gallery, .collections-grid {
    grid-template-columns: 1fr;
  }
  .topbar-actions .user-menu span {
    display: none;
  }
  .dropzone {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }
  .collection-summary {
    grid-template-columns: 1fr;
  }
  .modal-backdrop {
    padding: 8px;
  }
  .lightbox-media {
    min-height: 300px;
  }
  .lightbox-nav {
    top: 38%;
  }
}
