:root {
  color-scheme: light;
  color: #172033;
  background: #f5f7fb;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f7fb;
  transition: color 180ms ease, background 180ms ease;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100% - 32px, 1180px);
  margin-inline: auto;
  padding-block: 24px;
}

.site-header,
.header-actions {
  display: flex;
  align-items: center;
}

.site-header {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: 1.6rem;
}

h2 {
  font-size: 1.05rem;
}

.subtitle,
.quick-guide,
.privacy-badge {
  color: #64748b;
  font-size: 0.875rem;
}

.subtitle {
  margin-bottom: 0;
}

.app-intro {
  max-width: 720px;
}

.quick-guide {
  max-width: 680px;
  margin: 7px 0 0;
  line-height: 1.45;
}

.header-actions {
  flex-shrink: 0;
  gap: 12px;
}

.language-control select,
input[type="text"] {
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  color: #172033;
  background: #fff;
}

.language-control select {
  padding: 8px 30px 8px 10px;
  cursor: pointer;
}

.card {
  padding: 18px;
  border: 1px solid #dbe2ea;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 5px 20px rgb(23 32 51 / 5%);
}

.toolbar {
  display: grid;
  gap: 12px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.theme-toggle {
  width: 42px;
  padding: 0;
  margin-left: auto;
}

.theme-toggle__icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
}

.theme-toggle svg {
  grid-area: 1 / 1;
  width: 14px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: opacity 180ms ease, transform 180ms ease;
}

.theme-toggle__sun,
.theme-toggle[aria-checked="true"] .theme-toggle__moon {
  opacity: 0;
  transform: rotate(-45deg) scale(0.6);
}

.theme-toggle__moon,
.theme-toggle[aria-checked="true"] .theme-toggle__sun {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.watermark-settings {
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: #172033;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
}

.button.secondary {
  color: #172033;
  background: #e8edf4;
}

.button[aria-pressed="true"] {
  background: #b42318;
}

.button:disabled,
input:disabled,
select:disabled {
  cursor: wait;
  opacity: 0.6;
}

.button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(37 99 235 / 35%);
  outline-offset: 2px;
}

input[type="file"] {
  display: none;
}

.watermark-field {
  display: grid;
  flex: 1 1 280px;
  gap: 5px;
}

.watermark-weight-field {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 3ch;
  align-items: center;
  gap: 5px 10px;
  color: #475569;
  font-size: 0.8125rem;
}

.field-label {
  color: #475569;
  font-size: 0.8125rem;
  font-weight: 650;
}

.watermark-weight-field .field-label {
  grid-column: 1 / -1;
}

input[type="range"] {
  width: 100%;
  accent-color: #b42318;
  cursor: pointer;
}

.watermark-weight-field output {
  color: #172033;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
}

.status {
  min-height: 1.25rem;
  margin: 12px 0 0;
  color: #475569;
  font-size: 0.8125rem;
}

.progress {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e2e8f0;
}

.progress-bar {
  width: 0;
  height: 100%;
  background: #172033;
  transition: width 160ms ease;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.document-card {
  min-width: 0;
}

.document-save {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.add-pages-button {
  gap: 7px;
}

.add-pages-button > span:first-child {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1;
}

.export-actions {
  display: flex;
  gap: 10px;
}

#pages {
  display: flex;
  min-height: 300px;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.page-shell {
  display: grid;
  width: fit-content;
  max-width: 100%;
  gap: 8px;
}

.page-actions {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
}

.page-actions__group {
  display: flex;
  gap: 6px;
}

.page-actions__group:last-child {
  margin-left: auto;
}

.page-action {
  display: grid;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  color: #334155;
  background: #fff;
  cursor: pointer;
  place-items: center;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.page-action:hover:not(:disabled) {
  border-color: #8b5cf6;
  color: #6d28d9;
  background: #f5f3ff;
  transform: translateY(-1px);
}

.page-action[aria-pressed="true"] {
  border-color: #7c3aed;
  color: #fff;
  background: #7c3aed;
}

.page-action--confirm:not(:disabled) {
  border-color: #15803d;
  color: #fff;
  background: #15803d;
}

.page-action--danger:not(:disabled) {
  border-color: #fecaca;
  color: #b42318;
  background: #fff1f2;
}

.page-action--danger:hover:not(:disabled) {
  border-color: #b42318;
  color: #fff;
  background: #b42318;
}

.page-action:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.page-action:focus-visible {
  outline: 3px solid rgb(139 92 246 / 35%);
  outline-offset: 2px;
}

.page-action svg {
  width: 19px;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.page {
  position: relative;
  max-width: 100%;
  overflow: hidden;
  background: #e5e7eb;
  box-shadow: 0 4px 18px rgb(0 0 0 / 13%);
  transition: box-shadow 160ms ease;
}

.page.selected {
  box-shadow:
    0 0 0 3px #8b5cf6,
    0 8px 26px rgb(76 29 149 / 24%);
}

.document-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.page.grayscale .document-canvas {
  filter: grayscale(1);
}

.watermark-preview,
.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.watermark-preview {
  z-index: 1;
  pointer-events: none;
}

.overlay {
  z-index: 2;
  cursor: default;
  touch-action: none;
}

.overlay.redact-mode {
  cursor: crosshair;
}

.overlay.crop-mode {
  cursor: cell;
}

.redaction {
  position: absolute;
  border: 1px solid #111;
  background: #000;
}

.crop-selection {
  position: absolute;
  border: 2px solid #8b5cf6;
  background: rgb(139 92 246 / 16%);
  box-shadow:
    0 0 0 9999px rgb(15 23 42 / 48%),
    inset 0 0 0 1px rgb(255 255 255 / 65%);
}

.crop-handle {
  position: absolute;
  z-index: 1;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #7c3aed;
  box-shadow: 0 1px 5px rgb(15 23 42 / 45%);
  touch-action: none;
}

.crop-handle--nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
  transform: translate(-50%, -50%);
}

.crop-handle--ne {
  top: 0;
  right: 0;
  cursor: nesw-resize;
  transform: translate(50%, -50%);
}

.crop-handle--se {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
  transform: translate(50%, 50%);
}

.crop-handle--sw {
  bottom: 0;
  left: 0;
  cursor: nesw-resize;
  transform: translate(-50%, 50%);
}

.empty {
  padding: 80px 20px;
  color: #64748b;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

noscript {
  display: block;
  padding: 16px;
  color: #fff;
  background: #b42318;
  text-align: center;
}

html[data-theme="dark"] {
  color: #e6edf3;
  background: #0d1117;
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background: #0d1117;
}

html[data-theme="dark"] .subtitle,
html[data-theme="dark"] .quick-guide,
html[data-theme="dark"] .privacy-badge,
html[data-theme="dark"] .status,
html[data-theme="dark"] .field-label,
html[data-theme="dark"] .watermark-weight-field,
html[data-theme="dark"] .empty {
  color: #8c959f;
}

html[data-theme="dark"] .card {
  border-color: #30363d;
  background: #161b22;
  box-shadow: 0 8px 28px rgb(0 0 0 / 24%);
}

html[data-theme="dark"] .language-control select,
html[data-theme="dark"] input[type="text"] {
  border-color: #30363d;
  color: #e6edf3;
  background: #0d1117;
}

html[data-theme="dark"] .button {
  color: #0d1117;
  background: #f0f6fc;
}

html[data-theme="dark"] .button.secondary {
  color: #e6edf3;
  background: #30363d;
}

html[data-theme="dark"] .button[aria-pressed="true"] {
  color: #fff;
  background: #da3633;
}

html[data-theme="dark"] .watermark-settings {
  border-color: #30363d;
  background: #0d1117;
}

html[data-theme="dark"] .page-action {
  border-color: #30363d;
  color: #c9d1d9;
  background: #21262d;
}

html[data-theme="dark"] .page-action:hover:not(:disabled) {
  border-color: #a78bfa;
  color: #ddd6fe;
  background: #2d2342;
}

html[data-theme="dark"] .page-action[aria-pressed="true"] {
  border-color: #8b5cf6;
  color: #fff;
  background: #7c3aed;
}

html[data-theme="dark"] .page-action--confirm:not(:disabled) {
  border-color: #238636;
  color: #fff;
  background: #238636;
}

html[data-theme="dark"] .page-action--danger:not(:disabled) {
  border-color: #6e2b2b;
  color: #ff7b72;
  background: #2d1719;
}

html[data-theme="dark"] .page-action--danger:hover:not(:disabled) {
  border-color: #f85149;
  color: #fff;
  background: #b62324;
}

html[data-theme="dark"] .document-save {
  border-color: #30363d;
}

html[data-theme="dark"] .watermark-weight-field output {
  color: #e6edf3;
}

html[data-theme="dark"] .progress {
  background: #30363d;
}

html[data-theme="dark"] .progress-bar {
  background: #a78bfa;
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-block: 14px;
  }

  .site-header,
  .header-actions {
    align-items: flex-start;
  }

  .site-header {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .toolbar-row > *,
  .watermark-field,
  .watermark-weight-field {
    width: 100%;
    max-width: none;
  }

  .theme-toggle {
    width: 42px;
    margin-left: auto;
  }

  .document-save .button {
    width: 100%;
  }

  .export-actions {
    width: 100%;
    flex-direction: column;
  }

  .watermark-weight-field {
    grid-template-columns: minmax(0, 1fr) 3ch;
  }
}
