/* rply: one hand-written stylesheet for every browser page. The landing
   composition is the chosen mockup ("mix-headline"), scaled up from its
   300px preview card to a full page. */

:root {
  --bg-top: #312e81;
  --bg-mid: #1e1b4b;
  --bg-bottom: #0f172a;
  --accent: #5eead4;
  --accent-soft: rgba(94, 234, 212, 0.15);
  --text: #ffffff;
  --text-soft: #c7d2fe;
  --text-muted: #a5b4fc;
  --text-faint: #818cf8;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.12);
  --danger: #fca5a5;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: clamp(16px, 4vw, 32px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg-bottom);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-mid) 60%, var(--bg-bottom) 100%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
}

/* Header: small wordmark left, actions right. */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 18px var(--gutter);
  font-size: 14px;
}

.wordmark {
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 12px;
  min-width: 0;
}

.site-user {
  color: var(--text-soft);
  min-width: 0;
  overflow-wrap: anywhere;
}

.sign-out {
  margin: 0;
}

/* The teal outlined pill ("Sign in", "Sign out"). */

.pill {
  display: inline-block;
  padding: 4px 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
}

.pill:hover,
.pill:focus-visible {
  background: var(--accent-soft);
}

/* Flash messages. */

.flash {
  margin: 0 var(--gutter) 8px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 14px;
}

.flash-success {
  border-color: rgba(94, 234, 212, 0.35);
  background: var(--accent-soft);
  color: var(--accent);
}

.flash-failure {
  border-color: rgba(252, 165, 165, 0.4);
  background: rgba(252, 165, 165, 0.12);
  color: var(--danger);
}

/* Main area. */

main {
  flex: 1;
  width: 100%;
  min-width: 0;
}

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px var(--gutter) 32px;
}

.page-title {
  margin: 0 0 16px;
  font-size: 28px;
  font-weight: 700;
}

.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px var(--gutter);
}

/* Landing: centred headline and the example card. */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px var(--gutter) 48px;
}

.headline {
  margin: 0;
  font-size: clamp(28px, 4vw + 14px, 52px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-align: center;
}

.accent {
  color: var(--accent);
}

.example-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 360px);
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: clamp(13px, 1vw + 10px, 15px);
}

.example-short {
  color: var(--accent);
}

.example-arrow {
  color: var(--text-faint);
}

.example-long {
  padding-left: 18px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* Panels and forms (sign-in). */

.panel {
  width: min(100%, 380px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.panel-title {
  margin: 0 0 20px;
  font-size: 24px;
  font-weight: 700;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  color: var(--text-soft);
  font-size: 14px;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
  font: inherit;
}

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.button {
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--bg-bottom);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover,
.button:focus-visible {
  background: #99f6e4;
}

/* 404 and 500. */

.message {
  text-align: center;
}

.message-title {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: clamp(40px, 6vw + 16px, 64px);
  font-weight: 800;
  line-height: 1.1;
}

.message p {
  margin: 0;
  color: var(--text-soft);
}

/* Footer. */

.site-footer {
  padding: 16px var(--gutter);
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

/* Admin: link list, form and detail. */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head .page-title {
  margin: 0;
}

.button {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.search {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.search input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
  font: inherit;
}

.search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.link-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.link-table th {
  padding: 6px 8px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

.link-table td {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

.link-table .short {
  width: 30%;
  overflow-wrap: anywhere;
}

.link-table .created {
  width: 112px;
  color: var(--text-faint);
  text-align: right;
  white-space: nowrap;
}

.slug {
  color: var(--accent);
  font-family: var(--mono);
  text-decoration: none;
}

.slug:hover,
.slug:focus-visible {
  text-decoration: underline;
}

.link-table .destination {
  overflow: hidden;
  color: var(--text-muted);
  font-family: var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  font-size: 14px;
}

.pager-position {
  color: var(--text-faint);
}

.empty {
  margin: 32px 0;
  color: var(--text-muted);
  text-align: center;
}

.back {
  margin: 0 0 12px;
  font-size: 14px;
}

.form-panel {
  width: min(100%, 560px);
}

.prefixed {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.5);
}

.prefixed:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.prefix {
  display: flex;
  align-items: center;
  padding-left: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
  white-space: nowrap;
}

.field .prefixed input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: var(--mono);
}

.field .prefixed input:focus {
  outline: 0;
}

.field input[name="redirect_url"] {
  font-family: var(--mono);
}

.field-hint {
  margin: 0;
  color: var(--text-faint);
  font-size: 13px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.inline-form {
  margin: 0;
}

.pill-danger {
  border-color: rgba(252, 165, 165, 0.6);
  color: var(--danger);
}

.pill-danger:hover,
.pill-danger:focus-visible {
  background: rgba(252, 165, 165, 0.12);
}

.link-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.short-url {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: clamp(18px, 3vw + 8px, 24px);
}

.short-url-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.destination-full {
  margin: 8px 0 16px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.meta {
  margin: 0 0 20px;
  color: var(--text-faint);
  font-size: 13px;
}

/* Stats: tiles, the daily chart and the numeric columns. */

.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(165, 180, 252, 0.25);
  border-radius: 8px;
  background: var(--bg-mid);
}

.tile-label {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tile-value {
  font-size: clamp(15px, 4.8vw, 24px);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.result-count {
  margin: 0 0 8px;
  color: var(--text-faint);
  font-size: 13px;
}

.link-table .num {
  width: 72px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chart-title {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 96px;
  border-bottom: 1px solid var(--border);
}

.bar {
  display: flex;
  flex: 1;
  align-items: flex-end;
  min-width: 0;
  height: 100%;
}

.bar span {
  display: block;
  width: 100%;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

/* A day with no clicks is a hairline, so the 30 days still read as a row. */
.bar span.empty {
  height: 2px !important;
  opacity: 0.25;
}

.bars-axis {
  display: flex;
  justify-content: space-between;
  margin: 4px 0 12px;
  color: var(--text-faint);
  font-size: 11px;
}

/* Narrow screens: each link becomes a small card instead of a squeezed row. */

@media (max-width: 420px) {
  .tile {
    padding: 8px;
  }

  .tile-label {
    font-size: 10px;
    letter-spacing: 0.02em;
  }
}

@media (max-width: 600px) {
  .link-table,
  .link-table tbody {
    display: block;
  }

  .link-table thead {
    display: none;
  }

  .link-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 12px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
  }

  .link-table td {
    padding: 0;
    border-top: 0;
  }

  .link-table .short {
    grid-row: 1;
    width: auto;
  }

  .link-table .created {
    grid-column: 2 / -1;
    grid-row: 1;
    width: auto;
    font-size: 13px;
  }

  /* Counts go on their own line under the destination, labelled. */
  .link-table .num {
    grid-row: 3;
    width: auto;
    color: var(--text-muted);
    font-size: 13px;
    text-align: left;
  }

  .link-table .num::before {
    content: attr(data-label) " ";
    color: var(--text-faint);
  }

  .link-table .d30 {
    grid-column: 1;
  }

  .link-table .total {
    grid-column: 2 / -1;
  }

  .link-table .destination {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* Admin nav and the link-in-bio admin pages. */

.site-nav-link {
  color: var(--text-soft);
  font-size: 14px;
  text-decoration: none;
}

.site-nav-link:hover,
.site-nav-link:focus-visible {
  color: var(--accent);
}

.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.5);
  color: var(--text);
  font: inherit;
  font-family: var(--mono);
  font-size: 14px;
  resize: vertical;
}

.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

/* The "Links" source choice: a two-option segmented control. */

fieldset.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field legend {
  margin-bottom: 6px;
  padding: 0;
  color: var(--text-soft);
  font-size: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.5);
}

.segmented label {
  position: relative;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text-soft);
  font-size: 14px;
  text-align: center;
  cursor: pointer;
}

/* The radio stays focusable and readable by screen readers, just not drawn. */
.field .segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented label:has(input:checked) {
  background: var(--accent);
  color: var(--bg-bottom);
  font-weight: 600;
}

.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The API URL and token only matter for an API page. */
.stacked-form:has(input[name="source"][value="manual"]:checked) .api-only {
  display: none;
}

.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 14px;
}

.field .choice input {
  width: auto;
  margin: 0;
}

.field code {
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.bio-section {
  margin-top: 16px;
}

.bio-section-title {
  margin: 0 0 12px;
  font-size: 18px;
}

h3.bio-section-title {
  margin-top: 24px;
  font-size: 16px;
}

.bio-admin-title {
  margin: 8px 0;
  font-size: 22px;
}

.bio-api-url {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

.bio-admin-links {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.bio-admin-links li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.bio-admin-links .destination {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* Colour rows on the bio page form: swatch, label, hex field, reset. */

.colour-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.colour-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 4px 12px;
}

.field .colour-swatch {
  width: 40px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.colour-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.colour-text label {
  color: var(--text);
}

.field .colour-hex {
  width: 8.5em;
  font-family: var(--mono);
  font-size: 14px;
}

.colour-reset[hidden] {
  display: none;
}

.colour-error {
  grid-column: 1 / -1;
}

@media (max-width: 480px) {
  .colour-row {
    grid-template-columns: auto 1fr;
  }

  .field .colour-hex {
    width: 100%;
  }
}

/* The public link-in-bio page.
   A page's own colours arrive as --bio-* on <body> (see `bio::theme`); the
   fallbacks here are the defaults. Card surfaces and borders are mixed from
   the text colour, so they read on light backgrounds as well as dark. */

.bio-body {
  --bio-heading-c: var(--bio-heading, #ffffff);
  --bio-subheading-c: var(--bio-subheading, #ffffff);
  --bio-text-c: var(--bio-text, #c7d2fe);
  --bio-accent-c: var(--bio-accent, #5eead4);
  --bio-surface: color-mix(in srgb, var(--bio-text-c) 8%, transparent);
  --bio-surface-strong: color-mix(in srgb, var(--bio-text-c) 14%, transparent);
  --bio-border: color-mix(in srgb, var(--bio-text-c) 20%, transparent);
  background: var(--bio-bg, linear-gradient(160deg, var(--bg-top) 0%, var(--bg-mid) 60%, var(--bg-bottom) 100%));
  color: var(--bio-text-c);
}

.bio {
  flex: 1;
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 40px var(--gutter) 24px;
}

.bio-double {
  width: min(100%, 880px);
}

.bio-header {
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

.bio-title {
  margin: 0 0 10px;
  color: var(--bio-heading-c);
  font-size: clamp(24px, 3vw + 14px, 32px);
  font-weight: 800;
  line-height: 1.2;
}

.bio-description {
  font-size: 15px;
}

.bio-description a {
  color: var(--bio-accent-c);
}

.bio-description > :first-child {
  margin-top: 0;
}

.bio-description > :last-child {
  margin-bottom: 0;
}

.bio-description img {
  max-width: 100%;
  height: auto;
}

.bio-links {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 640px) {
  .bio-double .bio-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.bio-links li {
  display: flex;
}

/* A card: the image across the full width (at its own aspect ratio), then
   the title and text. */
.bio-link {
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--bio-border);
  border-radius: 14px;
  background: var(--bio-surface);
  color: var(--bio-text-c);
  text-decoration: none;
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}

.bio-link:hover,
.bio-link:focus-visible {
  border-color: var(--bio-accent-c);
  background: var(--bio-surface-strong);
  transform: translateY(-2px);
}

.bio-link:focus-visible {
  outline: 2px solid var(--bio-accent-c);
  outline-offset: 2px;
}

.bio-image {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bio-surface-strong);
}

.bio-link-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px 16px;
}

.bio-link-title {
  color: var(--bio-subheading-c);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.bio-link:hover .bio-link-title,
.bio-link:focus-visible .bio-link-title {
  color: var(--bio-accent-c);
}

/* Feed descriptions can be paragraphs; three lines is enough on a card. */
.bio-link-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  font-size: 14px;
  line-height: 1.45;
  opacity: 0.85;
}

.bio-empty {
  margin: 32px 0;
  text-align: center;
  opacity: 0.8;
}

.bio-footer {
  color: var(--bio-text-c);
  opacity: 0.6;
}

@media (prefers-reduced-motion: reduce) {
  .bio-link {
    transition: none;
  }

  .bio-link:hover,
  .bio-link:focus-visible {
    transform: none;
  }
}
