:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #667085;
  --paper: #fffdf8;
  --surface: #f4f0e8;
  --panel: #ffffff;
  --line: #d8d3c9;
  --accent: #245b57;
  --accent-strong: #183f3c;
  --note: #8f5b22;
  --blue: #235f9c;
  --shadow: 0 18px 50px rgba(37, 33, 27, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 20px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.76fr) minmax(420px, 1fr);
  gap: 20px;
  max-width: 1480px;
  margin: 0 auto;
}

.editor-pane,
.preview-pane {
  min-width: 0;
}

.editor-pane {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--note);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 40px;
  line-height: 0.98;
  letter-spacing: 0;
}

.download-area {
  display: grid;
  gap: 7px;
  justify-items: end;
  padding-top: 2px;
}

.metadata-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.52fr 0.72fr 0.72fr;
  gap: 10px;
}

.transpose-grid {
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(120px, 0.45fr) auto;
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field > span,
.check-row {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 52vh;
  padding: 14px;
  resize: vertical;
  font-family: Consolas, "Cascadia Mono", Menlo, Monaco, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.42;
  white-space: pre;
  overflow: auto;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 91, 87, 0.14);
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.stepper {
  display: grid;
  grid-template-columns: 42px minmax(70px, 1fr) 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.stepper button {
  min-height: 40px;
  border: 0;
  border-radius: 0;
  background: #ece7dd;
  color: var(--ink);
  font-size: 20px;
}

.stepper button:hover {
  background: #ded7ca;
}

.stepper input {
  width: 100%;
  min-width: 0;
  height: 40px;
  min-height: 40px;
  border-inline: 1px solid var(--line);
  border-block: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
  color: var(--ink);
  font: inherit;
  font-weight: 850;
  text-align: center;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--accent);
  color: white;
  box-shadow: 0 9px 24px rgba(36, 91, 87, 0.22);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.primary-button span[aria-hidden="true"] {
  display: grid;
  place-items: center;
  width: 30px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 5px;
  font-size: 11px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}

.file-button:hover {
  border-color: var(--accent);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.hint-status {
  min-height: 18px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.hint-status.is-error {
  color: #9b2c2c;
}

.hint-status.is-good {
  color: var(--accent-strong);
}

.bookmarklet-code {
  min-height: 84px;
  margin-top: 6px;
  padding: 10px;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-all;
}

.bookmarklet-code[hidden] {
  display: none;
}

.download-notice {
  min-width: 160px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(4px);
  text-align: right;
  transition: opacity 180ms ease, transform 180ms ease;
}

.download-notice.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.primary-button.is-busy {
  background: var(--note);
  box-shadow: 0 9px 24px rgba(143, 91, 34, 0.22);
}

.primary-button.is-done {
  background: #1f7a48;
  box-shadow: 0 9px 24px rgba(31, 122, 72, 0.22);
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.status.is-error {
  color: #9b2c2c;
}

.status.is-good {
  color: var(--accent-strong);
}

.import-guide {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  padding: 14px;
}

.import-guide-header {
  display: grid;
  gap: 3px;
}

.import-guide h2,
.import-guide-name,
.import-guide-item p {
  margin: 0;
}

.import-guide h2 {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.15;
  font-weight: 850;
}

.import-guide-grid {
  display: grid;
  margin-top: 12px;
  border-top: 1px solid rgba(216, 211, 201, 0.85);
}

.import-guide-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid rgba(216, 211, 201, 0.85);
}

.import-guide-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.import-guide-number {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

.import-guide-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.import-guide-item p:not(.import-guide-name) {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.import-guide-item.is-advanced .import-guide-number {
  background: var(--note);
}

.import-guide-item.is-advanced .import-guide-name {
  color: #5f4528;
}

.import-guide-body .file-button {
  margin-top: 9px;
}

.quiet-button {
  min-height: 34px;
  border-radius: 8px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 800;
}

.quiet-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.reset-button {
  height: 42px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.preview-pane {
  position: sticky;
  top: 20px;
  align-self: start;
  height: calc(100vh - 40px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-count,
.fit-summary {
  margin: 0;
}

.page-count {
  font-size: 15px;
  font-weight: 800;
}

.fit-summary {
  color: var(--muted);
  font-size: 13px;
}

.preview {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 18px;
  justify-items: center;
  padding: 6px 10px 24px;
}

.empty-preview {
  align-self: center;
  justify-self: center;
  color: var(--muted);
  font-size: 14px;
}

.pdf-page {
  position: relative;
  width: min(100%, 760px);
  aspect-ratio: var(--page-aspect);
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pdf-item {
  position: absolute;
  white-space: pre;
  line-height: 1;
  letter-spacing: 0;
  transform-origin: left top;
}

.pdf-title {
  font-family: Helvetica, Arial, sans-serif;
  font-weight: 800;
}

.pdf-meta,
.pdf-footer,
.pdf-small-header {
  font-family: Helvetica, Arial, sans-serif;
}

.pdf-body,
.pdf-heading {
  font-family: Consolas, "Cascadia Mono", Menlo, Monaco, "Courier New", monospace;
}

.pdf-heading {
  font-weight: 800;
}

.pdf-rule {
  position: absolute;
  height: 1px;
  background: #d5cec1;
}

.pdf-v-rule {
  position: absolute;
  width: 1px;
  background: #d5cec1;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 14px;
  }

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

  .preview-pane {
    position: static;
    height: auto;
    min-height: 64vh;
  }

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

  .transpose-grid {
    grid-template-columns: 1fr 1fr auto;
  }
}

@media (max-width: 620px) {
  .app-header {
    display: grid;
  }

  h1 {
    font-size: 32px;
  }

  .download-area {
    position: sticky;
    bottom: 10px;
    z-index: 4;
    justify-items: stretch;
    border: 1px solid rgba(216, 211, 201, 0.95);
    border-radius: 8px;
    padding: 10px;
    background: rgba(244, 240, 232, 0.96);
    box-shadow: 0 10px 30px rgba(37, 33, 27, 0.16);
  }

  .preview-pane {
    min-height: auto;
    gap: 10px;
  }

  .preview {
    overflow: visible;
    padding: 6px 0 96px;
  }

  .pdf-page {
    box-shadow: 0 12px 34px rgba(37, 33, 27, 0.18);
  }

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

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

  .primary-button,
  .file-button {
    width: 100%;
    justify-content: center;
  }

  .download-notice {
    min-width: 0;
    text-align: center;
  }
}
