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

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, sans-serif;
  background: linear-gradient(145deg, #f8fafc 0%, #eef2f9 100%);
  min-height: 100vh;
  padding: 2rem 1.5rem;
  color: #0f172a;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,300;14..32,400;14..32,500;14..32,600;14..32,700&display=swap');

.container {
  max-width: 1400px;
  margin: 0 auto;
}

.login-container {
  max-width: 440px;
  margin: 12vh auto;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-radius: 2rem;
  padding: 2rem 2rem 2.5rem;
  box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.login-container h2 {
  font-size: 1.9rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1.8rem;
  background: linear-gradient(135deg, #1e293b, #3b82f6);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.login-container input {
  width: 100%;
  padding: 0.9rem 1.2rem;
  margin: 0.7rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 1.2rem;
  font-size: 1rem;
  background: white;
  transition: all 0.2s;
}

.login-container input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.login-container button {
  width: 100%;
  padding: 0.9rem;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1.2rem;
  transition: 0.2s;
}

.login-container button:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.error {
  color: #ef4444;
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  padding: 1rem 1.8rem;
  border-radius: 2rem;
}

.header h2 {
  font-weight: 600;
  font-size: 1.6rem;
  background: linear-gradient(120deg, #0f172a, #3b82f6);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.logout-btn {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 0.5rem 1.2rem;
  border-radius: 2rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
}

.logout-btn:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
}

.add-form {
  background: white;
  padding: 1.2rem 1.5rem;
  border-radius: 1.8rem;
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.05);
}

.add-form input,
.add-form select {
  flex: 1;
  padding: 0.8rem 1.2rem;
  border: 1px solid #e2e8f0;
  border-radius: 1.5rem;
  font-size: 0.95rem;
  background: #fefefe;
}

.add-form select {
  flex: 0.5;
  min-width: 100px;
  cursor: pointer;
}

.add-form input:focus,
.add-form select:focus {
  border-color: #3b82f6;
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.add-form button {
  background: #3b82f6;
  border: none;
  padding: 0.8rem 1.8rem;
  border-radius: 2rem;
  font-weight: 600;
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.add-form button:hover {
  background: #2563eb;
  transform: scale(0.97);
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 2rem;
  align-items: center;
  padding: 0.2rem 0;
}

.tag-btn {
  background: #f1f5f9;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 2rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  color: #334155;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag-btn.active {
  background: #3b82f6;
  color: white;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.tag-btn.clear-filter {
  background: #eef2ff;
  border: 1px solid #cbd5e1;
}

.tag-btn:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.tag-count {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 20px;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 500;
  margin-left: 0.2rem;
}

.tag-btn.active .tag-count {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.card {
  background: white;
  border-radius: 1.2rem;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.02);
  position: relative;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 30px -12px rgba(0, 0, 0, 0.15);
}

.media-preview {
  width: 100%;
  aspect-ratio: 16/9;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.card:hover .media-preview img,
.card:hover .media-preview video {
  transform: scale(1.02);
}

.play-svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  pointer-events: none;
}

.card-info {
  padding: 0.5rem 0.7rem 0.6rem;
}

.card-url {
  display: none;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 1;
}

.card-actions {
  display: flex;
  align-items: center;
  margin-top: 0;
}

.tag {
  background: #eef2ff;
  padding: 0.2rem 0.7rem;
  border-radius: 1.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #1e40af;
  cursor: pointer;
  transition: 0.1s;
  line-height: 1.2;
}

.tag:hover {
  background: #dbeafe;
  transform: scale(1.02);
}

.more-btn {
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 1.5rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.2s;
  color: #64748b;
}

.more-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.action-menu {
  position: fixed;
  background: white;
  border-radius: 1rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
  z-index: 3000;
  min-width: 140px;
  overflow: hidden;
  animation: menuFadeIn 0.15s ease;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid #f1f5f9;
}

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

.menu-item:hover {
  background: #f8fafc;
}

.menu-item svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

.menu-item.delete-item {
  color: #dc2626;
}

.menu-item.delete-item svg {
  stroke: #dc2626;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: pointer;
}

.modal-content {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 2rem;
  overflow: hidden;
}

.modal-content img,
.modal-content video {
  max-width: 100%;
  max-height: 85vh;
  display: block;
  border-radius: 1.5rem;
}

.empty-message {
  text-align: center;
  padding: 4rem 2rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 2rem;
  color: #475569;
  backdrop-filter: blur(4px);
}

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: white;
  padding: 8px 16px;
  border-radius: 40px;
  font-size: 14px;
  z-index: 4000;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

.tag-editor-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tag-editor-dialog {
  background: white;
  border-radius: 1.5rem;
  width: 90%;
  max-width: 400px;
  padding: 1.5rem;
  box-shadow: 0 20px 35px -12px rgba(0, 0, 0, 0.2);
  animation: dialogFadeIn 0.2s ease;
}

@keyframes dialogFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.tag-editor-dialog h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #0f172a;
}

.tag-editor-dialog input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
  font-family: inherit;
}

.tag-editor-dialog input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tag-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
}

.tag-editor-actions button {
  padding: 0.5rem 1.2rem;
  border-radius: 2rem;
  font-weight: 500;
  cursor: pointer;
  transition: 0.2s;
  border: none;
}

.tag-editor-actions .cancel-btn {
  background: #f1f5f9;
  color: #334155;
}

.tag-editor-actions .save-btn {
  background: #3b82f6;
  color: white;
}

.tag-editor-actions .cancel-btn:hover {
  background: #e2e8f0;
}

.tag-editor-actions .save-btn:hover {
  background: #2563eb;
}

@media (max-width: 720px) {
  body {
    padding: 1rem;
  }

  .header {
    padding: 0.8rem 1rem;
  }

  .header h2 {
    font-size: 1.3rem;
  }

  .add-form {
    padding: 0.8rem 1rem;
    gap: 0.6rem;
  }

  .add-form input,
  .add-form select,
  .add-form button {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
  }

  .gallery {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }

  .card {
    border-radius: 0.8rem;
  }

  .card-info {
    padding: 0.4rem 0.5rem 0.5rem;
  }

  .tags-row {
    gap: 0.3rem;
  }

  .tags-list {
    gap: 0.3rem;
  }

  .tag {
    font-size: 0.65rem;
    padding: 0.15rem 0.6rem;
  }

  .more-btn {
    width: 26px;
    height: 26px;
  }

  .play-svg {
    width: 40px;
    height: 40px;
  }

  .action-menu {
    min-width: 130px;
  }

  .menu-item {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .menu-item svg {
    width: 16px;
    height: 16px;
  }

  .tag-editor-dialog {
    padding: 1.2rem;
  }

  .tag-count {
    font-size: 0.6rem;
    padding: 0.05rem 0.3rem;
  }
}

@media (max-width: 480px) {
  .gallery {
    gap: 0.6rem;
  }

  .card-info {
    padding: 0.3rem 0.4rem 0.4rem;
  }

  .tag {
    font-size: 0.6rem;
    padding: 0.1rem 0.5rem;
  }

  .more-btn {
    width: 24px;
    height: 24px;
  }

  .play-svg {
    width: 36px;
    height: 36px;
  }

  .tag-count {
    font-size: 0.55rem;
    padding: 0.05rem 0.25rem;
  }
}