.pdf-edit-page {
  background: #fff;
}

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

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

.pdf-edit {
  --pdf-edit-ink: #172033;
  --pdf-edit-muted: #667085;
  --pdf-edit-paper: #f8fafc;
  color: var(--pdf-edit-ink);
  padding: 12px 0 40px;
}

.pdf-edit__inner {
  width: auto;
}

.pdf-edit__app {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.pdf-edit__upload-panel {
  position: relative;
  z-index: 1;
}

.pdf-edit__dropzone {
  min-height: 128px;
}

.pdf-edit__status-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.pdf-edit__file-meta,
.pdf-edit__small-note {
  color: var(--pdf-edit-muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.pdf-edit__quick-actions {
  flex: 0 0 auto;
}

.pdf-edit__quick-actions .omoshiro-tool__button {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 13px;
}

.pdf-edit__source-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #edf1f5;
  border-radius: 8px;
  background: var(--pdf-edit-paper);
}

.pdf-edit__source-list {
  display: grid;
  gap: 8px;
}

.pdf-edit__source-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e6eaf0;
  border-radius: 8px;
  background: #fff;
  cursor: grab;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.pdf-edit__source-item:active {
  cursor: grabbing;
}

.pdf-edit__source-item.is-dragging {
  opacity: 0.58;
  transform: scale(0.99);
}

.pdf-edit__source-item.is-drop-before::before,
.pdf-edit__source-item.is-drop-after::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  z-index: 2;
  height: 4px;
  border-radius: 999px;
  background: var(--accent-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 18%, transparent);
  pointer-events: none;
}

.pdf-edit__source-item.is-drop-before::before {
  top: -7px;
}

.pdf-edit__source-item.is-drop-after::after {
  bottom: -7px;
}

.pdf-edit__source-name {
  display: block;
  overflow: hidden;
  color: var(--pdf-edit-ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-edit__source-meta {
  display: block;
  margin-top: 2px;
  color: var(--pdf-edit-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.pdf-edit__source-actions,
.pdf-edit__thumb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.pdf-edit__mini-button,
.pdf-edit__icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  background: #fff;
  color: var(--pdf-edit-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s;
}

.pdf-edit__mini-button:hover:not(:disabled),
.pdf-edit__icon-button:hover:not(:disabled) {
  border-color: var(--accent-color);
  background: #effaff;
  transform: translateY(-1px);
}

.pdf-edit__mini-button--move:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent-color) 48%, #d9e1ea);
  background: #effaff;
  color: #0277bd;
}

.pdf-edit__mini-button:disabled,
.pdf-edit__icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.pdf-edit__mini-button:focus-visible,
.pdf-edit__icon-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent-color) 20%, transparent);
  outline-offset: 2px;
}

.pdf-edit__workspace {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr) minmax(280px, 330px);
  gap: 14px;
  align-items: start;
}

.pdf-edit__pages-panel,
.pdf-edit__tools-panel {
  position: sticky;
  top: 96px;
}

.pdf-edit__pages-panel,
.pdf-edit__preview-panel,
.pdf-edit__tools-panel {
  min-width: 0;
}

.pdf-edit__pages-panel {
  max-height: calc(100vh - 116px);
  overflow: hidden;
}

.pdf-edit__thumb-list {
  position: relative;
  display: grid;
  gap: 10px;
  max-height: min(720px, calc(100vh - 240px));
  overflow-y: auto;
  padding: 10px 4px 0 0;
  scrollbar-gutter: stable;
}

.pdf-edit__thumb-list:empty {
  padding-top: 0;
}

.pdf-edit__thumb-list:empty + .omoshiro-tool__result-empty {
  margin-top: 6px;
}

.pdf-edit__thumb-list.is-drop-at-start::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 0;
  right: 8px;
  z-index: 2;
  height: 4px;
  border-radius: 999px;
  background: var(--accent-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 18%, transparent);
  pointer-events: none;
}

.pdf-edit__thumb-card {
  position: relative;
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 1px solid #d9e1ea;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: grab;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.pdf-edit__thumb-card:active {
  cursor: grabbing;
}

.pdf-edit__thumb-card.is-selected {
  border-color: var(--accent-color);
  background: #effaff;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-color) 14%, transparent);
}

.pdf-edit__thumb-card.is-dragging {
  opacity: 0.58;
  transform: scale(0.98);
}

.pdf-edit__thumb-card.is-drop-before::before,
.pdf-edit__thumb-card.is-drop-after::after {
  content: "";
  position: absolute;
  z-index: 2;
  border-radius: 999px;
  background: var(--accent-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-color) 18%, transparent);
  pointer-events: none;
}

.pdf-edit__thumb-card.is-drop-y.is-drop-before::before,
.pdf-edit__thumb-card.is-drop-y.is-drop-after::after {
  left: 8px;
  right: 8px;
  height: 4px;
}

.pdf-edit__thumb-card.is-drop-y.is-drop-before::before {
  top: -7px;
}

.pdf-edit__thumb-card.is-drop-y.is-drop-after::after {
  bottom: -7px;
}

.pdf-edit__thumb-card.is-drop-x.is-drop-before::before,
.pdf-edit__thumb-card.is-drop-x.is-drop-after::after {
  top: 8px;
  bottom: 8px;
  width: 4px;
}

.pdf-edit__thumb-card.is-drop-x.is-drop-before::before {
  left: -7px;
}

.pdf-edit__thumb-card.is-drop-x.is-drop-after::after {
  right: -7px;
}

.pdf-edit__thumb-card:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent-color) 20%, transparent);
  outline-offset: 2px;
}

.pdf-edit__thumb-preview {
  display: grid;
  place-items: center;
  min-height: 132px;
  overflow: hidden;
  border: 1px solid #edf1f5;
  border-radius: 6px;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-color: #fff;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.pdf-edit__thumb-preview canvas,
.pdf-edit__thumb-preview img {
  display: block;
  max-width: 100%;
  max-height: 160px;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 6px 14px rgba(16, 24, 40, 0.12);
}

.pdf-edit__thumb-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pdf-edit__thumb-number {
  color: var(--pdf-edit-ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

.pdf-edit__thumb-name {
  overflow: hidden;
  color: var(--pdf-edit-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-edit .pdf-edit__selected-info {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 6px;
  background: #fff0fa;
  color: var(--main-color);
  font-weight: 800;
}

.pdf-edit__preview-panel {
  min-height: 530px;
}

.pdf-edit__preview-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.pdf-edit__pager {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  padding: 4px;
  border: 1px solid #edf1f5;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--pdf-edit-ink);
  font-size: 13px;
  font-weight: 800;
}

.pdf-edit__preview-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
}

.pdf-edit__preview-toolbar .omoshiro-tool__button {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 13px;
}

.pdf-edit__zoom-label {
  min-width: 52px;
  color: var(--pdf-edit-ink);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.pdf-edit__canvas-frame {
  position: relative;
  display: grid;
  align-items: safe center;
  justify-items: safe center;
  min-height: 430px;
  max-height: min(72vh, 680px);
  margin-top: 12px;
  padding: 16px;
  overflow: auto;
  border: 1px solid #e6eaf0;
  border-radius: 8px;
  background: #f1f5f9;
}

.pdf-edit__canvas {
  display: block;
  max-width: none;
  width: auto;
  height: auto;
  background: #fff;
  box-shadow: 0 16px 34px rgba(16, 24, 40, 0.16);
}

.pdf-edit__empty-preview {
  align-self: stretch;
  justify-self: stretch;
  margin: auto;
}

.pdf-edit__tool-section {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid #edf1f5;
}

.pdf-edit__tool-section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.pdf-edit__tool-title {
  margin: 0 0 10px;
  color: var(--pdf-edit-ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
}

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

.pdf-edit__button-grid .omoshiro-tool__button,
.pdf-edit__tool-section > .omoshiro-tool__button {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
}

.pdf-edit__danger-button:not(:disabled) {
  border-color: color-mix(in srgb, var(--main-color) 32%, #d9e1ea);
  color: var(--main-color);
}

.pdf-edit__margin-list,
.pdf-edit__split-mode-list {
  margin-top: 10px;
}

.pdf-edit__margin-list.omoshiro-tool__radio-list--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.pdf-edit__split-mode-list .omoshiro-tool__radio {
  justify-content: flex-start;
  min-height: 52px;
  text-align: left;
}

.pdf-edit__split-mode-list .omoshiro-tool__radio span {
  gap: 2px;
}

.pdf-edit__split-button {
  margin-top: 12px;
}

.pdf-edit__field:not([hidden]) + .pdf-edit__split-button {
  margin-top: 0;
}

.pdf-edit__field {
  display: grid;
  gap: 6px;
  width: 100%;
  min-width: 0;
  margin: 10px 0;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.pdf-edit__field .omoshiro-tool__input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

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

@media (max-width: 1180px) {
  .pdf-edit__workspace {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  }

  .pdf-edit__tools-panel {
    position: static;
    grid-column: 1 / -1;
  }

  .pdf-edit__tools-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .pdf-edit__tools-panel > .omoshiro-tool__panel-head {
    grid-column: 1 / -1;
  }

  .pdf-edit__tool-section {
    padding: 12px;
    margin: 0;
    border: 1px solid #edf1f5;
    border-radius: 8px;
    background: #f8fafc;
  }
}

@media (max-width: 900px) {
  .pdf-edit__workspace {
    grid-template-columns: 1fr;
  }

  .pdf-edit__pages-panel,
  .pdf-edit__tools-panel {
    position: static;
  }

  .pdf-edit__pages-panel {
    max-height: none;
  }

  .pdf-edit__thumb-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .pdf-edit__preview-panel {
    min-height: 460px;
  }

  .pdf-edit__canvas-frame {
    min-height: 360px;
  }

  .pdf-edit__features-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .pdf-edit {
    padding-top: 8px;
  }

  .pdf-edit__status-row,
  .pdf-edit__preview-head,
  .pdf-edit__source-item {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pdf-edit__quick-actions,
  .pdf-edit__source-actions {
    justify-content: stretch;
  }

  .pdf-edit__source-actions .pdf-edit__mini-button {
    flex: 1 1 auto;
  }

  .pdf-edit__thumb-list,
  .pdf-edit__tools-panel,
  .pdf-edit__features-grid {
    grid-template-columns: 1fr;
  }

  .pdf-edit__thumb-preview {
    min-height: 170px;
  }

  .pdf-edit__preview-toolbar,
  .pdf-edit__pager {
    justify-content: center;
  }

  .pdf-edit__preview-toolbar .omoshiro-tool__button {
    width: auto;
  }

  .pdf-edit__canvas-frame {
    min-height: 320px;
    padding: 10px;
  }

  .pdf-edit__margin-list.omoshiro-tool__radio-list--three,
  .pdf-edit__button-grid {
    grid-template-columns: 1fr;
  }
}
