/* PDF Inspector Web UI — zero-dependency stylesheet */

:root {
  --heat: #fa5d19;
  --heat-dark: #db4808;
  --heat-8: rgba(250, 93, 25, .08);
  --heat-16: rgba(250, 93, 25, .16);

  --bg: #f7f7f6;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --ink: #232323;
  --ink-70: rgba(35, 35, 35, .70);
  --ink-50: rgba(35, 35, 35, .50);
  --ink-34: rgba(35, 35, 35, .34);
  --border: #e7e6e3;
  --border-2: #efeeec;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -12px rgba(0,0,0,.10);

  --ok: #16a34a;
  --warn: #d97706;
  --info: #2563eb;

  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --r: 12px;
  --w: 1360px;
}

html[data-theme="dark"] {
  --bg: #0f0f0f;
  --surface: #171717;
  --surface-2: #1c1c1c;
  --ink: #ededed;
  --ink-70: rgba(237, 237, 237, .70);
  --ink-50: rgba(237, 237, 237, .50);
  --ink-34: rgba(237, 237, 237, .34);
  --border: #2a2a2a;
  --border-2: #232323;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.7);
  --ok: #4ade80;
  --warn: #fbbf24;
  --info: #60a5fa;
}

* { box-sizing: border-box; }

/* Several panels below are display:flex, which would otherwise defeat [hidden]. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap { width: 100%; max-width: var(--w); margin: 0 auto; padding: 0 24px; }

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 62px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand img { border-radius: 6px; flex: none; }
.brand div { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 600; letter-spacing: -.015em; font-size: 15.5px; white-space: nowrap; }
.brand-name em { font-style: normal; color: var(--heat); }
.brand-sub { font-size: 11.5px; color: var(--ink-50); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; color: var(--ink-70); white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-34); flex: none; }
.dot-idle { animation: pulse 1.4s ease-in-out infinite; }
.dot-ready { background: var(--ok); animation: none; }
.dot-err { background: #ef4444; animation: none; }
@keyframes pulse { 0%,100% { opacity: .35 } 50% { opacity: 1 } }

.ghost-btn {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--ink-70); font-size: 12.5px; text-decoration: none; white-space: nowrap;
  transition: .14s;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--ink-34); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 30px; padding: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink-70); cursor: pointer; transition: .14s;
}
.icon-btn:hover:not(:disabled) { color: var(--heat); border-color: var(--heat-16); background: var(--heat-8); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn svg { width: 16px; height: 16px; }
.ico-sun, html[data-theme="dark"] .ico-moon { display: none; }
html[data-theme="dark"] .ico-sun { display: block; }
.ico-check { display: none; color: var(--ok); }
.icon-btn.copied .ico-copy { display: none; }
.icon-btn.copied .ico-check { display: block; }
.icon-btn.copied { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }

/* ---------------- layout ---------------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 20px;
  padding-top: 22px;
  padding-bottom: 28px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.input-col { padding: 14px; position: sticky; top: 84px; }
/* Pin the output panel to the viewport so the toolbar and stats stay in place
   while long documents scroll inside .out-body. */
.output-col {
  display: flex; flex-direction: column; overflow: hidden;
  position: sticky; top: 84px;
  height: calc(100vh - 166px); /* topbar + page padding + footer */
  min-height: 480px;
}

/* ---------------- tabs ---------------- */
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 9px; }
.tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  padding: 7px 10px; border-radius: 6px;
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink-50);
  transition: .14s; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
html[data-theme="dark"] .tab.is-active { background: #303030; }
.tabs-sm { flex: none; }
.tabs-sm .tab { flex: none; padding: 5px 12px; font-size: 12.5px; }

.tab-panel { display: none; padding-top: 14px; }
.tab-panel.is-active { display: block; }

/* ---------------- dropzone ---------------- */
.drop {
  border: 1.5px dashed var(--border);
  border-radius: 10px; background: var(--surface-2);
  padding: 34px 18px; text-align: center; cursor: pointer;
  transition: .16s;
}
.drop:hover, .drop.over { border-color: var(--heat); background: var(--heat-8); }
.drop.over { transform: scale(1.005); }
.drop-ico { width: 28px; height: 28px; color: var(--heat); margin-bottom: 10px; }
.drop-title { margin: 0; font-weight: 550; font-size: 14.5px; }
.drop-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-50); }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--heat); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------------- url + fields ---------------- */
.field-label { display: block; font-size: 12px; font-weight: 550; color: var(--ink-70); margin-bottom: 6px; }
.url-row { display: flex; gap: 8px; }
input[type="url"], input[type="text"], input[type="password"], select {
  width: 100%; min-width: 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--ink); font: inherit; font-size: 13px; padding: 8px 10px;
  transition: .14s;
}
select { cursor: pointer; }
input:focus, select:focus { outline: none; border-color: var(--heat); box-shadow: 0 0 0 3px var(--heat-8); }
input::placeholder { color: var(--ink-34); }

.btn {
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 550; padding: 8px 14px;
  transition: .14s; white-space: nowrap;
}
.btn-primary { background: var(--heat); color: #fff; }
.btn-primary:hover { background: var(--heat-dark); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }

.hint { margin: 9px 0 0; font-size: 11.5px; color: var(--ink-50); line-height: 1.45; }
.hint-top { margin: 0 0 10px; }

/* ---------------- samples ---------------- */
.samples { display: flex; flex-direction: column; gap: 7px; }
.sample {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  padding: 9px 11px; cursor: pointer; font: inherit; color: inherit; transition: .14s;
}
.sample:hover { border-color: var(--heat); background: var(--heat-8); }
.sample-badge {
  flex: none; width: 30px; height: 30px; border-radius: 7px;
  background: var(--heat-8); color: var(--heat);
  display: grid; place-items: center; font-size: 15px;
}
.sample-txt { min-width: 0; }
.sample-title { display: block; font-size: 13px; font-weight: 550; }
.sample-desc { display: block; font-size: 11.5px; color: var(--ink-50); }

/* ---------------- options ---------------- */
.options { margin-top: 14px; border-top: 1px solid var(--border-2); padding-top: 12px; }
.options summary {
  display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  font-size: 12.5px; font-weight: 550; color: var(--ink-70);
}
.options summary::-webkit-details-marker { display: none; }
.options summary:hover { color: var(--ink); }
.chev { width: 14px; height: 14px; transition: transform .16s; }
.options[open] .chev { transform: rotate(90deg); }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.opt { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.opt > span { font-size: 11.5px; font-weight: 550; color: var(--ink-70); }
.opt small { font-weight: 400; color: var(--ink-34); }
.opt-checks { grid-column: 1 / -1; flex-direction: row; gap: 16px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-70); cursor: pointer; }
.check input { accent-color: var(--heat); width: 14px; height: 14px; }

/* ---------------- filebar ---------------- */
.filebar {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); padding: 9px 11px;
}
.file-ico { width: 18px; height: 18px; color: var(--heat); flex: none; }
.filebar-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.filebar-name { font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filebar-size { font-size: 11px; color: var(--ink-50); }

/* ---------------- stats ---------------- */
.stats {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 12px 14px; border-bottom: 1px solid var(--border-2);
}
.stat {
  display: inline-flex; align-items: baseline; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  padding: 5px 10px; font-size: 12px;
}
.stat b { font-weight: 600; font-size: 12.5px; letter-spacing: -.01em; }
.stat span { color: var(--ink-50); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.stat-accent { border-color: var(--heat-16); background: var(--heat-8); }
.stat-accent b { color: var(--heat); }
.stat-ok b { color: var(--ok); }
.stat-warn { border-color: color-mix(in srgb, var(--warn) 34%, transparent); }
.stat-warn b { color: var(--warn); }

/* ---------------- output ---------------- */
.out-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border-2);
}
.out-actions { display: flex; gap: 6px; }
.out-body { position: relative; flex: 1; min-height: 0; overflow: auto; }

.view { margin: 0; padding: 22px 26px; }
.code {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word; color: var(--ink-70);
}
.code code { font: inherit; }

.empty, .loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 24px;
}
.empty-ico { width: 34px; height: 34px; color: var(--ink-34); margin-bottom: 8px; }
.empty-title { margin: 0; font-weight: 550; font-size: 14.5px; }
.empty-sub, .loading p { margin: 2px 0 0; font-size: 13px; color: var(--ink-50); }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--heat-16); border-top-color: var(--heat);
  animation: spin .7s linear infinite; margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg) } }

.error {
  display: flex; gap: 11px; margin: 16px; padding: 14px 16px;
  border: 1px solid color-mix(in srgb, #ef4444 34%, transparent);
  background: color-mix(in srgb, #ef4444 7%, transparent);
  border-radius: 10px;
}
.err-ico { width: 19px; height: 19px; color: #ef4444; flex: none; margin-top: 1px; }
.err-title { margin: 0; font-weight: 600; font-size: 13.5px; }
.err-msg { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-70); font-family: var(--mono); word-break: break-word; }

/* ---------------- markdown preview ---------------- */
.md-preview { font-size: 14.5px; line-height: 1.68; max-width: 78ch; }
.md-preview > :first-child { margin-top: 0; }
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4, .md-preview h5, .md-preview h6 {
  line-height: 1.28; letter-spacing: -.018em; margin: 1.6em 0 .55em; font-weight: 620;
}
.md-preview h1 { font-size: 1.72em; }
.md-preview h2 { font-size: 1.36em; padding-bottom: .28em; border-bottom: 1px solid var(--border-2); }
.md-preview h3 { font-size: 1.14em; }
.md-preview h4, .md-preview h5, .md-preview h6 { font-size: 1em; color: var(--ink-70); }
.md-preview p { margin: 0 0 1em; }
.md-preview ul, .md-preview ol { margin: 0 0 1em; padding-left: 1.35em; }
.md-preview li { margin: .22em 0; }
.md-preview a { color: var(--heat); text-decoration: underline; text-underline-offset: 2px; }
.md-preview hr { border: 0; border-top: 1px solid var(--border); margin: 1.8em 0; }
.md-preview blockquote {
  margin: 0 0 1em; padding: .1em 0 .1em 1em;
  border-left: 3px solid var(--heat-16); color: var(--ink-70);
}
.md-preview code {
  font-family: var(--mono); font-size: .875em;
  background: var(--surface-2); border: 1px solid var(--border-2);
  padding: .1em .38em; border-radius: 5px;
}
.md-preview pre {
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: 9px; padding: 13px 15px; overflow-x: auto; margin: 0 0 1em;
}
.md-preview pre code { background: none; border: 0; padding: 0; font-size: 12.5px; line-height: 1.65; }
.md-preview .table-scroll { overflow-x: auto; margin: 0 0 1.2em; }
.md-preview table { border-collapse: collapse; font-size: 13px; width: 100%; }
.md-preview th, .md-preview td {
  border: 1px solid var(--border); padding: 6px 11px; text-align: left; vertical-align: top;
}
.md-preview th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.md-preview tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.md-preview .page-marker {
  display: block; margin: 1.6em 0; text-align: center;
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-34);
  border-top: 1px dashed var(--border); padding-top: .9em;
}

/* ---------------- footer + toast ---------------- */
.foot { border-top: 1px solid var(--border); background: var(--surface); }
.foot-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-height: 52px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-50);
}
.foot a { color: var(--heat); text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.foot strong { color: var(--ink); font-weight: 600; }
.heart { color: var(--heat); }
.foot-right { font-size: 11.5px; color: var(--ink-34); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--bg); font-size: 12.5px; font-weight: 500;
  padding: 9px 16px; border-radius: 999px; z-index: 60;
  opacity: 0; transition: .2s; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- responsive ---------------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .input-col { position: static; }
  .output-col { position: static; height: auto; max-height: 78vh; min-height: 420px; }
  .brand-sub { display: none; }
}
@media (max-width: 620px) {
  .wrap { padding: 0 14px; }
  .view { padding: 16px; }
  .options-grid { grid-template-columns: 1fr; }
  .topbar-inner { height: 56px; }
  #engine-pill { display: none; }
}
