:root {
  --bg: #fff5f8;
  --bg-2: #ffe8f0;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-2: #fff0f5;
  --border: #f5c6d6;
  --text: #5a2a3d;
  --text-muted: #b0758c;
  --primary: #f06292;
  --primary-hover: #e84a80;
  --primary-soft: #f8bbd0;
  --success: #43a047;
  --error: #e53935;
  --accent: #ff8a65;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(240, 98, 146, 0.15);
  --font: "Nunito", system-ui, sans-serif;
  --font-brand: "Pacifico", cursive;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: linear-gradient(165deg, #fff7fb 0%, #ffe4ef 45%, #fff0f6 100%);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.bg-garden {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.5;
  animation: float 12s ease-in-out infinite;
  will-change: transform;
}

.blob-a {
  width: 280px;
  height: 280px;
  background: #ffc1d6;
  top: -60px;
  right: -40px;
}

.blob-b {
  width: 220px;
  height: 220px;
  background: #ffd4e5;
  bottom: 10%;
  left: -70px;
  animation-delay: -4s;
}

.blob-c {
  width: 160px;
  height: 160px;
  background: #ffe0c8;
  top: 40%;
  right: 10%;
  animation-delay: -7s;
}

.flower {
  position: absolute;
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 6px 10px rgba(240, 98, 146, 0.18));
  animation: sway 7s ease-in-out infinite;
  will-change: transform;
}

.flower-1 { top: 8%; left: 4%; width: 78px; height: 78px; animation-delay: 0s; }
.flower-2 { top: 18%; right: 3%; width: 64px; height: 64px; animation-delay: -1.5s; }
.flower-3 { bottom: 22%; left: 2%; width: 70px; height: 70px; animation-delay: -3s; }
.flower-4 { bottom: 12%; right: 6%; width: 58px; height: 58px; animation-delay: -2s; }
.flower-5 { top: 48%; left: -2%; width: 52px; height: 52px; opacity: 0.85; animation-delay: -4.5s; }
.flower-6 { top: 62%; right: -1%; width: 60px; height: 60px; opacity: 0.8; animation-delay: -5.5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(18px) scale(1.05); }
}

@keyframes sway {
  0%, 100% { transform: rotate(-6deg) translateY(0); }
  50% { transform: rotate(7deg) translateY(-8px); }
}

.brand {
  font-family: var(--font-brand);
  font-size: 1.75rem;
  color: var(--primary);
  line-height: 1.1;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.brand-tag {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

/* Login */
.login-page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 2rem 1.5rem 1.75rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: rise-in 0.55s ease both;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-badge {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #ff8fb3, #f06292);
  color: white;
  font-size: 1.5rem;
  box-shadow: 0 8px 20px rgba(240, 98, 146, 0.35);
  animation: pulse-soft 2.4s ease-in-out infinite;
}

@keyframes pulse-soft {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.login-card .brand {
  font-size: 2.4rem;
  margin-bottom: 0.35rem;
}

.login-card h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.35rem 0 1.25rem;
}

.login-form {
  text-align: left;
}

.login-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  margin-top: 0.75rem;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--surface-solid);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 16px; /* prevents iOS zoom on focus */
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(240, 98, 146, 0.15);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 247, 251, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.25rem;
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow-x: auto;
  white-space: nowrap;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.breadcrumb .sep {
  margin: 0 0.25rem;
}

.breadcrumb .current {
  color: var(--text);
  font-weight: 700;
}

.main {
  position: relative;
  z-index: 1;
  padding: 1rem 1.25rem 2.5rem;
  padding-bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
  max-width: 900px;
  margin: 0 auto;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px;
  padding: 0.75rem 1.2rem;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #ff7eb3, #f06292 55%, #ec407a);
  color: #fff;
  box-shadow: 0 8px 18px rgba(240, 98, 146, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ff6fa8, #e84a80);
}

.btn-secondary {
  background: var(--surface-solid);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.78rem;
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 1.25rem;
}

.btn-icon {
  font-size: 1rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.actions .btn-primary {
  flex: 1 1 160px;
}

.actions .btn-secondary {
  flex: 1 1 120px;
}

/* Flash */
.flash {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.flash-success {
  background: rgba(67, 160, 71, 0.12);
  border: 1px solid rgba(67, 160, 71, 0.25);
  color: var(--success);
}

.flash-error {
  background: rgba(229, 57, 53, 0.1);
  border: 1px solid rgba(229, 57, 53, 0.25);
  color: var(--error);
}

/* Upload panel */
.upload-panel {
  background: var(--surface-solid);
  border: 1.5px solid var(--primary-soft);
  border-radius: 22px;
  padding: 1rem 1.1rem 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  animation: rise-in 0.35s ease both;
  position: sticky;
  top: calc(4.5rem + env(safe-area-inset-top, 0px));
  z-index: 9;
}

.upload-panel.is-done {
  border-color: rgba(67, 160, 71, 0.45);
}

.upload-panel-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.upload-heart {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #ff8fb3, #f06292);
  color: #fff;
  font-size: 1.25rem;
  flex-shrink: 0;
  animation: pulse-soft 1.2s ease-in-out infinite;
}

.upload-panel.is-done .upload-heart {
  animation: none;
  background: linear-gradient(145deg, #66bb6a, #43a047);
}

.upload-panel-copy {
  flex: 1;
  min-width: 0;
}

.upload-title {
  font-weight: 800;
  font-size: 1rem;
}

.upload-progress-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.upload-percent {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
}

.upload-track {
  height: 12px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.65rem;
}

.upload-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff8fb3, #f06292, #ff8a65);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  transition: width 0.2s ease;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.upload-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.65rem;
}

.upload-file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 140px;
  overflow-y: auto;
}

.upload-file-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.45rem 0.65rem;
}

.upload-file-list .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

.upload-file-list .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #fff;
  border: 1.5px solid rgba(67, 160, 71, 0.35);
  color: var(--success);
  padding: 0.85rem 1.15rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: calc(100vw - 2rem);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
}

/* Sections */
.section {
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 800;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.folder-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1rem;
  background: var(--surface-solid);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  font-weight: 700;
}

.folder-card:hover, .folder-card:active {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.folder-icon {
  color: var(--primary);
  font-size: 1.1rem;
}

.folder-name {
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.75rem;
}

.image-card {
  display: block;
  background: var(--surface-solid);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  padding: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.image-card:hover, .image-card:active {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.image-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.video-thumb {
  position: relative;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #ffd1e1, #f8bbd0);
  overflow: hidden;
}

.video-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.25rem;
  color: #fff;
  background: rgba(240, 98, 146, 0.75);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 0.15rem;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(240, 98, 146, 0.35);
}

.image-name {
  display: block;
  padding: 0.5rem 0.6rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(90, 42, 61, 0.35);
}

.modal-card {
  position: relative;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  font-size: 1.2rem;
  font-weight: 800;
}

.modal-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.25rem 0 1rem;
}

.modal-card input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
}

.modal-card input:focus {
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Viewer */
.viewer-status {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.85rem;
  z-index: 2;
  background: rgba(240, 98, 146, 0.85);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-weight: 700;
}

.viewer-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.viewer-modal[hidden] {
  display: none;
}

.viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 20, 30, 0.92);
}

.viewer-content {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 0.5rem 1rem;
}

.viewer-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
}

.viewer-title {
  position: fixed;
  top: 1rem;
  left: 1rem;
  right: 4rem;
  color: #fff;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 2;
  font-weight: 700;
}

.viewer-play-btn {
  position: relative;
  z-index: 2;
  margin-bottom: 1rem;
  padding: 1rem 2rem;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: 800;
  background: linear-gradient(135deg, #ff7eb3, #f06292);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(240, 98, 146, 0.4);
}

.viewer-image,
.viewer-video {
  width: 100%;
  max-width: 100%;
  max-height: calc(100dvh - 5rem);
  object-fit: contain;
  background: #000;
  border-radius: var(--radius);
  display: block;
}

@media (max-width: 480px) {
  .flower {
    width: 56px;
    height: 56px;
  }

  .flower-1 { width: 64px; height: 64px; }
  .flower-5, .flower-6 { display: none; } /* keep phone uncluttered */

  .blob {
    filter: blur(28px);
    opacity: 0.4;
  }

  .brand {
    font-size: 1.55rem;
  }

  .login-card .brand {
    font-size: 2.1rem;
  }

  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .folder-grid {
    grid-template-columns: 1fr 1fr;
  }

  .upload-percent {
    font-size: 1.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blob,
  .flower,
  .upload-heart,
  .upload-progress-bar,
  .login-badge {
    animation: none !important;
  }
}

@media (min-width: 480px) {
  .modal {
    align-items: center;
  }

  .modal-card {
    border-radius: 24px;
  }
}
