:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --primary: #e11d48;
  --primary-hover: #be123c;
  --primary-soft: #ffe4e6;
  --accent-blue: #2563eb;
  --success: #059669;
  --success-soft: #d1fae5;
  --warning-bg: #fef3c7;
  --warning-border: #f59e0b;
  --danger: #dc2626;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.11);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top navigation bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 8px rgba(79, 70, 229, 0.25));
  transition: transform 0.15s ease;
}

.brand:hover .brand-logo {
  transform: scale(1.04);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-text strong {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-text small {
  font-size: 0.75rem;
  color: var(--text-light);
}

.quick-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav-pill {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 0.42rem 0.78rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.nav-pill:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-pill.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* Main container */
.container {
  max-width: 1320px;
  width: 100%;
  flex: 1;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

/* Site Footer */
.site-footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
}

.site-footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-light);
}

.footer-sep {
  color: var(--border-strong);
}

.footer-logo-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  vertical-align: middle;
}

.footer-brand-link {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.footer-brand-link:hover {
  color: var(--primary);
}

.footer-author-link {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed var(--border-strong);
  transition: color 0.14s ease, border-color 0.14s ease;
}

.footer-author-link:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.hidden {
  display: none !important;
}

/* Hero & Tool Cards Grid */
.hero {
  text-align: center;
  max-width: 760px;
  margin: 0.5rem auto 2.25rem;
}

.hero h1 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.65rem;
  color: var(--text);
}

.hero p {
  font-size: 1.05rem;
  color: var(--text-muted);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.15rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  box-shadow: var(--shadow-sm);
}

.tool-card:hover,
.tool-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  outline: none;
}

.tool-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
}

.icon-red { background: #ffe4e6; }
.icon-blue { background: #dbeafe; }
.icon-purple { background: #f3e8ff; }
.icon-green { background: #d1fae5; }
.icon-indigo { background: #e0e7ff; }
.icon-cyan { background: #cffafe; }
.icon-amber { background: #fef3c7; }
.icon-teal { background: #ccfbf1; }
.icon-slate { background: #e2e8f0; }

.tool-body h3 {
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.tool-body p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Workspace Section */
.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.btn-back {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-back:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.workspace-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex: 1;
}

.workspace-badge {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
}

.workspace-title-wrap h2 {
  font-size: 1.35rem;
  font-weight: 800;
}

.workspace-title-wrap p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 1.5rem;
  align-items: start;
}

.workspace-main,
.workspace-sidebar {
  min-width: 0;
}

@media (max-width: 980px) {
  .workspace-layout {
    grid-template-columns: 1fr;
  }
}

/* Dropzone */
.dropzone {
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2.6rem 1.5rem;
  text-align: center;
  transition: all 0.18s ease;
  cursor: pointer;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: #fff1f2;
}

.dropzone.compact {
  padding: 1.25rem 1.5rem;
}

.dropzone.compact .dropzone-icon {
  display: none;
}

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

.dropzone-icon {
  font-size: 2.8rem;
  margin-bottom: 0.65rem;
}

.dropzone-content h3 {
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.dropzone-content p {
  font-size: 0.88rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* Alert Box */
.alert-box {
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: #92400e;
}

.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.inline-password-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.inline-password-group input {
  padding: 0.4rem 0.7rem;
  border: 1px solid #d97706;
  border-radius: 6px;
  font-size: 0.88rem;
}

/* Files list bar */
.files-bar {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow-sm);
}

.files-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.files-bar-actions {
  display: flex;
  gap: 0.5rem;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
}

.file-item-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.file-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  background: #e2e8f0;
  color: #334155;
}

.file-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.file-meta {
  color: var(--text-light);
  font-size: 0.8rem;
}

.file-item-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: all 0.12s ease;
}

.icon-btn:hover {
  background: #e2e8f0;
  color: var(--text);
}

.icon-btn.danger:hover {
  background: #fee2e2;
  color: var(--danger);
  border-color: #fca5a5;
}

/* Preview Panel & Thumbnails Grid */
.preview-panel {
  margin-top: 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.preview-toolbar-left {
  display: flex;
  flex-direction: column;
}

.preview-hint {
  font-size: 0.8rem;
  color: var(--text-light);
}

.preview-toolbar-right {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.15rem;
  max-height: 640px;
  overflow-y: auto;
  padding: 1rem 0.75rem 0.5rem;
}

.page-card {
  background: var(--surface-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  user-select: none;
  transition: transform 0.14s ease, border-color 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.page-card.selectable {
  cursor: pointer;
}

.page-card.selected {
  border-color: var(--primary);
  background: #fff1f2;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}

.page-card.draggable {
  cursor: grab;
}

.page-card.draggable:active {
  cursor: grabbing;
}

.page-card.dragging {
  opacity: 0.38;
  border-style: dashed;
  border-color: var(--primary);
  transform: scale(0.97);
}

.page-card.drop-before {
  transform: translateX(5px);
  border-color: #fda4af;
  background: #fff1f2;
}

.page-card.drop-after {
  transform: translateX(-5px);
  border-color: #fda4af;
  background: #fff1f2;
}

.page-card.drop-before::before,
.page-card.drop-after::before {
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 4px;
  background: var(--primary);
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.2), 0 2px 8px rgba(225, 29, 72, 0.45);
  z-index: 10;
  pointer-events: none;
}

.page-card.drop-before::before {
  left: -13px;
}

.page-card.drop-after::before {
  right: -13px;
}

.page-card.drop-before::after,
.page-card.drop-after::after {
  content: attr(data-drop-label);
  position: absolute;
  top: -15px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(225, 29, 72, 0.35);
  z-index: 11;
  pointer-events: none;
}

.page-card.drop-before::after {
  left: -8px;
}

.page-card.drop-after::after {
  right: -8px;
}

.page-check-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: transparent;
  z-index: 2;
}

.page-card.selected .page-check-badge {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.page-thumb-wrap {
  width: 100%;
  height: 175px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  position: relative;
}

.page-zoom-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 3;
}

.page-card:hover .page-zoom-btn {
  opacity: 1;
}

.page-zoom-btn:hover {
  background: var(--primary);
  transform: scale(1.06);
}

.page-thumb-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.page-card-footer {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.page-card-footer-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.page-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
}

.page-order-badge {
  background: #e2e8f0;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.page-origin-text {
  font-size: 0.76rem;
  color: var(--text-light);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-card-controls {
  display: flex;
  gap: 0.3rem;
  width: 100%;
}

.page-card-footer-stacked .page-card-controls .icon-btn {
  flex: 1;
  height: 28px;
}

/* Sidebar settings */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 76px;
}

.settings-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.tool-options {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  margin-bottom: 1.2rem;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.field-help {
  display: block;
  font-size: 0.77rem;
  color: var(--text-light);
  margin-top: 0.3rem;
}

.text-input,
.select-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}

.text-input:focus,
.select-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}

.radio-cards {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.14s ease;
}

.radio-card:hover {
  background: var(--surface-alt);
}

.radio-card input[type="radio"] {
  margin-top: 0.22rem;
  accent-color: var(--primary);
}

.radio-card div {
  display: flex;
  flex-direction: column;
}

.radio-card strong {
  font-size: 0.88rem;
  font-weight: 600;
}

.radio-card small {
  font-size: 0.77rem;
  color: var(--text-light);
  line-height: 1.35;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.checkbox-row input {
  accent-color: var(--primary);
}

.option-note {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.info-pill {
  background: var(--surface-alt);
  border-left: 3px solid var(--accent-blue);
  padding: 0.65rem 0.8rem;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stats-mini {
  background: var(--surface-alt);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

/* Unobtrusive Metadata Accordion */
.metadata-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  margin-bottom: 1rem;
  overflow: hidden;
}

.metadata-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.14s ease;
}

.metadata-summary::-webkit-details-marker {
  display: none;
}

.metadata-summary:hover {
  background: #e2e8f0;
  color: var(--text);
}

.metadata-summary-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.metadata-summary-left::after {
  content: "▸";
  font-size: 0.75rem;
  color: var(--text-light);
  transition: transform 0.15s ease;
}

.metadata-accordion[open] .metadata-summary-left::after {
  transform: rotate(90deg);
}

.metadata-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.metadata-badge.badge-keep {
  background: #d1fae5;
  color: #065f46;
}

.metadata-badge.badge-strip {
  background: #fee2e2;
  color: #991b1b;
}

.metadata-badge.badge-info {
  background: #e2e8f0;
  color: #334155;
}

.metadata-body {
  padding: 0.75rem 0.85rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.metadata-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}

.metadata-hint-text {
  font-size: 0.74rem;
  color: var(--text-light);
}

.metadata-actions-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.btn-link-xs {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.18rem 0.52rem;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.btn-link-xs:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-link-danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.btn-link-danger:hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

.metadata-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  font-size: 0.77rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.meta-row-editing {
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  background: #f8fafc;
  padding: 0.4rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
}

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

.meta-row-left {
  min-width: 0;
  flex: 1;
}

.meta-row-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.meta-edit-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0;
  opacity: 0.72;
  transition: all 0.12s ease;
}

.meta-edit-btn:hover {
  opacity: 1;
  background: var(--surface-alt);
  border-color: var(--border);
  transform: scale(1.06);
}

.meta-inline-edit {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
}

.meta-inline-input {
  flex: 1;
  min-width: 0;
}

.meta-inline-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s ease;
}

.meta-inline-save {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.meta-inline-save:hover {
  background: #bbf7d0;
}

.meta-inline-clear {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.meta-inline-clear:hover {
  background: #fee2e2;
}

.meta-key {
  color: var(--text-light);
  font-weight: 600;
  margin-right: 0.3rem;
}

.meta-val {
  color: var(--text);
  font-weight: 500;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta-val.muted {
  color: #94a3b8;
  font-style: italic;
}

.meta-state {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.42rem;
  border-radius: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.meta-state.state-saved {
  background: #dcfce7;
  color: #166534;
}

.meta-state.state-edited {
  background: #dbeafe;
  color: #1e40af;
}

.meta-state.state-updated {
  background: #f1f5f9;
  color: #475569;
}

.meta-state.state-stripped {
  background: #fef2f2;
  color: #b91c1c;
  text-decoration: none;
}

.meta-note {
  font-size: 0.74rem;
  color: var(--text-light);
  line-height: 1.35;
}

.metadata-edit-form {
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.metadata-edit-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.metadata-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.metadata-edit-grid label {
  display: block;
  font-size: 0.71rem;
  color: var(--text-light);
  margin-bottom: 0.15rem;
}

.input-xs {
  padding: 0.34rem 0.5rem;
  font-size: 0.78rem;
}

/* Status & Result Cards */
.status-banner {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  margin-bottom: 1rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-banner.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.status-banner.info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.result-card {
  background: var(--success-soft);
  border: 1px solid #6ee7b7;
  border-radius: var(--radius-md);
  padding: 0.95rem;
  margin-bottom: 1rem;
  max-width: 100%;
  overflow: hidden;
}

.result-header {
  font-weight: 700;
  font-size: 0.92rem;
  color: #065f46;
  margin-bottom: 0.4rem;
}

.result-details {
  font-size: 0.83rem;
  color: #047857;
  margin-bottom: 0.75rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.45;
}

.result-filename {
  display: inline-block;
  max-width: 100%;
  font-weight: 700;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 0.6rem 1.15rem;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #0f172a;
  color: #ffffff;
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-alt);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-sm {
  padding: 0.38rem 0.75rem;
  font-size: 0.82rem;
}

.btn-xs {
  padding: 0.28rem 0.55rem;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 0.82rem 1.25rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

/* Quick Page Preview Modal (Lightbox) */
.page-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.page-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(4px);
}

.page-modal-dialog {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(980px, 94vw);
  height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}

.page-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.page-modal-title-group {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  min-width: 0;
}

.page-modal-title-group strong {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.page-modal-subtitle {
  font-size: 0.82rem;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 340px;
}

.page-modal-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.modal-counter {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 0.35rem;
  min-width: 48px;
  text-align: center;
}

.modal-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 0.2rem;
}

.modal-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 0.34rem 0.68rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.modal-btn:hover:not(:disabled) {
  background: #e2e8f0;
}

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

.modal-close-btn:hover {
  background: #fee2e2;
  color: var(--danger);
  border-color: #fca5a5;
}

.page-modal-body {
  flex: 1;
  background: #0f172a;
  position: relative;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.page-modal-body.zoomed {
  align-items: flex-start;
  justify-content: flex-start;
}

.modal-quality-badge {
  position: absolute;
  top: 12px;
  right: 16px;
  background: rgba(15, 23, 42, 0.82);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  z-index: 5;
}

.page-modal-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: auto;
}

.page-modal-stage img {
  max-width: 100%;
  max-height: calc(88vh - 150px);
  object-fit: contain;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  cursor: zoom-in;
  transition: transform 0.18s ease;
}

.page-modal-body.zoomed .page-modal-stage img {
  max-width: none;
  max-height: none;
  width: 1150px;
  cursor: zoom-out;
}

.page-modal-footer {
  padding: 0.55rem 1.2rem;
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* Loading & Progress Indicator Card */
.loading-card {
  margin-top: 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 0.95rem 1.15rem;
  box-shadow: var(--shadow-sm);
}

.loading-card-compact {
  margin-top: 0;
  margin-bottom: 1rem;
  padding: 0.8rem 0.95rem;
}

.loading-card-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.65rem;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid #bfdbfe;
  border-top-color: var(--accent-blue);
  animation: pdf-spin 0.75s linear infinite;
  flex-shrink: 0;
}

.loading-spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2.5px;
}

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

.loading-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.loading-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.loading-card-title-row strong {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e3a8a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading-percent {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-blue);
  background: #dbeafe;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.loading-percent:empty {
  display: none;
}

.loading-subtitle {
  font-size: 0.79rem;
  color: #1d4ed8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading-progress-track {
  width: 100%;
  height: 8px;
  background: #dbeafe;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-blue) 0%, #3b82f6 50%, var(--primary) 100%);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.loading-progress-bar.indeterminate {
  width: 45% !important;
  animation: pdf-progress-slide 1.25s ease-in-out infinite;
}

@keyframes pdf-progress-slide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(230%);
  }
}

.load-more-pages-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
  font-size: 0.86rem;
  color: #1e3a8a;
}

.footer-nav-link {
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.14s ease;
}

.footer-nav-link:hover {
  color: var(--primary);
}

/* Legal Pages (Privacy Policy & Terms of Use) */
.legal-page {
  max-width: 900px;
}

.legal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2.5rem;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 640px) {
  .legal-card {
    padding: 1.5rem 1.25rem;
  }
}

.legal-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
  margin-bottom: 1.65rem;
}

.legal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.24rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.legal-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.legal-en {
  font-weight: 600;
  color: var(--text-light);
  font-size: 1.2rem;
}

.legal-updated {
  font-size: 0.84rem;
  color: var(--text-light);
}

.legal-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.legal-section h2 {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.55rem;
}

.legal-section p {
  font-size: 0.94rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 0.65rem;
}

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

.legal-section ul {
  margin: 0.4rem 0 0.65rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.6;
}

.legal-section a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.legal-section a:hover {
  text-decoration: underline;
}

.legal-section code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1rem 0.38rem;
  font-size: 0.84rem;
  color: var(--text);
}


