/* App styles (admin, booth, gallery, orders). Load after base.css. */

/* ===== Panels & toggles ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 12px;
}

.local-backup-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.backup-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  transition: background-color 0.2s;
  border-radius: 26px;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background-color: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.toggle-label {
  font-size: 15px;
  font-weight: 500;
}

.no-storage-warning {
  font-size: 13px;
  color: var(--warning-text);
  background: var(--warning-soft);
  border-radius: 10px;
  padding: 8px 12px;
}

.backup-folder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 56px;
}

.btn-select-folder {
  padding: 6px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-select-folder:hover {
  border-color: var(--accent);
}

.folder-path {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.folder-path.selected {
  color: var(--accent-text);
  font-weight: 600;
}

/* ===== Loading ===== */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--muted);
}

/* Ring with a fading tail; only transform animates, so it stays on the compositor */
.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 20%, var(--accent));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
  animation: spin 1.2s linear infinite;
}

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

/* Button busy (loader "C"): a segment runs around a ring inside the button.
   Plays even with reduced motion turned on (owner's choice - Windows animations are off on their PC). */
.btn.is-busy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: progress;
}

.btn.is-busy:disabled {
  opacity: 0.85;
}

.btn-ring {
  display: inline-flex;
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
}

.btn-ring svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.btn-ring circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
}

.btn-ring-track {
  opacity: 0.25;
}

.btn-ring-run {
  stroke-linecap: round;
  stroke-dasharray: 14 43;
  transform-origin: 12px 12px;
  animation: btn-ring-run 1.6s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

@keyframes btn-ring-run {
  to { transform: rotate(360deg); }
}

/* ===== Login ===== */
.login-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 40px;
  max-width: 420px;
  margin: 12vh auto 0;
  box-shadow: var(--shadow-lg);
}

.login-box .brand {
  margin-bottom: 28px;
}

.login-box h1 {
  font-size: 26px;
  margin-bottom: 24px;
}

.login-box .btn {
  width: 100%;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
}

.form-group small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.form-group .checkbox-label {
  font-weight: 500;
}

.form-group .checkbox-label input {
  width: 18px;
}

.error-message {
  color: var(--danger);
  margin-top: 14px;
  text-align: center;
  font-size: 14px;
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.back-link:hover {
  color: var(--text);
}

/* ===== Admin ===== */
/* Layout: fixed sidebar (menu) + main content. Phones: sidebar slides in from the hamburger button. */
.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 900;
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.admin-sidebar .brand {
  padding: 0 8px;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.admin-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.admin-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.admin-nav-ext {
  margin-left: auto;
  opacity: 0.6;
}

.admin-sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.admin-logout {
  flex: 1;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.admin-logout:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

body.admin-authed {
  padding-left: 240px;
}

.admin-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 32px 24px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 20px;
}

.admin-topbar .db-status {
  margin-left: auto;
}

.admin-menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.admin-backdrop {
  position: fixed;
  inset: 0;
  z-index: 899;
  background: rgba(10, 11, 14, 0.45);
}

@media (max-width: 900px) {
  body.admin-authed {
    padding-left: 0;
  }

  .admin-sidebar {
    width: min(280px, 84vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }

  .admin-menu-open .admin-sidebar {
    transform: none;
  }

  .admin-menu-btn {
    display: inline-flex;
  }

  .admin-main {
    padding: 12px 16px 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .admin-sidebar,
  .admin-menu-open .admin-sidebar {
    transition: none;
  }
}

/* Upload queue status (capture page) */
.upload-queue-status {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  cursor: pointer;
}

.upload-queue-status[hidden] { display: none; }

.upload-queue-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--warning-text);
  animation: db-pulse 1.2s ease-in-out infinite;
}

.upload-queue-status[data-state="offline"] { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.upload-queue-status[data-state="offline"] .upload-queue-dot { animation: none; }
.upload-queue-status[data-state="error"] { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.upload-queue-status[data-state="error"] .upload-queue-dot { background: var(--danger); animation: none; }

@media (prefers-reduced-motion: reduce) {
  .upload-queue-dot { animation: none; }
}

/* Database (Supabase) status */
.db-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.db-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.db-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  flex-shrink: 0;
}

.db-status[data-state="active"] .db-status-dot { background: var(--success); }
.db-status[data-state="paused"] .db-status-pill { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.db-status[data-state="paused"] .db-status-dot { background: var(--warning-text); }
.db-status[data-state="waking"] .db-status-dot { background: var(--warning-text); animation: db-pulse 1.2s ease-in-out infinite; }
.db-status[data-state="error"] .db-status-pill { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.db-status[data-state="error"] .db-status-dot { background: var(--danger); }

.db-status-link {
  font-size: 13px;
  color: var(--accent-text);
}

@keyframes db-pulse {
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .db-status[data-state="waking"] .db-status-dot { animation: none; }
}

@media (max-width: 768px) {
  .db-status-pill span:last-child { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 30px;
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.event-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s;
}

.event-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.event-card h3 {
  font-size: 18px;
  margin-bottom: 10px;
}

.event-card p {
  color: var(--muted);
  font-size: 14px;
  margin: 2px 0;
}

.event-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.btn-icon {
  background: var(--surface-2);
  color: var(--text);
  border: none;
  border-radius: 12px;
  height: 40px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ===== Modal ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 14, 0.55);
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.modal-large {
  max-width: 1040px;
}

.modal-fullscreen {
  max-width: 95vw;
  max-height: 95vh;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-right: 52px;
}

.modal-header h2 {
  font-size: 22px;
}

.close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, color 0.15s;
}

.close-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ===== Capture page ===== */
.page-capture .container {
  max-width: none;
  padding: 0;
}

.capture-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  max-width: 1640px;
  margin: 0 auto;
  padding: 24px 28px;
}

.capture-main {
  /* Keep the 3:2 camera fully visible on a laptop screen: header + paddings + filter strip */
  width: min(100%, calc((100vh - 200px) * 1.5));
  margin: 0 auto;
}

.camera-stage {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--cam);
}

.camera-container {
  position: relative;
  width: 100%;
}

#video {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
}

/* GPU preview: video stays as the (invisible) source, canvas shows the adjusted image */
#video.video-source-hidden {
  opacity: 0;
}

.live-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Mirror mode: only the live view is flipped (the photo stays the real way round) */
.camera-container.is-mirrored #video,
.camera-container.is-mirrored .live-preview {
  transform: scaleX(-1);
}

/* Sidebar entry to the settings drawer + one-line summary of what is on */
.settings-entry {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-entry-btn {
  width: 100%;
  justify-content: center;
  gap: 10px;
}

.settings-entry-btn kbd {
  margin-left: 2px;
}

.settings-summary {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* Settings drawer groups: camera modes / adjustments / filters */
.drawer-group {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-group:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.drawer-group-title {
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.filter-strip.filter-grid {
  flex-wrap: wrap;
  margin-top: 0;
  padding: 0;
  overflow: visible;
  background: none;
  border: 0;
}

/* Camera resolution choice + what the camera really sends */
.camres-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.camres-select {
  min-height: 38px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.camres-info {
  margin: -6px 0 0;
}

.camres-info[data-state="warn"] {
  color: var(--warning-text);
}

/* Backdrop wrinkle removal: small badge on the photo preview while it is being processed */
.backdrop-badge {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.9rem;
  pointer-events: none;
}

.backdrop-badge[hidden] {
  display: none;
}

.backdrop-badge-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: backdropSpin 0.8s linear infinite;
}

/* Backdrop level picker on the photo preview (change without retaking) */
.backdrop-levels {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.85rem;
}

.backdrop-levels-label {
  padding: 0 8px 0 10px;
  white-space: nowrap;
}

.backdrop-levels-label kbd {
  font-size: 0.75rem;
  opacity: 0.8;
}

.backdrop-levels button {
  border: 0;
  border-radius: 999px;
  padding: 5px 12px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.backdrop-levels button:hover {
  background: rgba(255, 255, 255, 0.15);
}

.backdrop-levels button[aria-checked="true"] {
  background: #fff;
  color: #111;
  font-weight: 600;
}

.backdrop-levels button:disabled {
  cursor: wait;
}

@media (max-width: 600px) {
  .backdrop-levels-label { display: none; }
  .backdrop-badge { top: 60px; }
}

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

/* Camera modes (mirror / auto-center / countdown) */
.camera-modes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.camera-modes .toggle-label kbd {
  margin-left: 4px;
}

.camera-mode-status {
  margin: -4px 0 0 56px;
  font-size: 13px;
  color: var(--muted);
}

.camera-mode-status[hidden] {
  display: none;
}

.camera-mode-status[data-state="tracking"] {
  color: var(--accent-text);
}

.camera-mode-status[data-state="error"] {
  color: var(--danger);
}

.countdown {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.countdown-number {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 3px solid var(--cam-ring);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: 140px;
  font-weight: 700;
  line-height: 1;
  color: var(--cam-accent);
  animation: countdownPulse 1s ease-in-out;
}

@keyframes countdownPulse {
  0% { transform: scale(0.6); opacity: 0; }
  50% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.camera-controls {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.camera-controls > * {
  pointer-events: auto;
}

.camera-select {
  max-width: 280px;
  padding: 8px 14px;
  border-radius: 999px;
  border: none;
  background: rgba(20, 21, 25, 0.62);
  color: #F2F2F5;
  font-size: 13px;
  color-scheme: dark;
}

.btn-flip-camera {
  margin-left: auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: rgba(20, 21, 25, 0.62);
  color: #F2F2F5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-flip-camera:hover {
  background: rgba(20, 21, 25, 0.85);
}

.btn-flip-camera svg {
  width: 20px;
  height: 20px;
}

.preview-container {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--cam);
}

.preview-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.preview-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.filter-strip[hidden] {
  display: none;
}

.filter-strip {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding: 8px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  scrollbar-width: none;
}

.filter-strip::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  flex-shrink: 0;
  min-height: 40px;
  padding: 8px 16px;
  background: var(--surface-2);
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}

.filter-btn:hover {
  background: var(--accent-soft);
}

.filter-btn.active {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.capture-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.shot-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

.shot-head > span:first-child {
  font-size: 14px;
  color: var(--muted);
}

.photo-counter {
  font-family: var(--font-num);
  font-size: 28px;
  font-weight: 700;
}

.photo-counter-total {
  font-size: 18px;
  color: var(--muted);
}

.thumbnails {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.thumbnail {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid transparent;
  opacity: 0.5;
}

.thumbnail.active {
  border-color: var(--accent);
  opacity: 1;
}

.btn-adjust-more {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 14px;
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
}

.btn-adjust-more:hover {
  text-decoration: underline;
}

.quick-adjust {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.capture-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.btn-shutter {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 0 0 8px var(--accent-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background-color 0.15s;
}

.btn-shutter:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.btn-shutter:active:not(:disabled) {
  transform: scale(0.96);
}

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

.shutter-label {
  font-size: 15px;
  font-weight: 600;
}

/* ===== Frame selection ===== */
.frame-selection-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.frames-grid-container {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.frames-grid-with-preview {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 12px;
}

.frame-preview-card {
  position: relative;
  width: 180px;
  flex-shrink: 0;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s;
}

.frame-preview-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.frame-preview-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.frame-preview-card.selected::after {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  z-index: 10;
}

.frame-preview-canvas {
  width: 100%;
  display: block;
  aspect-ratio: 1 / 3;
  background: var(--surface-2);
}

.frame-preview-label {
  padding: 10px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.frame-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}

.frame-actions .btn {
  min-width: 200px;
}

.keyboard-hint {
  text-align: center;
  padding: 10px 18px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

.keyboard-hint kbd {
  margin: 0 2px;
  background: var(--surface);
}

/* ===== Success ===== */
.success-message {
  max-width: 560px;
  margin: 56px auto;
  padding: 40px 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
}

.success-icon {
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--success);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 700;
}

.success-message h2 {
  font-size: 28px;
  margin-bottom: 8px;
}

.success-message p {
  color: var(--muted);
}

.success-note {
  font-size: 14px;
  margin-top: 4px;
}

.success-message .button-group {
  justify-content: center;
  margin-top: 28px;
}

/* ===== Gallery ===== */
.page-gallery .container {
  padding: 40px 32px;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.gallery-header h1 {
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.gallery-info {
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 14px;
}

.gallery-info .gallery-notice {
  margin-top: 2px;
}

.photo-sets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
}

.photo-set-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s;
}

.photo-set-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
}

.photo-set-thumbnail {
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 6;
  object-fit: cover;
  border-radius: 12px;
  display: block;
  background: var(--surface-2);
}

.photo-set-info {
  padding: 10px 4px 2px;
}

.photo-set-info h3 {
  font-family: var(--font-num);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-set-info p {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* Photo viewer */
/* กดปุ่มถัดไป/ก่อนหน้าเร็วๆ บนมือถือไม่ให้กลายเป็น double-tap zoom (ยังถ่างนิ้วซูมได้) */
.photo-viewer-modal {
  touch-action: manipulation;
}

.photo-viewer-modal .modal-content {
  padding: 24px;
}

.photo-viewer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 60vh;
  position: relative;
  background: var(--surface-2);
  border-radius: 18px;
  padding: 20px;
}

.photo-display {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.photo-display img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.25s ease;
}

.photo-display img.loading {
  opacity: 0;
}

.photo-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 10;
}

.photo-loading.hidden {
  display: none;
}

.photo-loading p {
  color: var(--muted);
  font-size: 14px;
}

.nav-btn {
  z-index: 1;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.nav-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

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

.photo-info {
  width: fit-content;
  margin: 16px auto 8px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  font-family: var(--font-num);
  font-size: 15px;
}

.viewer-notice {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.viewer-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ===== Event detail ===== */
.event-detail-content {
  display: grid;
  gap: 16px;
}

.detail-section {
  padding: 18px;
  background: var(--surface-2);
  border-radius: 16px;
}

.detail-section h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}

.detail-section h4 {
  margin-bottom: 10px;
  font-size: 15px;
}

#eventInfo p {
  font-size: 14px;
  margin-bottom: 4px;
}

#eventInfo .checkbox-label {
  margin-top: 10px;
}

.link-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.link-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.link-item label {
  font-weight: 600;
  font-size: 14px;
}

.link-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-num);
  font-size: 13px !important;
}

.qr-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* QR stays black-on-white in dark mode too (scanners need the contrast) */
.qr-box {
  width: 220px;
  max-width: 100%;
  padding: 8px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid var(--line);
}

.qr-box svg {
  display: block;
  width: 100%;
  height: auto;
}

.qr-box[hidden] {
  display: none;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--text);
  color: var(--bg);
  padding: 14px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Admin frames ===== */
.frame-upload {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.frames-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.frames-grid.frames-grid-sets {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.frame-set {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.frame-item {
  position: relative;
  aspect-ratio: 1 / 3;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.frame-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frame-item-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.frame-item:hover .frame-item-actions,
.frame-item:focus-within .frame-item-actions {
  opacity: 1;
}

.frame-edit-btn,
.frame-delete-btn,
.frame-upload-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frame-edit-btn:hover,
.frame-upload-btn:hover {
  background: var(--accent);
  color: var(--on-accent);
}

.frame-delete-btn {
  color: var(--danger);
}

.frame-delete-btn:hover {
  background: var(--danger);
  color: var(--surface);
}

.frame-edit-btn svg,
.frame-delete-btn svg,
.frame-upload-btn svg,
.overlay-badge svg,
.btn-icon svg {
  pointer-events: none;
}

.overlay-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 5;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.frame-item-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 5;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
}

.frame-card-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
}

/* ===== Adjustment drawer ===== */
.adjustment-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100%;
  z-index: 90;
  /* Transparent container must not block taps (e.g. capture button on mobile) */
  pointer-events: none;
}

.adjustment-panel-floating {
  position: absolute;
  inset: 0;
  transform: translateX(100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-radius: 24px 0 0 24px;
  padding: 24px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transition: transform 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.adjustment-overlay.show .adjustment-panel-floating {
  transform: translateX(0);
  pointer-events: auto;
}

.adjustment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.adjustment-header h3 {
  font-size: 18px;
  margin-right: auto;
}

.btn-reset,
.btn-close-drawer {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}

.btn-reset:hover,
.btn-close-drawer:hover {
  background: var(--accent-soft);
}

.adjustment-section {
  margin-bottom: 18px;
}

.adjustment-section:last-child {
  margin-bottom: 0;
}

.adjustment-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 8px;
}

.adjustment-value {
  font-family: var(--font-num);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 14px;
  min-width: 40px;
  text-align: right;
}

.adjustment-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.adjustment-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.adjustment-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* ===== Frame editor ===== */
.frame-editor-container {
  display: flex;
  gap: 20px;
  min-height: 70vh;
}

.editor-sidebar {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface-2);
  padding: 20px;
  border-radius: 18px;
  overflow-y: auto;
  max-height: 80vh;
}

.editor-sidebar h3 {
  margin-bottom: 16px;
  font-size: 18px;
}

.tool-section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tool-section:last-child {
  border-bottom: none;
}

.tool-section h4 {
  margin-bottom: 10px;
  font-size: 15px;
}

.tool-section label {
  cursor: pointer;
  user-select: none;
}

.tool-info {
  color: var(--muted);
  font-size: 13px;
}

.tool-section input[type="color"] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  margin-bottom: 8px;
}

.tool-section input[type="text"],
.tool-section select {
  width: 100%;
  font-size: 14px;
  margin-bottom: 8px;
}

.tool-section input[type="range"] {
  width: 100%;
  margin-bottom: 8px;
  accent-color: var(--accent);
}

.tool-section .btn {
  margin: 0 6px 6px 0;
}

.text-controls {
  margin-bottom: 10px;
}

.text-controls label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.text-controls input[type="checkbox"] {
  margin-right: 6px;
  vertical-align: middle;
}

.editor-canvas-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--surface-2);
  border-radius: 18px;
  padding: 20px;
  overflow: auto;
}

#frameCanvas {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  background: #FFFFFF;
  cursor: default;
}

.text-list-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.text-preview {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-actions {
  display: flex;
  gap: 4px;
}

.btn-icon-small {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-small:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

/* ===== Greeting card + print options ===== */
.print-option-card {
  background: var(--surface-2);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 14px;
}

.print-option-card h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.print-option-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 14px;
}

.card-option-body {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.card-preview-canvas {
  width: 120px;
  aspect-ratio: 1 / 3;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}

.card-photo-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card-photo-option {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: border-color 0.15s;
}

.card-photo-option img {
  width: 96px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
}

.card-photo-option span {
  width: 100%;
  text-align: center;
  font-size: 13px;
  padding: 2px 0;
}

.card-photo-option:hover,
.card-photo-option.selected {
  border-color: var(--accent);
}

.card-photo-option.selected span {
  background: var(--accent);
  color: var(--on-accent);
}

.no-card-notice {
  margin-top: 12px;
  font-size: 13px;
  color: var(--warning-text);
  max-width: 320px;
}

.no-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning-text);
  font-size: 12px;
  font-weight: 600;
}

.quantity-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quantity-stepper .btn {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 22px;
}

.quantity-stepper input {
  width: 84px;
  height: 44px;
  text-align: center;
  font-family: var(--font-num);
  font-size: 20px;
}

.print-summary {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

/* Print modal: strip count per selected frame + greeting cards */
.print-count-list {
  display: grid;
  gap: 10px;
}

.print-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.print-count-name {
  font-weight: 600;
}

.print-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.print-card-head h3 {
  margin-bottom: 0;
}

#cardSettings[hidden] {
  display: none;
}

.print-card-auto {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin: 6px 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.btn-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.btn-link[hidden],
.card-frame-picker[hidden] {
  display: none;
}

.card-frame-picker {
  margin-bottom: 14px;
}

.card-frame-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-frame-option {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.card-frame-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

/* Frame selection: keyboard cursor (dashed) - Space adds/removes this frame */
.frame-preview-card.is-cursor {
  outline: 3px dashed var(--accent);
  outline-offset: 4px;
}

/* Frame selection: order number when several frames are picked (1 = main frame) */
/* sits left of the ✓ (top-left is taken by the "no card frame" badge) */
.frame-order-badge {
  position: absolute;
  top: 11px;
  right: 46px;
  z-index: 2;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-size: 14px;
  font-weight: 700;
}

.frame-selection-count {
  margin-left: 8px;
  color: var(--accent-text);
}

.print-type-options {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.print-type-options label,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .hero-visual {
    display: none;
  }

  .capture-content {
    grid-template-columns: 1fr;
  }

  .capture-main {
    width: 100%;
  }

  .capture-side {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }

  .capture-actions {
    order: -1;
    grid-column: 1 / -1;
    margin-top: 0;
  }
}

@media (max-width: 1024px) {
  .frame-editor-container {
    flex-direction: column;
  }

  .editor-sidebar {
    width: 100%;
    max-height: none;
  }

  .editor-canvas-container {
    min-height: 400px;
  }

  #frameCanvas {
    max-height: 60vh;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 16px;
  }

  .page-home .container {
    padding: 20px 16px;
  }

  .welcome-screen {
    padding: 32px 0;
  }

  .subtitle {
    font-size: 17px;
  }

  .hero-stats {
    gap: 24px;
  }

  .app-bar {
    padding: 10px 16px;
    gap: 12px;
  }

  .stepper {
    display: none;
  }

  .stepper + .app-bar-actions {
    margin-left: auto;
  }

  .capture-content {
    padding: 16px;
    gap: 16px;
  }

  .camera-stage {
    border-radius: 16px;
  }

  .countdown-number {
    width: 150px;
    height: 150px;
    font-size: 90px;
  }

  .preview-actions .btn-action {
    padding: 10px 16px;
    min-height: 44px;
    font-size: 15px;
  }

  .btn-flip-camera {
    width: 48px;
    height: 48px;
  }

  .backup-folder {
    padding-left: 0;
    flex-wrap: wrap;
  }

  .page-gallery .container {
    padding: 24px 16px;
  }

  .photo-sets-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  .events-grid {
    grid-template-columns: 1fr;
  }

  .section-header h2 {
    font-size: 24px;
  }

  .modal {
    padding: 12px;
  }

  .modal-content {
    padding: 20px;
  }

  .link-input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .photo-viewer {
    padding: 10px;
    gap: 8px;
    min-height: 50vh;
  }

  .photo-display {
    min-height: 300px;
  }

  .photo-display img {
    max-height: 60vh;
  }

  .nav-btn {
    width: 44px;
    height: 44px;
    font-size: 26px;
  }

  .frame-preview-card {
    width: 150px;
  }

  .frame-actions .btn {
    min-width: 0;
    flex: 1;
  }

  .login-box {
    padding: 28px 22px;
    margin-top: 6vh;
  }

}

/* Touch devices: keyboard shortcut hints are noise */
@media (hover: none) and (pointer: coarse) {
  kbd,
  .keyboard-hint,
  .shutter-label {
    display: none !important;
  }
}

/* ===== Mobile: gallery photo viewer goes edge-to-edge ===== */
@media (max-width: 768px) {
  .photo-viewer-modal.active {
    padding: 0;
    align-items: stretch;
  }

  .photo-viewer-modal .modal-content {
    max-width: none;
    max-height: none;
    min-height: 100vh;
    min-height: 100dvh;
    border: none;
    border-radius: 0;
    padding: 64px 0 20px;
    display: flex;
    flex-direction: column;
  }

  .photo-viewer-modal .close-btn {
    top: 12px;
    right: 12px;
  }

  .photo-viewer {
    flex: 1;
    min-height: 0;
    padding: 0;
    gap: 0;
    border-radius: 0;
  }

  .photo-display {
    min-height: 50vh;
  }

  .photo-display img {
    max-width: 100%;
    max-height: 72vh;
    max-height: 72dvh;
    border-radius: 0;
    box-shadow: none;
  }

  /* Arrows float over the photo instead of taking width from it */
  .photo-viewer .nav-btn {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    font-size: 26px;
    border: none;
    background: rgba(20, 21, 25, 0.45);
    color: #FFFFFF;
  }

  .photo-viewer .prev-btn {
    left: 8px;
  }

  .photo-viewer .next-btn {
    right: 8px;
  }

  .photo-viewer .nav-btn:disabled {
    opacity: 0;
  }

  .photo-viewer-modal .viewer-notice,
  .photo-viewer-modal .viewer-actions {
    padding: 0 16px;
  }

  .photo-viewer-modal .viewer-actions .btn {
    flex: 1;
    min-height: 48px;
  }
}

/* ===== Mobile: capture page ===== */
@media (max-width: 768px) {
  /* Room for the fixed shutter bar */
  .page-capture .container {
    padding-bottom: 112px;
  }

  .page-capture .app-bar {
    min-height: 56px;
  }

  .capture-content {
    padding: 12px;
    gap: 12px;
  }

  .camera-stage {
    border-radius: 14px;
  }

  .camera-controls {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .filter-strip {
    margin-top: 10px;
    padding: 6px;
    border-radius: 14px;
  }

  .filter-btn {
    min-height: 40px;
    padding: 8px 14px;
  }

  .capture-side {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .panel {
    padding: 14px;
    border-radius: 16px;
  }

  /* Shutter docks at the bottom like a camera app */
  .capture-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    margin: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    box-shadow: 0 -6px 24px rgba(16, 24, 40, 0.12);
  }

  .btn-shutter {
    width: 72px;
    height: 72px;
    box-shadow: 0 0 0 6px var(--accent-soft);
  }

  .btn-shutter svg {
    width: 30px;
    height: 30px;
  }

  .preview-actions {
    bottom: 10px;
    gap: 8px;
    padding: 0 10px;
  }

  .preview-actions .btn-action {
    flex: 1;
    max-width: 180px;
  }

  .adjustment-panel-floating {
    border-radius: 0;
    padding: 20px 16px;
  }

  .frame-selection-content {
    padding: 16px 12px 32px;
  }

  .frames-grid-with-preview {
    gap: 12px;
    padding: 4px;
  }

  .frame-preview-card {
    width: calc(50% - 6px);
    max-width: 180px;
  }

  .success-message {
    margin: 24px 12px;
    padding: 28px 20px;
  }

  .success-message .button-group .btn {
    flex: 1 1 100%;
  }
}

@media (max-width: 400px) {
  .countdown-number {
    width: 110px;
    height: 110px;
    font-size: 64px;
  }
}

/* Phone held sideways: camera and controls side by side, fitted to the short height */
@media (max-height: 520px) and (orientation: landscape) {
  .page-capture .container {
    padding-bottom: 0;
  }

  .page-capture .app-bar {
    min-height: 48px;
    padding: 4px 16px;
  }

  .page-capture .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 15px;
  }

  .capture-content {
    grid-template-columns: minmax(0, 1fr) 220px;
    padding: 8px 12px;
    gap: 12px;
  }

  .capture-main {
    width: min(100%, calc((100vh - 48px - 16px - 58px) * 1.5));
  }

  .filter-strip {
    margin-top: 6px;
  }

  .capture-side {
    display: flex;
    gap: 8px;
  }

  .capture-actions {
    position: static;
    order: -1;
    padding: 10px;
    border-radius: 16px;
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }

  .btn-shutter {
    width: 64px;
    height: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  /* A looping spinner at 0.01ms would spin frantically - slow it down instead.
     Loaders keep playing at normal speed even with reduced motion (owner's choice). */
  .spinner {
    animation-duration: 2s !important;
  }

  .btn-ring-run {
    animation-duration: 1.6s !important;
  }

  .backdrop-badge-dot {
    animation-duration: 0.8s !important;
  }
}

/* ===== Photo positions: frame thumbnail preview + frame editor position mode ===== */
.frame-slot-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* Overlay on top of the photo boxes, like the real print */
.frame-item .frame-item-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.frame-slot-preview rect {
  fill: rgba(255, 105, 180, 0.22);
  stroke: #ff1493;
  stroke-width: 2;
  stroke-dasharray: 6 4;
  vector-effect: non-scaling-stroke;
}

.frame-slot-preview text {
  fill: #ff1493;
  font-family: 'Space Grotesk', 'Anuphan', sans-serif;
  font-size: 420px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

.editor-mode-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 10px;
  border-radius: 999px;
  background: var(--surface-2);
}

.editor-mode-toggle .btn {
  flex: 1;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  box-shadow: none;
}

.editor-mode-toggle .btn.active {
  background: var(--accent);
  color: var(--on-accent);
}

.editor-layout-panel {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-layout-panel[hidden] {
  display: none;
}

#frameCanvas.layout-mode {
  touch-action: none;
}

.layout-slot-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layout-slot-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.layout-slot-item span {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.layout-slot-item.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ===== Orders (admin + customer page) ===== */
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="search"] {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  transition: border-color 0.15s;
}

input[type="tel"]:focus,
input[type="url"]:focus,
input[type="date"]:focus,
input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Status pill (shared) */
.order-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}

.order-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.order-status[data-status="pending_deposit"] { background: var(--warning-soft); color: var(--warning-text); }
.order-status[data-status="confirmed"] { background: var(--accent-soft); color: var(--accent-text); }
.order-status[data-status="editing"] { background: var(--info-soft); color: var(--info-text); }
.order-status[data-status="awaiting_balance"] { background: var(--warning-soft); color: var(--warning-text); }
.order-status[data-status="completed"] { background: var(--surface-2); color: var(--text); }
.order-status[data-status="cancelled"] { background: var(--danger-soft); color: var(--danger); }

/* Admin orders layout */
.orders-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.orders-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.orders-toolbar input[type="search"] {
  width: 100%;
}

.orders-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.orders-filters::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip span {
  font-family: var(--font-num);
  font-size: 12px;
  opacity: 0.75;
}

.chip:hover {
  color: var(--text);
}

.chip.is-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

.orders-day-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 4px 6px 4px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
}

.chip-clear {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.chip-clear:hover {
  background: var(--surface);
}

.orders-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.orders-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.order-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s;
}

.order-row:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.order-date {
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}

.order-date b {
  font-family: var(--font-num);
  font-size: 20px;
}

.order-date small {
  font-size: 11px;
  color: var(--muted);
}

.order-date.is-today {
  background: var(--accent);
  color: var(--on-accent);
}

.order-date.is-today small {
  color: inherit;
  opacity: 0.8;
}

.order-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.order-main strong {
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-main small {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-side {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.order-side small {
  font-family: var(--font-num);
  font-size: 13px;
  color: var(--muted);
}

/* Calendar */
.orders-calendar {
  position: sticky;
  top: 16px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-nav {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.cal-nav:hover {
  background: var(--surface-2);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.cal-weekday {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 4px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-num);
  font-size: 14px;
  cursor: pointer;
}

.cal-day:hover {
  background: var(--surface-2);
}

.cal-day.has-orders {
  background: var(--surface-2);
  font-weight: 700;
}

.cal-day.is-today {
  border-color: var(--accent);
}

.cal-day.is-selected {
  background: var(--accent);
  color: var(--on-accent);
}

.cal-dots {
  display: flex;
  gap: 2px;
  height: 5px;
}

.cal-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.cal-dots i[data-status="pending_deposit"],
.cal-dots i[data-status="awaiting_balance"] { background: var(--warning-text); }
.cal-dots i[data-status="editing"] { background: var(--info-text); }
.cal-dots i[data-status="completed"] { background: var(--muted); }

.cal-day.is-selected .cal-dots i {
  background: var(--on-accent);
}

.cal-today {
  margin-top: 12px;
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent-text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.cal-today:hover {
  background: var(--accent-soft);
}

/* Order modal */
.order-modal {
  max-width: 820px;
}

.order-status-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  margin-bottom: 22px;
  border-radius: 18px;
  background: var(--surface-2);
}

.order-status-top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.order-stepper {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  font-size: 12px;
  color: var(--muted);
}

.order-stepper li:not(:last-child)::after {
  content: "\203A";
  margin: 0 8px;
  opacity: 0.6;
}

.order-stepper li.is-done {
  color: var(--accent-text);
}

.order-stepper li.is-current {
  color: var(--text);
  font-weight: 700;
}

.order-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.order-hint {
  margin-top: -6px;
  font-size: 13px;
  color: var(--muted);
}

.order-status-panel .link-input-group {
  flex-wrap: wrap;
}

.order-status-panel .link-input {
  min-width: 200px;
}

.order-form fieldset {
  border: 0;
  margin-bottom: 8px;
}

.order-form legend {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 16px;
}

.order-reschedule {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 500 !important;
  color: var(--warning-text);
}

.order-balance {
  margin-top: -8px;
  margin-bottom: 12px;
  font-weight: 600;
  color: var(--accent-text);
}

.order-balance:empty {
  display: none;
}

.order-form .error-message {
  text-align: left;
}

.order-form .error-message:empty {
  display: none;
}

#deleteOrderBtn {
  margin-right: auto;
}

@media (max-width: 1100px) {
  .orders-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .orders-calendar {
    position: static;
    order: -1;
    max-width: 420px;
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .order-row {
    gap: 12px;
    padding: 12px 14px;
  }

  .order-side small {
    display: none;
  }

  .orders-calendar {
    max-width: none;
  }

  .order-modal {
    padding: 22px 18px;
  }
}

/* ===== Customer order page (/order/<token>) ===== */
.od-wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 0;
}

.od-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.od-card {
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.od-loading {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.od-skeleton {
  display: block;
  height: 16px;
  border-radius: 8px;
  background: var(--surface-2);
  animation: db-pulse 1.4s ease-in-out infinite;
}

.od-kicker {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-text);
}

.od-head h1 {
  font-size: 30px;
  line-height: 1.2;
  margin: 2px 0;
}

.od-package {
  color: var(--muted);
  margin-bottom: 14px;
}

.od-head .order-status {
  font-size: 14px;
  padding: 6px 14px;
}

.od-status-text {
  margin-top: 8px;
  font-size: 15px;
}

.od-title {
  font-size: 16px;
  margin-bottom: 14px;
}

/* Payment */
.od-pay {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 45%),
    var(--surface);
}

.od-pay-amount {
  font-family: var(--font-num);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
}

/* QR stays black on white in dark mode (scanners need contrast) */
.od-qr {
  width: min(260px, 100%);
  padding: 14px;
  border-radius: 16px;
  background: #FFFFFF;
  border: 1px solid var(--line);
}

.od-qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.od-account {
  font-size: 14px;
}

.od-hint {
  font-size: 13px;
  color: var(--muted);
  max-width: 340px;
}

.od-pay-after {
  width: 100%;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.od-pay-after .btn {
  width: 100%;
}

/* Thank you / cancelled */
.od-thanks {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
}

.od-thanks h2 {
  font-size: 22px;
}

.od-thanks p {
  color: var(--muted);
}

.od-thanks .btn {
  width: 100%;
  margin-top: 6px;
}

.od-thanks-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--on-accent);
  animation: od-pop 0.4s ease;
}

@keyframes od-pop {
  from { transform: scale(0.6); opacity: 0; }
}

.od-notice-cancel {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

/* Timeline */
.od-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.od-steps li {
  position: relative;
  display: flex;
  gap: 14px;
  padding-bottom: 18px;
  color: var(--muted);
}

.od-steps li:last-child {
  padding-bottom: 0;
}

.od-steps li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}

.od-steps li.is-done:not(:last-child)::before {
  background: var(--accent);
}

.od-step-dot {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 3px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--surface);
}

.od-steps li.is-done .od-step-dot {
  border-color: var(--accent);
  background: var(--accent);
}

.od-steps li.is-current .od-step-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.od-steps li.is-done,
.od-steps li.is-current {
  color: var(--text);
}

.od-steps li.is-current strong {
  color: var(--accent-text);
}

.od-steps small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

/* Detail rows */
.od-rows {
  display: flex;
  flex-direction: column;
}

.od-row {
  display: grid;
  grid-template-columns: 22px 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px dashed var(--line);
  font-size: 15px;
}

.od-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.od-row-icon {
  color: var(--accent-text);
  padding-top: 2px;
}

.od-row-label {
  color: var(--muted);
}

.od-row-value {
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Amounts */
.od-amounts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.od-amount-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.od-amount-row span {
  color: var(--muted);
}

.od-amount-row strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-num);
}

.od-paid {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--font);
  font-size: 12px;
}

.od-terms ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 18px;
  font-size: 14px;
  color: var(--muted);
}

.od-terms b {
  color: var(--text);
}

.od-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
}

.od-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 40px 22px;
}

.od-empty h1 {
  font-size: 24px;
}

.od-empty p {
  color: var(--muted);
}

.page-order .app-footer {
  margin-top: 24px;
}

@media (prefers-reduced-motion: reduce) {
  .od-skeleton,
  .od-thanks-mark {
    animation: none;
  }
}

/* QR save fallback: image to long-press (phones where the share sheet isn't available) */
.od-qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 11, 14, 0.6);
}

.od-qr-sheet {
  width: min(360px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.od-qr-sheet-title {
  font-size: 15px;
}

.od-qr-sheet img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  -webkit-touch-callout: default;
  user-select: auto;
}

/* ===== Frames export (admin) ===== */
.fx-status {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

.fx-preview {
  display: flex;
  justify-content: center;
  min-height: 120px;
  max-height: 62vh;
  overflow: auto;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface-2, var(--bg));
  border: 1px solid var(--line);
}

.fx-preview img {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

/* ===== List toolbar: search + sort (events / orders) ===== */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.orders-toolbar .list-toolbar {
  margin-bottom: 0;
}

.list-toolbar input[type="search"] {
  flex: 1 1 220px;
  min-width: 0;
  width: auto;
}

.list-toolbar select {
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.sort-dir {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sort-dir:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sort-dir:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sort-dir svg {
  transition: transform 0.2s ease;
}

.sort-dir[data-dir="asc"] svg {
  transform: rotate(180deg);
}

/* List loading (events): ring + text in the middle of the grid */
.list-loading {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 0;
  color: var(--muted);
  font-size: 14px;
}

.list-loading .btn {
  margin-top: 4px;
}

.list-empty {
  grid-column: 1 / -1;
  padding: 32px 0;
  text-align: center;
  color: var(--muted);
}

/* ===== Admin: nav badge ===== */
.admin-nav-badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--danger);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}

:root[data-theme="dark"] .admin-nav-badge {
  color: #16171B;
}

/* ===== Admin: order form additions ===== */
.time-range {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-range select {
  flex: 1;
  min-width: 0;
  color: var(--text);
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn input {
  flex: 1;
  min-width: 0;
}

.input-with-btn .btn {
  white-space: nowrap;
}

#ofProvince {
  color: var(--text);
}

.order-balance {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.order-balance b {
  font-size: 18px;
}

/* ===== Admin: overview (alerts + dashboard) ===== */
/* Chart series colors (validated pair: CVD + contrast, light and dark) */
:root {
  --ov-received: #4E7A2A;
  --ov-pending: #2A78D6;
}

:root[data-theme="dark"] {
  --ov-received: #6F9A3A;
  --ov-pending: #3987E5;
}

.ov-alerts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.ov-alerts-empty {
  grid-column: 1 / -1;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.ov-alert {
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--alert-color, var(--line));
}

.ov-alert[data-tone="info"] { --alert-color: var(--info-text); }
.ov-alert[data-tone="warning"] { --alert-color: var(--warning-text); }
.ov-alert[data-tone="neutral"] { --alert-color: var(--muted); }

.ov-alert header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--alert-color);
}

.ov-alert header strong {
  color: var(--text);
}

.ov-alert-count {
  margin-left: auto;
  min-width: 26px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  text-align: center;
}

.ov-alert-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ov-alert-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ov-alert-item:hover {
  background: var(--accent-soft);
}

.ov-alert-item small {
  color: var(--muted);
}

.ov-year {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.ov-year strong {
  min-width: 90px;
  text-align: center;
  font-size: 18px;
}

.ov-year small {
  color: var(--muted);
}

.ov-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.ov-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.ov-stat span {
  color: var(--muted);
  font-size: 13px;
}

.ov-stat strong {
  font-family: var(--font-num);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.ov-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
}

.ov-card {
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.ov-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.ov-card-head h3 {
  font-size: 16px;
}

.ov-legend {
  display: flex;
  gap: 14px;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
}

.ov-legend li,
.ov-tip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ov-legend i,
.ov-tip i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.is-received { --c: var(--ov-received); }
.is-pending { --c: var(--ov-pending); }

.ov-legend i,
.ov-tip i,
.ov-seg {
  background: var(--c);
}

.ov-chart {
  display: flex;
  gap: 8px;
  height: 240px;
}

.ov-chart-empty {
  margin: auto;
  color: var(--muted);
}

.ov-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 24px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ov-axis span {
  line-height: 1;
}

.ov-plot {
  position: relative;
  flex: 1;
  display: flex;
  min-width: 0;
}

.ov-grid-lines {
  position: absolute;
  inset: 0 0 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.ov-grid-lines i {
  border-top: 1px dashed var(--line);
}

.ov-grid-lines i:last-child {
  border-top-style: solid;
}

.ov-col {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: default;
}

.ov-col:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.ov-col:hover .ov-bar,
.ov-col:focus-visible .ov-bar {
  filter: brightness(1.08);
}

.ov-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  width: min(60%, 28px);
}

.ov-seg {
  display: block;
  min-height: 2px;
}

.ov-bar .ov-seg:first-child {
  border-radius: 4px 4px 0 0;
}

.ov-month {
  height: 24px;
  padding-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.ov-col.is-now .ov-month {
  color: var(--text);
  font-weight: 700;
}

.ov-tip {
  position: absolute;
  top: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.ov-tip b {
  margin-left: auto;
  padding-left: 8px;
}

.ov-table-toggle {
  margin-top: 12px;
  font-size: 14px;
}

.ov-table-toggle summary {
  color: var(--muted);
  cursor: pointer;
}

.ov-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 13px;
}

.ov-table th,
.ov-table td {
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ov-table th:first-child {
  text-align: left;
}

.ov-services {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ov-service-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 6px;
}

.ov-service-top span:last-child {
  color: var(--muted);
}

.ov-service-top b {
  color: var(--text);
}

.ov-service-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.ov-service-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--ov-received);
}

@media (max-width: 1100px) {
  .ov-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .ov-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ov-month {
    font-size: 10px;
  }
}

/* ===== Admin: settings ===== */
.settings-card {
  max-width: 760px;
  padding: 22px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.settings-card h3 {
  margin-bottom: 6px;
}

.settings-hint {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}

.settings-preview {
  margin-top: 8px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 14px;
}

.settings-preview ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 16px;
  margin-top: 6px;
}

.settings-preview li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.settings-preview small {
  color: var(--muted);
  font-weight: 400;
}

/* ===== Customer order page: countdown next to the event date ===== */
.od-countdown {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

/* Payment: deducted deposit in red, one dashed line above the remaining balance */
.od-amount-minus strong {
  color: var(--danger);
}

.od-amount-balance {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

/* Gallery: anonymous stats notice (PDPA) */
.footer-privacy {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

/* ===== Admin: event stats (admin-stats.js) ===== */
/* Stats: square icon button at the end of the card actions (same row as capture / gallery) */
.btn-stats {
  margin-left: auto;
  width: 40px;
  padding: 0;
  flex-shrink: 0;
}

.stats-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 999px;
  background: var(--surface-2);
}

.stats-tabs button {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.stats-tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.stats-heading {
  margin: 4px 0 10px;
  font-size: 15px;
  color: var(--muted);
}

.stats-sub {
  color: var(--muted);
  font-size: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stats-bars {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.stats-bars li {
  display: grid;
  grid-template-columns: minmax(64px, 30%) 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.stats-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.stats-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.stats-bar-value {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.stats-table-wrap { overflow-x: auto; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table th,
.stats-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.stats-table th {
  color: var(--muted);
  font-weight: 600;
}

.stats-table td:not(:first-child),
.stats-table th:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

.stats-note,
.stats-empty {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.stats-notes {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.stats-warn {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--warning-text);
  font-size: 13px;
}

@media (max-width: 760px) {
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
}

.stats-danger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

.stats-danger p {
  margin: 0;
  flex: 1 1 260px;
  color: var(--muted);
  font-size: 12px;
}

.stats-switch {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
}

.stats-switch .toggle-switch {
  flex-shrink: 0;
}

.stats-switch strong {
  display: block;
  font-size: 14px;
}

.stats-switch small {
  color: var(--muted);
  font-size: 12px;
}

/* Booth: photo from the camera (EOS Utility) - folder / check buttons under the switch */
.eos-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 4px;
}

.eos-row[hidden] {
  display: none;
}

.eos-focus-btn {
  margin-top: 8px;
}

.eos-focus-btn[hidden] {
  display: none;
}

/* Sub-option under "ใช้รูปจากกล้อง" */
.eos-sub {
  padding-left: 14px;
}

.eos-sub[hidden] {
  display: none;
}
