/* UI refinements layered on top of the production bundle. */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.tool-tabs {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}

.password-help {
  margin: 8px 2px 0;
  color: #778296;
  font-size: 0.78rem;
  line-height: 1.5;
}

.protect-password-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.protect-password-mode[hidden],
.generated-password-options[hidden],
#custom-password-options[hidden] {
  display: none;
}

.protect-password-mode legend {
  grid-column: 1 / -1;
  margin-bottom: 7px;
  color: #17233a;
  font-size: 0.84rem;
  font-weight: 800;
}

.protect-password-mode label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #ccd7e3;
  border-radius: 12px;
  color: #40506a;
  background: #fff;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 750;
}

.protect-password-mode label:has(input:checked) {
  border-color: #298474;
  color: #126653;
  background: #edf8f4;
  box-shadow: 0 0 0 2px rgb(41 132 116 / 10%);
}

.protect-password-mode input,
.generated-password-settings input[type="checkbox"] {
  accent-color: #16705a;
}

.generated-password-options {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.generated-password-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.password-length-control {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.password-length-control > label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  color: #17233a;
  font-size: 0.84rem;
  font-weight: 800;
}

.password-length-control input[type="range"] {
  width: 100%;
  accent-color: #16705a;
}

.password-length-control output {
  color: #236a9f;
  font-weight: 800;
}

.password-length-control datalist {
  display: none;
}

.password-strength-scale {
  position: relative;
  height: 34px;
  margin-inline: 14px;
  color: #778296;
}

.password-strength-scale span {
  position: absolute;
  top: 0;
  left: var(--scale-position);
  display: grid;
  gap: 1px;
  justify-items: center;
  transform: translateX(-50%);
  font-size: 0.68rem;
}

.password-strength-scale span:nth-child(1) { --scale-position: 0%; }
.password-strength-scale span:nth-child(2) { --scale-position: 25%; }
.password-strength-scale span:nth-child(3) { --scale-position: 50%; }
.password-strength-scale span:nth-child(4) { --scale-position: 75%; }
.password-strength-scale span:nth-child(5) { --scale-position: 100%; }

.password-strength-scale b {
  color: #526075;
  font-size: 0.7rem;
}

.password-strength-scale small {
  font-size: 0.66rem;
  white-space: nowrap;
}

.password-strength-warning {
  margin: 3px 0 0;
  padding: 8px 10px;
  border-left: 3px solid #c47b16;
  border-radius: 7px;
  color: #7b4b0e;
  background: #fff7e8;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.45;
}

.password-strength-warning[hidden] {
  display: none;
}

.generated-password-settings .check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: #344158;
  font-size: 0.82rem;
  font-weight: 750;
}

.generated-password-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #b9dfd1;
  border-radius: 12px;
  background: #eff9f5;
}

.generated-password-result code {
  min-width: 0;
  overflow-x: auto;
  padding: 5px 7px;
  color: #173a33;
  font-size: 0.94rem;
  font-weight: 800;
  white-space: nowrap;
  user-select: all;
}

.generated-password-result button,
.secondary-button {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid #16705a;
  border-radius: 10px;
  color: #fff;
  background: #16705a;
  cursor: pointer;
  font-weight: 800;
}

.secondary-button {
  justify-self: start;
  color: #16705a;
  background: #fff;
}

.generated-password-result button:hover,
.secondary-button:hover {
  filter: brightness(0.95);
}

.generated-password-result button:focus-visible,
.secondary-button:focus-visible,
.protect-password-mode input:focus-visible {
  outline: 3px solid rgb(35 106 159 / 24%);
  outline-offset: 2px;
}

.language-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #526075;
  font-size: 0.78rem;
  font-weight: 750;
}

.language-switcher select {
  min-width: 138px;
  min-height: 38px;
  padding: 7px 34px 7px 11px;
  border: 1px solid #c8d2de;
  border-radius: 10px;
  color: #344158;
  background: #fff;
  cursor: pointer;
}

.language-switcher select:focus-visible {
  outline: 3px solid rgb(35 106 159 / 24%);
  outline-offset: 2px;
}

@media (min-width: 901px) {
  .card {
    width: min(100%, 1480px);
    padding: clamp(28px, 4vw, 48px);
    transition: width 180ms ease;
  }

  .card.page-manager-mode .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .card.page-manager-mode .page-preview {
    height: 180px;
  }
}

.privacy-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid #b9dfd1;
  border-radius: 999px;
  color: #126048;
  background: #e9f7f1;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
}

.tool-heading-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  align-items: start;
  gap: 18px 28px;
  margin-bottom: 18px;
}

.tool-heading-row .tool-intro {
  margin-bottom: 0;
}

.unlock-legal-notice {
  padding: 11px 13px;
  border: 1px solid #d7e5df;
  border-left: 4px solid #16705a;
  border-radius: 10px;
  color: #486057;
  background: #f2f9f6;
  font-size: 0.76rem;
  line-height: 1.6;
}

.unlock-legal-notice[hidden] {
  display: none;
}

.site-footer a {
  color: #526f8a;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.site-footer a:hover {
  color: #16705a;
}

.tool-tab:focus-visible,
.page-toolbar button:focus-visible,
.order-button:focus-visible,
.text-button:focus-visible,
.primary-button:focus-visible,
.mobile-tool-picker select:focus-visible {
  outline: 3px solid rgba(35, 106, 159, 0.28);
  outline-offset: 2px;
}

.status {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid #dce5ed;
  box-shadow: 0 3px 10px rgba(38, 55, 78, 0.05);
}

.status::before {
  flex: 0 0 auto;
  color: #647187;
  content: "●";
  font-size: 0.7rem;
  line-height: 1.9;
}

.status[data-kind="working"]::before { color: #1e6799; content: "◌"; font-size: 1rem; line-height: 1.25; }
.status[data-kind="success"]::before { color: #16705a; content: "✓"; font-size: 0.95rem; line-height: 1.35; }
.status[data-kind="error"]::before { color: #a02e37; content: "!"; font-weight: 900; line-height: 1.4; }

.status.is-success-toast {
  position: fixed;
  right: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 50;
  width: min(420px, calc(100vw - 32px));
  margin: 0;
  border-color: #b9dfd1;
  box-shadow: 0 14px 36px rgba(22, 96, 72, 0.2);
  animation: toast-in 180ms ease-out;
}

.status.is-toast-hidden { display: none; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.history-section.is-collapsed .history-list,
.history-section.is-collapsed #clear-history {
  display: none;
}

.history-section.is-collapsed {
  padding-bottom: 14px;
}

.history-section {
  overflow: hidden;
  padding: 0 14px 14px;
  border: 1px solid #c7d8e5;
  border-radius: 14px;
  color: #314158;
  background: #f6fafd;
  box-shadow: inset 0 1px 0 #fff, 0 8px 24px rgb(43 75 102 / 9%);
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.terminal-titlebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 36px;
  margin: 0 -14px 14px;
  padding: 7px 11px;
  border-bottom: 1px solid #c7d8e5;
  color: #60758d;
  background: #e8f0f6;
  font-size: 0.67rem;
  letter-spacing: 0.02em;
}

.terminal-titlebar > span:nth-child(2) {
  font-weight: 750;
}

.terminal-lights {
  display: flex;
  gap: 6px;
}

.terminal-lights i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff5f57;
}

.terminal-lights i:nth-child(2) { background: #febc2e; }
.terminal-lights i:nth-child(3) { background: #28c840; }

.history-section .section-kicker {
  display: none;
}

.history-section .section-kicker::before {
  margin-right: 5px;
  color: #236a9f;
  content: "$";
}

.history-section .queue-heading h3 {
  color: #223149;
  font-size: 0.94rem;
  font-weight: 700;
}

.history-section .queue-heading h3::after {
  margin-left: 5px;
  color: #16705a;
  content: "_";
  animation: terminal-cursor 1.05s steps(1) infinite;
}

@keyframes terminal-cursor {
  50% { opacity: 0; }
}

.history-section .text-button.compact,
.history-section .history-actions button {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid #b8cddd;
  border-radius: 7px;
  color: #236a9f;
  background: #fff;
  font-size: 0.72rem;
}

.history-section .text-button.compact:hover,
.history-section .history-actions button:hover {
  border-color: #6ea3c5;
  color: #174f78;
  background: #edf6fb;
}

.history-section .history-list {
  scrollbar-color: #a8bdcc #edf3f7;
}

.history-section .empty-list {
  border-color: #c7d8e5;
  color: #687b91;
  background: #fff;
  text-align: left;
}

.history-section .empty-list::before {
  margin-right: 7px;
  color: #21a179;
  content: "●";
  font-size: 0.55rem;
  vertical-align: 0.12em;
}

.history-section .history-item {
  border-color: #d4e0e9;
  color: #314158;
  background: #fff;
}

.history-section .history-item summary {
  color: #314158;
}

.history-section .history-time,
.history-section .history-summary,
.history-section .history-file,
.history-section .released-note {
  color: #687b91;
}

.history-section .history-summary [data-kind="success"] { color: #16705a; }
.history-section .history-summary [data-kind="failed"] { color: #a02e37; }
.history-section .history-details { border-color: #e1e9ef; }

.history-section .history-actions .release-result {
  color: #a02e37;
}

.page-card[draggable="true"] {
  contain: layout paint style;
  cursor: grab;
  touch-action: pan-y;
  -webkit-touch-callout: none;
}

.page-card[draggable="true"] img {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.page-card[draggable="true"]:active {
  cursor: grabbing;
}

.page-card.is-touch-dragging {
  z-index: 3;
  opacity: 0.58;
  cursor: grabbing;
  transform: scale(0.97);
  box-shadow: 0 12px 28px rgba(38, 55, 78, 0.2);
}

.page-card.is-touch-drop-target {
  outline: 3px dashed #236a9f;
  outline-offset: 3px;
  background: #e7f3fa;
}

body.is-touch-sorting {
  overscroll-behavior: contain;
  user-select: none;
}

body.is-native-sorting,
body.is-native-sorting .drag-handle,
body.is-native-sorting .page-card {
  cursor: grabbing !important;
}

body.is-native-sorting {
  overflow-x: clip;
  overscroll-behavior: contain;
}

body.is-native-sorting {
  user-select: none;
  -webkit-user-select: none;
}

body.is-native-sorting .page-card,
body.is-native-sorting .page-preview img {
  transition: none !important;
}

body.is-native-sorting .page-card:hover {
  transform: none;
}

.decorate-options .watermark-type-options,
.decorate-options .page-number-options {
  margin-top: 14px;
}

.decorate-options .watermark-source-options {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.decorate-options .watermark-source-options[hidden] {
  display: none;
}

#watermark-font-label[hidden],
#watermark-size-label[hidden] {
  display: none;
}

.decorate-options .option-label {
  color: #344158;
  font-weight: 600;
}

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

.watermark-image-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 2px 0;
}

.watermark-image-picker .watermark-upload-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  margin: 0;
  padding: 10px 15px;
  border-radius: 10px;
  color: #fff;
  background: #167c73;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
}

.watermark-image-picker .watermark-upload-button:hover {
  background: #11685f;
}

.watermark-image-picker:focus-within .watermark-upload-button {
  outline: 3px solid rgb(22 124 115 / 20%);
  outline-offset: 2px;
}

.watermark-upload-formats {
  color: #778296;
  font-size: 0.8rem;
  line-height: 1.45;
}

.decorate-options .option-help {
  margin: 0;
  color: #778296;
  font-size: 0.76rem;
  line-height: 1.5;
}

.decorate-options .option-help[data-kind="success"] { color: #16705a; }
.decorate-options .option-help[data-kind="error"] { color: #a02e37; }

.decoration-preview {
  margin-top: 20px;
  padding: 14px;
  border: 1px solid #dce5ed;
  border-radius: 14px;
  background: #f8fafc;
}

.decoration-preview[hidden] {
  display: none;
}

@media (min-width: 901px) {
  .decorate-mode .activity-panel > .decoration-preview {
    position: sticky;
    top: 18px;
    z-index: 2;
    margin: 0 0 22px;
    padding: 16px;
    background: #fff;
    box-shadow: 0 12px 30px rgb(38 55 78 / 9%);
  }

  .decorate-mode .activity-panel > .decoration-preview .decoration-preview-paper {
    width: min(100%, 360px);
  }
}

.decoration-preview-heading,
.error-notice-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.decoration-preview-heading strong { font-size: 0.9rem; }
.decoration-preview-heading span { color: #778296; font-size: 0.72rem; }

.decoration-preview-paper {
  position: relative;
  width: min(100%, 330px);
  margin: 12px auto;
  overflow: hidden;
  aspect-ratio: 210 / 297;
  border: 1px solid #cfd9e3;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(38, 55, 78, 0.12);
}

.preview-document-content {
  position: absolute;
  inset: 11% 10%;
  display: grid;
  align-content: start;
  gap: 8%;
}

.preview-document-content[hidden],
.preview-pdf-page[hidden] {
  display: none;
}

.preview-pdf-page {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.preview-document-content::before {
  width: 52%;
  height: 8px;
  border-radius: 3px;
  background: #c9d4df;
  content: "";
}

.preview-document-content span {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #dce4eb 0 84%, transparent 84%);
}

.preview-document-content span:nth-child(2n) {
  background: linear-gradient(90deg, #dce4eb 0 68%, transparent 68%);
}

.preview-watermark-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.preview-watermark-layer.is-repeat {
  inset: -18%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  place-items: center;
  gap: 7% 5%;
}

.preview-watermark-mark {
  position: absolute;
  max-width: 82%;
  color: #274766;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
  transform-origin: center;
}

.preview-watermark-layer.is-repeat .preview-watermark-mark {
  position: static;
  width: 86%;
  white-space: normal;
}

.preview-watermark-layer.is-repeat.is-image-repeat {
  inset: 0;
  display: block;
}

.preview-watermark-layer.is-image-repeat .preview-watermark-mark {
  position: absolute;
  max-width: none;
  white-space: normal;
  transform-origin: center;
}

.preview-watermark-layer.is-image-repeat .preview-watermark-mark img {
  max-height: none;
}

.preview-watermark-mark img {
  display: block;
  width: 100%;
  max-height: 90px;
  object-fit: contain;
}

.preview-page-number {
  position: absolute;
  right: 0;
  bottom: 3.5%;
  left: 0;
  color: #404d61;
  text-align: center;
}

.error-notice {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #efb8bd;
  border-left: 4px solid #a02e37;
  border-radius: 12px;
  color: #76232b;
  background: #fff4f5;
}

.error-notice[hidden] { display: none; }
.error-notice-heading strong { font-size: 0.9rem; }
.error-notice-heading button { width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px; color: #8d3540; background: transparent; cursor: pointer; font-size: 1.25rem; }
.error-notice-heading button:hover { background: #f9dfe2; }
.error-notice p { margin: 8px 0 0; font-size: 0.82rem; line-height: 1.55; }
.error-notice .error-reason { color: #8d3540; font-weight: 700; }
.error-notice ul { margin: 8px 0 0; padding-left: 20px; color: #5f3b40; font-size: 0.78rem; line-height: 1.55; }

.decorate-options .page-number-options[hidden] {
  display: none;
}

.decorate-options output {
  display: inline-block;
  min-width: 54px;
  margin-top: 5px;
  color: #236a9f;
  font-size: 0.78rem;
  font-weight: 800;
}

.decorate-options input[type="range"] {
  width: 100%;
  accent-color: #16705a;
}

#watermark-position-label.is-disabled-option {
  opacity: 0.5;
}

@media (max-width: 640px) {
  .card {
    padding-top: 16px;
  }

  .eyebrow {
    letter-spacing: 0.08em;
  }

  .language-switcher > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .language-switcher select {
    min-width: 116px;
    min-height: 40px;
    max-width: 42vw;
    padding-inline: 10px 30px;
    font-size: 0.82rem;
  }

  h1 {
    margin: 3px 0 7px;
    font-size: clamp(1.85rem, 9.5vw, 2.35rem);
  }

  .privacy-note {
    gap: 7px;
    margin-bottom: 17px;
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .privacy-badge {
    min-height: 25px;
    padding: 3px 8px;
    font-size: 0.72rem;
  }

  .mobile-tool-picker {
    margin-bottom: 17px;
  }

  .tool-intro {
    margin-bottom: 14px;
  }

  .tool-heading-row {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .tool-heading-row .tool-intro {
    margin-bottom: 0;
  }

  .workspace {
    gap: 16px;
  }

  .activity-panel {
    padding: 12px 10px;
  }

  .protect-password-mode,
  .generated-password-settings,
  .generated-password-result {
    grid-template-columns: 1fr;
  }

  .generated-password-result button,
  .secondary-button {
    width: 100%;
  }

  .activity-panel .empty-list {
    padding: 16px 12px;
  }

  .activity-panel .file-list,
  .activity-panel .history-list {
    max-height: 180px;
  }

  .history-section {
    margin-top: 14px;
    padding-top: 0;
  }

  .page-manager-section {
    margin-top: 0;
  }

  #extract-pages {
    grid-column: 1 / -1;
  }

  .page-manager-section > .primary-button {
    position: sticky;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 12;
    margin-top: 18px;
    box-shadow: 0 12px 28px rgba(27, 105, 125, 0.3);
  }

  .status.is-success-toast {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .status.is-success-toast {
    transition: none;
    animation: none;
  }

  .history-section .queue-heading h3::after {
    animation: none;
  }

}
