:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1c1b19;
  --muted: #6b6860;
  --border: #e3e0d8;
  --accent: #2f5bea;
  --accent-text: #ffffff;
  --danger: #c43d2f;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }

.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
.narrow { max-width: 420px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stack > * + * { margin-top: 12px; }

label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 4px; }
input, textarea, select {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 72px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  border-radius: 8px; padding: 10px 16px; background: var(--accent); color: var(--accent-text);
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { opacity: .6; cursor: default; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-sm { padding: 6px 10px; font-size: .875rem; }
.full { width: 100%; }

.tabs { display: flex; gap: 4px; background: var(--border); padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.tabs button { flex: 1; background: transparent; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--text); }

.password-field { position: relative; }
.password-field input { padding-right: 44px; }
.eye-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 36px; height: 36px; padding: 0; background: transparent; color: var(--muted); border-radius: 6px;
}
.eye-toggle:hover { color: var(--text); }
.eye-toggle:focus-visible { outline: 2px solid var(--accent); }
.eye-toggle .eye-closed, .eye-toggle[aria-pressed="true"] .eye-open { display: none; }
.eye-toggle[aria-pressed="true"] .eye-closed { display: block; }

.msg { font-size: .875rem; min-height: 1.25em; }
.msg.error { color: var(--danger); }
.msg.ok { color: #2e7d4f; }

.hero { text-align: center; padding: 32px 0 24px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }

/* ---------- landing ---------- */
.landing {
  max-width: 1040px; min-height: calc(100vh - 120px); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 420px);
  gap: 56px; align-items: center; padding-top: 48px;
}
@media (max-width: 860px) {
  .landing { grid-template-columns: minmax(0, 1fr); gap: 32px; min-height: 0; padding-top: 24px; }
  .landing-intro { text-align: center; }
  .perks { display: inline-block; text-align: left; }
}
.landing-intro h1 { font-size: clamp(1.8rem, 4.2vw, 2.6rem); margin: 24px 0 8px; }
.landing-intro > p { font-size: 1.05rem; margin: 0 0 16px; }
.hero-art { width: 100%; aspect-ratio: 16 / 10; border-radius: 20px; object-fit: cover; display: block; }
.hero-art.placeholder {
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 600;
  border: 2px dashed var(--border); background: repeating-linear-gradient(45deg, transparent 0 14px, rgba(0,0,0,.025) 14px 28px);
}
@media (max-width: 860px) { .hero-art { max-height: 220px; } }
.perks { list-style: none; padding: 0; margin: 0; }
.perks li { padding-left: 26px; position: relative; margin: 6px 0; }
.perks li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.brand-title { text-align: center; font-size: 1.4rem; margin-bottom: 16px; }

/* ---------- footer & content pages ---------- */
.site-footer { text-align: center; padding: 24px 16px 40px; font-size: .875rem; color: var(--muted); }
.site-footer nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 8px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }
.site-footer p { margin: 0; }

.doc { max-width: 720px; }
.doc h1 { font-size: 2rem; margin-top: 8px; }
.doc h2 { font-size: 1.2rem; margin: 28px 0 8px; }
.doc p, .doc li { color: #3a3833; }
.doc ul { padding-left: 20px; }
.contact-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.contact-option { display: flex; align-items: center; gap: 12px; padding: 16px; text-decoration: none; color: var(--text); }
.contact-option:hover { border-color: var(--accent); }
.contact-option .icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.contact-option strong { display: block; }

/* ---------- dashboard ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 800px) { .editor { grid-template-columns: minmax(0, 1fr); } }
.preview-wrap { position: sticky; top: 16px; }
.phone { border: 1px solid var(--border); border-radius: 28px; overflow: hidden; height: 600px; overflow-y: auto; }

.link-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.link-list:empty { display: none; }
.link-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); flex-wrap: wrap; }
.link-row + .link-row { border-top: 1px solid var(--border); }
.link-row.disabled .link-info { opacity: .5; }
.link-info { flex: 1 1 200px; min-width: 0; }
.link-title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.link-title .badge-18 { margin-left: 0; }
.link-url { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-actions { display: flex; align-items: center; gap: 6px; }
.link-actions .btn-sm { padding: 6px 10px; }
.tag-hidden { font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--border); color: var(--muted); }

/* on/off switch built from a checkbox */
.switch {
  appearance: none; -webkit-appearance: none; width: 38px; height: 22px; padding: 0; margin: 0 4px 0 0; flex: none;
  border: none; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.toggle { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; margin: 0; }
.toggle input { width: auto; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border-radius: 999px; font-weight: 500; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.share { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share code { background: var(--bg); padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); word-break: break-all; }

/* ---------- public profile (also used by the preview) ---------- */
.bio-page {
  --p-bg: #f6f5f2; --p-text: #1c1b19; --p-muted: #6b6860;
  --p-btn: #ffffff; --p-btn-text: #1c1b19; --p-btn-border: #e3e0d8;
  background: var(--p-bg); color: var(--p-text); min-height: 100%;
  padding: 48px 16px; display: flex; flex-direction: column; align-items: center; text-align: center;
}
.bio-page[data-theme="dark"]   { --p-bg: #141414; --p-text: #f2f2f2; --p-muted: #a3a3a3; --p-btn: #242424; --p-btn-text: #f2f2f2; --p-btn-border: #333; }
.bio-page[data-theme="sunset"] { --p-bg: linear-gradient(160deg, #ff9a6b, #e8508a 60%, #7b3fa0); --p-text: #fff; --p-muted: #ffe6f0; --p-btn: rgba(255,255,255,.18); --p-btn-text: #fff; --p-btn-border: rgba(255,255,255,.45); }
.bio-page[data-theme="ocean"]  { --p-bg: linear-gradient(170deg, #0f4c75, #1b7a9e 55%, #3fc1c9); --p-text: #fff; --p-muted: #d6f3f6; --p-btn: rgba(255,255,255,.15); --p-btn-text: #fff; --p-btn-border: rgba(255,255,255,.4); }
.bio-page[data-theme="forest"] { --p-bg: #1f3a2e; --p-text: #f1efe6; --p-muted: #c3cdb9; --p-btn: #f1efe6; --p-btn-text: #1f3a2e; --p-btn-border: #f1efe6; }

.bio-inner { width: 100%; max-width: 560px; }
.avatar {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin: 0 auto 16px; display: flex;
  align-items: center; justify-content: center; font-size: 2.2rem; font-weight: 700;
  background: var(--p-btn); color: var(--p-btn-text); border: 1px solid var(--p-btn-border);
}
.bio-name { font-size: 1.4rem; margin-bottom: 4px; }
.bio-text { color: var(--p-muted); margin: 0 0 28px; white-space: pre-line; }
.bio-links { display: flex; flex-direction: column; gap: 12px; }
.bio-link {
  display: block; padding: 16px; border-radius: 14px; text-decoration: none; font-weight: 600;
  background: var(--p-btn); color: var(--p-btn-text); border: 1px solid var(--p-btn-border);
  transition: transform .12s ease; overflow-wrap: anywhere;
}
.bio-link:hover { transform: translateY(-2px); }
.bio-foot { margin-top: 40px; font-size: .8rem; color: var(--p-muted); }
.bio-foot a { color: inherit; }
.bio-page.has-cover { padding-top: 0; }
.bio-cover { width: calc(100% + 32px); margin: 0 -16px; max-width: none; height: clamp(140px, 28vw, 240px); overflow: hidden; }
.bio-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.has-cover .avatar { margin-top: -48px; position: relative; border: 4px solid var(--p-btn); box-sizing: content-box; }
.badge-18 {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  vertical-align: middle; background: #c43d2f; color: #fff;
}

.age-gate {
  border: none; border-radius: 16px; padding: 24px; max-width: 360px; width: calc(100% - 32px);
  background: var(--surface); color: var(--text); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.age-gate::backdrop { background: rgba(0,0,0,.6); }
.age-gate p { color: var(--muted); margin: 0 0 20px; }
.age-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.age-actions button { flex: 1 1 140px; }

/* dashboard add-link dialog */
.modal {
  border: none; border-radius: 16px; padding: 24px; max-width: 440px; width: calc(100% - 32px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.modal::backdrop { background: rgba(0,0,0,.5); }
.modal h2 { margin: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* dashboard image pickers */
.image-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.avatar-thumb { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--bg); border: 1px solid var(--border); flex: none; }
.cover-thumb { width: 100%; aspect-ratio: 3 / 1; border-radius: 10px; object-fit: cover; background: var(--bg); border: 1px dashed var(--border); display: block; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

body.profile { background: #141414; }
body.profile .bio-page { min-height: 100vh; }

/* dashboard autosave status */
.save-status {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  background: var(--text); color: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
@media (min-width: 801px) { .save-status { left: auto; right: 24px; transform: none; } }
.save-status.saved { background: #2e7d4f; color: #fff; }
.save-status.error { background: var(--danger); color: #fff; border-radius: 14px; }
.save-status .btn-sm { background: #fff; color: var(--danger); padding: 4px 10px; }
