/* add-margin-pdf — a PDF margin editor that runs entirely in the browser */

:root {
  --bg: #faf9f6;
  --fg: #17171a;
  --muted: #6d6d68;
  --soft: #4a4a44;
  --line: #e3e1db;
  --card: #ffffff;
  --hover: #f1efe9;
  --accent: #1d1d1b;
  --on-accent: #faf9f6;
  --band: #eceade;
  --paper: #ffffff;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(23, 23, 26, .05), 0 16px 34px -22px rgba(23, 23, 26, .45);
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ease: 160ms cubic-bezier(.2, .7, .3, 1);
}

html.dark {
  --bg: #12120f;
  --fg: #f2f1ec;
  --muted: #96968e;
  --soft: #b9b9ad;
  --line: #2a2a26;
  --card: #191916;
  --hover: #232320;
  --accent: #f2f1ec;
  --on-accent: #12120f;
  --band: #2b2b25;
  --paper: #1d1d19;
  --danger: #ff8e84;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 18px 40px -24px rgba(0, 0, 0, .95);
}

* { box-sizing: border-box; }

/* Author display rules would otherwise beat the [hidden] attribute. */
[hidden] { display: none !important; }

/* Kept in the tab order so the file picker can be opened from the keyboard. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; }

/* ---------- top bar ---------- */

.bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 54px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.home {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.home-mark {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--accent);
  position: relative;
  flex: none;
}

.home-mark::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1.8px solid var(--bg);
  border-bottom-color: transparent;
  border-right-color: transparent;
  transform: rotate(-45deg);
}

.home-label { color: var(--muted); font-weight: 500; }

.bar-title {
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.privacy {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 550;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}

.btn:hover { background: var(--hover); }
.btn:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: default; }
.icon-btn { width: 34px; padding: 0; }
.icon { width: 16px; height: 16px; flex: none; }

/* ---------- layout ---------- */

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  min-height: min(calc(100dvh - 54px), 780px);
}

.workspace[data-state="empty"] { grid-template-columns: minmax(0, 1fr); }

/* ---------- drop zone ---------- */

.drop {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 22px;
  padding: 48px 24px;
  min-height: 320px;
  border: 1.5px dashed var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}

.drop:hover,
.drop:focus-within {
  border-color: var(--soft);
  color: var(--fg);
}

body.is-over .drop {
  border-color: var(--fg);
  background: var(--hover);
  color: var(--fg);
}

.drop-icon { width: 54px; height: 54px; color: var(--muted); margin-bottom: 10px; }
.drop-icon svg { width: 100%; height: 100%; }

.drop-title {
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.drop-sub { font-size: 0.875rem; }

.drop-link {
  color: var(--fg);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- editor and preview ---------- */

.editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 14px 16px 16px;
  gap: 12px;
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  padding: 7px 10px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--card);
}

.file-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--hover);
  color: var(--soft);
  flex: none;
}

.file-icon svg { width: 17px; height: 17px; }

.file-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.file-text strong {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-text span { font-size: 0.75rem; color: var(--muted); }

.link-btn {
  margin-left: auto;
  flex: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 7px;
  cursor: pointer;
}

.link-btn:hover { color: var(--fg); background: var(--hover); }
.link-btn:focus-visible { outline: 2px solid var(--fg); outline-offset: 1px; }

.pager {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.pager .btn { height: 30px; width: 30px; border-radius: 8px; }
.pager #page-label { min-width: 74px; text-align: center; font-variant-numeric: tabular-nums; }

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 18px 18px,
    var(--bg);
  overflow: hidden;
}

.sheet {
  position: relative;
  flex: none;
  background: var(--band);
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06), 0 12px 28px -16px rgba(0, 0, 0, .4);
}

html.dark .sheet { box-shadow: 0 1px 1px rgba(0, 0, 0, .5), 0 14px 30px -18px rgba(0, 0, 0, .9); }

.sheet-inner {
  position: absolute;
  background: var(--paper);
  border: 1px dashed color-mix(in srgb, var(--soft) 45%, transparent);
  border-radius: 1px;
}

.band {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--muted);
  overflow: hidden;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.band.is-tight { color: transparent; }
.band-top { top: 0; left: 0; right: 0; }
.band-bottom { bottom: 0; left: 0; right: 0; }
.band-left { left: 0; top: 0; bottom: 0; width: 40px; }
.band-right { right: 0; top: 0; bottom: 0; width: 40px; }

.stage-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- settings panel ---------- */

.panel {
  border-left: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
  min-height: 0;
  overflow-y: auto;
}

.block {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block legend {
  padding: 0;
  margin-bottom: 2px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

.preset {
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--soft);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 7px 2px;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.preset:hover { background: var(--hover); color: var(--fg); }
.preset[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.preset:focus-visible { outline: 2px solid var(--fg); outline-offset: -1px; }

.slide {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slide input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
  height: 20px;
}

.slide input[type="range"]:disabled { opacity: .35; }

.slide output {
  min-width: 58px;
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.unit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.unit select {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 6px;
  cursor: pointer;
}

.unit select:focus-visible { outline: 2px solid var(--fg); outline-offset: 1px; }

.link-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 9px;
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.link-toggle .icon { width: 13px; height: 13px; }
.link-toggle[aria-pressed="true"] { color: var(--fg); border-color: var(--soft); background: var(--hover); }
.link-toggle:focus-visible { outline: 2px solid var(--fg); outline-offset: 1px; }

.sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
}

.side-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  padding: 0 9px 0 0;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.side-field:focus-within {
  border-color: var(--soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent);
}

.side-field input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  padding: 7px 4px 7px 9px;
  font-variant-numeric: tabular-nums;
}

.side-field input:focus { outline: none; }

/* The spinners steal room in a two-column grid. */
.side-field input::-webkit-outer-spin-button,
.side-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.side-field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.suffix { font-size: 0.6875rem; font-weight: 600; color: var(--muted); text-transform: none; }

.sides[data-linked="true"] .side:not(:first-child) { opacity: .55; }

.choice {
  display: flex;
  gap: 9px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}

.choice:hover { border-color: var(--soft); }
.choice:has(input:checked) { border-color: var(--fg); background: var(--hover); }
.choice input { margin: 3px 0 0; accent-color: var(--accent); flex: none; }

.choice-body { display: flex; flex-direction: column; gap: 2px; }
.choice-title { font-size: 0.8125rem; font-weight: 600; letter-spacing: -0.01em; }
.choice-note { font-size: 0.75rem; color: var(--muted); line-height: 1.4; }

.summary {
  margin: 0;
  padding: 10px 11px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--muted);
}

.summary b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }

.error {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--danger);
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: opacity var(--ease), transform var(--ease);
}

.primary:hover { opacity: .9; }
.primary:active { transform: translateY(1px); }
.primary:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
.primary:disabled { opacity: .55; cursor: progress; }

.tiny { margin: 0; font-size: 0.6875rem; color: var(--muted); line-height: 1.5; }

/* ---------- information section ---------- */

.info {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 22px 8px;
  border-top: 1px solid var(--line);
  width: 100%;
}

.info h2 {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.info h2 + h2 { margin-top: 34px; }

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 10px;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 34px;
  font-size: 0.875rem;
  color: var(--soft);
  line-height: 1.55;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.steps strong { color: var(--fg); font-weight: 650; }

.faq { margin: 0; display: grid; gap: 16px; }

.faq div { display: grid; gap: 4px; }

.faq dt { font-size: 0.875rem; font-weight: 650; letter-spacing: -0.01em; }

.faq dd {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
}

.info-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 30px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
}

.info-links a { color: var(--fg); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--line); }
.info-links a:hover { border-color: var(--fg); }

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px;
  font-size: 0.75rem;
  color: var(--muted);
}

.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--fg); }
.dot { color: var(--line); }

/* ---------- smaller screens ---------- */

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    min-height: 0;
  }

  .editor { min-height: 420px; }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    overflow: visible;
  }
}

@media (max-width: 620px) {
  .bar { gap: 10px; height: 50px; padding: 0 10px; }
  .home-label { display: none; }
  .bar-title { font-size: 0.875rem; padding-left: 10px; }
  .privacy { display: none; }

  .drop { margin: 12px; padding: 40px 16px; }
  .editor { padding: 10px 10px 14px; min-height: 60vh; }
  .stage { padding: 12px; border-radius: 12px; }
  .stage-note { font-size: 0.6875rem; }
  .sides { gap: 6px; }
  .info { padding: 30px 16px 8px; }
}
