/* Toolzo Link in Bio — plain CSS, mobile-first. No framework, no webfonts. */

:root {
  --ink: #111827;
  --muted: #4b5563;
  --line: #e5e7eb;
  --bg: #f9fafb;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #b91c1c;
  --radius: 12px;
  --focus: 0 0 0 3px rgba(37, 99, 235, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .25rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem;
  padding: .75rem 1rem;
  background: var(--ink); color: #f9fafb;
}
.brand { display: inline-flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 2rem; height: 2rem; border-radius: .5rem;
  background: #f59e0b; color: #111827; font-weight: 800; font-size: .95rem;
}
.brand-name { font-size: 1.05rem; }
.topbar-tag { margin: 0; font-size: .85rem; color: #d1d5db; }

/* ---------- Layout ---------- */
.layout {
  display: grid; gap: 1.5rem;
  max-width: 1100px; margin: 0 auto; padding: 1rem;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .preview-wrap { position: sticky; top: 1rem; }
}

.builder, .preview-wrap { min-width: 0; }
.lede { color: var(--muted); }

/* ---------- Form ---------- */
fieldset {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: 1rem; margin: 0 0 1rem;
}
legend { font-weight: 700; padding: 0 .4rem; }
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
label { display: block; font-weight: 600; margin-bottom: .3rem; }
.hint { font-size: .85rem; color: var(--muted); margin: .3rem 0 0; }

input[type="text"], input[type="url"], textarea, select {
  width: 100%; padding: .6rem .7rem;
  font: inherit; color: inherit;
  border: 1px solid #d1d5db; border-radius: 8px; background: #fff;
}
textarea { resize: vertical; }
input[type="file"] { font: inherit; max-width: 100%; }

.photo-row { display: flex; gap: .75rem; align-items: flex-start; flex-wrap: wrap; }
.photo-thumb {
  width: 72px; height: 72px; object-fit: cover; border-radius: 50%;
  border: 2px solid var(--line);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: .55rem .9rem;
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--ink);
  text-decoration: none;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-small { padding: .3rem .55rem; font-size: .85rem; }

/* ---------- Themes ---------- */
.theme-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem;
}
.theme-swatch {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem; border: 2px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; font: inherit; text-align: left;
}
.theme-swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: var(--focus); }
.theme-dot { width: 1.4rem; height: 1.4rem; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.15); }

/* ---------- Link editor ---------- */
.count-badge {
  display: inline-block; min-width: 1.4rem; padding: 0 .35rem;
  border-radius: 999px; background: var(--ink); color: #fff;
  font-size: .8rem; text-align: center; vertical-align: middle;
}
.link-editor-list { list-style: none; margin: 0 0 .75rem; padding: 0; }
.link-editor-list li {
  border: 1px solid var(--line); border-radius: 8px;
  padding: .75rem; margin-bottom: .5rem; background: #fff;
}
.link-editor-list .row { display: flex; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.link-editor-list .row:last-child { margin-bottom: 0; }
.link-editor-list label { font-size: .85rem; margin-bottom: .15rem; }
.link-editor-list .grow { flex: 1 1 160px; min-width: 0; }
.link-editor-list .grow input, .link-editor-list .grow select { width: 100%; }
.link-actions { display: flex; gap: .4rem; align-items: end; }

/* ---------- QR ---------- */
.qr-grid { display: grid; gap: 1rem; }
@media (min-width: 560px) { .qr-grid { grid-template-columns: 1fr 1fr; } }
.qr-card { border: 1px solid var(--line); border-radius: 8px; padding: .75rem; text-align: center; }
.qr-box { display: grid; place-items: center; min-height: 160px; margin: .5rem 0; }
.qr-box svg { width: 160px; height: 160px; max-width: 100%; }
.qr-box .qr-empty { color: var(--muted); font-size: .9rem; }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
#save-status { margin-top: .75rem; }

.attribution { font-size: .85rem; color: var(--muted); padding: 0 .25rem; }
.attribution p { margin-bottom: .5rem; }

/* ---------- Phone preview ---------- */
.phone {
  border: 10px solid #111827; border-radius: 36px;
  max-width: 380px; margin: 0 auto; overflow: hidden;
  background: #111827;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.phone-screen { min-height: 560px; padding: 2rem 1.25rem 1.5rem; text-align: center; }
.preview-inner { max-width: 340px; margin: 0 auto; }
.preview-photo {
  width: 96px; height: 96px; object-fit: cover; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.6); margin: 0 auto .75rem; display: block;
}
.preview-photo.fallback {
  display: grid; place-items: center;
  font-size: 2rem; font-weight: 800;
  background: rgba(255,255,255,.2); color: inherit;
}
.preview-name { font-size: 1.35rem; margin: 0 0 .25rem; overflow-wrap: anywhere; }
.preview-bio { font-size: .95rem; opacity: .85; overflow-wrap: anywhere; }
.preview-links { list-style: none; margin: 1.25rem 0; padding: 0; display: grid; gap: .65rem; }
.preview-links a {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1rem; border-radius: 999px;
  font-weight: 700; text-decoration: none;
  transition: transform .12s ease, filter .12s ease;
}
.preview-links a:hover, .preview-links a:focus-visible { transform: translateY(-1px); filter: brightness(1.07); }
.preview-links a:active { transform: translateY(0); }
.preview-links .link-icon { font-size: 1.1rem; line-height: 1; }
.preview-footer { font-size: .8rem; opacity: .6; margin-top: 1.5rem; }

/* Brand button styles (own Toolzo palette, inspired by the link-in-bio idea) */
.btn-brand-default { background: #e5e7eb; color: #111827; }
.btn-brand-whatsapp { background: #25d366; color: #062e16; }
.btn-brand-instagram { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); color: #fff; }
.btn-brand-facebook { background: #1877f2; color: #fff; }
.btn-brand-tiktok { background: #111; color: #fff; }
.btn-brand-youtube { background: #ff0000; color: #fff; }
.btn-brand-phone { background: #059669; color: #fff; }
.btn-brand-email { background: #ea4335; color: #fff; }

/* ---------- Themes (preview) ---------- */
.phone-screen[data-theme="midnight"] { background: linear-gradient(180deg, #111827, #1f2937); color: #f9fafb; }
.phone-screen[data-theme="sunset"]   { background: linear-gradient(180deg, #fb923c, #db2777); color: #fff; }
.phone-screen[data-theme="forest"]   { background: linear-gradient(180deg, #14532d, #166534); color: #f0fdf4; }
.phone-screen[data-theme="ocean"]    { background: linear-gradient(180deg, #0ea5e9, #0369a1); color: #f0f9ff; }
.phone-screen[data-theme="cream"]    { background: #fef3c7; color: #451a03; }
.phone-screen[data-theme="cream"] .preview-photo { border-color: rgba(69,26,3,.35); }
.phone-screen[data-theme="cream"] .preview-photo.fallback { background: rgba(69,26,3,.12); }
.phone-screen[data-theme="mono"]     { background: #fff; color: #111; }
.phone-screen[data-theme="mono"] .preview-links a { border: 2px solid #111; border-radius: 8px; }
.phone-screen[data-theme="mono"] .preview-photo { border-color: #111; }
.phone-screen[data-theme="mono"] .preview-photo.fallback { background: #eee; }

@media (prefers-reduced-motion: reduce) {
  .preview-links a { transition: none; }
}
