:root {
  /* macOS "Tahoe" Dark Theme Palette */
  --bg-color: #1e1e1e;
  --window-bg: rgba(30, 30, 30, 0.6);
  --card-bg: rgba(255, 255, 255, 0.05);
  --text-primary: #f5f5f7;
  --text-secondary: #86868b;
  --accent-blue: #0a84ff;
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  --blur-strength: 20px;
  --radius-l: 18px;
  --radius-m: 12px;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.3);
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: #000;
  background-image: radial-gradient(
      circle at 10% 20%,
      rgba(10, 132, 255, 0.15) 0%,
      transparent 40%
    ),
    radial-gradient(
      circle at 90% 80%,
      rgba(172, 142, 104, 0.1) 0%,
      transparent 40%
    ),
    linear-gradient(to bottom, #1c1c1e, #000000);
  color: var(--text-primary);
  font-family: var(--font-stack);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: scroll; /* Always show scrollbar to prevent layout shift */
}

/* The Main Window Container */
.app-container {
  width: 100%;
  max-width: 1400px;
  /* Glassmorphism Effect */
  background: var(--window-bg);
  backdrop-filter: blur(var(--blur-strength));
  -webkit-backdrop-filter: blur(var(--blur-strength));
  border: var(--glass-border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Title Bar (Simulating macOS Window) */
.title-bar {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: var(--glass-border);
  position: sticky;
  top: 0;
  background: rgba(30, 30, 30, 0.8);
  backdrop-filter: blur(10px);
  z-index: 50;
  justify-content: space-between; /* Changed for better spacing */
}

.traffic-lights {
  display: flex;
  gap: 8px;
  width: 60px; /* Fixed width to balance center alignment */
  flex-shrink: 0;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot.red {
  background-color: #ff5f57;
}
.dot.yellow {
  background-color: #febc2e;
}
.dot.green {
  background-color: #28c840;
}

/* Submerged URL Input Style */
.url-input-container {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center; /* Vertically align input and button */
  padding: 0 20px;
  gap: 8px; /* Space between input and button */
}

.url-input {
  background: rgba(0, 0, 0, 0.2);
  border: none;
  border-radius: 6px;
  height: 28px;
  width: 100%;
  max-width: 340px; /* Slightly reduced to make room for button */
  color: var(--text-secondary);
  font-family: var(--font-stack);
  font-size: 13px;
  text-align: center;
  padding: 0 10px;
  /* The "submerged" effect */
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
  outline: none;
}

.url-input:focus {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(10, 132, 255, 0.3);
}

.url-input::placeholder {
  color: rgba(134, 134, 139, 0.5);
}

/* New Action Button (Submerged Style) */
.action-btn {
  height: 28px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  border: none;
  border-radius: 6px;
  padding: 0 10px;
  font-family: var(--font-stack);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.action-btn:hover {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
}

.action-btn:active {
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
  transform: translateY(0.5px);
}

/* Spacer to balance traffic lights */
.header-spacer {
  width: 60px;
}

/* Masonry Grid Layout */
.gallery-container {
  padding: 20px;
  position: relative; /* Essential for JS Masonry */
  width: 100%;
    margin-top: 15px;
}

.gallery-item {
  position: absolute; /* Set by JS */
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--card-bg);
  border: var(--glass-border);
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.3s ease,
    top 0.5s ease, left 0.5s ease;
  will-change: top, left, transform;
}

.gallery-item:hover {
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  /* border-color: rgba(255, 255, 255, 0.3); */
  z-index: 10;
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.3s ease;
}

.gallery-item:hover img {
  opacity: 0.9;
}

/* Delete Button */
.delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 20;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.delete-btn:hover {
  background: #ff453a;
  transform: scale(1.1);
}

.gallery-item:hover .delete-btn {
  opacity: 1;
}

/* Overlay Info (Hidden by default, shown on hover) */
.item-info {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 15px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  opacity: 0.5;

  transform: translateY(0px);
  transition: transform 0.3s ease, opacity 0.3s ease;
  /*  pointer-events: none; */
}

.gallery-item:hover .info-title {
  color: #fff;
}
.gallery-item:hover .item-info {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.gallery-item:hover:has(.info-url-btn) {
  /* background: rgba(255, 255, 255, 0.2); */
  opacity: 1;

  backdrop-filter: blur(4px) saturate(180%);
  -webkit-backdrop-filter: blur(4px) saturate(180%);
}

.info-title {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
}

.info-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 2px;
}

.item-info {
  display: flex;
  justify-content: space-between;
}

.item-info-left {
  display: flex;
  flex-direction: column;
}

.item-action-right {
  opacity: 1;
  display: flex;
  flex-direction: column;
}

.info-url-btn:hover {
  opacity: 1;
}

.info-url-btn:focus-visible {
  border: none;
  outline: none;
}

.info-url-btn {
  border: none;
  position: absolute;
  bottom: 15px;
  right: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px) saturate(180%);
  -webkit-backdrop-filter: blur(4px) saturate(180%);
  color: #fff;
  font: 11px Arial, sans-serif;
  white-space: nowrap;
  opacity: 0.5;
  transform: translateY(0px);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 999;
}

.info-url-btn[data-state="copied"] {
  transition: all 1s ease;
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px) saturate(180%);
  -webkit-backdrop-filter: blur(8px) saturate(180%);
}

.info-url-btn[data-state="open-url"] {
  transition: all 1s ease;
  opacity: 0.5;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px) saturate(180%);
  -webkit-backdrop-filter: blur(4px) saturate(180%);
}

.info-url-btn[data-state="open-url"]:hover {
  transition: all 1s ease;

  opacity: 1;
}

.info-url-btn:hover {
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);

  background: rgba(255, 255, 255, 0.4);

  transition: all 0.4s ease;
}

/* Lightbox (Full Screen View) */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.lightbox.active {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-m);
  box-shadow: 0 50px 100px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
  user-select: none;
}

.lightbox.active .lightbox-content {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 30px;
  right: 30px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: background 0.2s;
  z-index: 101;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
  /* JS handles columns */
}
@media (max-width: 800px) {
  /* JS handles columns */
}
@media (max-width: 500px) {
  .app-container {
    border-radius: 0;
    height: 100vh;
    border: none;
  }
  body {
    padding: 0;
  }
}
