:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #637069;
  --paper: #f7f5ef;
  --panel: #ffffff;
  --line: #dcd8cc;
  --accent: #0f7c70;
  --accent-dark: #095c53;
  --gold: #c99124;
  --danger-bg: #fff1ee;
  --danger-text: #9c2d1f;
  --shadow: 0 24px 80px rgba(36, 43, 37, 0.12);
  --soft-shadow: 0 10px 28px rgba(36, 43, 37, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(15, 124, 112, 0.12), transparent 28rem),
    linear-gradient(135deg, #f7f5ef 0%, #edf4f0 58%, #f7f5ef 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

a:hover {
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

::selection {
  background: rgba(15, 124, 112, 0.2);
}

button,
input {
  font: inherit;
}

button,
.admin-link,
.header-actions a,
.not-found a {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  user-select: none;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
  box-shadow: none;
}

button:disabled:hover {
  background: var(--accent);
  transform: none;
  box-shadow: none;
}

button:hover,
.admin-link:hover,
.header-actions a:hover,
.not-found a:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(15, 124, 112, 0.22);
}

button:active,
.admin-link:active,
.header-actions a:active,
.not-found a:active {
  transform: translateY(0);
  box-shadow: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(201, 145, 36, 0.42);
  outline-offset: 3px;
}

.home {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.hero {
  min-height: 74vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.topbar,
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  letter-spacing: 0;
  box-shadow: inset 0 -10px 20px rgba(255, 255, 255, 0.08);
}

.admin-link,
.header-actions a,
.not-found a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
}

.hero-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 760px);
  align-items: start;
  justify-content: center;
  gap: 32px;
  padding: 64px 0 36px;
  text-align: center;
}

.intro {
  display: grid;
  justify-items: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 5.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.lead {
  max-width: 640px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.8;
}

.shortener,
.login-panel {
  border: 1px solid rgba(23, 32, 27, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.88)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.shortener {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 28px;
  text-align: left;
}

.url-form,
.stack,
.search-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 16px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 124, 112, 0.12);
}

input::placeholder {
  color: #9aa49e;
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  box-shadow: none;
}

.input-row,
.copy-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.input-row button,
.copy-row button,
.search-form button {
  padding: 0 22px;
  white-space: nowrap;
}

.alert {
  margin-top: 18px;
  border: 1px solid rgba(156, 45, 31, 0.22);
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger-text);
  padding: 14px 16px;
  font-weight: 700;
}

.notice {
  margin-top: 18px;
  border: 1px solid rgba(15, 124, 112, 0.22);
  border-radius: 8px;
  background: #eef8f5;
  color: var(--accent-dark);
  padding: 14px 16px;
  font-weight: 700;
}

.consent-note {
  margin: -4px 0 0;
  color: var(--danger-text);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.6;
}

.result {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  border-top: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf9;
  padding-top: 22px;
  padding: 22px;
}

.modal-open {
  overflow: hidden;
}

.consent-modal[hidden] {
  display: none;
}

.consent-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
}

.consent-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 27, 0.58);
  backdrop-filter: blur(8px);
}

.consent-dialog {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  display: grid;
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
  padding: 28px;
}

.consent-dialog h2,
.legal-document h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  line-height: 1.1;
}

.consent-scroll {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
  padding: 18px;
}

.consent-scroll h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.consent-scroll h3:not(:first-child) {
  margin-top: 18px;
}

.consent-scroll p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.consent-scroll p + p {
  margin-top: 12px;
}

.consent-scroll a,
.legal-document a {
  color: var(--accent-dark);
  font-weight: 800;
}

.consent-check {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.6;
}

.consent-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.consent-actions a {
  color: var(--accent-dark);
  font-weight: 800;
}

.consent-actions button {
  padding: 0 20px;
}

.legal-page {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.legal-brand {
  margin-bottom: 28px;
}

.legal-document {
  border: 1px solid rgba(23, 32, 27, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--soft-shadow);
  padding: clamp(24px, 5vw, 46px);
}

.legal-document h2 {
  margin: 32px 0 10px;
  font-size: 1.22rem;
}

.legal-document p,
.legal-document li {
  color: var(--muted);
  line-height: 1.85;
}

.legal-document ul {
  margin: 10px 0 0;
  padding-left: 1.25rem;
}

.legal-date {
  margin-top: 34px;
  font-weight: 800;
}

.result span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.result a {
  color: var(--accent-dark);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
  text-align: center;
}

.metrics div,
.stat-grid div {
  border: 1px solid rgba(23, 32, 27, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 18px;
  box-shadow: var(--soft-shadow);
}

.metrics strong,
.metrics span,
.stat-grid span,
.stat-grid strong {
  display: block;
}

.metrics span,
.stat-grid span {
  margin-top: 6px;
  color: var(--muted);
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 28px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer a {
  color: var(--accent-dark);
  font-weight: 800;
}

.admin-login {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  padding: 30px;
}

.login-panel h1 {
  font-size: 2rem;
  line-height: 1.1;
  margin-bottom: 24px;
}

.stack button {
  width: 100%;
}

.admin {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), transparent 260px),
    #f5f3ec;
}

.admin-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.admin-header h1 {
  font-size: clamp(2.1rem, 5vw, 4.2rem);
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 28px 0 18px;
}

.stat-grid strong {
  margin-top: 8px;
  font-size: 2rem;
  line-height: 1;
}

.admin-tools {
  margin: 18px 0;
}

.search-form {
  grid-template-columns: 1fr auto;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

th,
td {
  border-bottom: 1px solid #ebe7dc;
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #fbfaf6;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  font-size: 0.94rem;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: #f8fbf9;
}

td a {
  color: var(--accent-dark);
  font-weight: 700;
}

.url-cell {
  min-width: 380px;
  max-width: 520px;
  overflow-wrap: anywhere;
}

.inline-edit-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.inline-edit-form input {
  min-height: 42px;
}

.inline-edit-form button,
.delete-form button {
  min-height: 42px;
  padding: 0 14px;
}

.original-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.delete-form button {
  background: #b23b2e;
}

.delete-form button:hover {
  background: #8f2f25;
  box-shadow: 0 12px 28px rgba(178, 59, 46, 0.2);
}

.confirm-modal[hidden] {
  display: none;
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 22px;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 32, 27, 0.58);
  backdrop-filter: blur(8px);
}

.confirm-dialog {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
  padding: 28px;
}

.confirm-dialog h2 {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.15;
}

.confirm-dialog p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.7;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.secondary-button {
  background: #eef4f1;
  color: var(--ink);
}

.secondary-button:hover {
  background: #e1ebe7;
  box-shadow: none;
}

.danger-button {
  background: #b23b2e;
}

.danger-button:hover {
  background: #8f2f25;
  box-shadow: 0 12px 28px rgba(178, 59, 46, 0.2);
}

code {
  border-radius: 6px;
  background: #eef4f1;
  padding: 3px 7px;
  color: #28584f;
  font-size: 0.88em;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.not-found {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100vh;
  width: min(680px, calc(100% - 32px));
  margin: 0 auto;
  text-align: center;
}

.not-found h1 {
  font-size: clamp(2.4rem, 8vw, 5rem);
}

.not-found p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

@media (max-width: 820px) {
  .hero-grid,
  .metrics,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .hero-grid {
    gap: 28px;
    padding: 42px 0 28px;
  }

  .input-row,
  .copy-row,
  .search-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .shortener,
  .login-panel {
    padding: 20px;
  }
}

@media (max-width: 520px) {
  .home,
  .admin-shell {
    width: min(100% - 24px, 1180px);
  }

  .topbar,
  .admin-header {
    gap: 14px;
  }

  .admin-link,
  .header-actions a {
    width: 100%;
  }

  .header-actions {
    width: 100%;
  }

  h1 {
    font-size: clamp(2.25rem, 16vw, 3.5rem);
    line-height: 1;
  }

  .lead {
    font-size: 1rem;
    line-height: 1.7;
  }

  .metrics div,
  .stat-grid div {
    padding: 16px;
  }

  .result {
    padding: 18px;
  }

  .consent-modal {
    padding: 12px;
  }

  .consent-dialog {
    max-height: calc(100vh - 24px);
    padding: 20px;
  }

  .consent-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .consent-actions button,
  .consent-actions a {
    width: 100%;
    text-align: center;
  }

  .legal-page {
    width: min(100% - 24px, 920px);
    padding-top: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
