.pdf-editor-app {
  --bg: #f5f7f8;
  --ink: #182023;
  --muted: #657174;
  --line: #d9e0e2;
  --panel: #ffffff;
  --accent: #0c7c59;
  --accent-dark: #075f45;
  --danger: #b83232;
  --focus: #d8eee7;
  --shadow: 0 12px 28px rgba(24, 32, 35, 0.08);
}

.pdf-editor-app,
.pdf-editor-app * {
  box-sizing: border-box;
}

.pdf-editor-app [hidden] {
  display: none !important;
}

.pdf-editor-app {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.pdf-editor-app button,
.pdf-editor-app input,
.pdf-editor-app select {
  font: inherit;
}

.pdf-editor-app button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.pdf-editor-app button:hover {
  border-color: #9eb2b7;
}

.pdf-editor-app button.primary,
.pdf-editor-app .upload-button {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.pdf-editor-app button.primary:hover,
.pdf-editor-app .upload-button:hover {
  background: var(--accent-dark);
}

.pdf-editor-app button.active {
  border-color: var(--accent);
  background: var(--focus);
}

.pdf-editor-app button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.pdf-editor-app .pdf-editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 84px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.pdf-editor-app .tool-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.pdf-editor-app .tool-tabs a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  text-decoration: none;
}

.pdf-editor-app .tool-tabs a.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.pdf-editor-app h1,
.pdf-editor-app h2,
.pdf-editor-app p {
  margin: 0;
}

.pdf-editor-app h1 {
  font-size: 24px;
  font-weight: 750;
}

.pdf-editor-app h2 {
  margin-bottom: 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.pdf-editor-app .pdf-editor-topbar p {
  margin-top: 4px;
  color: var(--muted);
}

.pdf-editor-app .upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  white-space: nowrap;
  cursor: pointer;
}

.pdf-editor-app .upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.pdf-editor-app .workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: 16px;
  padding: 16px;
  min-width: 0;
}

.pdf-editor-app .sidebar {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
}

.pdf-editor-app .panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.pdf-editor-app .editor {
  min-width: 0;
  min-height: calc(100vh - 116px);
}

.pdf-editor-app .toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.pdf-editor-app .document-list,
.pdf-editor-app .merge-list,
.pdf-editor-app .results {
  display: grid;
  gap: 8px;
}

.pdf-editor-app .document-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: left;
  background: #fff;
}

.pdf-editor-app .document-item.active {
  border-color: var(--accent);
  background: var(--focus);
}

.pdf-editor-app .document-select {
  display: grid;
  gap: 4px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  text-align: left;
  background: transparent;
}

.pdf-editor-app .document-select:hover {
  border: 0;
}

.pdf-editor-app .document-delete {
  min-height: 30px;
  padding: 0 8px;
  border-color: rgba(184, 50, 50, 0.28);
  color: var(--danger);
  background: rgba(184, 50, 50, 0.06);
}

.pdf-editor-app .merge-list .document-item {
  grid-template-columns: 1fr;
  min-width: 0;
}

.pdf-editor-app .merge-document-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 6px;
  min-width: 0;
}

.pdf-editor-app .merge-document-name {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pdf-editor-app .document-name {
  overflow: hidden;
  font-weight: 650;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pdf-editor-app .document-meta,
.pdf-editor-app .status,
.pdf-editor-app .field label {
  color: var(--muted);
  font-size: 13px;
}

.pdf-editor-app .field {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin-bottom: 12px;
}

.pdf-editor-app .field.compact {
  max-width: 140px;
}

.pdf-editor-app input,
.pdf-editor-app select {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
}

.pdf-editor-app select {
  text-overflow: ellipsis;
}

.pdf-editor-app .segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.pdf-editor-app .panel-hint {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.pdf-editor-app .panel-divider {
  height: 1px;
  margin: 14px 0;
  background: var(--line);
}

.pdf-editor-app .range-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.pdf-editor-app .empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 360px;
  margin-top: 16px;
  border: 1px dashed #b8c5c9;
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.pdf-editor-app .empty-state strong {
  color: var(--ink);
  font-size: 18px;
}

.pdf-editor-app .active-page-viewer {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.pdf-editor-app .active-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.pdf-editor-app .active-page-head strong {
  color: var(--ink);
  font-size: 15px;
}

.pdf-editor-app .active-page-canvas {
  display: grid;
  place-items: center;
  min-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef2f3;
}

.pdf-editor-app .active-page-canvas img {
  max-width: min(100%, 900px);
  max-height: 78vh;
  transform-origin: center;
  box-shadow: 0 16px 34px rgba(24, 32, 35, 0.16);
}

.pdf-editor-app .page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 16px 0;
}

.pdf-editor-app .page-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.pdf-editor-app .page-card.selected {
  border-color: var(--accent);
  background: var(--focus);
}

.pdf-editor-app .page-card.viewing {
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 2px rgba(12, 124, 89, 0.18), var(--shadow);
}

.pdf-editor-app .page-card.removed {
  border-color: #e6b7b7;
  opacity: 0.55;
}

.pdf-editor-app .page-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 0.72;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #eef2f3;
}

.pdf-editor-app .page-preview img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center;
}

.pdf-editor-app .page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.pdf-editor-app .page-actions {
  display: flex;
  gap: 4px;
}

.pdf-editor-app .page-actions button {
  min-width: 28px;
  min-height: 28px;
  padding: 0;
}

.pdf-editor-app .danger {
  color: var(--danger);
}

.pdf-editor-app .result-link {
  display: block;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-dark);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: #fff;
}

@media (max-width: 1080px) {
  .pdf-editor-app .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .pdf-editor-app .sidebar.right {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .pdf-editor-app .pdf-editor-topbar,
  .pdf-editor-app .workspace {
    grid-template-columns: 1fr;
  }

  .pdf-editor-app .pdf-editor-topbar {
    align-items: stretch;
  }

  .pdf-editor-app .workspace {
    padding: 10px;
  }

  .pdf-editor-app .sidebar.right {
    grid-template-columns: 1fr;
  }

  .pdf-editor-app .toolbar {
    position: static;
  }
}
