/* Theme palettes. Dark is the default (bare :root); the toggle sets
   data-theme="light" on <html> to switch. All UI colors are variables so both
   themes fall out of these two blocks. */
:root {
  --bg: #0f1115;
  --surface: #181b22;
  --ink: #e7e9f0;
  --muted: #9aa3b2;
  --line: #2a2f3a;
  --brand: #8b8bf5;
  --brand-ink: #ffffff;
  --danger: #f0707a;
  --ok: #3ecf9a;
  --lead: #b8c0cf;
  --code-bg: #232833;
  --input-bg: #12151b;
  --error-bg: #2a1719;
  --error-line: #5a2b30;
  --error-ink: #f2818a;
  --success-bg: #10241c;
  --success-line: #245a43;
  --success-ink: #45d6a0;
  --pill-free-bg: #232833;
  --pill-free-ink: #aab2c0;
  --pill-pro-bg: #241f4a;
  --result-link: #8ab4f8;
  --result-link-visited: #c58af9;
  --result-url: #5bc98a;
  --result-snippet: #b3bccb;
  --admin-note-bg: #2a2410;
  --admin-note-line: #5a4d1e;
  --admin-note-ink: #e3c778;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
}
:root[data-theme="light"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #1c2130;
  --muted: #6b7280;
  --line: #e6e8ef;
  --brand: #5b5bd6;
  --brand-ink: #ffffff;
  --danger: #d64550;
  --ok: #1a936f;
  --lead: #414759;
  --code-bg: #eef0f7;
  --input-bg: #ffffff;
  --error-bg: #fdecee;
  --error-line: #f4c9cd;
  --error-ink: #d64550;
  --success-bg: #e7f6ef;
  --success-line: #bfe6d4;
  --success-ink: #1a936f;
  --pill-free-bg: #eef0f7;
  --pill-free-ink: #55607a;
  --pill-pro-bg: #efe9ff;
  --result-link: #1a0dab;
  --result-link-visited: #6c1ea8;
  --result-url: #006621;
  --result-snippet: #4d5156;
  --admin-note-bg: #fff7e6;
  --admin-note-line: #ffe1a8;
  --admin-note-ink: #8a5a00;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 8px 24px rgba(20, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg); }
body {
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--code-bg); padding: .1em .4em; border-radius: 6px; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* --- app chrome --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.container { max-width: 760px; margin: 0 auto; padding: 32px 20px 64px; }

/* theme toggle — available to every viewer, no login needed */
.theme-toggle {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); cursor: pointer; font-size: 1rem; line-height: 1;
  padding: 6px 9px;
}
.theme-toggle:hover { border-color: var(--brand); }

/* --- buttons --- */
.btn {
  display: inline-block; background: var(--brand); color: var(--brand-ink);
  border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 600;
  cursor: pointer; font-size: 1rem; line-height: 1; text-align: center;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn-sm { padding: 7px 12px; font-size: .88rem; border-radius: 8px; }
.btn-block { width: 100%; padding: 13px; }
.btn-ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--error-line); }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0; }
.inline { display: inline; }

/* --- hero / landing --- */
.hero { text-align: center; padding: 32px 0 12px; }
.hero h1 { font-size: 2.1rem; line-height: 1.15; margin: 0 0 12px; letter-spacing: -.02em; }
.lead { font-size: 1.1rem; color: var(--lead); max-width: 52ch; margin: 0 auto 24px; }
.claim {
  display: flex; align-items: stretch; gap: 8px; max-width: 460px; margin: 0 auto 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; box-shadow: var(--shadow);
}
.claim-prefix { display: flex; align-items: center; padding-left: 10px; color: var(--muted); white-space: nowrap; }
.claim-input { flex: 1; border: 0; outline: none; font-size: 1rem; padding: 8px 6px; background: transparent; color: var(--ink); }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 44px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 6px; font-size: 1rem; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; }

/* --- forms / auth --- */
.auth-card { max-width: 420px; margin: 12px auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.auth-card h1 { margin-top: 0; font-size: 1.5rem; }
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: .95rem; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: var(--ink); background: var(--input-bg);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; }
.slug-field { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; }
.slug-field input { border: 0; }
.slug-field:focus-within { outline: 2px solid var(--brand); outline-offset: 1px; }
.slug-field .claim-prefix { padding: 0; }

.error { background: var(--error-bg); color: var(--error-ink); border: 1px solid var(--error-line); padding: 10px 12px; border-radius: 10px; }
.success { background: var(--success-bg); color: var(--success-ink); border: 1px solid var(--success-line); padding: 10px 12px; border-radius: 10px; }

/* --- dashboard --- */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dash-head h1 { margin: 0; font-size: 1.6rem; }
.pill { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.pill-free { background: var(--pill-free-bg); color: var(--pill-free-ink); }
.pill-pro { background: var(--pill-pro-bg); color: var(--brand); }
.empty { text-align: center; padding: 48px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.page-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.page-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.page-slug { font-weight: 600; }
.page-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-row-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* --- editor --- */
.editor { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.links-editor { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 16px 0; }
.links-editor legend { padding: 0 6px; font-weight: 600; }
.link-pair { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; margin-bottom: 8px; }

/* --- public profile page (uses its own per-page theme, below) --- */
body.public { display: flex; min-height: 100vh; align-items: flex-start; justify-content: center; }
.profile { width: 100%; max-width: 560px; padding: 64px 22px 40px; text-align: center; }
.avatar { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700;
  background: rgba(255, 255, 255, .18); border: 2px solid rgba(255, 255, 255, .35); }
.profile-title { font-size: 1.6rem; margin: 0 0 6px; }
.profile-bio { margin: 0 auto 26px; max-width: 42ch; opacity: .85; }
.links { display: flex; flex-direction: column; gap: 12px; }
.link-button { display: block; padding: 15px 18px; border-radius: 12px; font-weight: 600;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .28); color: inherit; }
.link-button:hover { background: rgba(255, 255, 255, .28); text-decoration: none; transform: translateY(-1px); }
.made-with { margin-top: 34px; font-size: .82rem; opacity: .7; }
.made-with a { color: inherit; }
.redirect-note { display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* admin stats bar on public pages (shown only to admins) */
body.public.has-admin { padding-top: 46px; }
.admin-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  background: #14181f; color: #cbd5e1; font-size: .8rem;
  padding: 8px 14px; border-bottom: 1px solid #2a2f3a; text-align: left; }
.admin-bar a { color: #93c5fd; }
.admin-badge { background: var(--danger); color: #fff; font-weight: 700;
  border-radius: 6px; padding: 1px 7px; font-size: .7rem; letter-spacing: .05em; }

/* theme palettes for public pages (owner-chosen, independent of the site toggle) */
/* keep the themed background covering the whole viewport regardless of content height */
html:has(body.public) { min-height: 100%; }
body.public { background-attachment: fixed; background-repeat: no-repeat; background-size: cover; }
body.theme-default { background: #f6f7fb; color: #1c2130; }
body.theme-default .link-button { background: #fff; border-color: #e6e8ef; box-shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 8px 24px rgba(20, 24, 40, .06); }
body.theme-default .avatar { background: #5b5bd6; color: #fff; border-color: transparent; }
body.theme-midnight { background: radial-gradient(1200px 600px at 50% -10%, #2a2a55, #0d0d1f); color: #ececff; }
body.theme-mint { background: linear-gradient(160deg, #10b981, #0e7490); color: #f0fff8; }
body.theme-sunset { background: linear-gradient(160deg, #ff7e5f, #b5179e); color: #fff5f0; }

/* landing: explore examples strip */
.explore { margin-top: 44px; text-align: center; }
.explore-title {
  font-size: .82rem; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em; margin: 0 0 16px;
}
.explore-links { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.explore-chip {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  text-align: left; background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--brand); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .12s ease;
}
.explore-chip:hover {
  transform: translateY(-2px); text-decoration: none;
  box-shadow: var(--shadow);
}
.explore-name { font-weight: 650; color: var(--ink); font-size: .98rem; }
.explore-slug { font-size: .82rem; color: var(--muted); }
.explore-chip.theme-default { border-left-color: var(--brand); }
.explore-chip.theme-midnight { border-left-color: #4c566a; }
.explore-chip.theme-mint { border-left-color: var(--ok); }
.explore-chip.theme-sunset { border-left-color: #e07a5f; }

/* landing: index of pages (old-style search results) */
.index { margin-top: 48px; text-align: left; }
.index-head { display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.index-title { margin: 0; font-size: 1.1rem; }
.results { list-style: none; padding: 0; margin: 0; }
.result { margin: 0 0 26px; }
.result-title { color: var(--result-link); font-size: 1.2rem; line-height: 1.3; }
.result-title:visited { color: var(--result-link-visited); }
.result-url { color: var(--result-url); font-size: .82rem; margin-top: 2px; word-break: break-all; }
.result-tag { color: var(--muted); background: var(--code-bg); border-radius: 6px;
  padding: 0 6px; font-size: .72rem; margin-left: 4px; }
.result-snippet { margin: 3px 0 0; color: var(--result-snippet); font-size: .92rem; }
.result-links { margin: 3px 0 0; color: var(--muted); font-size: .84rem; }
.result-admin { margin: 5px 0 0; font-size: .78rem; color: var(--admin-note-ink);
  background: var(--admin-note-bg); border: 1px solid var(--admin-note-line); border-radius: 6px;
  padding: 3px 8px; display: inline-block; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.pager-link { display: inline-block; min-width: 34px; text-align: center; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--brand); background: var(--surface); }
.pager-link:hover { text-decoration: none; border-color: var(--brand); }
.pager-current { background: var(--brand); color: var(--brand-ink);
  border-color: var(--brand); font-weight: 700; }

@media (max-width: 560px) {
  .how { grid-template-columns: 1fr; }
  .claim { flex-wrap: wrap; }
  .link-pair { grid-template-columns: 1fr; }
  .dash-head { flex-direction: column; align-items: flex-start; }
  .explore-links { grid-template-columns: repeat(2, 1fr); }
}

/* --- redirect ad interstitial --------------------------------------------- */
body.interstitial { display: flex; min-height: 100vh; align-items: center;
  justify-content: center; background: var(--bg); margin: 0; padding: 24px; }
.interstitial-card { width: 100%; max-width: 760px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px 24px; }
.interstitial-label { letter-spacing: .08em; text-transform: uppercase; }
.ad-slot { margin: 8px auto 18px; min-height: 90px; display: flex;
  align-items: center; justify-content: center; overflow: hidden; }
.ad-slot img { max-width: 100%; height: auto; border-radius: 6px; }
.interstitial-card .continue { color: var(--ink); font-size: 1.02rem; margin: 0 0 16px; }
.interstitial-card .btn { display: inline-block; }

/* --- admin-line hover tooltips -------------------------------------------- */
.result-admin .tip { position: relative; cursor: help; }
.result-admin .tip::after {
  content: attr(data-tip);
  position: absolute; left: 0; bottom: 145%; z-index: 30;
  width: max-content; max-width: 260px;
  padding: 7px 10px; border-radius: 8px;
  background: var(--ink); color: var(--bg);
  font-size: .76rem; font-weight: 500; line-height: 1.4; white-space: normal;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  opacity: 0; visibility: hidden; transform: translateY(4px);
  transition: opacity .12s ease, transform .12s ease; pointer-events: none;
}
.result-admin .tip:hover::after,
.result-admin .tip:focus::after { opacity: 1; visibility: visible; transform: translateY(0); }

/* --- about page ----------------------------------------------------------- */
.about-page { max-width: 640px; }
.about-page h2 { margin-top: 24px; }
.plans { width: 100%; border-collapse: collapse; margin: 12px 0; }
.plans th, .plans td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.plans thead th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.plans td:first-child { color: var(--muted); }
