html,
body {
  min-height: 100%;
}

body {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(18, 24, 32, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(18, 24, 32, 0.05) 1px, transparent 1px),
    #f5f1e8;
  background-size: 40px 40px;
}

body[data-dragging="true"] {
  overflow: hidden;
}

.playground-tool {
  width: min(1540px, calc(100% - 24px));
  min-height: calc(100vh - 24px);
  margin: 12px auto;
  display: grid;
  grid-template-rows: auto minmax(620px, 1fr);
  gap: 12px;
}

.landing-panel,
.playground-panel {
  background: #fffdf8;
  border: 1px solid #202833;
  border-radius: 8px;
  box-shadow: 5px 5px 0 #202833;
  overflow: hidden;
}

.landing-panel {
  padding: clamp(14px, 2vw, 24px);
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  color: #515b66;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.masthead a {
  color: inherit;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.masthead a:hover {
  border-color: #202833;
  color: #121820;
}

.landing-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.62fr) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 44px);
  align-items: end;
}

.landing-grid > * {
  min-width: 0;
}

.landing-panel h1 {
  margin: 0;
  max-width: 14ch;
  color: #121820;
  font-size: clamp(38px, 5.4vw, 82px);
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: 0;
}

.format-cloud {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 7px 11px;
  color: #27313d;
  font-size: clamp(18px, 1.75vw, 30px);
  line-height: 1.03;
  font-weight: 850;
}

.format-cloud span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.format-cloud span:nth-child(4n + 1) {
  color: #174ea6;
}

.format-cloud span:nth-child(4n + 2) {
  color: #0f6b4f;
}

.format-cloud span:nth-child(4n + 3) {
  color: #8b2c34;
}

.upload-form {
  box-sizing: border-box;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-top: clamp(18px, 3vw, 30px);
  margin-inline: auto;
  padding: clamp(14px, 2vw, 20px);
  border: 1px solid #d8d2c5;
  border-radius: 8px;
  background: #fffdf8;
}

.file-dropzone {
  box-sizing: border-box;
  width: 100%;
  min-height: 180px;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: clamp(22px, 4vw, 36px);
  border: 2px dashed #7c8794;
  border-radius: 8px;
  background: #f7f2e8;
  color: #121820;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease;
}

.file-dropzone:hover,
.file-dropzone:focus-within {
  border-color: #0f6b4f;
  background: #f3f8f5;
}

.file-dropzone[data-disabled="true"] {
  background: #efede8;
  color: #6b7280;
}

.dropzone-title {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
  font-weight: 900;
}

.dropzone-help {
  color: #515b66;
  font-size: 14px;
  font-weight: 750;
}

.picker-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.picker-button {
  box-sizing: border-box;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid #202833;
  border-radius: 6px;
  background: #174ea6;
  color: #fffdf8;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
}

.picker-button-secondary {
  background: #fffdf8;
  color: #202833;
}

.file-dropzone[data-disabled="true"] .picker-button {
  pointer-events: none;
  background: #d9d6cf;
  color: #6b7280;
}

.picker-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.selected-file {
  width: min(100%, 440px);
  min-width: 0;
  display: grid;
  gap: 5px;
}

.selected-file span {
  color: #515b66;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.selected-file strong {
  box-sizing: border-box;
  min-height: 42px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 8px 12px;
  border: 1px solid #d8d2c5;
  border-radius: 6px;
  background: #fffdf8;
  color: #121820;
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-mode-control,
.pdf-mode-control {
  box-sizing: border-box;
  width: min(100%, 440px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 10px;
  border: 1px solid #d8d2c5;
  border-radius: 6px;
}

.image-mode-control[hidden],
.pdf-mode-control[hidden] {
  display: none;
}

.image-mode-control legend,
.pdf-mode-control legend {
  padding: 0 6px;
  color: #515b66;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.image-mode-control label,
.pdf-mode-control label {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 8px;
  border: 1px solid #d8d2c5;
  border-radius: 6px;
  background: #fffdf8;
  color: #27303a;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.image-mode-control input,
.pdf-mode-control input {
  flex: 0 0 auto;
}

.image-mode-control label:has(input:checked),
.pdf-mode-control label:has(input:checked) {
  border-color: #0f6b4f;
  background: #edf8f3;
  color: #0f513c;
}

.upload-form[data-busy="true"] .image-mode-control,
.upload-form[data-busy="true"] .pdf-mode-control {
  color: #6b7280;
}

.upload-form[data-busy="true"] .image-mode-control label,
.upload-form[data-busy="true"] .pdf-mode-control label {
  cursor: not-allowed;
}

#convert-button {
  box-sizing: border-box;
  min-height: 44px;
  width: min(100%, 320px);
  border: 1px solid #202833;
  border-radius: 6px;
  background: #0f6b4f;
  color: #fffdf8;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

#convert-button:disabled {
  background: #d9d6cf;
  color: #6b7280;
  box-shadow: none;
  cursor: not-allowed;
}

.conversion-progress {
  width: min(100%, 440px);
  min-height: 30px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #27303a;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.upload-form[data-busy="true"] .conversion-progress {
  display: flex;
}

.quality-panel {
  box-sizing: border-box;
  width: min(100%, 440px);
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #d8d2c5;
  border-left: 4px solid #0f6b4f;
  border-radius: 6px;
  background: #f7fbf8;
  color: #27303a;
  text-align: left;
}

.quality-panel[hidden] {
  display: none;
}

.quality-panel[data-status="truncated"],
.quality-panel[data-status="partial"],
.quality-panel[data-status="media_missing"] {
  border-left-color: #8b2c34;
  background: #fff6f5;
}

.quality-panel[data-status="layout_uncertain"],
.quality-panel[data-status="best_effort"] {
  border-left-color: #d8a942;
  background: #fffaf0;
}

.quality-panel strong {
  font-size: 13px;
  font-weight: 900;
}

.quality-panel p {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.35;
}

.quality-panel ul {
  margin: 0;
  padding-left: 18px;
  color: #515b66;
  font-size: 13px;
  line-height: 1.35;
}

.quality-panel ul:empty {
  display: none;
}

.retry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.retry-actions[hidden] {
  display: none;
}

.retry-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #202833;
  border-radius: 6px;
  background: #fffdf8;
  color: #202833;
  font: inherit;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.retry-actions button:hover {
  background: #f3f8f5;
}

.progress-spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid #d8d2c5;
  border-top-color: #0f6b4f;
  border-radius: 999px;
  animation: progress-spin 800ms linear infinite;
}

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

.status-panel {
  margin-top: 12px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #27303a;
  font-size: 13px;
  font-weight: 750;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #8b949e;
  flex: 0 0 auto;
}

.status-dot[data-state="loading"] {
  background: #d8a942;
}

.status-dot[data-state="ready"] {
  background: #0f6b4f;
}

.status-dot[data-state="error"] {
  background: #8b2c34;
}

#log-output {
  margin: 8px 0 0;
  max-height: 96px;
  overflow: auto;
  padding: 9px 10px;
  background: #121820;
  color: #f7f2e8;
  border-radius: 6px;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.playground-panel {
  position: relative;
  min-height: max(620px, calc(100vh - 292px));
  background: #121820;
  isolation: isolate;
}

.playground-empty {
  min-height: max(620px, calc(100vh - 292px));
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 32px;
  color: #f7f2e8;
  text-align: center;
}

.playground-empty span {
  color: #d8a942;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.playground-empty strong {
  max-width: 12ch;
  font-size: clamp(38px, 6vw, 84px);
  line-height: 0.92;
  letter-spacing: 0;
}

.playground-panel iframe {
  width: 100%;
  height: max(620px, calc(100vh - 292px));
  min-height: 620px;
  border: 0;
  display: none;
  background: #fff;
}

.page-drop-overlay {
  position: fixed;
  inset: 12px;
  z-index: 20;
  display: none;
  place-content: center;
  border: 3px dashed #fffdf8;
  border-radius: 10px;
  background: rgba(18, 24, 32, 0.9);
  color: #fffdf8;
  text-align: center;
  pointer-events: none;
}

body[data-dragging="true"] .page-drop-overlay {
  display: grid;
}

.page-drop-overlay strong {
  max-width: 12ch;
  font-size: clamp(46px, 7vw, 96px);
  line-height: 0.9;
  letter-spacing: 0;
}

.playground-panel[data-state="loading"] .playground-empty,
.playground-panel[data-state="converting"] .playground-empty,
.playground-panel[data-state="ready"] .playground-empty {
  display: none;
}

.playground-panel[data-state="loading"] iframe,
.playground-panel[data-state="converting"] iframe,
.playground-panel[data-state="ready"] iframe {
  display: block;
}

@media (max-width: 1060px) {
  .playground-tool {
    grid-template-rows: auto minmax(560px, 1fr);
  }

  .landing-grid {
    grid-template-columns: 1fr;
  }

  .landing-panel h1 {
    max-width: 15ch;
  }

  #convert-button,
  .file-dropzone {
    width: 100%;
  }

  .playground-panel,
  .playground-empty,
  .playground-panel iframe {
    min-height: 560px;
    height: max(560px, calc(100vh - 360px));
  }
}

@media (max-width: 640px) {
  .playground-tool {
    width: calc(100% - 16px);
    min-height: calc(100vh - 16px);
    margin: 8px auto;
    grid-template-rows: auto minmax(520px, 1fr);
    gap: 8px;
  }

  .landing-panel,
  .playground-panel {
    box-shadow: 3px 3px 0 #202833;
  }

  .landing-panel {
    padding: 14px;
  }

  .masthead {
    margin-bottom: 12px;
  }

  .landing-panel h1 {
    font-size: clamp(36px, 13vw, 50px);
  }

  .format-cloud {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px 6px;
    font-size: 14px;
    line-height: 1.35;
  }

  .format-cloud span {
    display: block;
    margin-right: 0;
  }

  .upload-form {
    padding: 10px;
  }

  .file-dropzone {
    min-height: 150px;
    padding: 20px 14px;
  }

  .picker-actions {
    width: 100%;
  }

  .picker-button {
    width: min(100%, 220px);
  }

  .selected-file strong {
    white-space: normal;
  }

  .image-mode-control {
    grid-template-columns: 1fr;
  }

  #log-output {
    max-height: 84px;
  }

  .playground-panel,
  .playground-empty,
  .playground-panel iframe {
    min-height: 520px;
    height: 520px;
  }
}
