:root {
  --ios-bg: #f2f2f7;
  --ios-grouped: #ffffff;
  --ios-separator: rgba(60, 60, 67, 0.12);
  --text-primary: #1c1c1e;
  --text-secondary: #8e8e93;
  --accent: #f5c400;
  --accent-dark: #d4a800;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  background: var(--ios-bg);
  color: var(--text-primary);
  min-height: 100dvh;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(242, 242, 247, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--ios-separator);
  padding: calc(0.75rem + var(--safe-top)) 1rem 0.75rem;
}

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.12));
}

.brand-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Cards */
.ios-card {
  background: var(--ios-grouped);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 0.5px solid rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    box-shadow 0.25s ease;
}

.ios-card:active {
  transform: scale(0.98);
}

.album-cover {
  aspect-ratio: 2 / 1;
  object-fit: cover;
  width: 100%;
  background: #e5e5ea;
}

.album-meta {
  padding: 0.875rem 1rem 1rem;
}

.album-meta h2 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  letter-spacing: -0.01em;
}

.album-meta p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.badge-count {
  background: var(--accent);
  color: #1c1c1e;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

/* Photo grid in album */
.photo-thumb {
  aspect-ratio: 2 / 1;
  border-radius: 12px;
  object-fit: cover;
  width: 100%;
  background: #e5e5ea;
}

.photo-item {
  text-decoration: none;
  color: inherit;
  display: block;
}

.photo-item h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0.5rem 0 0.125rem;
}

.photo-item span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Buttons */
.btn-ios {
  background: var(--accent);
  color: #1c1c1e;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  transition: background 0.2s, transform 0.15s;
}

.btn-ios:hover,
.btn-ios:focus {
  background: var(--accent-dark);
  color: #1c1c1e;
}

.btn-ios:active {
  transform: scale(0.97);
}

.btn-ios-outline {
  background: transparent;
  border: 1.5px solid var(--ios-separator);
  color: var(--text-primary);
  font-weight: 600;
  border-radius: 12px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Viewer */
.viewer-shell {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
}

.viewer-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 210;
  padding: calc(0.5rem + var(--safe-top)) 0.75rem 0.5rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.viewer-topbar .btn-back {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.viewer-title {
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  flex: 1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewer-error {
  position: absolute;
  top: calc(3.5rem + var(--safe-top));
  left: 0.75rem;
  right: 0.75rem;
  z-index: 215;
  margin: 0;
  padding: 0.625rem 0.75rem;
  background: rgba(255, 59, 48, 0.92);
  color: #fff;
  font-size: 0.8125rem;
  border-radius: 10px;
  text-align: center;
}

.viewer-hint {
  position: absolute;
  bottom: calc(5rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 210;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.6s ease;
}

.viewer-hint.hidden {
  opacity: 0;
}

.viewer-nav {
  position: absolute;
  bottom: calc(1rem + var(--safe-bottom));
  left: 0;
  right: 0;
  z-index: 210;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 0 1rem;
}

.viewer-nav button {
  background: rgba(255, 255, 255, 0.92);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.viewer-nav button:disabled {
  opacity: 0.35;
}

.psv-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Búsqueda y filtros */
.search-panel {
  background: var(--ios-grouped);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1rem;
}

.search-input {
  width: 100%;
  border: none;
  background: var(--ios-bg);
  border-radius: 10px;
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  outline: none;
}

.search-input:focus {
  box-shadow: 0 0 0 2px rgba(245, 196, 0, 0.45);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.625rem;
}

.filter-row input {
  flex: 1 1 45%;
  min-width: 120px;
  border: none;
  background: var(--ios-bg);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-size: 0.8125rem;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.toolbar-actions .btn-ios {
  flex: 1;
}

.toolbar-actions .btn-delete {
  flex: 1;
  white-space: nowrap;
}

/* FAB */
.fab {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + var(--safe-bottom));
  z-index: 90;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #1c1c1e;
  border: none;
  font-size: 1.75rem;
  font-weight: 300;
  line-height: 1;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

/* Modal iOS */
.modal-ios {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-ios.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: var(--ios-grouped);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 1rem 1rem calc(1.25rem + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-ios.open .modal-sheet {
  transform: translateY(0);
}

.modal-sheet h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.modal-sheet label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
  display: block;
}

.modal-sheet .form-field {
  margin-bottom: 0.75rem;
}

.modal-sheet input,
.modal-sheet textarea {
  width: 100%;
  border: none;
  background: var(--ios-bg);
  border-radius: 10px;
  padding: 0.625rem 0.75rem;
  font-size: 1rem;
}

.modal-sheet textarea {
  min-height: 72px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.modal-actions button {
  flex: 1;
}

.thumb-360 {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 2 / 1;
  border-radius: 12px;
  background: linear-gradient(135deg, #2c2c2e 0%, #1c1c1e 100%);
  color: var(--accent);
  font-size: 2rem;
  font-weight: 700;
}

.upload-progress {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 0.5rem;
}

.btn-delete {
  background: #ff3b30;
  color: #fff;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
}

.btn-delete:active {
  opacity: 0.85;
}

.btn-delete-sm {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 59, 48, 0.92);
  color: #fff;
  font-size: 1.125rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.photo-card-wrap {
  position: relative;
}

.album-card-wrap {
  position: relative;
}

.album-card-wrap .btn-delete-sm {
  top: 10px;
  right: 10px;
}

/* Utilidades (sin Bootstrap) */
.app-header-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.text-secondary {
  color: var(--text-secondary);
}

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.loading-wrap {
  display: flex;
  justify-content: center;
  padding: 1rem 0;
}

/* Explorador — estilo Archivos iOS */
.explorer-main {
  max-width: 520px;
  margin: 0 auto;
  padding: 0.5rem 0.75rem calc(2rem + var(--safe-bottom));
}

.breadcrumb-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.8125rem;
  margin-bottom: 0.625rem;
  padding: 0.35rem 0.15rem;
}

.breadcrumb-bar .crumb {
  background: none;
  border: none;
  color: #007aff;
  font-weight: 500;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
}

.breadcrumb-bar .crumb:active {
  background: rgba(0, 122, 255, 0.12);
}

.breadcrumb-bar .crumb.current {
  color: var(--text-primary);
  font-weight: 600;
}

.crumb-sep {
  color: #c7c7cc;
  font-size: 0.75rem;
  user-select: none;
}

.explorer-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.explorer-toolbar .toolbar-grow {
  flex: 1;
  min-width: 0;
}

.search-panel {
  margin: 0.5rem 0;
}

.btn-icon {
  min-width: 44px;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  flex-shrink: 0;
}

.file-list {
  background: var(--ios-grouped);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  border: 0.5px solid rgba(0, 0, 0, 0.04);
}

.fi-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem 0.625rem 0.875rem;
  border-bottom: 0.5px solid var(--ios-separator);
  cursor: pointer;
  position: relative;
  transition: background 0.12s ease;
  min-height: 60px;
}

.fi-row:last-child {
  border-bottom: none;
}

.fi-row:active {
  background: rgba(0, 0, 0, 0.05);
}

.fi-row--folder {
  padding-right: 2.5rem;
}

/* Iconos SVG */
.fi-icon-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fi-icon-wrap--folder {
  width: 44px;
  height: 44px;
}

.fi-svg {
  display: block;
}

.fi-svg-folder {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 1px 2px rgba(0, 80, 200, 0.2));
}

.fi-icon-wrap--thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: #e5e5ea;
  position: relative;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

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

.fi-svg-pano {
  width: 56px;
  height: 56px;
}

.fi-badge {
  position: absolute;
  right: 3px;
  bottom: 3px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  line-height: 1;
}

.fi-info {
  flex: 1;
  min-width: 0;
  padding-right: 0.25rem;
}

.fi-info strong {
  display: block;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.fi-row--folder .fi-info strong {
  font-weight: 500;
}

.fi-meta {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.125rem;
}

.fi-chevron {
  position: absolute;
  right: 2.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #c7c7cc;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.fi-svg-chevron {
  width: 8px;
  height: 14px;
}

.fi-row .btn-delete-sm {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 28px;
  height: 28px;
  font-size: 1rem;
  opacity: 0.85;
}

.fi-row--file {
  padding-right: 2.5rem;
}

.fi-row--file .fi-chevron {
  display: none;
}

/* Animations */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.delay-1 {
  animation-delay: 0.06s;
}
.delay-2 {
  animation-delay: 0.12s;
}
.delay-3 {
  animation-delay: 0.18s;
}
.delay-4 {
  animation-delay: 0.24s;
}

/* Empty / loading */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
}

.spinner-ios {
  width: 28px;
  height: 28px;
  border: 2.5px solid #e5e5ea;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.section-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}
