:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #e4e4e4;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-2: #7c3aed;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #991b1b;
  --radius: 10px;
  --max-width: 640px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.brand span { color: var(--accent); }

.site-nav a {
  margin-left: 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.site-nav a:hover { color: var(--accent); }
.site-nav a.active { color: var(--accent); font-weight: 600; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.hero h1 {
  font-size: 1.9rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 1.75rem;
}

/* Homepage hero band with a soft gradient backdrop */
.hero-band {
  background: radial-gradient(1200px 480px at 50% -10%, rgba(37, 99, 235, 0.10), transparent 60%),
              linear-gradient(180deg, #f5f7ff 0%, var(--bg) 65%);
  padding: 3.5rem 0 3rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero-band .container {
  max-width: 620px;
  padding-bottom: 0;
}

.hero-band h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, var(--text) 0%, var(--accent) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-band .subtitle {
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

.shorten-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: left;
}

.shorten-form-hero {
  box-shadow: var(--shadow);
  padding: 1.35rem;
  gap: 1rem;
}

.url-row {
  display: flex;
  gap: 0.6rem;
}

.url-input {
  flex: 1;
  font-size: 1.05rem;
  padding: 0.85rem 1rem;
}

.btn-shorten {
  flex-shrink: 0;
  padding: 0 1.4rem;
}

.custom-code-row {
  text-align: left;
}

.custom-code-row label {
  display: block;
  margin-bottom: 0.4rem;
}

.custom-code-input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.custom-code-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.custom-code-prefix {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background: #f3f4f6;
  color: var(--text-muted);
  font-size: 0.9rem;
  white-space: nowrap;
  border-right: 1px solid var(--border);
}

.custom-code-input input {
  border: none;
  border-radius: 0;
}
.custom-code-input input:focus {
  box-shadow: none;
}

/* Feature cards below the fold on the homepage */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  padding-top: 3rem;
  max-width: 900px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: left;
}

.feature-icon {
  font-size: 1.5rem;
  margin-bottom: 0.6rem;
}

.feature-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.feature-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.feature-card a {
  color: var(--accent);
  text-decoration: none;
}
.feature-card a:hover {
  text-decoration: underline;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.optional {
  font-weight: 400;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-row {
  display: flex;
  gap: 0.9rem;
}
.form-col { flex: 1; }
.form-col-narrow { flex: 0 0 110px; }

.btn {
  display: inline-block;
  padding: 0.7rem 1.2rem;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-copy {
  background: var(--text);
  color: #fff;
  flex-shrink: 0;
}
.btn-copy:hover { opacity: 0.85; }
.btn-copy.copied { background: #059669; }

.alert {
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}
.alert p { margin: 0.25rem 0; }

.alert-error {
  background: var(--error-bg);
  border-color: var(--error-border);
  color: var(--error-text);
}

.alert-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.result-box label {
  color: var(--success-text);
}

.result-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.4rem 0 0.6rem;
}
.result-row input {
  font-weight: 600;
}

.hint {
  font-size: 0.85rem;
  opacity: 0.9;
  word-break: break-all;
}

.status-page {
  text-align: center;
  padding: 3rem 0;
}
.status-page h1 { margin-bottom: 0.5rem; }
.status-page p { color: var(--text-muted); margin-bottom: 1.5rem; }

.prose p { margin-bottom: 1rem; color: var(--text); }

/* Custom code checkbox toggle */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.custom-code-toggle {
  margin-top: -0.3rem;
}

/* Result box: QR code + action buttons */
.qr-box {
  text-align: center;
  margin: 1.1rem 0 0.4rem;
}
.qr-box img {
  width: 160px;
  height: 160px;
  border-radius: 8px;
  border: 1px solid var(--success-border);
  background: #fff;
  display: inline-block;
}
.qr-box a {
  display: inline-block;
  line-height: 0;
}
.qr-hint {
  margin-top: 0.4rem;
  text-align: center;
}

.result-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}
.result-actions .btn {
  flex: 1;
  text-align: center;
}

/* Monitoring interstitial (flagged links) */
.interstitial {
  max-width: 480px;
  margin: 0 auto;
}
.interstitial-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: left;
  margin: 1.25rem 0;
}
.interstitial-details p {
  margin: 0.3rem 0;
  font-size: 0.9rem;
  word-break: break-all;
}
.truncate-inline {
  word-break: break-all;
}

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.site-footer a { color: var(--text-muted); }

@media (max-width: 480px) {
  .form-row { flex-direction: column; }
  .form-col-narrow { flex: 1; }
  .site-nav a { margin-left: 0.75rem; font-size: 0.8rem; }
  .url-row { flex-direction: column; }
  .btn-shorten { padding: 0.75rem; }
  .features { grid-template-columns: 1fr; padding-top: 2rem; }
  .hero-band { padding: 2.5rem 0 2rem; }
  .result-actions { flex-direction: column; }
}

/* Monitoring interstitial: the ring depletes in lock-step with the
   countdown number — both are driven by the same JS tick, so the ring
   always finishes exactly when the countdown reaches zero, whatever the
   configured duration is. */
.interstitial-ring {
  position: relative;
  width: 76px;
  height: 76px;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress, 100%), var(--border) var(--progress, 100%));
  transition: background 1s linear;
}
.interstitial-ring::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--surface);
}
.interstitial-count {
  position: relative;
  z-index: 2;
  display: block;
}
.interstitial.is-complete .interstitial-ring {
  color: var(--accent-hover);
}
.interstitial-actions {
  display: flex;
  gap: .6rem;
  justify-content: center;
  flex-wrap: wrap;
}
.interstitial-actions .btn { min-width: 140px; }
@media (max-width: 520px) {
  .interstitial-actions { flex-direction: column; }
  .interstitial-actions .btn { width: 100%; }
}
