:root {
  --primary: #0051c3;
  --primary-hover: #003a8c;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --input-bg: #ffffff;
  --badge-bg: #e2e8f0;
  --badge-text: #334155;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
}

:root[data-theme="dark"] {
  --primary: #38bdf8;
  --primary-hover: #0284c7;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --bg-color: #0b0f19;
  --card-bg: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --input-bg: #0f172a;
  --badge-bg: #334155;
  --badge-text: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

body { 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; 
  background: var(--bg-color); 
  color: var(--text-main); 
  padding: 24px 16px; 
  line-height: 1.5;
  transition: background-color 0.2s ease, color 0.2s ease;
}

header { 
  margin-bottom: 32px; 
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

.header-content {
  flex-grow: 1;
  text-align: center;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  color: var(--text-main);
}

header p {
  color: var(--text-muted);
  font-size: 14px;
}

.header-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.btn-theme {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, background-color 0.2s;
}

.btn-theme:hover {
  transform: rotate(25deg);
}

/* Lock Screen */
.lock-screen {
  min-height: 75vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: lockFadeIn 0.3s ease;
}

.lock-icon {
  font-size: 48px;
  margin-bottom: 2px;
}

.lock-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

.lock-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.lock-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.lock-card input[type="password"],
.lock-card input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text-main);
}

.badge-role {
  font-size: 11px;
  padding: 4px 10px;
  font-weight: 600;
}

.badge-role.admin {
  background: #dcfce7;
  color: #15803d;
}

.badge-role.viewer {
  background: #e0f2fe;
  color: #0369a1;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

@keyframes lockFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Upload Section */
.upload-section { 
  background: var(--card-bg); 
  padding: 24px; 
  border-radius: var(--radius-md); 
  max-width: 540px; 
  margin: 0 auto 40px; 
  box-shadow: var(--shadow-md); 
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-password-wrapper input {
  width: 100%;
  padding-right: 40px;
}

.btn-icon {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 15px;
  color: var(--text-muted);
}

.checkbox-row {
  margin-top: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.upload-section input[type="text"],
.upload-section input[type="password"] { 
  padding: 10px 14px; 
  border: 1px solid var(--border-color); 
  border-radius: var(--radius-sm); 
  font-size: 14px; 
  background: var(--input-bg);
  color: var(--text-main);
}

.upload-section input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 81, 195, 0.15);
}

/* Drop Zone */
.drop-zone {
  position: relative;
  border: 2px dashed #94a3b8;
  border-radius: var(--radius-sm);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-color);
  transition: border-color 0.2s, background-color 0.2s;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.08);
}

.drop-zone-prompt {
  pointer-events: none;
}

.drop-zone-prompt .upload-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 6px;
}

.drop-zone-prompt p {
  font-size: 14px;
  color: var(--text-main);
}

.drop-zone-prompt .highlight {
  color: var(--primary);
  font-weight: 600;
}

.drop-zone-prompt .file-hint {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Multi-file Queue Container */
.queue-container {
  margin-top: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.queue-thumb {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.queue-item-info {
  flex-grow: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.queue-item-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}

.queue-item-size {
  color: var(--text-muted);
  font-size: 11px;
}

.queue-item-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  flex-shrink: 0;
}

.queue-item-status.pending { background: var(--badge-bg); color: var(--badge-text); }
.queue-item-status.processing { background: #e0f2fe; color: #0369a1; }
.queue-item-status.success { background: #dcfce7; color: #15803d; }
.queue-item-status.error { background: #fee2e2; color: #b91c1c; }

/* Progress Bar */
.progress-wrapper {
  margin-bottom: 14px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  text-align: center;
}

/* Buttons */
.btn-primary { 
  width: 100%;
  padding: 12px 16px;
  background: var(--primary); 
  color: white; 
  border: none; 
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer; 
  font-weight: 600; 
  transition: background 0.2s;
}

.btn-primary:hover { 
  background: var(--primary-hover); 
}

.btn-primary:disabled { 
  background: #94a3b8; 
  cursor: not-allowed; 
}

.btn-secondary {
  padding: 8px 14px;
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-color);
  border-color: var(--primary);
}

.btn-danger {
  padding: 8px 14px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  padding: 0;
  text-decoration: underline;
}

/* Status Message */
.status-msg { 
  margin-top: 14px; 
  font-size: 13px; 
  text-align: center; 
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: none;
}

.status-msg.success {
  display: block;
  background: #dcfce7;
  color: #166534;
}

.status-msg.error {
  display: block;
  background: #fee2e2;
  color: #991b1b;
}

.status-msg.info {
  display: block;
  background: #e0f2fe;
  color: #075985;
}

/* Gallery Section */
.gallery-section {
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.gallery-title-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gallery-title-wrapper h2 {
  font-size: 20px;
  font-weight: 700;
}

.badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.gallery-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-select {
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text-main);
  cursor: pointer;
}

.sort-select {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--input-bg);
  color: var(--text-main);
  cursor: pointer;
}

.album-picker-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 170px;
  background: var(--input-bg);
  color: var(--text-main);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Storage Card */
.storage-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.storage-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.storage-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-main);
}

.storage-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 4px;
}

.storage-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.storage-badge.status-good {
  background: #dcfce7;
  color: #15803d;
}

.storage-badge.status-warn {
  background: #fef3c7;
  color: #b45309;
}

.storage-badge.status-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.storage-track {
  width: 100%;
  height: 7px;
  background: var(--border-color);
  border-radius: 999px;
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  border-radius: 999px;
  background: #10b981;
  transition: width 0.5s ease, background-color 0.3s ease;
}

.storage-fill.warn {
  background: #f59e0b;
}

.storage-fill.danger {
  background: #ef4444;
}

.storage-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* Album Tabs */
.album-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 20px;
  scrollbar-width: thin;
}

.album-tab {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.album-tab:hover {
  color: var(--text-main);
  border-color: var(--primary);
}

.album-tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.album-tab.album-tab-add {
  border-style: dashed;
  color: var(--primary);
  font-weight: 600;
}

.album-tab.album-tab-add:hover {
  background: rgba(56, 189, 248, 0.1);
}

/* Grid & Cards */
.grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); 
  gap: 20px; 
}

.card { 
  background: var(--card-bg); 
  border-radius: var(--radius-md); 
  overflow: hidden; 
  box-shadow: var(--shadow-sm); 
  border: 1px solid var(--border-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.card:hover { 
  transform: translateY(-4px); 
  box-shadow: var(--shadow-md); 
}

.card-image-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #1e293b;
  cursor: pointer;
}

.card img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  display: block; 
  transition: transform 0.3s ease;
}

.card:hover img {
  transform: scale(1.03);
}

.card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  color: #f8fafc;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.card-details {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
  justify-content: space-between;
}

.card-title { 
  font-weight: 600; 
  font-size: 14px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-date {
  font-size: 11px;
  color: var(--text-muted);
}

.pagination-wrapper {
  text-align: center;
  margin-top: 32px;
}

/* Lightbox Modal */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 29, 0.88);
  backdrop-filter: blur(6px);
}

.lightbox-content {
  position: relative;
  z-index: 1001;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1002;
  background: rgba(15, 23, 42, 0.6);
  color: white;
  border: none;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: rgba(15, 23, 42, 0.9);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1002;
  background: rgba(15, 23, 42, 0.6);
  color: white;
  border: none;
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}

.lightbox-nav:hover {
  background: rgba(15, 23, 42, 0.9);
}

.lightbox-nav.prev { left: 16px; }
.lightbox-nav.next { right: 16px; }

.lightbox-image-wrapper {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 72vh;
  overflow: hidden;
}

.lightbox-image-wrapper img {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  display: block;
}

.lightbox-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  gap: 16px;
  flex-wrap: wrap;
}

.lightbox-meta-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.lightbox-meta h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.lightbox-meta p {
  font-size: 12px;
  color: var(--text-muted);
}

.lightbox-actions {
  display: flex;
  gap: 10px;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
  .lightbox-content {
    max-width: 96vw;
  }
  .lightbox-nav {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
}