: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); }

/* ---------- 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-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--bg); }
.link-item.disabled { opacity: .55; }
.link-item .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.link-item .row + .row { margin-top: 8px; }
.link-item .row input { flex: 1 1 180px; }
.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; }
