/* ==========================================================================
   Pictr — Minimalist & Monochrome Design System
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Grid zoom variable */
  --grid-columns: 4;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 240ms cubic-bezier(0.16, 1, 0.3, 1);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Sidebar sizing */
  --sidebar-width: 280px;
  --sidebar-min-width: 200px;
  --sidebar-max-width: 600px;
}

/* Dark Mode (Default) */
[data-theme="dark"] {
  --bg-app: #09090b;
  --bg-sidebar: #09090b;
  --bg-surface: #121215;
  --bg-surface-elevated: #18181b;
  --bg-card: #18181b;
  --bg-hover: #27272a;
  --bg-active: #3f3f46;
  --bg-glass: rgba(9, 9, 11, 0.82);

  --border: #27272a;
  --border-subtle: #1c1c1f;
  --border-strong: #3f3f46;

  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-inverse: #09090b;

  --accent-primary: #fafafa;
  --accent-hover: #e4e4e7;
  --badge-bg: #27272a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.8);

  /* Scrollbars */
  --scrollbar-thumb: rgba(255, 255, 255, 0.18);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.32);
  --scrollbar-track: transparent;
}

/* Light Mode */
[data-theme="light"] {
  --bg-app: #ffffff;
  --bg-sidebar: #fafafa;
  --bg-surface: #f4f4f5;
  --bg-surface-elevated: #ffffff;
  --bg-card: #f4f4f5;
  --bg-hover: #e4e4e7;
  --bg-active: #d4d4d8;
  --bg-glass: rgba(255, 255, 255, 0.85);

  --border: #e4e4e7;
  --border-subtle: #f4f4f5;
  --border-strong: #d4d4d8;

  --text-primary: #09090b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-inverse: #ffffff;

  --accent-primary: #09090b;
  --accent-hover: #27272a;
  --badge-bg: #e4e4e7;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);

  /* Scrollbars */
  --scrollbar-thumb: rgba(0, 0, 0, 0.18);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.32);
  --scrollbar-track: transparent;
}

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

html, body {
  width: 100%;
  min-height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Custom Minimalist Scrollbars (Modern & Theme-Integrated)
   ========================================================================== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track, transparent);
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  background-clip: padding-box;
  transition: background-color var(--transition-fast);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* App page is a strictly fixed-viewport SPA */
html:not(.landing-html) {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body:not(.landing-page) {
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

/* Landing page allows natural smooth vertical scrolling */
html.landing-html,
html:has(body.landing-page),
body.landing-page {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto !important;
  scroll-behavior: smooth;
  position: static;
}

/* App Layout */
.app-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   Left Sidebar
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width, 280px);
  min-width: var(--sidebar-min-width, 200px);
  max-width: var(--sidebar-max-width, 600px);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 20;
  user-select: none;
  flex-shrink: 0;
  position: relative;
}

/* Sidebar Resizer Divider */
.sidebar-resizer {
  width: 10px;
  margin-left: -5px;
  margin-right: -5px;
  height: 100%;
  cursor: col-resize;
  position: relative;
  z-index: 25;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  outline: none;
}

.sidebar-resizer::after {
  content: '';
  width: 2px;
  height: 100%;
  background-color: transparent;
  transition: background-color var(--transition-fast), width var(--transition-fast);
  border-radius: 2px;
}

.sidebar-resizer:hover::after,
.sidebar-resizer.is-dragging::after {
  background-color: var(--accent-blue, #3b82f6);
  width: 3px;
}

.sidebar-resizer:focus-visible::after {
  background-color: var(--accent-blue, #3b82f6);
  width: 3px;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

/* Global state while dragging the resizer */
body.is-resizing-sidebar {
  cursor: col-resize !important;
  user-select: none !important;
}

body.is-resizing-sidebar * {
  cursor: col-resize !important;
  user-select: none !important;
}

.sidebar-header {
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

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

.brand-icon {
  width: 24px;
  height: 24px;
  color: var(--text-primary);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.sidebar-section {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-scrollable-body {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 4px;
}

.section-header-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 4px 4px;
}

.scrollable-section {
  flex: 1;
  overflow-y: auto;
  min-height: 120px;
}

/* Filter Buttons */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
}

.filter-btn svg {
  width: 17px;
  height: 17px;
  opacity: 0.85;
}

.filter-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.filter-btn.active {
  background-color: var(--bg-hover);
  border-color: var(--border);
  color: var(--text-primary);
  font-weight: 600;
}

.count-badge {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--badge-bg);
  color: var(--text-secondary);
}

.filter-btn.active .count-badge {
  color: var(--text-primary);
}

/* Years Navigation & Month Accordion */
.years-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.year-accordion-item {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.year-header-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  text-align: left;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.year-header-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.year-header-btn.active {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  font-weight: 600;
}

.year-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.year-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.year-chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: transform var(--transition-normal);
  transform-origin: center;
}

.year-accordion-item.expanded .year-chevron {
  transform: rotate(180deg);
  color: var(--text-primary);
}

/* Month List within Accordion */
.year-months-panel {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 3px 0 6px 14px;
  margin-left: 10px;
  border-left: 2px solid var(--border-subtle);
  animation: accordionIn 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.year-accordion-item.expanded .year-months-panel {
  display: flex;
}

@keyframes accordionIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.month-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.month-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.month-link.active {
  color: var(--text-primary);
  font-weight: 600;
  background: var(--bg-hover);
}

.badge-month {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.month-link.active .badge-month {
  color: var(--text-primary);
  background: var(--badge-bg);
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--badge-bg);
  color: var(--text-muted);
}

/* Jump Navigation Buttons */
.jump-nav-btn {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.jump-nav-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

/* Floating Back to Top Button */
.floating-jump-btn {
  position: absolute;
  bottom: 24px;
  right: 28px;
  z-index: 85;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md), 0 4px 16px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--transition-normal), transform var(--transition-normal), background-color var(--transition-fast), border-color var(--transition-fast);
}

.floating-jump-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.floating-jump-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-lg), 0 6px 22px rgba(0, 0, 0, 0.6);
  transform: translateY(-2px);
}

.floating-jump-btn:active {
  transform: translateY(0);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--bg-sidebar);
}

.sync-status-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.sync-info {
  display: flex;
  flex-direction: column;
}

.sync-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.sync-time {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.user-profile-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.user-details {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-bottom-controls {
  display: flex;
  gap: 6px;
}

/* ==========================================================================
   Main Content & Topbar
   ========================================================================== */
.main-content {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-app);
}

.topbar {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.view-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.view-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.view-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* Zoom Slider & Buttons */
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.zoom-controls input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.zoom-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.zoom-controls input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ==========================================================================
   Timeline Container & Photos Grid
   ========================================================================== */
.timeline-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 80px 28px;
  scroll-behavior: smooth;
}

.timeline-stream {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.timeline-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline-group-header {
  position: sticky;
  top: -24px;
  z-index: 5;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 10px 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.group-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.group-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Variable Column Grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), 1fr);
  gap: 12px;
}

.media-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--bg-card);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.media-card.thumb-pending {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-surface) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: thumbSkeletonPulse 1.8s ease-in-out infinite;
}

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

.media-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.media-card:focus,
.media-card.selected {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary), var(--shadow-md);
  transform: translateY(-2px);
  z-index: 2;
}

.media-card:focus img,
.media-card.selected img {
  transform: scale(1.03);
}

.media-card:focus .media-card-actions,
.media-card.selected .media-card-actions {
  opacity: 1;
  pointer-events: auto;
}

.media-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease, transform var(--transition-normal);
  background-color: var(--bg-surface);
}

.media-card img.thumb-loaded {
  opacity: 1;
}

.media-card.thumb-pending img:not([src*="svg"]) {
  opacity: 0.15;
}

.media-card:hover img {
  transform: scale(1.03);
}

/* Video badge */
.video-indicator {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(4px);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 4px;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  pointer-events: none;
}

.video-indicator svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* Load Previous Year Banner & End of Archive */
.load-previous-year-box {
  margin: 36px 0 24px 0;
  padding: 22px 28px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all var(--transition-fast);
}

.load-previous-year-box:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-elevated);
}

.load-year-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.load-year-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.load-year-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.load-year-count {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.end-of-timeline-box {
  margin: 40px auto 20px auto;
  padding: 24px;
  max-width: 420px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--border-subtle);
}

.end-of-timeline-box svg {
  opacity: 0.45;
  margin-bottom: 2px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  gap: 16px;
}

.empty-icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-state h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 440px;
}

.empty-state code {
  font-family: var(--font-mono);
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 5px 11px;
}

.btn-xs {
  font-size: 0.72rem;
  padding: 3px 8px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--text-primary);
  color: var(--text-inverse);
  border-color: var(--text-primary);
}

.btn-primary:hover {
  background-color: var(--text-secondary);
  border-color: var(--text-secondary);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn.btn-sm {
  width: 28px;
  height: 28px;
}

.icon-btn.btn-sm svg {
  width: 15px;
  height: 15px;
}

.icon-btn.btn-xs {
  width: 24px;
  height: 24px;
}

.icon-btn.btn-xs svg {
  width: 13px;
  height: 13px;
}

/* ==========================================================================
   Drag & Drop Overlay & Upload Card
   ========================================================================== */
.drag-drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drag-drop-overlay.active {
  display: flex;
}

.drag-box {
  border: 2px dashed var(--text-primary);
  border-radius: var(--radius-lg);
  padding: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.drag-box svg {
  width: 48px;
  height: 48px;
}

.upload-progress-card {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 320px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.progress-pct {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--text-primary);
  transition: width 150ms ease;
}

/* ==========================================================================
   Lightbox / Media Viewer Dialog
   ========================================================================== */
dialog.media-viewer {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  background-color: rgba(9, 9, 11, 0.96);
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: #fff;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--transition-normal);
  outline: none;
}

dialog.media-viewer[open] {
  opacity: 1;
}

dialog.media-viewer::backdrop {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.viewer-header {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0) 100%);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  user-select: none;
}

.viewer-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.viewer-meta-short {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.viewer-counter {
  font-size: 0.8rem;
  font-weight: 600;
  color: #a1a1aa;
  white-space: nowrap;
}

.viewer-filename {
  font-size: 0.88rem;
  font-weight: 500;
  color: #fafafa;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.viewer-header .icon-btn {
  color: #d4d4d8;
}

.viewer-header .icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

/* Viewer More Dropdown Menu */
.viewer-more-container {
  position: relative;
  display: inline-flex;
}

.viewer-more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: #18181b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: viewerMenuFadeIn 0.12s ease-out;
}

@keyframes viewerMenuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.viewer-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: #e4e4e7;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.viewer-menu-item svg {
  flex-shrink: 0;
  color: #a1a1aa;
}

.viewer-menu-item span {
  flex: 1;
  white-space: nowrap;
}

.viewer-menu-kbd {
  font-size: 10px;
  font-family: inherit;
  color: #71717a;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 1px 5px;
}

.viewer-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.viewer-menu-item:hover svg {
  color: #ffffff;
}

.viewer-menu-item.danger {
  color: var(--accent-red);
}

.viewer-menu-item.danger svg {
  color: var(--accent-red);
}

.viewer-menu-item.danger:hover {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
}

.viewer-menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* Bottom Rotation Save/Cancel Popup Bar */
.viewer-rotate-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  background: rgba(24, 24, 27, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9999px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  z-index: 70;
  animation: viewerBarSlideUp 0.18s cubic-bezier(0.2, 0, 0.2, 1);
}

@keyframes viewerBarSlideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.viewer-rotate-bar-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #f4f4f5;
  white-space: nowrap;
}

.viewer-rotate-bar-info svg {
  color: #38bdf8;
}

.viewer-rotate-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-rotate-bar-actions .btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 9999px;
}

.viewer-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.media-container {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-viewer.video-fit-width .media-container,
.media-viewer.video-fit-height .media-container {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
}

.media-container img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-sm);
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
}

.media-container video {
  max-width: 100vw;
  max-height: 100vh;
  border-radius: var(--radius-sm);
  outline: none;
  background: #000;
  transition: width 0.15s ease, height 0.15s ease, max-width 0.15s ease, max-height 0.15s ease;
}

#viewerBtnFitMode svg {
  width: 18px;
  height: 18px;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: rgba(24, 24, 27, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 40;
}

.nav-arrow svg {
  width: 22px;
  height: 22px;
}

.nav-arrow:hover {
  background: rgba(24, 24, 27, 0.9);
  transform: translateY(-50%) scale(1.08);
}

.prev-arrow {
  left: 20px;
}

.next-arrow {
  right: 20px;
}

/* Info Drawer */
.viewer-info-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background: #121215;
  border-left: 1px solid #27272a;
  z-index: 60;
  padding: 24px;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--shadow-lg);
}

.viewer-info-drawer.open {
  transform: translateX(0);
}

.info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #27272a;
  padding-bottom: 12px;
}

.info-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fafafa;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.info-list dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #71717a;
  font-weight: 600;
}

.info-list dd {
  font-size: 0.88rem;
  color: #d4d4d8;
  word-break: break-all;
}

/* ==========================================================================
   Toasts & Utilities
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toastIn 180ms ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-only {
  display: none !important;
}

.sidebar-backdrop {
  display: none;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 820px) {
  .mobile-only {
    display: inline-flex !important;
  }

  .desktop-only {
    display: none !important;
  }

  .floating-jump-btn {
    bottom: 18px;
    right: 18px;
    padding: 6px 12px;
    font-size: 0.76rem;
  }

  .sidebar-resizer {
    display: none !important;
  }

  .sidebar {
    width: 280px !important;
    min-width: 0 !important;
    max-width: 85vw !important;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }

  .sidebar-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 15;
    display: none;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .topbar {
    padding: 0 16px;
  }

  .timeline-container {
    padding: 16px 16px 80px 16px;
  }

  #btnJumpBottom,
  .jump-nav-btn {
    display: none !important;
  }

  .zoom-controls {
    display: none !important;
  }

  :root {
    --grid-columns: 2 !important;
  }

  .prev-arrow {
    left: 8px;
  }

  .next-arrow {
    right: 8px;
  }

  .viewer-header {
    height: 52px;
    padding: 0 8px;
    gap: 4px;
  }

  .viewer-header-left {
    gap: 6px;
    min-width: 0;
    flex-shrink: 1;
  }

  .viewer-meta-short {
    gap: 6px;
    min-width: 0;
  }

  .viewer-filename {
    max-width: 80px;
    font-size: 0.8rem;
  }

  .viewer-counter {
    font-size: 0.75rem;
  }

  /* Hide Saved Offline label on mobile */
  .viewer-offline-badge {
    display: none !important;
  }

  .viewer-actions {
    gap: 2px;
    flex-shrink: 0;
  }

  .viewer-actions .icon-btn {
    width: 32px;
    height: 32px;
    padding: 0;
  }

  .viewer-rotate-bar {
    bottom: 16px;
    width: calc(100% - 24px);
    max-width: 360px;
    padding: 6px 12px;
    justify-content: space-between;
  }
}

@media (max-width: 420px) {
  #viewerBtnZoomIn,
  #viewerBtnZoomOut {
    display: none !important;
  }
}

/* ==========================================================================
   Pictr Minimalist Landing Page
   ========================================================================== */
.landing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  overflow-y: auto;
  overflow-x: hidden;
}

.landing-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.4px;
}

.landing-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.landing-hero {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 72px 24px 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.2px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.hero-badge svg {
  width: 14px;
  height: 14px;
  color: var(--text-primary);
}

.hero-title {
  font-size: clamp(34px, 5.2vw, 62px);
  font-weight: 700;
  letter-spacing: -1.8px;
  line-height: 1.12;
  margin: 0 0 20px 0;
  color: var(--text-primary);
}

.hero-subtitle {
  font-size: clamp(16px, 1.8vw, 18px);
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 720px;
  margin: 0 0 36px 0;
  font-weight: 400;
}

.hero-cta-group {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-hero-primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn-hero-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-hero-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn-hero-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

/* Landing Preview Mockup */
.landing-preview {
  max-width: 960px;
  width: 100%;
  margin: 48px auto 20px auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  text-align: left;
}

.preview-window-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.preview-dots {
  display: flex;
  gap: 6px;
}

.preview-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-strong);
}

.preview-url {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.preview-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--badge-bg);
  color: var(--text-secondary);
}

.preview-body {
  display: grid;
  grid-template-columns: 190px 1fr;
  min-height: 320px;
}

.preview-sidebar {
  padding: 18px 14px;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-app);
}

.preview-sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.preview-nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.preview-nav-item.active {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-weight: 500;
}

.preview-nav-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.preview-content {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.preview-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  aspect-ratio: 4/3;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
}

.preview-card-bg-1 {
  background: linear-gradient(135deg, #1c1c24 0%, #0d0d12 100%);
}
.preview-card-bg-2 {
  background: linear-gradient(135deg, #272733 0%, #15151c 100%);
}
.preview-card-bg-3 {
  background: linear-gradient(135deg, #191c24 0%, #0e1117 100%);
}
.preview-card-bg-4 {
  background: linear-gradient(135deg, #22222a 0%, #111116 100%);
}
.preview-card-bg-5 {
  background: linear-gradient(135deg, #1d212a 0%, #0e1218 100%);
}
.preview-card-bg-6 {
  background: linear-gradient(135deg, #2b2b36 0%, #16161d 100%);
}

.preview-card-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  background: rgba(9, 9, 11, 0.7);
  backdrop-filter: blur(4px);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  display: inline-block;
  align-self: flex-start;
}

/* Features Grid */
.landing-features {
  max-width: 1100px;
  width: 100%;
  margin: 60px auto 40px auto;
  padding: 0 24px;
}

.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-label {
  font-size: 11px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.section-title {
  font-size: clamp(24px, 3.2vw, 36px);
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text-primary);
  margin: 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}

.feature-card {
  padding: 28px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.feature-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.feature-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--badge-bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.feature-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  margin: 0 0 10px 0;
}

.feature-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

/* Steps Grid */
.landing-steps {
  max-width: 1100px;
  width: 100%;
  margin: 40px auto 60px auto;
  padding: 0 24px;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.step-card {
  padding: 28px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.step-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: block;
}

.step-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.step-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0;
}

/* Landing Footer */
.landing-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 36px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: auto;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .landing-nav {
    padding: 12px 18px;
  }
  .preview-body {
    grid-template-columns: 1fr;
  }
  .preview-sidebar {
    display: none;
  }
  .preview-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .landing-footer {
    flex-direction: column;
    text-align: center;
  }
}

/* ==========================================================================
   Account Switcher & Access Management
   ========================================================================== */
.account-section {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.account-select-wrapper {
  position: relative;
  width: 100%;
}

.account-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 30px 8px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.account-select:hover {
  border-color: var(--border-focus);
}

.account-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.account-select-wrapper::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 5px;
  background-color: var(--text-secondary);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  pointer-events: none;
}

.view-heading-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-indicator-badge {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.3);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.shared-notice-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: rgba(59, 130, 246, 0.08);
  border-bottom: 1px solid rgba(59, 130, 246, 0.2);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Offline Mode Banner */
.offline-notice-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px;
  background: rgba(245, 158, 11, 0.09);
  border-bottom: 1px solid rgba(245, 158, 11, 0.22);
  color: var(--text-primary);
  font-size: 0.82rem;
  flex-wrap: wrap;
  z-index: 10;
}

.offline-banner-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.offline-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
  display: inline-block;
  flex-shrink: 0;
}

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

.viewer-offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 9999px;
  padding: 2px 7px;
  margin-left: 8px;
  vertical-align: middle;
}


/* ==========================================================================
   Access Modal Dialog
   ========================================================================== */
dialog.access-modal {
  background: transparent;
  border: none;
  padding: 0;
  margin: auto;
  outline: none;
  max-width: 90vw;
  width: 500px;
  max-height: calc(100dvh - 32px);
  overflow: visible;
}

dialog.access-modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
}

.modal-dialog-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 20px 40px rgba(0, 0, 0, 0.4);
  padding: 24px;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  box-sizing: border-box;
  animation: modalIn 180ms ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-group h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin: 0;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-actions-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.modal-help-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0 0 4px 0;
}

.share-url-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.share-url-input {
  flex: 1;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 0.85rem;
  font-family: var(--font-mono, monospace);
  color: var(--text-primary);
  outline: none;
  cursor: text;
}

.share-url-input:focus {
  border-color: var(--accent);
}

.add-user-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.add-user-input {
  flex: 1;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
}

.add-user-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.allowed-users-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px;
  background: var(--bg-app);
}

.allowed-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}

.allowed-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.allowed-user-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}

.allowed-user-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--badge-bg);
  color: var(--text-secondary);
}

.allowed-user-remove {
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.allowed-user-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.empty-allowed-msg {
  padding: 14px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Access & Permissions Monochrome Toggle Switches & Checkboxes
   ========================================================================== */
.access-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  gap: 16px;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.access-toggle-row:hover {
  border-color: var(--border-strong);
}

.access-toggle-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.access-toggle-desc {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Modern Monochrome Switch */
.switch-label {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}

.switch-checkbox {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--bg-hover);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.switch-slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  transition: transform var(--transition-fast), background-color var(--transition-fast);
}

.switch-checkbox:checked + .switch-slider {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.switch-checkbox:checked + .switch-slider::before {
  transform: translateX(20px);
  background-color: var(--text-inverse);
}

.switch-checkbox:focus-visible + .switch-slider {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Toggle Checkbox Row (Account Access & Album Sharing) */
.toggle-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.toggle-checkbox-label:hover {
  border-color: var(--border-strong);
}

.toggle-checkbox-text strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}

.toggle-checkbox-text small {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 2px;
}

.custom-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--bg-hover);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all var(--transition-fast);
}

.custom-checkbox:hover {
  border-color: var(--text-secondary);
}

.custom-checkbox:checked {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.custom-checkbox:checked::before {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--text-inverse);
  border-bottom: 2px solid var(--text-inverse);
  transform: rotate(-45deg) translate(1px, -1px);
}

.custom-checkbox:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* ==========================================================================
   Upload Modal & Drop Zone Styles
   ========================================================================== */
dialog.upload-modal {
  width: 540px;
  max-width: 95vw;
  max-height: calc(100dvh - 32px);
  margin: auto;
}

.upload-modal-content {
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 16px;
  padding: 24px;
}

.upload-modal-content .modal-header {
  flex-shrink: 0;
}

.upload-modal-content .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.upload-modal-content .modal-actions-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
  position: sticky;
  bottom: 0;
  z-index: 10;
}

@media (max-width: 600px) {
  dialog.access-modal,
  dialog.upload-modal {
    width: 96vw;
    max-width: 96vw;
    max-height: calc(100dvh - 16px);
  }
  .modal-dialog-content,
  .upload-modal-content {
    max-height: calc(100dvh - 16px);
    padding: 16px 14px 12px 14px;
    gap: 12px;
  }
  .upload-year-notice {
    padding: 10px 12px;
  }
  .upload-files-preview-box {
    max-height: 120px;
  }
}

.upload-year-notice {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-primary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.upload-year-notice .notice-icon {
  flex-shrink: 0;
  color: var(--text-primary);
  margin-top: 2px;
}

.upload-year-notice .notice-text {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.upload-year-notice .notice-text strong {
  display: block;
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.upload-year-notice .notice-text code {
  font-family: var(--font-mono);
  background: var(--badge-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.upload-dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bg-app);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--text-primary);
  background: var(--bg-surface-elevated);
}

.dropzone-icon {
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dropzone-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  margin-bottom: 14px;
}

.dropzone-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.upload-selected-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeIn 150ms ease-out;
}

.upload-selection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.upload-file-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-file-size {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 6px;
}

.upload-year-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-year-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.upload-year-badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.upload-year-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.year-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-app);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0 10px;
  width: 100%;
}

.year-prefix,
.year-suffix {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text-muted);
  user-select: none;
}

.year-number-input {
  border: none !important;
  background: transparent !important;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  width: 100px;
  padding: 8px 6px !important;
  outline: none !important;
  box-shadow: none !important;
}

.year-hint-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.upload-files-preview-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.upload-preview-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.upload-preview-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}

.upload-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 3px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.upload-preview-item:last-child {
  border-bottom: none;
}

.upload-preview-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

.upload-preview-size {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.upload-progress-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.upload-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  font-weight: 600;
}

.upload-progress-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.storage-input {
  width: 100%;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-sizing: border-box;
}

.storage-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.storage-key-area {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  resize: vertical;
  min-height: 80px;
  line-height: 1.4;
}

.tab-toggle-group {
  display: flex;
  gap: 6px;
}

.tab-toggle-btn {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-toggle-btn.active {
  background: var(--bg-app);
  border-color: var(--border-strong);
  color: var(--text-primary);
  font-weight: 600;
}

.field-hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
}

.storage-test-result {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 0.84rem;
  line-height: 1.5;
  animation: fadeIn 150ms ease-out;
}

.storage-test-result.success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
}

.storage-test-result.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.storage-test-years {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.badge-year {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-primary);
}

.modal-actions-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.75s linear infinite;
  margin-right: 6px;
}

/* ==========================================================================
   Sync & Thumbnail Generation Progress Modal
   ========================================================================== */
.sync-progress-modal {
  max-width: 520px;
}

.sync-progress-phase-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 18px;
}

.sync-progress-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.progress-bar-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.progress-bar-track {
  width: 100%;
  height: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width 200ms ease;
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.18) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(255, 255, 255, 0.18) 75%,
    transparent 75%,
    transparent
  );
  background-size: 24px 24px;
  animation: progressStripe 1s linear infinite;
}

@keyframes progressStripe {
  from { background-position: 0 0; }
  to { background-position: 24px 0; }
}

.progress-bar-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.progress-bar-meta span:first-child {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.88rem;
}

.sync-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.sync-metric-card {
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  text-align: center;
}

.sync-metric-card .metric-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.sync-metric-card .metric-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.current-file-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
}

.current-file-label {
  flex-shrink: 0;
  font-weight: 600;
}

.current-file-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  font-family: monospace;
}

/* ==========================================================================
   Public & Password Protection Settings
   ========================================================================== */
.access-protection-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.toggle-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--text-primary);
  margin-top: 2px;
  cursor: pointer;
}

.toggle-checkbox-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-checkbox-text strong {
  font-size: 0.85rem;
  color: var(--text-primary);
}

.toggle-checkbox-text small {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.password-field-container {
  padding-top: 6px;
}

/* ==========================================================================
   Albums Sidebar & List
   ========================================================================== */
.albums-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.years-scroll-section {
  flex-shrink: 0;
}

.albums-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.album-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.83rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 120ms ease;
  user-select: none;
}

.album-nav-item:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.album-nav-item.active {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  font-weight: 600;
}

.album-item-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-item-title-group svg {
  flex-shrink: 0;
  opacity: 0.75;
}

.album-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Album Hero Banner (Main Stream View)
   ========================================================================== */
.album-hero-banner {
  margin: 16px 20px 24px 20px;
  padding: 22px 26px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.album-hero-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.album-hero-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.album-hero-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.album-hero-desc {
  margin: 8px 0 0 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.album-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.btn-danger-hover:hover {
  color: #e53e3e !important;
  border-color: #e53e3e !important;
}

/* ==========================================================================
   Media Card Action Overlay (Add to Album / Remove)
   ========================================================================== */
.media-card {
  position: relative;
}

.media-card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
  z-index: 6;
}

.media-card:hover .media-card-actions,
.media-card:focus-within .media-card-actions {
  opacity: 1;
  pointer-events: auto;
}

.card-action-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 120ms ease;
  padding: 0;
}

.card-action-btn:hover {
  background: rgba(0, 0, 0, 0.95);
  transform: scale(1.08);
}

.card-action-btn.remove-btn:hover {
  background: #e53e3e;
  border-color: #e53e3e;
}

/* ==========================================================================
   Add to Album Modal Preview & List
   ========================================================================== */
.add-to-album-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.add-to-album-thumb {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  flex-shrink: 0;
}

.add-to-album-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.add-to-album-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.preview-filename {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-date {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.add-to-album-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.add-to-album-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.add-to-album-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.album-choice-title {
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   Libraries Sidebar & Navigation
   ========================================================================== */
.libraries-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.libraries-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.library-item-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.83rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 120ms ease;
  user-select: none;
}

.library-item-nav:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.library-item-nav.active {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  font-weight: 600;
}

.library-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.library-item-info svg {
  flex-shrink: 0;
  opacity: 0.75;
}

.library-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.library-item-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-app);
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.library-settings-btn {
  opacity: 0.6;
  transition: opacity 120ms ease;
}

.library-item-nav:hover .library-settings-btn,
.library-settings-btn:hover {
  opacity: 1;
}

/* ==========================================================================
   Zero Libraries State
   ========================================================================== */
.zero-libraries-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  max-width: 520px;
  margin: 40px auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.zero-libraries-state .zero-icon {
  margin-bottom: 20px;
  color: var(--text-muted);
}

/* ==========================================================================
   Tags View & Navigation
   ========================================================================== */
.tags-nav-section {
  padding: 8px 16px 12px 16px;
  border-top: 1px solid var(--border-subtle);
}

.nav-tags-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.nav-tags-btn.active {
  background-color: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  font-weight: 600;
}

.tags-view-container {
  flex: 1 1 0%;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-app);
}

.tags-view-header {
  padding: 18px 28px 12px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.tags-view-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.tags-view-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tags-view-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text-primary);
}

.tags-view-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tags-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 6px 12px;
  min-width: 190px;
  max-width: 280px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.tags-search-box:focus-within {
  border-color: var(--border);
  box-shadow: 0 0 0 1px var(--border);
}

.tags-search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  width: 100%;
}

.tags-search-box input::placeholder {
  color: var(--text-muted);
}

.tags-pills-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.tags-pills-bar::-webkit-scrollbar {
  height: 4px;
}

.tags-pills-bar::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-app);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms ease;
  white-space: nowrap;
  user-select: none;
}

.tag-pill:hover {
  border-color: var(--border);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tag-pill.active {
  background: var(--text-primary);
  color: var(--bg-app);
  border-color: var(--text-primary);
  font-weight: 600;
}

.tag-pill .tag-pill-count {
  font-size: 0.7rem;
  opacity: 0.8;
  padding: 1px 5px;
  border-radius: 8px;
  background: rgba(128, 128, 128, 0.15);
}

.tag-pill.active .tag-pill-count {
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
}

.tags-content-body {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 28px 80px 28px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.tags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.tag-media-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  display: flex;
  flex-direction: column;
}

.tag-media-card:hover {
  transform: translateY(-2px);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.tag-media-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-surface);
  overflow: hidden;
}

.tag-media-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tag-media-meta {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-card);
}

.tag-media-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-media-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.tag-media-tag-chip {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 9999px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.tag-media-desc-preview {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-media-edit-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 120ms ease;
  cursor: pointer;
  z-index: 2;
}

.tag-media-card:hover .tag-media-edit-btn {
  opacity: 1;
}

.tag-media-edit-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.05);
}

.tags-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  gap: 12px;
}

.tags-empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.tags-empty-state p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
  max-width: 360px;
}

@media (max-width: 820px) {
  .tags-view-header {
    padding: 14px 16px 10px 16px;
  }
  .tags-content-body {
    padding: 16px 16px 80px 16px;
  }
  .tags-search-box {
    width: 100%;
    max-width: 100%;
  }
}

/* ==========================================================================
   Viewer Description Overlay
   ========================================================================== */
.viewer-desc-overlay {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 600px;
  width: calc(100% - 48px);
  background: rgba(18, 18, 18, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  color: #fff;
  z-index: 25;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  animation: descFadeIn 180ms ease-out;
}

@keyframes descFadeIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.viewer-desc-inner {
  flex: 1 1 0%;
  min-width: 0;
}

.viewer-desc-text {
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0;
  color: #f3f4f6;
  word-break: break-word;
  white-space: pre-wrap;
}

.viewer-desc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.viewer-tag-badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
}

/* ==========================================================================
   Edit Tags & Description Modal
   ========================================================================== */
.metadata-dialog-content {
  max-width: 500px;
  width: 100%;
}

.meta-item-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.meta-item-preview img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-app);
  flex-shrink: 0;
}

.meta-item-preview-info {
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.meta-preview-filename {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.meta-preview-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.meta-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.meta-form-hint {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Beautiful modern description textarea */
.meta-description-textarea {
  width: 100%;
  min-height: 110px;
  max-height: 240px;
  padding: 12px 14px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.55;
  resize: vertical;
  box-sizing: border-box;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.meta-description-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.meta-description-textarea:hover {
  border-color: var(--text-secondary);
}

.meta-description-textarea:focus {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--border);
  background: var(--bg-surface);
}

/* Modern tags container */
.meta-tags-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 42px;
  box-sizing: border-box;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.meta-tags-container:hover {
  border-color: var(--text-secondary);
}

.meta-tags-container:focus-within {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--border);
  background: var(--bg-surface);
}

.meta-tags-container input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  flex: 1;
  min-width: 120px;
  padding: 3px 4px;
}

.meta-tags-container input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.meta-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 9999px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-primary);
}

.meta-tag-remove {
  cursor: pointer;
  opacity: 0.6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 11px;
  line-height: 1;
}

.meta-tag-remove:hover {
  opacity: 1;
}

.suggested-tags-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}

.suggested-tags-label {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
}

.suggested-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.suggested-tag-btn {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 9999px;
  background: transparent;
  border: 1px dashed var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 120ms ease;
}

.suggested-tag-btn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: var(--bg-hover);
}

