:root {
  --black: #0a0a0a;
  --white: #ffffff;
  --paper: #f5f5f2;
  --line: #d8d8d3;
  --muted: #656565;
  --danger: #9d1c1c;
  --radius: 0;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--black);
  background: var(--paper);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--black); display: flex; flex-direction: column; }
a { color: inherit; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.site-header {
  min-height: 72px;
  padding: 16px clamp(20px, 4vw, 64px);
  background: var(--white);
  border-bottom: 1px solid var(--black);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 900; letter-spacing: .06em; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 34px; display: block; }
.nav { display: flex; align-items: center; gap: 20px; }
.nav a:not(.button) { text-decoration-thickness: 1px; text-underline-offset: 4px; }
.nav form, .actions form { margin: 0; }

.container { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 80px; flex: 1 0 auto; }
.site-footer { min-height: 72px; padding: 22px clamp(20px, 4vw, 64px); border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; display: flex; align-items: center; justify-content: space-between; gap: 18px; background: var(--white); }
.footer-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--black); font-weight: 800; }
.footer-brand img { width: 22px; height: 22px; display: block; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(2rem, 5vw, 4.5rem); line-height: .98; letter-spacing: -.055em; }
h2 { margin-bottom: 12px; font-size: 1.25rem; }
.eyebrow { margin-bottom: 12px; font-weight: 800; letter-spacing: .14em; font-size: .75rem; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.button {
  display: inline-flex;
  min-height: 46px;
  padding: 11px 18px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--black);
  border-radius: var(--radius);
  background: var(--black);
  color: var(--white);
  text-decoration: none;
  font-weight: 750;
  cursor: pointer;
}
.button:hover { background: #2b2b2b; }
.button-secondary { background: var(--white); color: var(--black); }
.button-secondary:hover { background: var(--paper); }
.button-small { min-height: 38px; padding: 8px 13px; font-size: .9rem; }
.link-button, .danger-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.danger-link { color: var(--danger); }

.page-heading { margin-bottom: 42px; }
.page-heading p:last-child { max-width: 700px; }
.split { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.split-compact { align-items: center; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--black); margin-bottom: 28px; background: var(--white); }
.stats article { padding: 24px; border-right: 1px solid var(--black); display: grid; gap: 4px; }
.stats article:last-child { border-right: 0; }
.stats strong { font-size: clamp(1.8rem, 4vw, 3rem); letter-spacing: -.05em; line-height: 1; }
.stats span { color: var(--muted); font-size: .9rem; }

.search { display: flex; gap: 10px; margin-bottom: 20px; }
.search input { flex: 1; }
input, textarea {
  width: 100%;
  min-height: 46px;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid var(--black);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
}
textarea { resize: vertical; min-height: 100px; }
input:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid #8b8b8b; outline-offset: 2px; }
label { display: block; font-weight: 700; }
label small { display: block; margin-top: 6px; color: var(--muted); font-weight: 400; }

.table-card, .panel, .auth-card { border: 1px solid var(--black); background: var(--white); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--black); color: var(--white); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; overflow-wrap: anywhere; }
.badge, .status { display: inline-block; padding: 4px 8px; border: 1px solid var(--black); font-size: .78rem; white-space: nowrap; }
.status-off { border-color: var(--line); color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; font-size: .9rem; }
.empty { padding: 64px 24px; text-align: center; }
.pagination { display: flex; justify-content: center; gap: 22px; margin-top: 24px; }

.auth-card { width: min(520px, 100%); margin: 30px auto; padding: clamp(28px, 6vw, 54px); }
.auth-card-wide { width: min(640px, 100%); }
.auth-card h1 { font-size: clamp(2.2rem, 7vw, 4rem); }
.stack { display: grid; gap: 22px; }
.errors, .flash { margin-bottom: 24px; padding: 15px 18px; border: 1px solid var(--black); background: var(--white); }
.errors { border-left: 6px solid var(--danger); }
.errors p { margin: 0 0 4px; }
.errors p:last-child { margin-bottom: 0; }
.flash-success { border-left: 6px solid var(--black); }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .7fr); align-items: start; gap: 24px; }
.panel { padding: clamp(22px, 4vw, 38px); }
fieldset { margin: 0; padding: 18px; border: 1px solid var(--black); }
legend { padding: 0 8px; font-weight: 800; }
.choice { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.choice + .choice { margin-top: 10px; }
.choice input { width: 18px; min-height: 18px; margin: 0; }
#multi-fields[hidden], #direct-fields[hidden] { display: none; }
.link-row { display: grid; grid-template-columns: .8fr 1.4fr 42px; gap: 8px; align-items: end; margin-top: 10px; }
.link-row input { margin: 0; }
.icon-button { min-height: 46px; border: 1px solid var(--black); background: var(--white); font-size: 1.6rem; cursor: pointer; }
.preview-panel { position: sticky; top: 20px; text-align: center; }
.qr-preview { width: min(100%, 360px); height: auto; display: block; margin: 0 auto 16px; border: 1px solid var(--line); }
.permanent-url { display: block; margin-bottom: 20px; }
.download-grid { display: grid; gap: 10px; }
hr { margin: 28px 0; border: 0; border-top: 1px solid var(--line); }

.public-page { display: grid; min-height: 100vh; padding: 24px; place-items: center; background: var(--black); }
.link-page { width: min(600px, 100%); padding: clamp(28px, 7vw, 64px); background: var(--white); border: 1px solid var(--white); }
.link-page h1 { font-size: clamp(2.4rem, 10vw, 5rem); overflow-wrap: anywhere; }
.link-description { margin-bottom: 34px; color: var(--muted); font-size: 1.05rem; white-space: pre-line; }
.link-list { display: grid; gap: 12px; }
.link-list a { display: flex; justify-content: space-between; gap: 20px; padding: 17px 18px; border: 1px solid var(--black); text-decoration: none; font-weight: 800; }
.link-list a:hover { background: var(--black); color: var(--white); }

@media (max-width: 820px) {
  .site-header, .split { align-items: flex-start; flex-direction: column; }
  .nav { width: 100%; flex-wrap: wrap; }
  .container { width: min(100% - 28px, 1180px); padding-top: 34px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats article:nth-child(2) { border-right: 0; }
  .stats article:nth-child(-n+2) { border-bottom: 1px solid var(--black); }
  .editor-grid { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
}

@media (max-width: 520px) {
  .site-footer { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: 1fr; }
  .stats article { border-right: 0; border-bottom: 1px solid var(--black); }
  .stats article:nth-child(2) { border-bottom: 1px solid var(--black); }
  .stats article:last-child { border-bottom: 0; }
  .search { flex-direction: column; }
  .link-row { grid-template-columns: 1fr 42px; }
  .link-row input:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .link-row .icon-button { grid-column: 2; grid-row: 1; }
}
