:root {
  --bg: oklch(97% 0.008 90);
  --surface: oklch(99% 0.005 90);
  --surface-2: oklch(96% 0.012 80);
  --surface-3: oklch(94% 0.020 80);
  --border: oklch(86% 0.010 80);
  --border-strong: oklch(82% 0.020 80);
  --ink: oklch(18% 0.005 330);
  --muted: oklch(34% 0.005 330);
  --muted-2: oklch(54% 0.005 330);
  --accent: oklch(46% 0.13 330);
  --accent-hover: oklch(58% 0.16 330);
  --accent-fg: oklch(99% 0.004 330);
  --success: oklch(38% 0.10 150);
  --danger: oklch(38% 0.080 30);
  --danger-bg: oklch(96% 0.030 30);
  --danger-border: oklch(78% 0.060 30);
  --display: 'Space Grotesk', 'Plus Jakarta Sans', system-ui, sans-serif;
  --body: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.pdfmd-page-body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  min-height: 100vh;
}

.pdfmd-page-body ::selection {
  background: var(--accent);
  color: var(--bg);
}

.pdfmd-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 24px;
}

@media (max-width: 640px) {
  .pdfmd-main { padding: 40px 20px; }
}

.pdfmd-hero { text-align: center; }

.pdfmd-hero h1 {
  margin: 20px 0 0;
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.pdfmd-hero h1 .accent { color: var(--accent); }

.pdfmd-hero p {
  margin: 16px auto 0;
  max-width: 34rem;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
}

.pdfmd-card {
  margin-top: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 24px;
  padding: 20px;
  box-shadow:
    inset 0 1px 0 oklch(100% 0 0 / 0.6),
    0 18px 50px -30px oklch(20% 0 0 / 0.18),
    0 3px 10px -8px oklch(20% 0 0 / 0.05);
}

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

.dropzone {
  position: relative;
  display: block;
  cursor: pointer;
  border: 2px dashed var(--border-strong);
  background: var(--surface-2);
  border-radius: 16px;
  padding: 48px 24px;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--surface-3);
}

.drop-icon {
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 var(--accent-hover);
  transition: transform 0.2s;
}

.dropzone:hover .drop-icon { transform: translateY(-2px); }
.drop-icon i { font-size: 1.6rem; }

.drop-label {
  pointer-events: none;
  margin-top: 16px;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.drop-hint {
  pointer-events: none;
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--muted-2);
}

.dropzone input { display: none; }

.pdfmd-form-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 480px) {
  .pdfmd-form-actions { flex-direction: column; align-items: stretch; }
}

.pdfmd-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.pdfmd-link:hover { color: var(--accent-hover); }

@media (max-width: 480px) {
  .pdfmd-link { justify-content: center; }
}

.pdfmd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 22px;
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s, background 0.2s, color 0.2s;
}

.pdfmd-btn--primary {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: inset 0 1px 0 var(--accent-hover), 0 1px 2px oklch(15% 0 0 / 0.06);
}

.pdfmd-btn--primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.pdfmd-btn--primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  background: var(--accent);
}

@media (max-width: 480px) {
  .pdfmd-btn--primary { width: 100%; }
}

.pdfmd-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.pdfmd-chip:hover { background: var(--surface-3); }

.pdfmd-chip--primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  box-shadow: inset 0 1px 0 var(--accent-hover);
}

.pdfmd-chip--primary:hover { background: var(--accent-hover); }

.notify-box {
  margin: 4px 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 14px;
}

.notify-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.notify-head i {
  color: var(--accent);
  font-size: 1.1rem;
  margin-top: 2px;
}

.notify-title { font-weight: 600; font-size: 0.95rem; }
.notify-sub { color: var(--muted-2); font-size: 0.82rem; line-height: 1.45; margin-top: 2px; }

.notify-form {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.notify-email-line { font-size: 0.88rem; color: var(--muted); }
.notify-form .pdfmd-btn { padding: 10px 16px; font-size: 0.88rem; }

.notify-status {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 0;
}

.notify-status.ok { color: var(--success); }
.notify-status.err { color: var(--danger); }

.notify-box.is-set .notify-form { display: none; }

.upload-note {
  margin: 16px auto 0;
  max-width: 34rem;
  text-align: left;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted-2);
}

.upload-note--stacked { margin-top: 8px; }

.upload-note a {
  color: var(--accent);
  font-weight: 600;
}

.result-card { margin-top: 24px; }

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.result-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.result-actions {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
}

.result-actions.is-visible { display: flex; }

.result-footer {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

@media (max-width: 480px) {
  .result-footer { flex-direction: column; }
  .result-footer .pdfmd-btn { width: 100%; }
}

.pdfmd-panel {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 16px;
  padding: 20px;
  max-height: 640px;
  overflow: auto;
}

.pdfmd-panel-raw {
  width: 100%;
  min-height: 460px;
  padding: 16px;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.55;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 16px;
  resize: vertical;
}

.pdfmd-main .hidden { display: none !important; }

.error-box {
  margin-top: 8px;
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 12px;
  padding: 16px;
  font-size: 0.92rem;
}

@keyframes forgeSpin { to { transform: rotate(360deg); } }
@keyframes forgeFade {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: forgeSpin 0.8s linear infinite;
  flex-shrink: 0;
}

.status-list { margin-bottom: 12px; }

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  color: var(--muted);
  font-size: 0.85rem;
  animation: forgeFade 0.25s ease-out;
}

.status-line.done { color: var(--success); }
.status-line.failed { color: var(--danger); }

.status-line .status-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.status-elapsed {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted-2);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 16px 0 8px;
  line-height: 1.25;
  font-family: var(--display);
  letter-spacing: -0.01em;
}

.markdown-body h1 { font-size: 1.5rem; }
.markdown-body h2 { font-size: 1.2rem; }
.markdown-body h3 { font-size: 1.05rem; }

.markdown-body p,
.markdown-body li {
  font-size: 0.95rem;
  line-height: 1.6;
}

.markdown-body table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 0.88rem;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.markdown-body th { background: oklch(92% 0.015 80); }

.markdown-body code {
  background: oklch(92% 0.015 80);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.markdown-body pre {
  background: var(--ink);
  color: oklch(94% 0.012 80);
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
  font-size: 0.82rem;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 8px 0;
  padding: 6px 14px;
  color: var(--muted);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
}

.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.markdown-body img { max-width: 100%; }

/* Dashboard integration */
.dashboard-body.pdfmd-page-body { background: var(--dash-bg); font-family: "Plus Jakarta Sans", "Inter", sans-serif; }
.dashboard-body .pdfmd-main { max-width: 1172px; padding: 46px 26px 4rem; }
.dashboard-body .pdfmd-hero,
.dashboard-body .pdfmd-card,
.dashboard-body .upload-note { max-width: 820px; }
.dashboard-body .pdfmd-hero { text-align: left; }
.dashboard-body .pdfmd-hero h1 { max-width: 720px; font-size: var(--dash-page-title-size); line-height: 1.12; }
.dashboard-body .pdfmd-hero h1 .accent { color: var(--dash-purple); }
.dashboard-body .pdfmd-hero p { max-width: 700px; margin-left: 0; font-size: var(--dash-body-size); }
.dashboard-body .pdfmd-card { border-color: var(--dash-border); border-radius: .85rem; box-shadow: none; }
.dashboard-body .dropzone { border-radius: .7rem; }
.dashboard-body .pdfmd-btn,
.dashboard-body .pdfmd-chip,
.dashboard-body .pdfmd-link { font-size: .85rem; }
.dashboard-body .pdfmd-btn--primary,
.dashboard-body .pdfmd-chip--primary { background: var(--dash-purple); }
.dashboard-body .drop-label { font-size: 1rem; }
.dashboard-body .drop-hint,
.dashboard-body .upload-note,
.dashboard-body .notify-sub,
.dashboard-body .notify-email-line { font-size: .8rem; }

@media (max-width: 640px) {
  .dashboard-body .pdfmd-main { padding: 2rem 18px 3rem; }
}
