/* QES Link Tree: black + metallic gold (QES brand) */
:root {
  --black: #0B0B0C; --panel: #151516; --panel-2: #1C1C1E; --line: rgba(212,163,70,.28);
  --gold-1: #8A5A1C; --gold-2: #D4A346; --gold-3: #F6DFA0; --cream: #F3E9D2; --dim: rgba(243,233,210,.62);
  --gold: linear-gradient(135deg, var(--gold-1) 0%, var(--gold-2) 45%, var(--gold-3) 70%, var(--gold-2) 100%);
  --serif: "Cinzel", Georgia, serif; --ui: "Inter", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--black); color: var(--cream); }
body { font: 400 16px/1.5 var(--ui); -webkit-text-size-adjust: 100%; min-height: 100vh; }
a { color: var(--gold-2); }
button, input { font: inherit; }

/* ---------- public page ---------- */
body.public { background: radial-gradient(80% 50% at 50% 0%, rgba(212,163,70,.14), transparent 70%), var(--black); }
.tree { max-width: 560px; margin: 0 auto; padding: max(48px, env(safe-area-inset-top)) 16px 32px; display: grid; gap: 28px; min-height: 100vh; grid-template-rows: auto 1fr auto; }
.hero { text-align: center; display: grid; justify-items: center; gap: 10px; }
.avatar { width: 112px; height: 112px; border-radius: 50%; padding: 3px; background: var(--gold); box-shadow: 0 10px 40px rgba(212,163,70,.25); display: grid; place-items: center; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--black); }
.avatar.mono span { width: 100%; height: 100%; border-radius: 50%; background: var(--black); display: grid; place-items: center; font: 900 32px var(--serif); letter-spacing: .06em; color: var(--gold-2); }
.avatar.small { width: 72px; height: 72px; }
.avatar.small.mono span { font-size: 20px; }
.name { margin: 6px 0 0; font: 900 clamp(24px, 6vw, 32px)/1.15 var(--serif); letter-spacing: .04em; text-transform: uppercase;
  background: var(--gold); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: 0; font: italic 500 20px/1.3 "Cormorant Garamond", Georgia, serif; color: var(--cream); opacity: .9; }

.links { display: grid; gap: 14px; align-content: start; }
.link { position: relative; display: grid; grid-template-columns: 44px 1fr 20px; align-items: center; gap: 12px; padding: 14px 16px; min-height: 64px;
  border-radius: 16px; text-decoration: none; color: var(--cream); background: var(--panel); border: 1px solid var(--line);
  transition: transform .2s, border-color .2s, background .2s, box-shadow .2s; animation: rise .5s both; animation-delay: calc(var(--i) * 60ms); }
.link:hover, .link:focus-visible { transform: translateY(-2px); border-color: var(--gold-2); background: var(--panel-2); box-shadow: 0 12px 30px rgba(0,0,0,.45), 0 0 0 1px rgba(212,163,70,.25); outline: none; }
.link .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: rgba(212,163,70,.12); color: var(--gold-2); }
.link .ic svg { width: 22px; height: 22px; }
.link .lt { font-weight: 600; font-size: 16px; text-align: center; overflow-wrap: anywhere; }
.link .go { color: var(--gold-2); font-size: 26px; line-height: 1; text-align: right; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .link { animation: none; } }
.empty { text-align: center; color: var(--dim); }
.foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--dim); border-top: 1px solid rgba(243,233,210,.08); padding-top: 16px; }
.owner-link { color: var(--dim); text-decoration: none; }
.owner-link:hover { color: var(--gold-2); }

/* ---------- shared controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--cream); cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn.gold { background: var(--gold); color: #1a1206; border: 0; }
.btn.gold:disabled { opacity: .45; cursor: default; }
.btn.ghost:hover { border-color: var(--gold-2); color: var(--gold-3); }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.card h1, .card h2 { margin: 0 0 6px; font: 700 20px var(--serif); letter-spacing: .04em; color: var(--gold-3); }
.muted { color: var(--dim); font-size: 14px; margin: 0 0 12px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--dim); }
input:not([type=checkbox]):not([type=file]) { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(243,233,210,.16); background: var(--black); color: var(--cream); font-size: 16px; }
input:focus { border-color: var(--gold-2); outline: none; }
.msg { min-height: 1.4em; margin: 0; color: var(--gold-3); font-size: 14px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(70% 50% at 50% 0%, rgba(212,163,70,.12), transparent 70%); }
.login { width: min(400px, 100%); display: grid; gap: 14px; justify-items: stretch; }
.login .avatar { justify-self: center; }
.login h1 { text-align: center; }
.login .muted { text-align: center; }
.back { text-align: center; text-decoration: none; }

/* ---------- editor ---------- */
.bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; background: rgba(11,11,12,.92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font: 900 16px var(--serif); letter-spacing: .08em; color: var(--gold-2); }
.brand span { color: var(--cream); font-weight: 700; }
.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.editor { max-width: 760px; margin: 0 auto; padding: 20px 16px 120px; display: grid; gap: 18px; }
.profile-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.profile-row .avatar { width: 96px; height: 96px; }
.profile-fields { flex: 1 1 260px; display: grid; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.file { color: var(--cream); font-size: 14px; }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.edit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.erow { display: grid; grid-template-columns: 20px 1fr auto auto auto auto; gap: 10px; align-items: center; padding: 10px; border-radius: 14px; background: var(--black); border: 1px solid rgba(243,233,210,.1); }
.erow.dragging { opacity: .5; }
.erow.over { border-color: var(--gold-2); }
.erow.hidden-link .efields { opacity: .5; }
.grip { cursor: grab; color: var(--dim); font-size: 18px; user-select: none; text-align: center; }
.efields { display: grid; gap: 6px; min-width: 0; }
.efields input { min-height: 40px !important; }
.eu { font-size: 14px !important; color: var(--dim) !important; }
.clicks { font-size: 12px; color: var(--dim); white-space: nowrap; }
.switch { position: relative; width: 44px; height: 26px; display: block; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: rgba(243,233,210,.18); transition: background .2s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--cream); transition: transform .2s; }
.switch input:checked + i { background: var(--gold-2); }
.switch input:checked + i::after { transform: translateX(18px); background: #1a1206; }
.switch input:focus-visible + i { outline: 2px solid var(--gold-3); outline-offset: 2px; }
.emove { display: grid; gap: 2px; }
.emove button, .del { border: 1px solid rgba(243,233,210,.14); background: transparent; color: var(--dim); border-radius: 8px; cursor: pointer; width: 32px; height: 20px; font-size: 10px; padding: 0; }
.del { height: 36px; font-size: 14px; }
.del:hover { color: #f0a08a; border-color: #f0a08a; }
.emove button:hover { color: var(--gold-3); border-color: var(--gold-2); }
.pw-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.savebar { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translate(-50%, 140%); z-index: 6; display: flex; gap: 14px; align-items: center;
  padding: 10px 10px 10px 18px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0,0,0,.6); transition: transform .3s; max-width: calc(100% - 32px); }
.savebar.on { transform: translate(-50%, 0); }
.savebar span { font-size: 14px; color: var(--cream); }
@media (max-width: 560px) {
  .erow { grid-template-columns: 18px 1fr auto; grid-template-areas: "g f f" ". c s" ". m d"; }
  .erow .grip { grid-area: g; } .erow .efields { grid-area: f; } .erow .clicks { grid-area: c; } .erow .switch { grid-area: s; justify-self: end; }
  .erow .emove { grid-area: m; display: flex; gap: 6px; } .erow .del { grid-area: d; justify-self: end; height: 30px; }
  .emove button { width: 40px; height: 30px; }
}
