/* ============================================================
   PDF MAKER — Design System
   ============================================================ */

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
}

/* ---------- Tokens ---------- */
:root {
  /* Brand palette */
  --violet-900: #2e1065;
  --violet-800: #3b0764;
  --purple-700: #5b21b6;
  --purple-600: #6d28d9;
  --purple-500: #7c3aed;
  --purple-400: #a855f7;
  --purple-300: #c4b5fd;
  --purple-200: #ddd6fe;
  --purple-100: #ede9fe;
  --purple-50:  #f5f3ff;

  /* Neutral */
  --ink:        #1a1530;
  --slate-700:  #334155;
  --slate-600:  #475569;
  --slate-500:  #64748b;
  --slate-400:  #94a3b8;
  --slate-200:  #e2e8f0;
  --slate-100:  #f1f5f9;
  --white:      #ffffff;

  /* Surface */
  --bg:         #f3f0fb;
  --surface:    #ffffff;
  --line:       #e4ddf8;
  --line-soft:  #ede9fe;

  /* Semantic */
  --danger:     #ef4444;
  --danger-bg:  #fef2f2;
  --danger-dark:#dc2626;

  /* Elevation shadows */
  --shadow-xs:  0 1px 3px rgba(109,40,217,0.08);
  --shadow-sm:  0 2px 8px rgba(109,40,217,0.10);
  --shadow-md:  0 6px 20px rgba(109,40,217,0.12);
  --shadow-lg:  0 14px 40px rgba(109,40,217,0.14);
  --shadow-purple: 0 4px 16px rgba(109,40,217,0.30);

  /* Radii */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  18px;
  --radius-pill:9999px;

  /* Motion */
  --ease-out:   cubic-bezier(0.22,1,0.36,1);
  --ease-in-out:cubic-bezier(0.4,0,0.2,1);
  --dur-fast:   120ms;
  --dur-mid:    200ms;
  --dur-slow:   320ms;

  /* Dynamic layout */
  --bulk-bar-h: 0px;
}

/* ---------- Base ---------- */
html, body {
  margin: 0;
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  transition:
    background var(--dur-fast) var(--ease-out),
    color      var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    opacity    var(--dur-fast) var(--ease-out),
    transform  var(--dur-fast) var(--ease-out);
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

/* ============================================================
   TOP BAR
   ============================================================ */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  width: 100%;
  max-width: 100vw;
}

.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 22px;
  flex-shrink: 0;
  z-index: 20;
  box-shadow: var(--shadow-xs);
  min-width: 0;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--purple-400), var(--purple-700));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(109,40,217,0.38);
  flex-shrink: 0;
}

.brand-icon svg {
  width: 17px;
  height: 17px;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.brand-name a {
  color: var(--purple-600);
}

/* Filename group */
.filename-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.top-label {
  font-size: 12px;
  color: var(--slate-400);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.filename-input-wrap {
  position: relative;
  flex: 1;
  max-width: 300px;
  min-width: 0;
  display: flex;
  align-items: center;
}

.file-name-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 32px 8px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  outline: none;
  background: var(--purple-50);
  transition: border-color var(--dur-fast) var(--ease-out),
              background  var(--dur-fast) var(--ease-out),
              box-shadow  var(--dur-fast) var(--ease-out);
}

.file-name-input::placeholder {
  color: var(--slate-400);
}

.file-name-input:focus {
  border-color: var(--purple-500);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--purple-100);
}

.edit-icon {
  position: absolute;
  right: 10px;
  width: 13px;
  height: 13px;
  color: var(--slate-400);
  pointer-events: none;
}

.page-badge {
  background: linear-gradient(135deg, var(--purple-100), var(--purple-200));
  color: var(--purple-700);
  border-radius: var(--radius-pill);
  padding: 5px 13px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.2px;
  border: 1px solid var(--purple-200);
}

/* Top action buttons */
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.preview-btn {
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--slate-700);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.preview-btn svg {
  width: 15px;
  height: 15px;
}

.preview-btn:hover {
  background: var(--purple-50);
  border-color: var(--purple-200);
  color: var(--purple-700);
  box-shadow: var(--shadow-xs);
}

.preview-btn.active {
  background: var(--purple-700);
  border-color: var(--purple-700);
  color: var(--white);
  box-shadow: var(--shadow-purple);
}

.download-btn {
  background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: var(--shadow-purple);
  letter-spacing: 0.1px;
}

.download-btn svg {
  width: 15px;
  height: 15px;
}

.download-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--purple-600), var(--violet-800));
  box-shadow: 0 6px 22px rgba(109,40,217,0.38);
}

.download-btn.loading {
  background: var(--purple-700);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.75;
}

/* Select toggle button (same visual language as preview-btn) */
.select-toggle-btn {
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--slate-700);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.select-toggle-btn svg {
  width: 15px;
  height: 15px;
}

.select-toggle-btn:hover {
  background: var(--purple-50);
  border-color: var(--purple-200);
  color: var(--purple-700);
  box-shadow: var(--shadow-xs);
}

.select-toggle-btn.active {
  background: var(--purple-700);
  border-color: var(--purple-700);
  color: var(--white);
  box-shadow: var(--shadow-purple);
}

/* ============================================================
   BULK SELECTION BAR
   ============================================================ */

.bulk-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--purple-50);
  border-bottom: 1px solid var(--purple-200);
  padding: 10px 22px;
  flex-shrink: 0;
  z-index: 15;
}

.bulk-bar.visible {
  display: flex;
}

.bulk-select-all {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--purple-700);
  min-width: 0;
}

.bulk-select-all input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--purple-600);
  cursor: pointer;
  flex-shrink: 0;
}

.bulk-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.bulk-cancel-btn {
  background: var(--white);
  border: 1.5px solid var(--line);
  color: var(--slate-700);
  border-radius: var(--radius-md);
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.bulk-cancel-btn:hover {
  background: var(--purple-100);
}

.bulk-delete-btn {
  background: var(--danger);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 10px rgba(239,68,68,0.30);
}

.bulk-delete-btn svg {
  width: 14px;
  height: 14px;
}

.bulk-delete-btn:hover:not(:disabled) {
  background: var(--danger-dark);
}

.bulk-delete-btn:disabled {
  background: var(--slate-200);
  color: var(--slate-400);
  cursor: not-allowed;
  box-shadow: none;
}

/* Per-thumbnail selection checkmark, shown only while selecting */
.thumb-select-check {
  display: none;
  position: absolute;
  top: 5px;
  right: -3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--white);
  border: 1.5px solid var(--slate-400);
  align-items: center;
  justify-content: center;
  color: transparent;
  z-index: 3;
  pointer-events: none;
  box-shadow: var(--shadow-xs);
}

.thumb-select-check svg {
  width: 13px;
  height: 13px;
}

.thumb-list.selecting .thumb-menu {
  display: none;
}

.thumb-list.selecting .thumb-select-check {
  display: flex;
}

.thumb-row.selected .thumb-select-check {
  background: var(--purple-600);
  border-color: var(--purple-600);
  color: var(--white);
}

.thumb-row.selected .thumb-card {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px var(--purple-100);
}

.thumb-list.selecting .thumb-row {
  cursor: pointer;
}

/* ============================================================
   BODY LAYOUT
   ============================================================ */

.body-wrap {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  width: 224px;
  min-width: 224px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left var(--dur-slow) var(--ease-out);
}

.app.preview-mode .sidebar {
  margin-left: -224px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--slate-500);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  padding: 16px 16px 10px;
}

.thumb-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--purple-200) transparent;
}

.thumb-list::-webkit-scrollbar {
  width: 4px;
}
.thumb-list::-webkit-scrollbar-thumb {
  background: var(--purple-200);
  border-radius: var(--radius-pill);
}

/* Thumbnail row */
.thumb-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: opacity var(--dur-mid) var(--ease-out),
              transform var(--dur-mid) var(--ease-out);
}

.thumb-row:hover .thumb-card {
  border-color: var(--purple-300);
  box-shadow: var(--shadow-sm);
}

.thumb-row.dragging {
  opacity: 0.35;
  transform: scale(0.97);
}

.thumb-row.drag-over-top .thumb-card {
  box-shadow: 0 -3px 0 0 var(--purple-500);
}

.thumb-row.drag-over-bottom .thumb-card {
  box-shadow: 0 3px 0 0 var(--purple-500);
}

.thumb-card-wrap {
  position: relative;
  width: 100%;
  pointer-events: none;
}

.thumb-badge {
  position: absolute;
  top: -7px;
  left: -7px;
  background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
  color: var(--white);
  font-size: 10.5px;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 2px 7px rgba(109,40,217,0.40);
}

.thumb-menu {
  position: absolute;
  top: 5px;
  right: -3px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--line);
  color: var(--slate-400);
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  z-index: 2;
  pointer-events: auto;
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(6px);
}

.thumb-menu:hover {
  color: var(--danger);
  border-color: #fecaca;
  background: var(--danger-bg);
}

.thumb-card {
  width: 100%;
  height: 136px;
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow   var(--dur-fast) var(--ease-out);
}

.thumb-row.active .thumb-card {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px var(--purple-100), var(--shadow-sm);
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fafafe;
}

.thumb-empty {
  color: var(--purple-200);
}

.thumb-empty svg {
  width: 28px;
  height: 28px;
}

.thumb-label {
  margin-top: 7px;
  font-size: 12px;
  color: var(--slate-500);
  font-weight: 500;
  pointer-events: none;
  letter-spacing: 0.1px;
}

.thumb-row.active .thumb-label {
  color: var(--purple-700);
  font-weight: 700;
}

/* Sidebar action buttons */
.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 16px;
  border-top: 1px solid var(--line);
}

.side-action-btn {
  width: 100%;
  background: var(--white);
  border: 1.5px solid var(--line);
  color: var(--slate-700);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  margin: 0;
}

.side-action-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--purple-500);
}

.side-action-btn:disabled {
  color: var(--slate-400);
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 0.5;
}

.side-action-btn:hover:not(:disabled) {
  border-color: var(--purple-300);
  background: var(--purple-50);
  color: var(--purple-700);
  box-shadow: var(--shadow-xs);
}

.side-action-btn:hover:not(:disabled) svg {
  color: var(--purple-600);
}

.new-page-btn svg {
  color: var(--purple-600);
}

/* ============================================================
   MAIN WORKSPACE
   ============================================================ */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px;
  gap: 14px;
}

/* The A4 preview card */
.preview-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 1px 0 var(--line);

  height: calc(100dvh - var(--chrome-h, 228px) - var(--bulk-bar-h, 0px));
  width: calc((100dvh - var(--chrome-h, 228px) - var(--bulk-bar-h, 0px)) / 1.4142);
  max-width: 90%;

  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  transition: box-shadow var(--dur-mid) var(--ease-out);
}

.preview-card:hover {
  box-shadow: 0 18px 52px rgba(109,40,217,0.16), 0 1px 0 var(--line);
}

.preview-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform var(--dur-mid) var(--ease-out);
}

.preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fafafe;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 0 28px;
  text-align: center;
}

.empty-illustration {
  width: 148px;
  height: 148px;
  margin-bottom: 6px;
  filter: drop-shadow(0 8px 18px rgba(109,40,217,0.15));
}

.empty-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  margin: 4px 0 2px;
  letter-spacing: -0.3px;
}

.empty-subtext {
  font-size: 13.5px;
  color: var(--slate-500);
  margin: 0 0 18px;
  line-height: 1.6;
}

.empty-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-img-btn,
.cam-inline-btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 20px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.1px;
}

.upload-img-btn svg,
.cam-inline-btn svg {
  width: 16px;
  height: 16px;
}

.upload-img-btn {
  background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
  color: var(--white);
  box-shadow: var(--shadow-purple);
}

.upload-img-btn:hover {
  background: linear-gradient(135deg, var(--purple-600), var(--violet-800));
  box-shadow: 0 6px 22px rgba(109,40,217,0.38);
}

.cam-inline-btn {
  background: var(--white);
  color: var(--purple-700);
  border: 1.5px solid var(--purple-200);
  box-shadow: var(--shadow-xs);
}

.cam-inline-btn:hover {
  background: var(--purple-50);
  border-color: var(--purple-300);
  box-shadow: var(--shadow-sm);
}

.empty-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin: 18px 0 14px;
  color: var(--slate-400);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.empty-divider::before,
.empty-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.drop-zone-static {
  width: 100%;
  max-width: 340px;
  border: 1.5px dashed var(--purple-200);
  border-radius: var(--radius-md);
  padding: 13px 0;
  color: var(--slate-400);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(245,243,255,0.5);
  transition: border-color var(--dur-fast) var(--ease-out),
              background   var(--dur-fast) var(--ease-out);
}

.drop-zone-static:hover {
  border-color: var(--purple-300);
  background: var(--purple-50);
}

.drop-zone-static svg {
  width: 15px;
  height: 15px;
}

/* Image overlay action buttons */
.image-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 7px;
}

.change-img-btn,
.crop-img-btn,
.rotate-img-btn {
  background: rgba(46,16,101,0.78);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
  letter-spacing: 0.15px;
}

.change-img-btn:hover,
.crop-img-btn:hover,
.rotate-img-btn:hover {
  background: rgba(109,40,217,0.92);
}

/* ============================================================
   NAV ROW
   ============================================================ */

.nav-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
  width: 100%;
  max-width: calc((100dvh - var(--chrome-h, 228px) - var(--bulk-bar-h, 0px)) / 1.4142 + 200px);
}

.nav-btn {
  background: var(--white);
  border: 1.5px solid var(--line);
  color: var(--slate-700);
  border-radius: var(--radius-md);
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-xs);
}

.nav-btn svg {
  width: 14px;
  height: 14px;
}

.nav-btn:hover:not(:disabled) {
  background: var(--purple-50);
  border-color: var(--purple-200);
  color: var(--purple-700);
}

.nav-btn:disabled {
  background: var(--slate-100);
  color: var(--slate-400);
  border-color: var(--line);
  cursor: not-allowed;
  box-shadow: none;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 3px;
  box-shadow: var(--shadow-xs);
}

.zoom-btn {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--slate-600);
  font-size: 17px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.zoom-btn:hover {
  background: var(--purple-50);
  color: var(--purple-700);
}

.zoom-label {
  font-size: 12px;
  color: var(--slate-500);
  font-weight: 700;
  min-width: 46px;
  text-align: center;
  letter-spacing: 0.2px;
}

/* ============================================================
   FOOTER
   ============================================================ */

.workspace-footer {
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 10px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.brand-link {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.2px;
}

.brand-link:hover {
  color: var(--purple-600);
}

.footer-divider {
  width: 1px;
  height: 16px;
  background: var(--line);
}

.social-links {
  display: flex;
  gap: 14px;
}

.social-links a {
  font-size: 12px;
  color: var(--slate-400);
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease-out);
}

.social-links a svg {
  width: 13px;
  height: 13px;
}

.social-links a:hover {
  color: var(--purple-600);
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}

.dev-label {
  color: var(--slate-400);
  font-weight: 500;
}

.dev-name {
  color: var(--slate-700);
  font-weight: 700;
}

.dev-name a {
  color: inherit;
}

.dev-name a:hover {
  color: var(--purple-600);
}

.linkedin-link {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a66c2;
  font-weight: 800;
  font-size: 11px;
  margin-left: 2px;
  border: 1.5px solid var(--slate-200);
  border-radius: 5px;
  background: var(--slate-100);
  transition: background var(--dur-fast) var(--ease-out),
              color      var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.linkedin-link:hover {
  background: #0a66c2;
  color: var(--white);
  border-color: #0a66c2;
}

/* ============================================================
   DROP OVERLAY
   ============================================================ */

.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(124,58,237,0.08);
  border: 2px dashed var(--purple-400);
  border-radius: var(--radius-lg);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.drop-overlay.visible {
  display: flex;
}

.drop-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--purple-600);
  background: rgba(245,243,255,0.9);
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   CAMERA MODAL
   ============================================================ */

.camera-modal {
  position: fixed;
  inset: 0;
  background: rgba(15,10,35,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  backdrop-filter: blur(6px);
}

.camera-modal.visible {
  display: flex;
  animation: modal-in var(--dur-mid) var(--ease-out);
}

.camera-box {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 22px;
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.camera-box h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.video-container {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0a0a12;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}

#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-controls {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.cam-btn {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  letter-spacing: 0.1px;
}

.capture-btn {
  background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
  color: var(--white);
  box-shadow: var(--shadow-purple);
}

.capture-btn:hover {
  background: linear-gradient(135deg, var(--purple-600), var(--violet-800));
}

.cancel-btn {
  background: var(--purple-50);
  color: var(--slate-700);
  border: 1.5px solid var(--line);
}

.cancel-btn:hover {
  background: var(--purple-100);
  border-color: var(--purple-200);
}

/* ============================================================
   CROP MODAL
   ============================================================ */

.crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(15,10,35,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  backdrop-filter: blur(6px);
}

.crop-modal.visible {
  display: flex;
  animation: modal-in var(--dur-mid) var(--ease-out);
}

.crop-box {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 22px;
  width: auto;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--line);
  align-items: center;
  box-shadow: var(--shadow-lg);
}

.crop-box h3 {
  margin: 0;
  align-self: flex-start;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.crop-stage {
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-image-box {
  position: relative;
  user-select: none;
  touch-action: none;
  line-height: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.crop-image-box img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.crop-overlay {
  position: absolute;
  border: 1.5px solid rgba(255,255,255,0.9);
  outline: 2px solid var(--purple-400);
  box-shadow: 0 0 0 9999px rgba(10,5,25,0.55);
  cursor: move;
}

.crop-overlay::before,
.crop-overlay::after {
  content: "";
  position: absolute;
}

.crop-overlay::before {
  left: 33.333%;
  right: 33.333%;
  top: 0;
  bottom: 0;
  border-left: 1px solid rgba(255,255,255,0.35);
  border-right: 1px solid rgba(255,255,255,0.35);
}

.crop-overlay::after {
  top: 33.333%;
  bottom: 33.333%;
  left: 0;
  right: 0;
  border-top: 1px solid rgba(255,255,255,0.35);
  border-bottom: 1px solid rgba(255,255,255,0.35);
}

.crop-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--white);
  border: 2px solid var(--purple-500);
  border-radius: 50%;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.crop-handle.tl { top: -7px;    left: -7px;  cursor: nwse-resize; }
.crop-handle.tr { top: -7px;    right: -7px; cursor: nesw-resize; }
.crop-handle.bl { bottom: -7px; left: -7px;  cursor: nesw-resize; }
.crop-handle.br { bottom: -7px; right: -7px; cursor: nwse-resize; }

/* ============================================================
   CONFIRM / DELETE MODAL
   ============================================================ */

.confirm-modal {
  position: fixed;
  inset: 0;
  background: rgba(15,10,35,0.68);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 600;
  padding: 20px;
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--dur-mid) var(--ease-out);
}

.confirm-modal.visible {
  display: flex;
  opacity: 1;
}

.confirm-box {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: scale(0.94);
  transition: transform var(--dur-mid) var(--ease-out);
}

.confirm-modal.visible .confirm-box {
  transform: scale(1);
}

.confirm-icon {
  width: 52px;
  height: 52px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  border: 1.5px solid #fecaca;
}

.confirm-icon svg {
  width: 24px;
  height: 24px;
}

.confirm-box h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.confirm-box p {
  margin: 0 0 24px;
  color: var(--slate-500);
  font-size: 14px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.confirm-btn {
  flex: 1;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  letter-spacing: 0.1px;
}

.confirm-btn.cancel-btn {
  background: var(--slate-100);
  color: var(--slate-700);
  border: 1.5px solid var(--slate-200);
}

.confirm-btn.cancel-btn:hover {
  background: var(--slate-200);
}

.confirm-btn.danger-btn {
  background: var(--danger);
  color: var(--white);
  box-shadow: 0 3px 10px rgba(239,68,68,0.30);
}

.confirm-btn.danger-btn:hover {
  background: var(--danger-dark);
  box-shadow: 0 4px 14px rgba(239,68,68,0.38);
}

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom));
  right: calc(22px + env(safe-area-inset-right));
  background: var(--ink);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
  z-index: 700;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--dur-mid) var(--ease-out),
              transform var(--dur-mid) var(--ease-out);
  pointer-events: none;
  letter-spacing: 0.1px;
  border: 1px solid rgba(255,255,255,0.08);
}

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

/* ============================================================
   THUMBNAIL CONTEXT MENU
   ============================================================ */

.thumb-context-menu {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,0.14);
  min-width: 148px;
  overflow: hidden;
  animation: tcm-in var(--dur-fast) var(--ease-out);
}

@keyframes tcm-in {
  from { opacity: 0; transform: scale(0.94) translateY(-4px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    }
}

.tcm-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--slate-700);
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
}

.tcm-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--slate-400);
}

.tcm-item:hover {
  background: var(--purple-50);
  color: var(--purple-700);
}

.tcm-item:hover svg {
  color: var(--purple-500);
}

.tcm-item.danger {
  color: var(--danger);
}

.tcm-item.danger svg {
  color: var(--danger);
}

.tcm-item.danger:hover {
  background: var(--danger-bg);
  color: var(--danger-dark);
}

/* ============================================================
   UNDO BUTTON
   ============================================================ */

#undoBtn {
  opacity: 1;
  transition: opacity var(--dur-fast) var(--ease-out);
}

#undoBtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================
   MODAL ENTRANCE ANIMATION
   ============================================================ */

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

/* ============================================================
   SCROLLBAR POLISH
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--purple-200);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--purple-300);
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */

/* --- Tablet ≤ 768px --- */
@media (max-width: 768px) {
  :root { --chrome-h: 300px; }

  .top-bar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }

  .brand { flex: 1; }
  .brand-name { font-size: 15px; }

  .filename-group {
    order: 3;
    flex-basis: 100%;
    gap: 8px;
  }

  .top-label { display: none; }

  .filename-input-wrap {
    max-width: none;
    flex: 1;
  }

  .preview-btn span,
  .download-btn span,
  .select-toggle-btn span { display: none; }

  .preview-btn,
  .download-btn,
  .select-toggle-btn { padding: 9px 12px; }

  .bulk-bar { padding: 8px 14px; }

  .sidebar { width: 188px; min-width: 188px; }

  .app.preview-mode .sidebar { margin-left: -188px; }

  .thumb-card { height: 110px; }

  .workspace-footer { padding: 10px 14px; }

  .social-links { display: none; }

  .footer-divider { display: none; }

  .brand-avatar { width: 24px; height: 24px; }
}

/* --- Mobile ≤ 540px --- */
@media (max-width: 540px) {
  .app { height: 100dvh; }

  .top-bar { padding: 8px 12px; gap: 8px; }

  .brand-name { font-size: 14px; }

  .brand-icon { width: 28px; height: 28px; }

  .filename-group { flex-wrap: wrap; gap: 6px; }

  .page-badge { font-size: 11px; padding: 4px 10px; }

  /* Body: main(order1) → footer(order2) → sidebar strip(order3) */
  .body-wrap { flex-direction: column; }

  .bulk-bar {
    padding: 8px 12px;
    gap: 8px;
  }

  .bulk-select-all { font-size: 12px; }

  .bulk-cancel-btn,
  .bulk-delete-btn { padding: 6px 11px; font-size: 11.5px; }

  .workspace-footer {
    order: 2;
    width: 100%;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    flex-wrap: nowrap;
    gap: 6px;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    height: 130px;
    min-height: 130px;
    flex-shrink: 0;
    flex-direction: row;
    display: flex;
    border-right: none;
    border-top: 1px solid var(--line);
    order: 3;
    overflow: hidden;
    transition: none;
  }

  .app.preview-mode .sidebar {
    margin-left: 0;
    display: none;
  }

  .sidebar-header { display: none; }

  .thumb-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px;
    gap: 10px;
    align-items: center;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .thumb-list::-webkit-scrollbar { display: none; }

  .thumb-row {
    flex-shrink: 0;
    width: 72px;
    scroll-snap-align: start;
  }

  .thumb-card { height: 88px; width: 72px; }

  .thumb-label { font-size: 10px; margin-top: 4px; }

  .thumb-badge {
    width: 16px; height: 16px;
    font-size: 9px; top: -5px; left: -5px;
  }

  .sidebar-actions {
    flex-direction: column;
    border-top: none;
    border-left: 1px solid var(--line);
    padding: 8px 8px;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-start;   /* align to top so scroll works */
    min-width: 82px;
    max-width: 82px;
    overflow-y: auto;              /* scroll when buttons overflow */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sidebar-actions::-webkit-scrollbar { display: none; }

  .side-action-btn {
    flex-direction: column;
    padding: 6px 8px;
    font-size: 9.5px;
    gap: 4px;
    width: 64px;
    height: 62px;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-md);
    white-space: nowrap;
  }

  .side-action-btn svg { width: 18px; height: 18px; }

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

  /* Re-slot footer inside body-wrap so it sits beside/below the sidebar strip */

  .preview-area {
    padding: 10px 10px 8px;
    gap: 8px;
    justify-content: flex-start;
    align-self: stretch;
    align-items: stretch;
    overflow: hidden;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  .preview-card {
    flex: 1;
    min-height: 0;
    height: 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
  }

  /* Empty state scrolls inside card */
  .preview-content {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .empty-state { padding: 16px 20px 20px; }

  .empty-illustration { margin-bottom: 4px; width: 100px; height: 100px; }

  .empty-title { font-size: 17px; }

  .empty-subtext { font-size: 12.5px; }

  .empty-actions { flex-direction: column; gap: 8px; width: 100%; }

  .upload-img-btn,
  .cam-inline-btn { width: 100%; justify-content: center; padding: 12px 20px; }

  .empty-divider { margin: 12px 0 10px; }

  .drop-zone-static { font-size: 12px; padding: 10px 0; }

  .nav-row { max-width: 100%; gap: 8px; padding: 0 2px; }

  .nav-btn { padding: 7px 12px; font-size: 12px; gap: 4px; }

  .nav-btn svg { width: 13px; height: 13px; }

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

  .zoom-label { font-size: 11.5px; min-width: 36px; }

  /* image-actions: compact pill at bottom-center */
  .image-actions {
    top: auto;
    bottom: 8px;
    right: 50%;
    transform: translateX(50%);
    gap: 2px;
    background: rgba(109,40,217,0.84);
    padding: 3px 6px;
    border-radius: var(--radius-pill);
    backdrop-filter: blur(10px);
    box-shadow: 0 3px 12px rgba(109,40,217,0.32);
  }

  .change-img-btn,
  .crop-img-btn,
  .rotate-img-btn {
    padding: 4px 7px;
    font-size: 10px;
    gap: 4px;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    border-radius: var(--radius-pill);
  }

  .change-img-btn svg,
  .crop-img-btn svg,
  .rotate-img-btn svg {
    width: 11px;
    height: 11px;
  }

  .change-img-btn:hover,
  .crop-img-btn:hover,
  .rotate-img-btn:hover {
    background: rgba(255,255,255,0.15);
  }

  .camera-box,
  .crop-box { padding: 16px; max-width: 100%; border-radius: var(--radius-lg); }

  .confirm-box { padding: 20px 16px; border-radius: var(--radius-lg); }

  .cam-btn { padding: 10px 14px; font-size: 13.5px; }

  .camera-controls { flex-direction: row; gap: 10px; }

  .footer-left { min-width: 0; flex-shrink: 1; overflow: hidden; }

  .brand-link { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .footer-right { min-width: 0; flex-shrink: 0; }

  .dev-label { display: none; }

  .dev-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .toast {
    bottom: calc(14px + env(safe-area-inset-bottom));
    right: calc(12px + env(safe-area-inset-right));
    left: calc(12px + env(safe-area-inset-left));
    text-align: center; font-size: 13px;
  }
}

/* --- Very small ≤ 360px --- */
@media (max-width: 360px) {
  .brand-name { font-size: 12px; }

  .side-action-btn { width: 54px; height: 56px; font-size: 9px; }

  .thumb-row { width: 60px; }

  .thumb-card { width: 60px; height: 74px; }

  .preview-btn,
  .download-btn { padding: 8px 10px; }
}

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