/* ==========================================================
   Design tokens
   Concept: shortening a link = tearing off a small claim-ticket
   from a long strip. Deep ink-navy stage, kraft-paper ticket,
   thread-red accent, dashed perforation as the one recurring motif.
   ========================================================== */
:root {
  --ink:        #12182B;
  --ink-soft:   #1C2440;
  --paper:      #EFE9DC;
  --paper-dim:  #DCD2BA;
  --thread:     #C2452D;
  --thread-dim: #9C3A26;
  --text-hi:    #F6F3EA;
  --text-mid:   #B9C0D6;
  --text-on-paper: #2B2416;
  --line:       rgba(246, 243, 234, 0.14);
  --radius-sm:  4px;
  --radius-md:  10px;
  --serif:  'Fraunces', Georgia, serif;
  --sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:   'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--text-hi);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
}

/* subtle film-grain texture over the dark stage */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 0;
  background-image: radial-gradient(var(--text-hi) 0.5px, transparent 0.5px);
  background-size: 3px 3px;
}

/* ---------- topbar ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 24px;
}
.brand {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand__dot { color: var(--thread); }
.topbar__tag {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mid);
}

/* ---------- hero ---------- */
main.wrap { position: relative; z-index: 1; flex: 1; }

.hero {
  padding: 72px 0 40px;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--thread);
  margin: 0 0 14px;
}
.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.08;
  margin: 0 0 20px;
  max-width: 14ch;
}
.lede {
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-mid);
  max-width: 46ch;
  margin: 0;
}
.hero--error { padding-bottom: 60px; }

/* ---------- form panel ---------- */
.panel {
  padding-bottom: 40px;
}
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
}
.field__label em {
  font-style: normal;
  color: rgba(185, 192, 214, 0.6);
}
.field input[type="url"],
.field input[type="text"] {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text-hi);
  background: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.15s ease;
}
.field input::placeholder { color: rgba(185, 192, 214, 0.45); }
.field input:focus {
  border-color: var(--thread);
}
.field__prefix-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.field__prefix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-mid);
  background: rgba(246, 243, 234, 0.04);
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.field__prefix-group input {
  border: none;
  border-radius: 0;
  flex: 1;
  min-width: 0;
}
.field__prefix-group input:focus { border: none; }
.field__hint {
  font-size: 12px;
  color: rgba(185, 192, 214, 0.55);
}

.alert {
  font-size: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin: 0;
}
.alert--error {
  background: rgba(194, 69, 45, 0.12);
  border: 1px solid rgba(194, 69, 45, 0.4);
  color: #F0B4A6;
}

.btn {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 22px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.btn--primary {
  background: var(--thread);
  color: var(--text-hi);
  align-self: flex-start;
}
.btn--primary:hover { background: var(--thread-dim); }
.btn--primary:active { transform: scale(0.98); }
.btn--ghost {
  display: inline-block;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-hi);
  text-decoration: none;
}
.btn--ghost:hover { border-color: var(--thread); }
.btn--copy {
  font-size: 13px;
  padding: 8px 14px;
  background: var(--text-on-paper);
  color: var(--paper);
}
.btn--copy:hover { background: #3a3120; }
.btn--copied { background: #3E6B4C !important; color: #fff !important; }

/* ---------- the "claim ticket" result ---------- */
.ticket {
  margin-top: 28px;
  background: var(--paper);
  color: var(--text-on-paper);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  position: relative;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}
.ticket__row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ticket__row--muted { padding-top: 16px; }
.ticket__label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(43, 36, 22, 0.6);
}
.ticket__value-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ticket__value {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  color: var(--text-on-paper);
  text-decoration: none;
  word-break: break-all;
}
.ticket__value:hover { color: var(--thread); }
.ticket__original {
  font-family: var(--mono);
  font-size: 13px;
  color: rgba(43, 36, 22, 0.65);
  word-break: break-all;
}
.ticket__perforation {
  border-top: 2px dashed rgba(43, 36, 22, 0.28);
  margin: 18px -24px 0;
}

/* ---------- feature strip ---------- */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 20px 0 72px;
  border-top: 1px solid var(--line);
  margin-top: 16px;
}
.feature__num {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--thread);
  margin-bottom: 10px;
}
.feature h3 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
}
.feature p {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-mid);
  margin: 0;
}

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  position: relative;
  z-index: 1;
}
.footer__inner {
  display: flex;
  justify-content: space-between;
  padding: 20px 24px;
  font-size: 12.5px;
  color: var(--text-mid);
}
.footer__muted { color: rgba(185, 192, 214, 0.55); }
.footer__admin { color: rgba(185, 192, 214, 0.55); text-decoration: none; font-size: 12px; }
.footer__admin:hover { color: var(--thread); }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .features { grid-template-columns: 1fr; gap: 28px; }
  .hero { padding: 48px 0 32px; }
  .ticket__value-group { align-items: flex-start; }
}

/* ==========================================================
   Admin panel additions
   ========================================================== */
.wrap--wide { max-width: 1040px; }
.wrap--narrow { max-width: 560px; }

.hero--tight { padding: 44px 0 24px; }
.h1--sm { font-size: clamp(26px, 4vw, 34px); max-width none; }

.admin-nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn--sm { padding: 8px 14px; font-size: 13px; }
.btn--danger { background: transparent; border: 1px solid rgba(194, 69, 45, 0.5); color: #F0B4A6; }
.btn--danger:hover { background: rgba(194, 69, 45, 0.15); }

.alert--success {
  background: rgba(63, 107, 76, 0.15);
  border: 1px solid rgba(63, 107, 76, 0.4);
  color: #BFE3C8;
}

.stat-row {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
}
.stat-box {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  background: rgba(246, 243, 234, 0.03);
}
.stat-box__num {
  display: block;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
}
.stat-box__label {
  font-size: 12.5px;
  color: var(--text-mid);
}

.panel--collapsible {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.panel--collapsible summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-hi);
  list-style: none;
}
.panel--collapsible summary::-webkit-details-marker { display: none; }
.panel--collapsible[open] summary { margin-bottom: 16px; }

.form--inline {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 14px;
  align-items: end;
}
.form--inline .field { gap: 6px; }

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.search-bar input {
  flex: 1;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-hi);
  background: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
}
.search-bar input:focus { border-color: var(--thread); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.admin-table th {
  text-align: left;
  font-size: 11.5px;
  color: var(--text-mid);
  font-weight: 500;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .mono { font-family: var(--mono); }
.admin-table__url {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-mid);
}
.admin-table__date { color: var(--text-mid); white-space: nowrap; }
.admin-table__actions { display: flex; gap: 8px; white-space: nowrap; }
.admin-table__empty { text-align: center; color: var(--text-mid); padding: 32px 16px; }
.admin-table a { color: var(--text-hi); }
.admin-table a:hover { color: var(--thread); }

.pagination {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 60px;
}
.pagination__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-mid);
  text-decoration: none;
  font-size: 13px;
  font-family: var(--mono);
}
.pagination__link.is-active {
  background: var(--thread);
  border-color: var(--thread);
  color: var(--text-hi);
}

.form__actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

@media (max-width: 640px) {
  .form--inline { grid-template-columns: 1fr; }
  .stat-row { flex-direction: column; }
}

/* ---------- accessibility ---------- */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--thread);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
