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

:root {
  --primary: #e94560;
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-light: #1f3056;
  --text: #eee;
  --text-muted: #999;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Header */
header {
  background: var(--surface);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.photo-count {
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-light);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Sections */
.tab-content {
  display: none;
  padding: 16px;
}

.tab-content.active {
  display: block;
}

/* Camera Fullscreen Overlay */
.camera-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  flex-direction: column;
}

.camera-container {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

.camera-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform-origin: center center;
}

/* Camera overlay controls */
.camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

.camera-overlay-top {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  padding-top: calc(env(safe-area-inset-top, 12px) + 8px);
  pointer-events: auto;
}

.camera-overlay-bottom {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  padding: 0 24px 32px;
  padding-bottom: calc(env(safe-area-inset-bottom, 16px) + 24px);
  pointer-events: auto;
}

.cam-nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.2s;
}

.cam-nav-btn:active {
  transform: scale(0.9);
  background: rgba(0, 0, 0, 0.6);
}

.zoom-indicator {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 0.3s;
}

.zoom-indicator.visible {
  opacity: 1;
}

/* Project bar */
.project-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.project-bar:active {
  background: var(--surface-light);
}

.project-bar.no-project {
  background: rgba(233, 69, 96, 0.15);
  border-color: var(--primary);
  color: var(--primary);
  animation: pulse-bar 2s infinite;
}

@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Checklist */
.checklist-header {
  margin-bottom: 12px;
}

.checklist-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  color: var(--text);
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 0.95rem;
}

.checklist-item:active {
  background: var(--surface-light);
}

.checklist-item-status {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.checklist-item.has-photos .checklist-item-status {
  background: #4caf50;
  color: #fff;
}

.checklist-item-info {
  flex: 1;
  min-width: 0;
}

.checklist-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.checklist-item-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.checklist-item-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.checklist-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--surface-light);
}

.checklist-complete-btn {
  width: 100%;
}

/* Camera category label */
.camera-category-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 16px;
}

/* Project picker modal */
.picker-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 250;
  background: var(--bg);
  flex-direction: column;
}

.picker-modal.open {
  display: flex;
}

.picker-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  padding-top: calc(env(safe-area-inset-top, 14px) + 4px);
  background: var(--surface);
  border-bottom: 2px solid var(--primary);
  gap: 12px;
}

.picker-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
}

.picker-back,
.picker-close {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
}

.picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--surface-light);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 1rem;
}

.picker-item:active {
  background: var(--surface-light);
}

.picker-item-label {
  font-weight: 600;
}

.picker-item-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.picker-item-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
}

.picker-item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
}

.picker-item-delete:active {
  color: var(--primary);
  background: rgba(233, 69, 96, 0.1);
}

.picker-add {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  padding-bottom: calc(env(safe-area-inset-bottom, 12px) + 8px);
  background: var(--surface);
  border-top: 1px solid var(--surface-light);
}

.picker-input {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

.picker-input.invalid {
  border-color: var(--primary);
}

.picker-add-btn {
  white-space: nowrap;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.capture-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  position: relative;
}

.capture-btn::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(0, 0, 0, 0.08);
}

.capture-btn:active {
  transform: scale(0.88);
}

.capture-btn:active::after {
  background: #ddd;
}

.capture-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Preview — fullscreen overlay */
.preview-section {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 160;
  background: var(--bg);
  flex-direction: column;
  overflow-y: auto;
}

.preview-section.visible {
  display: flex;
}

.preview-section img {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  background: #000;
  display: block;
  flex-shrink: 0;
}

.preview-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.preview-form input,
.preview-form textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.preview-form textarea {
  resize: vertical;
  min-height: 70px;
}

.preview-actions {
  display: flex;
  gap: 10px;
}

.preview-actions .btn {
  flex: 1;
}

.preview-actions-simple {
  display: flex;
  gap: 16px;
  padding: 20px 16px;
  padding-bottom: calc(env(safe-area-inset-bottom, 16px) + 20px);
}

.preview-actions-simple .btn {
  flex: 1;
  justify-content: center;
}

.btn-large {
  padding: 16px 24px;
  font-size: 1.05rem;
}

/* Camera error / fallback */
.camera-fallback {
  text-align: center;
  padding: 40px 20px;
}

.camera-fallback p {
  margin-bottom: 16px;
  color: var(--text-muted);
}

.file-input-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.file-input-label input {
  display: none;
}

/* Gallery breadcrumb & folders */
.gallery-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.gallery-breadcrumb-item {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.gallery-breadcrumb-item:active {
  background: var(--surface-light);
}

.gallery-breadcrumb-item.current {
  color: var(--text);
  cursor: default;
}

.gallery-breadcrumb-sep {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.gallery-folders {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.gallery-folder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  color: var(--text);
  transition: background 0.15s;
}

.gallery-folder:active {
  background: var(--surface-light);
}

.gallery-folder svg {
  color: var(--primary);
}

.gallery-folder-name {
  font-size: 0.85rem;
  font-weight: 600;
  word-break: break-all;
  text-align: center;
}

.gallery-folder-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Gallery */
.gallery-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.gallery-empty p:first-child {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

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

.photo-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s;
}

.photo-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.photo-card-info {
  padding: 10px 12px;
}

.photo-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
  word-break: break-word;
}

.photo-card-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  word-break: break-word;
}

.photo-card-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.photo-card-actions {
  padding: 0 12px 10px;
  display: flex;
  justify-content: flex-end;
}

.btn-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.btn-delete:hover {
  color: var(--primary);
  background: rgba(233, 69, 96, 0.1);
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 12px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-light);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform 0.3s ease;
  z-index: 300;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 480px) {
  header h1 {
    font-size: 1rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  .photo-card-info {
    padding: 8px 10px;
  }

  .photo-card-title {
    font-size: 0.85rem;
  }

  .tab-content {
    padding: 12px;
  }
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

/* Header sync indicator */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  display: none;
}

.sync-indicator.syncing {
  display: inline-block;
  background: #f0c040;
  animation: pulse 1s infinite;
}

.sync-indicator.synced {
  display: inline-block;
  background: #4caf50;
}

.sync-indicator.offline {
  display: inline-block;
  background: #f44336;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Upload badge on photo cards */
.photo-card {
  position: relative;
}

.upload-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  color: #fff;
  pointer-events: none;
}

.upload-badge.pending {
  background: #f0c040;
  color: #333;
}

.upload-badge.uploaded {
  background: #4caf50;
}

.upload-badge.error {
  background: #f44336;
}

/* Settings */
.settings-form {
  max-width: 480px;
  margin: 0 auto;
}

.settings-heading {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.settings-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 12px;
}

.settings-form input[type="text"],
.settings-form input[type="password"] {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.settings-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.settings-select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.settings-actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
}

.settings-actions .btn {
  flex: 1;
}

.settings-status {
  margin-top: 12px;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.settings-status.success {
  color: #4caf50;
}

.settings-status.error {
  color: #f44336;
}

.settings-queue-info {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.settings-info {
  background: var(--surface);
  border: 1px solid var(--surface-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.settings-info p {
  margin: 0;
}

.settings-details {
  margin-top: 8px;
}

.settings-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
  font-size: 0.85rem;
}

.settings-details ol {
  margin: 8px 0 0 0;
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 0.83rem;
  line-height: 1.7;
}
