:root {
  --color-bg-top: #efe6d3;
  --color-bg-mid: #ece0c9;
  --color-bg-bottom: #e8dac0;
  --color-surface: #ffffff;
  --color-surface-alt: #f8f2e6;
  --color-text: #2b2621;
  --color-muted: #7a7267;
  --color-muted-light: #a89f92;
  --color-border: #e6dac5;
  --color-border-light: #ddcdb0;
  --color-accent: #fa7268;
  --color-accent-hover: #e35b52;
  --color-accent-soft: #ffe5e0;
  --color-danger: #dc2626;
  --color-danger-soft: #fef2f2;
  --color-success: #16a34a;
  --color-success-soft: #f0fdf4;
  --color-warn-bg: #fff8e6;
  --color-warn-border: #f6dfa6;
  --color-warn-text: #92700c;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 28px rgba(250, 114, 104, 0.14), 0 4px 10px rgba(15, 23, 42, 0.05);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }
a { color: var(--color-accent); }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, var(--color-bg-top) 0%, var(--color-bg-mid) 45%, var(--color-bg-bottom) 100%);
  background-attachment: fixed;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- Top bar (brand) ---------- */
.topbar {
  padding: 18px 20px 0;
}
.topbar-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-inner.wide {
  max-width: 760px;
}
.logo-dot {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(250, 114, 104, 0.3);
}
.logo-text {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--color-text);
}

/* ---------- Public page (mobile-first) ---------- */
/* Separate decorative layer from content for a future optional hero treatment. */
.public-backdrop { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.link-icon { display: block; width: 24px; height: 24px; flex-shrink: 0; }
.public-link-label { min-width: 0; overflow-wrap: anywhere; }
.public-tag a:focus-visible { outline: 3px solid var(--color-text); outline-offset: 4px; }
.public-tag .public-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  text-align: left;
  line-height: 1.5;
}
.public-page {
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}
.bg-blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  z-index: 0;
  pointer-events: none;
}
.bg-blob-1 {
  width: 280px;
  height: 280px;
  top: -80px;
  left: -60px;
  background: radial-gradient(circle, rgba(250, 114, 104, 0.35), rgba(250, 114, 104, 0));
}
.bg-blob-2 {
  width: 260px;
  height: 260px;
  top: 30%;
  right: -100px;
  background: radial-gradient(circle, rgba(255, 200, 120, 0.4), rgba(255, 200, 120, 0));
}
.bg-blob-3 {
  width: 320px;
  height: 320px;
  bottom: -100px;
  left: 10%;
  background: radial-gradient(circle, rgba(224, 122, 95, 0.3), rgba(224, 122, 95, 0));
}
.public-page h1 {
  text-align: center;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 12px 0 32px;
  word-break: break-word;
  color: var(--color-text);
}
.public-page .btn-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.public-btn {
  display: block;
  width: 100%;
  padding: 18px 18px;
  font-size: 1.02rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--color-text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.35));
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius);
  box-shadow:
    0 10px 24px rgba(43, 38, 33, 0.10),
    0 2px 6px rgba(43, 38, 33, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 1px rgba(43, 38, 33, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, background 0.15s ease;
}
.public-btn:hover {
  border-color: rgba(255, 255, 255, 0.85);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.45));
  box-shadow:
    0 14px 30px rgba(43, 38, 33, 0.14),
    0 3px 8px rgba(43, 38, 33, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 1px rgba(43, 38, 33, 0.04);
  transform: translateY(-2px);
}
.public-btn:active {
  transform: translateY(0);
  box-shadow:
    0 4px 10px rgba(43, 38, 33, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 1px 3px rgba(43, 38, 33, 0.08);
}
.public-empty {
  text-align: center;
  color: var(--color-muted);
  margin-top: 40px;
}
.powered-by {
  margin-top: 44px;
  font-size: 0.75rem;
  color: var(--color-muted-light);
  text-align: center;
  line-height: 1.9;
}
.powered-by a {
  color: var(--color-muted-light);
}

/* ---------- Verify / Config (vertical flow) ---------- */
.flow-page {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.flow-page h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-align: center;
  margin-bottom: 4px;
}
.flow-page .subtitle {
  text-align: center;
  color: var(--color-muted);
  margin-bottom: 28px;
  font-size: 0.9rem;
}
.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--color-muted);
}
.field input[type="text"],
.field input[type="password"],
.field input[type="url"],
.field input[type="tel"],
.field select {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
  background: var(--color-surface);
}
.btn {
  display: inline-block;
  width: 100%;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(47, 123, 246, 0.28);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--color-accent-hover); box-shadow: 0 8px 20px rgba(47, 123, 246, 0.35); }
.btn:active { transform: scale(0.98); }
.btn.secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border-light);
  box-shadow: none;
}
.btn.secondary:hover { background: var(--color-surface-alt); box-shadow: none; }
.btn.danger {
  background: var(--color-surface);
  color: var(--color-danger);
  border: 1px solid var(--color-border-light);
  box-shadow: none;
}
.btn.danger:hover { background: var(--color-danger-soft); border-color: var(--color-danger); box-shadow: none; }
.btn.small {
  width: auto;
  padding: 8px 16px;
  font-size: 0.85rem;
}
.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.tag-id-box {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin: 8px 0 24px;
  padding: 12px;
  background: var(--color-accent-soft);
  color: var(--color-accent-hover);
  border-radius: var(--radius-sm);
}
[hidden] { display: none !important; }
#add-link-form { margin-top: 14px; }
.section-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 32px 0 14px;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-text);
  padding-bottom: 8px;
}
.link-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.link-item .meta {
  flex: 1;
  min-width: 0;
}
.link-item .meta .type {
  font-size: 0.72rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.link-item .meta .label {
  font-weight: 600;
  overflow-wrap: anywhere;
  margin: 4px 0;
}
.link-item .meta .url {
  font-size: 0.8rem;
  color: var(--color-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.link-item .link-actions { grid-column: 1 / -1; justify-content: flex-end; margin-top: 4px; }
.link-item .link-actions .btn { min-height: 44px; }
.owner-link-icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; background: var(--color-surface-alt); color: var(--color-text); }
.error-msg {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.9rem;
  font-weight: 500;
}
.success-msg {
  background: var(--color-success-soft);
  color: var(--color-success);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.9rem;
  font-weight: 500;
}
.muted { color: var(--color-muted); font-size: 0.85rem; }
.muted a { color: var(--color-accent); text-decoration: none; }
.muted a:hover { text-decoration: underline; }
.divider { border: none; border-top: 1px solid var(--color-border); margin: 28px 0; }
form.inline { display: inline; }

/* ---------- Admin ---------- */
.admin-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.admin-page h1 {
  margin: 12px 0 4px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.stat-row {
  display: flex;
  gap: 12px;
  margin: 20px 0 30px;
  flex-wrap: wrap;
}
.stat-box {
  flex: 1;
  min-width: 140px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.stat-box .num { font-size: 1.4rem; font-weight: 800; color: var(--color-accent); }
.stat-box .label { font-size: 0.72rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
table.batches {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.9rem;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.batches th, table.batches td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
}
table.batches th { color: var(--color-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; background: var(--color-surface-alt); }
a.download-link { margin-right: 12px; color: var(--color-accent); text-decoration: none; font-weight: 500; }
a.download-link:hover { text-decoration: underline; }
.generate-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}
.generate-form .field { margin-bottom: 0; flex: 1; }
.generate-form .btn { width: auto; }
.warn-box {
  background: var(--color-warn-bg);
  border: 1px solid var(--color-warn-border);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--color-warn-text);
  margin-bottom: 20px;
  line-height: 1.5;
}
