:root {
  color-scheme: dark;
  --canvas: #101313;
  --surface: #1a2020;
  --surface-strong: #242d2b;
  --text: #eef2ec;
  --muted: #abb7ae;
  --line: #38433d;
  --accent: #d3ff68;
  --accent-ink: #172000;
  --danger: #ff998c;
  --success: #bff3b6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 82% 0%, #274039 0, transparent 28rem), var(--canvas);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }

.page-shell { width: min(100% - 2rem, 800px); margin: 0 auto; padding: 5rem 0 2.5rem; }
.admin-shell { width: min(100% - 2rem, 1260px); }
.hero { margin-bottom: 2rem; }
.hero.compact { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.eyebrow { margin: 0 0 .65rem; color: var(--accent); letter-spacing: .16em; font-size: .73rem; font-weight: 700; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 12ch; margin-bottom: .8rem; font-size: clamp(2.25rem, 6vw, 4.3rem); line-height: 1.01; letter-spacing: -.055em; }
h2 { margin-bottom: 1.25rem; font-size: 1.15rem; }
.lead { max-width: 56ch; color: var(--muted); line-height: 1.65; }
.card { border: 1px solid var(--line); border-radius: 1.1rem; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 1.2rem 4rem #0003; }
.form-card { padding: clamp(1.25rem, 3vw, 2rem); }
label { display: block; margin-bottom: .45rem; font-size: .88rem; font-weight: 650; }
input, textarea {
  display: block;
  width: 100%;
  margin-bottom: 1.1rem;
  padding: .76rem .9rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  outline: none;
  color: var(--text);
  background: #111716;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #d3ff6821; }
textarea { resize: vertical; }
.hint, .footer-note, .site-footer { color: var(--muted); font-size: .83rem; line-height: 1.55; }
.hint { margin-top: -.5rem; margin-bottom: 1.25rem; }
button, .download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .65rem 1.05rem;
  border: 0;
  border-radius: .55rem;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 750;
  text-decoration: none;
}
button:hover:not(:disabled), .download-link:hover { filter: brightness(1.08); }
.result { margin-top: 1.25rem; padding: 1rem; border-radius: .65rem; border: 1px solid var(--line); }
.result p { margin-bottom: .7rem; }
.result.success { border-color: #83b779; background: #19311d; }
.result.error { border-color: #9f5e57; background: #321f20; }
.result.error p { color: #ffd4cf; }
.footer-note { margin: 1.5rem .2rem; }
.site-footer { margin: 1.5rem .2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.site-footer p { margin-bottom: .35rem; }
.community-note { color: var(--text); font-weight: 650; letter-spacing: .02em; }
.admin-footer { margin-top: 1.25rem; text-align: center; }
.text-link { color: var(--accent); text-decoration: none; }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .85rem; margin-bottom: 1rem; }
.stat-card { padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); }
.stat-card span, .stat-card small { display: block; color: var(--muted); font-size: .78rem; }
.stat-card strong { display: block; margin: .55rem 0 .25rem; color: var(--accent); font-size: 2rem; line-height: 1; }
.admin-card { padding: 1.2rem; }
.section-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.section-header .hint { max-width: 52rem; margin-bottom: 0; }
.link-health-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin-top: 1rem; }
.link-health-grid span { display: block; padding: .7rem; border-radius: .6rem; color: var(--muted); background: #111716; font-size: .78rem; }
.link-health-grid strong { display: block; margin-top: .25rem; color: var(--text); font-size: 1.15rem; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: .8rem; align-items: end; }
.form-grid label { margin: 0; }
.form-grid input { margin: .45rem 0 0; }
.generated-codes { overflow: auto; padding: 1rem; border: 1px solid #7ca16d; border-radius: .6rem; color: var(--success); background: #111a13; line-height: 1.7; }
.admin-message { min-height: 1.3rem; margin: 1rem 0 0; font-size: .9rem; }
.admin-message.success { color: var(--success); }
.admin-message.error { color: var(--danger); }
.admin-grid { display: grid; grid-template-columns: minmax(250px, .7fr) minmax(0, 1.3fr); gap: 1rem; margin-top: 1rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { padding: .65rem .55rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.danger-button { min-height: auto; padding: .35rem .55rem; color: #ffd4cf; border: 1px solid #9f5e57; background: transparent; font-size: .78rem; }
.redemption-card { margin-top: 1rem; }
.search-form { display: flex; align-items: center; gap: .55rem; }
.search-form input { width: min(24rem, 45vw); margin: 0; }
.secondary-button { color: var(--text); border: 1px solid var(--line); background: transparent; }
.mirror-card { margin-top: 1rem; }
.button-row { display: flex; gap: .55rem; }
.mirror-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; margin: 1rem 0; }
.mirror-details div { min-width: 0; padding: .7rem; border-radius: .6rem; background: #111716; }
.mirror-details dt { color: var(--muted); font-size: .76rem; }
.mirror-details dd { overflow-wrap: anywhere; margin: .3rem 0 0; font-size: .86rem; }
.mirror-list { display: grid; gap: .55rem; }
.mirror-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: .6rem; }
.mirror-item strong { color: var(--accent); font-size: .78rem; }
.compact-button { min-height: auto; padding: .35rem .55rem; font-size: .78rem; }
.user-agent-cell { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; }
.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; }

@media (max-width: 780px) {
  .page-shell { padding-top: 3rem; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-grid, .form-grid, .link-health-grid { grid-template-columns: 1fr; }
  .section-header { align-items: stretch; flex-direction: column; }
  .search-form { align-items: stretch; flex-direction: column; }
  .search-form input { width: 100%; }
  .button-row, .mirror-item { align-items: stretch; flex-direction: column; }
  .mirror-details { grid-template-columns: 1fr; }
  .hero.compact { align-items: start; flex-direction: column; }
}
