:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #176b87;
  --accent-dark: #10546a;
  --danger: #b42318;
  --shadow: 0 14px 35px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
.button-link {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0 16px;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  background: var(--accent-dark);
}

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

.secondary {
  background: #344054;
}

.secondary:hover {
  background: #1d2939;
}

.danger {
  background: var(--danger);
}

.danger:hover {
  background: #8f1d14;
}

.hidden {
  display: none !important;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2.3rem;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

.upload-panel,
.viewer,
.status {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-panel {
  padding: 28px;
}

#uploadForm {
  display: grid;
  gap: 16px;
}

.file-drop {
  border: 2px dashed var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 8px;
  padding: 42px 24px;
  text-align: center;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

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

.file-drop.drag-over {
  background: #eef8fb;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.file-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.file-name {
  color: var(--muted);
}

#pdfFile {
  display: none;
}

.status {
  color: var(--muted);
  margin: 18px 0;
  padding: 14px 16px;
}

.status.error {
  border-color: #fda29b;
  color: var(--danger);
}

.viewer {
  padding: 22px;
}

.viewer-toolbar,
.downloads {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.page-input {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  gap: 8px;
}

.page-input input {
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
  height: 42px;
  padding: 0 10px;
  width: 88px;
}

.content-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
}

.content-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.text-output {
  background: #111827;
  border-radius: 8px;
  color: #f9fafb;
  font-family: Consolas, "Courier New", monospace;
  min-height: 380px;
  margin: 0;
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

.image-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.image-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.image-item img {
  background: #eef2f6;
  display: block;
  height: 180px;
  object-fit: contain;
  width: 100%;
}

.image-item a {
  color: var(--accent);
  display: block;
  font-weight: 700;
  padding: 10px;
  text-decoration: none;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
}

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

  .topbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 1.85rem;
  }

  .content-grid {
    display: grid;
  }
}
