:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #171a1f;
  --muted: #5f6875;
  --line: #dde3ea;
  --accent: #16705b;
  --accent-strong: #0f5a48;
  --accent-soft: #e7f5f0;
  --danger: #b72d2d;
  --shadow: 0 16px 40px rgba(20, 31, 45, .08);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a {
  color: inherit;
  text-decoration: none;
}
.wrap {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 56px;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand {
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
}
.badge {
  border: 1px solid #b7dccc;
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 700;
}
.home-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.hero {
  margin-bottom: 22px;
}
h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 54px);
  line-height: 1.08;
  letter-spacing: 0;
}
.lead {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr);
  gap: 16px;
  align-items: start;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 22px;
  letter-spacing: 0;
}
.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
label {
  color: #313842;
  font-size: 14px;
  font-weight: 750;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
textarea {
  min-height: 150px;
  resize: vertical;
}
.output-text {
  min-height: 260px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.compact-actions {
  margin: 0 0 10px;
}
button,
.button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-weight: 750;
}
button.primary,
.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
button.danger {
  border-color: #e9b8b8;
  color: var(--danger);
}
.mode-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.preview {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed #c8d1dc;
  border-radius: 8px;
  background: #fbfcfd;
  overflow: auto;
  padding: 16px;
}
.preview img,
.preview canvas {
  max-width: 100%;
  height: auto;
}
.pdf-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.pdf-preview-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}
.pdf-preview-card canvas {
  width: 100%;
  height: 156px;
  object-fit: contain;
  border: 1px solid #e2e7ee;
  border-radius: 6px;
  background: #fff;
}
.pdf-preview-card strong,
.pdf-preview-card span {
  display: block;
  margin-top: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-preview-card strong {
  font-size: 13px;
}
.pdf-preview-card span {
  color: var(--muted);
  font-size: 12px;
}
.pdf-preview-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 9px;
}
.pdf-preview-actions button {
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
}
.pdf-preview-actions button:disabled {
  cursor: not-allowed;
  opacity: .42;
}
.pdf-output-preview {
  display: grid;
  min-height: 360px;
  margin-bottom: 14px;
  border: 1px dashed #c8d1dc;
  border-radius: 8px;
  background: #fbfcfd;
  overflow: hidden;
}
.pdf-output-preview iframe {
  width: 100%;
  min-height: 520px;
  border: 0;
  background: #fff;
}
.pdf-output-preview .muted {
  align-self: center;
  justify-self: center;
  padding: 18px;
  text-align: center;
}
.pdf-select-preview {
  display: grid;
  place-items: start center;
  min-height: 360px;
  max-height: 620px;
  overflow: auto;
  border: 1px dashed #c8d1dc;
  border-radius: 8px;
  background: #eef2f6;
  padding: 16px;
}
.pdf-select-preview .muted {
  align-self: center;
  justify-self: center;
}
.pdf-select-page {
  position: relative;
  flex: none;
  overflow: hidden;
  border: 1px solid #dfe5ec;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(20, 31, 45, .1);
}
.pdf-select-page canvas {
  display: block;
}
.pdf-text-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 1;
  line-height: 1;
  user-select: text;
  pointer-events: none;
}
.pdf-text-layer span {
  position: absolute;
  color: transparent;
  cursor: text;
  white-space: pre;
  transform-origin: 0 0;
  user-select: text;
  pointer-events: auto;
}
.pdf-text-layer span::selection {
  color: transparent;
  background: rgba(22, 112, 91, .32);
}
.pdf-area-layer {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}
.text-select-mode .pdf-area-layer {
  pointer-events: none;
}
.area-select-mode .pdf-text-layer span {
  pointer-events: none;
}
.pdf-area-selection {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(22, 112, 91, .18);
  box-shadow: 0 0 0 9999px rgba(17, 24, 39, .12);
  pointer-events: none;
}
.file-list {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
}
.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}
.file-row strong,
.file-row span {
  display: block;
  overflow-wrap: anywhere;
}
.file-row strong {
  font-size: 14px;
}
.file-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.small-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}
.muted {
  color: var(--muted);
  line-height: 1.6;
}
.result {
  margin-top: 14px;
  border: 1px solid #dcebe5;
  border-radius: 8px;
  background: #f3fbf8;
  padding: 14px;
  color: #21463d;
  white-space: pre-wrap;
  line-height: 1.6;
}
.compact-result {
  margin: 0 0 12px;
  padding: 10px 12px;
}
.progress-wrap {
  margin-top: 16px;
}
.progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf2;
}
.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .2s ease;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.tab {
  min-height: 38px;
  border-radius: 999px;
}
.tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.hidden {
  display: none !important;
}
.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.site-footer a {
  color: var(--accent-strong);
  font-weight: 800;
}
.content-section {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}
.content-section h2 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: 0;
}
.content-section h3 {
  margin: 18px 0 8px;
  font-size: 17px;
  letter-spacing: 0;
}
.content-section p,
.content-section li {
  color: var(--muted);
  line-height: 1.75;
}
.content-section p {
  margin: 0 0 10px;
}
.content-section ul {
  margin: 0;
  padding-left: 20px;
}
.content-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 820px) {
  .grid,
  .row,
  .content-columns {
    grid-template-columns: 1fr;
  }
  .top {
    align-items: flex-start;
    flex-direction: column;
  }
}
