/* ===============================
   Theme tokens (dark + light)
   =============================== */
:root {
  --bg:#0d0d0d; --card:#1a1a1a; --text:#fff; --muted:#c7c7c7;
  --accent:#34d399; --btn:#2a2a2a; --btn-hover:#3a3a3a;
  --focus:#f59e0b; --border:rgba(255,255,255,.12);
}
@media (prefers-color-scheme: light){
  :root {
    --bg:#f8fafc; --card:#fff; --text:#0b0f19; --muted:#475569;
    --btn:#f1f5f9; --btn-hover:#e2e8f0; --border:rgba(2,6,23,.12);
  }
}
html{scroll-behavior:smooth}
body{background:var(--bg);color:var(--text);margin:0}

/* ===============================
   A11y helpers
   =============================== */
.sr-only,.visually-hidden{
  position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;border:0;
  white-space:nowrap;              /* prevents accidental line wrap */
  clip-path: inset(50%);           /* modern replacement */
}
.skip-link{position:absolute;left:-9999px}
.skip-link:focus{position:static;padding:.5rem 1rem;background:#000;color:#fff}

/* ===============================
   Header / Nav
   =============================== */
.site-header{
  position:sticky;top:0;z-index:50;background:var(--card);
  border-bottom:1px solid var(--border);backdrop-filter:saturate(140%) blur(6px);
}
.header-inner{
  display:flex;align-items:center;justify-content:space-between;gap:1rem;
  padding:.75rem 1.25rem;max-width:1100px;margin:0 auto;
}
.logo{height:40px;width:auto;display:block}

/* Primary nav */
.nav-links ul{display:flex;align-items:center;gap:1rem;list-style:none;margin:0;padding:0}
.nav-links a{
  text-decoration:none;color:var(--text);font-weight:600;padding:.4rem .7rem;border-radius:.6rem;
  transition:background .15s ease, opacity .15s ease;
}
.nav-links a:hover{background:var(--btn)}
.nav-links a[aria-current="page"]{outline:2px solid var(--border)}

/* Mobile toggle */
/* Mobile toggle */
.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--card);
  align-items: center;
  justify-content: center;
  flex-direction: column;      /* 👈 stack bars vertically */
  gap: 4px;                    /* space between bars */
  padding: 0;
  cursor: pointer;             /* optional: makes it clickable */
}

.nav-toggle .bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;          /* smoother ends */
  transition: all 0.3s ease;   /* optional: smooth animation */
}

@media (max-width: 768px) {
  .nav-toggle {
    display: inline-flex;      /* 👈 shows toggle only on mobile */
  }

  .nav-links {
    position: absolute;
    right: 1.25rem;
    top: 64px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
    padding: 0.5rem;
    display: none;
  }

  .nav-links.open {
    display: block;
  }

  .nav-links ul {
    display: grid;
    gap: 0.25rem;
  }

  .nav-links a {
    display: block;
  }
}


/* =========================================
   Shared Button Styles
   ========================================= */

/* Base button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center; /* centers text */
  gap: .35rem;
  padding: .6rem 1.5rem;
  border-radius: .75rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}

.btn:hover {
  background: rgba(255,255,255,.06);
}

/* Green primary button (Sign In, Create Account) */
.btn.primary {
  background: var(--accent);
  border: none;
  color: #0b0f19;
}

.btn.primary:hover {
  background: #2ec08d; /* slightly darker green */
}

/* Grey secondary button (Register, Cancel) */
.btn.secondary {
  background: #e2e8f0;
  border: none;
  color: #0b0f19;
}

.btn.secondary:hover {
  background: #cbd5e1; /* darker grey on hover */
}


/* ===============================
   Forms (global)
   =============================== */
form input[type="text"],
form input[type="url"],
form input[type="number"],
form input[type="password"],
form input[type="file"],
form textarea{
  width:100%; box-sizing: border-box; max-width: 100%; padding:.6rem .75rem;border-radius:.75rem;border:1px solid var(--border);
  background:var(--card);color:var(--text);
}

/* Index (login) – white inputs for clarity */
body.index-page form input[type="text"],
body.index-page form input[type="password"]{
  background:#fff;color:#0b0f19;border:1px solid var(--border);
}

/* ===============================
   Index (login) layout
   =============================== */
.links-page{max-width:880px;margin:2rem auto;padding:0 1rem;display:grid;gap:1rem}
body.index-page .login-page{max-width:400px;margin:4rem auto;text-align:center}
body.index-page #welcome-title{margin-bottom:1.5rem}
body.index-page form{display:grid;gap:1rem;text-align:left;margin:0 auto}
body.index-page form .form-row, 
body.index-page form > div{display:grid;gap:.4rem}
body.index-page .login-button-wrap{display:flex;justify-content:center;margin-top:1.2rem}

/* Center "New here?" label and Register button on index page */
body.index-page .new-here {
  text-align: center;
  margin-top: 1rem;        /* add some spacing above */
}

body.index-page .new-here label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;   /* small gap before the button */
  color: var(--text);      /* consistent text color */
}

body.index-page .new-here .login-button-wrap {
  justify-content: center; /* centers the Register button */
}


/* ===============================
   Modal (register)
   =============================== */
.modal[hidden], .modal-backdrop[hidden]{display:none !important} /* ensure hidden means hidden */
.modal-backdrop{
  position:fixed;top:0;right:0;bottom:0;left:0;background:rgba(0,0,0,.55);
  backdrop-filter:blur(2px);z-index:9998;
}
.modal{
  position:fixed;top:0;right:0;bottom:0;left:0;display:grid;place-items:center;z-index:9999;
}
.modal-card{
  width:min(92vw,480px);background:var(--card);color:var(--text);
  border:1px solid var(--border);border-radius:1rem;padding:1rem;
  box-shadow:0 20px 50px rgba(0,0,0,.4);display:grid;gap:.75rem;
}
.modal-head{
  position:relative;display:flex;align-items:center;justify-content:center;
  padding-top:.5rem;margin-bottom:.5rem;
}
.modal-head .close-btn{ /* “X” in top-right */
  position:absolute;top:.5rem;right:.75rem;background:transparent;border:none;
  color:var(--muted);font-size:1.4rem;line-height:1;cursor:pointer;
}
.modal-head .close-btn:hover{color:var(--text)}
.modal-foot{display:grid;gap:.5rem} /* stack Create + Cancel vertically */

/* ===============================
   Profile (public)
   =============================== */
.profile{max-width:640px;margin:2rem auto;padding:1rem;display:grid;gap:1.5rem}
.profile-header{text-align:center;display:grid;gap:.5rem}
.avatar-wrap{display:flex;justify-content:center}
.avatar{
  width:128px;height:128px;border-radius:50%;object-fit:cover;object-position:center;
  border:4px solid var(--card);box-shadow:0 10px 30px rgba(0,0,0,.25);display:block;
}
.display-name{font-size:clamp(1.4rem,2.5vw,2rem);margin:.25rem 0 0}
.handle{color:var(--muted);margin:0}
.bio{margin:.5rem auto 0;color:var(--muted);max-width:50ch}
.actions{display:flex;gap:.75rem;justify-content:center;margin-top:.5rem;flex-wrap:wrap}
.link-list{list-style:none;padding:0;margin:0;display:grid;gap:.9rem}
.link-btn{
  display:flex;justify-content:space-between;align-items:center;width:100%;
  text-decoration:none;padding:1rem 1.1rem;border-radius:1rem;background:var(--card);
  border:1px solid rgba(255,255,255,.08);box-shadow:0 8px 16px rgba(0,0,0,.15);
  transition:transform .12s ease, box-shadow .12s ease;
}
.link-btn:hover{transform:translateY(-1px);box-shadow:0 10px 20px rgba(0,0,0,.25)}

/* ===============================
   Editor (dashboard) essentials
   =============================== */
.page-header{display:grid;gap:.5rem}
.alerts{display:grid;gap:.5rem}
.alert{border:1px solid var(--border);padding:.75rem .9rem;border-radius:.75rem;background:var(--card)}

/* Messages: variant styles for Django tags */
.alert.success {
  border-color: #16a34a1f;            /* subtle green border */
  background: rgba(22, 163, 74, .12); /* green tint */
  color: #16a34a;                     /* readable on both themes */
}

.alert.info {
  border-color: #2563eb1f;
  background: rgba(37, 99, 235, .12);
  color: #2563eb;
}

.alert.warning {
  border-color: #f59e0b1f;
  background: rgba(245, 158, 11, .14);
  color: #b45309;
}

.alert.error {
  border-color: #b91c1c1f;
  background: rgba(185, 28, 28, .12);
  color: #b91c1c;
}

/* Optional: links inside messages */
.alert a {
  font-weight: 600;
  text-decoration: underline;
  color: inherit;
}

/* Optional: spacing so banners don’t hug the edges on small screens */
.alerts {
  margin: 0 1rem 1rem;
}
@media (min-width: 768px) {
  .alerts { margin: 0 auto 1rem; max-width: 800px; }
}

.editor-grid{display:grid;gap:1rem;grid-template-columns:1.1fr 1.4fr 1fr}
@media (max-width:1024px){.editor-grid{grid-template-columns:1fr}}
.card{
  background:var(--card);border:1px solid var(--border);border-radius:1rem;
  padding:1rem;display:grid;gap:.75rem;
}
.card-head{display:flex;align-items:baseline;justify-content:space-between;gap:.5rem}
.card-foot{display:flex;justify-content:flex-end}
.link-list.editable .row{
  display:grid;grid-template-columns:44px 1fr auto;align-items:center;gap:.75rem;padding:.8rem;
  border-radius:1rem;background:var(--card);border:1px solid var(--border);
  transition:box-shadow .12s ease, transform .12s ease;
}
.link-list.editable .row:hover{box-shadow:0 8px 16px rgba(0,0,0,.18);transform:translateY(-1px)}
.row:focus-visible{outline:3px solid var(--focus);outline-offset:3px}

/* ===============================
   Motion & small-screen tweaks
   =============================== */
@media (max-width:640px){
  .link-list.editable .row{grid-template-columns:32px 1fr}
  .actions{grid-column:1 / -1;justify-content:center}
}

@media (prefers-reduced-motion: reduce){
  *{transition:none !important;animation:none !important}
}

@media (max-width: 480px) {
  .card-foot {
    flex-direction: column !important;
  }
  .card-foot .btn {
    width: 100% !important;
  }
}
/* --- overrides to match global button + background styles --- */

/* give breathing room after the last link */
.links { margin-bottom: 1.0rem; }

@media (max-width: 600px) {
  .links
 {
    padding: 3rem;
  }
}

/* toolbar matches site background and isn’t sticky */
.toolbar {
  position: static;                 /* no sticky bar */
  background: transparent;          /* same as site background */
  backdrop-filter: none;
  border-top: none;
  padding: 0;                       /* rely on button padding */
  margin-top: 1.5rem;               /* space above the buttons */
  display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap;
}

/* Editor toolbar – match page background */
.profile-shell .toolbar {
  background: var(--bg);      /* same as body background */
  position: static;           /* not sticky */
  backdrop-filter: none;
  border-top: none;
  padding: 0;
  margin-top: 1.5rem;         /* space above buttons */
}

/* ===== edit icon styling ===== */
.editable-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.edit-icon {
  width: 16px;
  height: 16px;
  opacity: .45;
  flex: 0 0 auto;
  transition: opacity .15s ease;
}

/* show pencil on hover/focus or when the field has value */
.editable-wrap:hover .edit-icon,
.editable-wrap:focus-within .edit-icon {
  opacity: .9;
}

/* contenteditable needs inline-block to sit with the icon */
.bio-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ===== avatar pencil badge ===== */
.avatar-pencil {
  width: 128px; height: 128px; margin: 0 auto 1rem; position: relative;
}

.avatar-edit-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  opacity: .9;
  pointer-events: none; /* clicks go to the file input beneath */
}

.avatar-edit-badge svg { width: 16px; height: 16px; opacity: .7; }

/* pop a little on hover */
.avatar-wrap:hover .avatar-edit-badge { opacity: 1; }

.login-status-container {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 1rem;
}

.login-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.login-status .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: grey;
}

.login-status.logged-in .dot {
  background-color: #2ecc71; /* green */
}

.login-status.logged-out .dot {
  background-color: #e74c3c; /* red */
}

    .tagline {
      font-size: clamp(0.95rem, 1.6vw, 1.05rem); /* smaller */
      font-weight: 400;                           /* not bold */
      line-height: 1.5;
      color: #6b7280;                             /* softer gray */
      margin: .4rem 0 1rem;
      max-width: 72ch;
    }
    .login-button-wrap { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; flex-wrap: wrap; }

  /* ===============================
   Error Pages (403 / 404 / 500)
   =============================== */

/* Container & layout */
.nf-shell {
  max-width: 640px;
  margin: 3rem auto;
  padding: 1.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 80vh; /* vertical centering */
}

/* Card */
.nf-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
}

/* Typography */
.nf-title {
  font-size: clamp(1.6rem, 2.8vw, 2.2rem);
  margin-bottom: 0.75rem;
}

.nf-text {
  color: var(--muted);
  margin-bottom: 1.25rem;
}

/* CTA group */
.cta {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* Improve button focus visibility (keeps your existing btn styles) */
.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* 404 “Jump to @handle” form */
.jump {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.jump input {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 0.6rem;
  min-width: 240px;
}

.jump input::placeholder {
  color: var(--muted);
}

/* ===== Login page (clean overrides) ===== */
body.index-page .login-page {
  max-width: 520px;       /* override older 400px */
  margin: 0 auto;         /* override older 4rem auto */
  padding: 2rem 1rem 3rem;
  text-align: center;
}

/* Tighten heading in card header */
.card-head h1 { margin: 0; }

/* Error message block for login failures */
.alert-error {
  color: #b91c1c;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: rgba(185, 28, 28, .10);
}

/* ===============================
   Profile Links Editor (dashboard)
   =============================== */

/* Shell */
.profile-shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 2rem 1rem 6rem;
  text-align: center;
}

/* Avatar container (scoped so it doesn't affect public profile) */
.profile-shell .avatar-wrap {
  width: 128px;
  height: 128px;
  margin: 0 auto 1rem;
  position: relative;
}
.profile-shell .avatar-wrap img {
  width: 128px;
  height: 128px;
  border-radius: 9999px;
  object-fit: cover;
}
.profile-shell .avatar-wrap input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Editable inputs / areas */
.editable-text {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  width: 100%;
  font: inherit;
  color: inherit;
  outline: none;
}
.editable-text:focus { outline: 2px dashed #9ca3af; outline-offset: 2px; }
.editable-area[contenteditable="true"]:focus { outline: 2px dashed #9ca3af; outline-offset: 2px; }

/* Placeholder for empty contenteditable bios */
.editable-area[data-empty="true"]::before {
  content: attr(data-placeholder);
  color: #9ca3af;
  pointer-events: none;
}

/* Page-specific tweaks moved from inline styles */
.profile-shell h1 { margin-top: 0.75rem; }
.profile-shell h1 .editable-text { text-align: center; }

/* Handle row */
.profile-shell .handle {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: .25rem;
  font-size: .95rem;
  color: var(--muted);
}
.profile-shell .handle .editable-text {
  text-align: center;
  width: auto;
  min-width: 6ch;
  padding: 0;
  margin: 0;
  line-height: 1;
}

/* Links list + cards */
.links { display: grid; gap: 10px; margin-top: 1.5rem; }
.link-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--card);
}
.link-guts { display: grid; gap: 6px; text-align: left; }
.link-title { font-weight: 600; }
.link-url { font-size: .9rem; color: var(--muted); word-break: break-all; }

/* Actions */
.link-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: #0b0f19;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.icon-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Drag handle helper */
.drag { cursor: grab; user-select: none; font-size: 18px; }
.drag:active { cursor: grabbing; }

/* Utilities used by the template */
.hidden { display: none !important; }
.text-red-500 { color: #ef4444; }
.text-sm { font-size: 0.875rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.muted { color: var(--muted); } /* used by <small class="muted">Edited</small> */

/* ===============================
   Public Profile (profile_detail)
   =============================== */

/* Round, pill-style action buttons */
.copy-btn,
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .9rem;
  border-radius: 9999px;
  background: var(--btn);
  color: var(--text);
  border: 1px solid transparent;
  font: inherit;
  text-decoration: none;
}
.copy-btn:hover,
.share-btn:hover {
  background: var(--btn-hover);
}

/* Focus ring for interactive elements not using .btn */
.copy-btn:focus-visible,
.share-btn:focus-visible,
.link-btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Small top spacing for the public profile links block only */
article.profile nav.links { margin-top: .25rem; }

/* Icon sizes used in buttons/links */
.icon { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }
.icon.external { opacity: .8; }

/* Footer brand link style */
.profile-footer { text-align: center; margin-bottom: .5rem; }
.brand { color: var(--muted); text-decoration: none; }
.brand:hover { text-decoration: underline; }

/* Optional placeholder avatar style (fixes a typo from inline rules) */
.avatar.placeholder {
  width: 128px;
  height: 128px;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  font-size: 4rem;
  font-weight: 700;
  background: var(--btn);
  color: var(--muted);
}

/* Make inline <svg class="edit-icon"> visible in dark mode */
.edit-icon {
  fill: var(--muted);     /* works with <use> content */
  color: var(--muted);    /* for safety if you prefer currentColor */
  opacity: .6;            /* a touch more visible than .45 */
}

/* On hover/focus, pop a bit */
.editable-wrap:hover .edit-icon,
.editable-wrap:focus-within .edit-icon,
.bio-wrap:hover .edit-icon,
.bio-wrap:focus-within .edit-icon {
  fill: var(--text);
  color: var(--text);
  opacity: .95;
}

/* Make all inline icons follow the surrounding text color */
.icon,
.icon * {
  fill: currentColor;   /* use the element's color for SVG fill */
}

/* Ensure the surrounding elements provide the right color */
.copy-btn,
.share-btn,
.link-btn {
  color: var(--text);   /* already set for buttons, add for link-btn just in case */
}

/* Optional: a little hover pop */
.copy-btn:hover .icon,
.share-btn:hover .icon,
.link-btn:hover .icon {
  opacity: .95;
}

/* Bio contenteditable should behave like a textarea */
.bio.editable-area[contenteditable="true"] {
  white-space: pre-wrap;   /* keep line breaks */
  min-height: 6.5rem;      /* similar to rows="6" */
  text-align: left;        /* better for multi-line text */
}

/* If using Alpine’s x-cloak anywhere */
[x-cloak] { display: none !important; }

/* === Unified white “input-like” surfaces for editable fields === */

/* Base surface used by display name, handle, and bio */
.editable-surface {
  background: #ffffff;          /* crisp white in both themes */
  color: #0b0f19;               /* readable on white */
  border: 1px solid #e5e7eb;    /* subtle gray border */
  border-radius: .75rem;
  padding: .6rem .75rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.03) inset;
}

/* Keep existing layout behavior for the input wrappers */
.editable-wrap.editable-surface {
  display: flex;
  align-items: center;
  gap: 6px;                     /* space for the pencil icon */
  width: 100%;
}

/* Make the input fill the surface and remove its own bg/border */
.editable-surface .editable-text {
  background: transparent;
  border: 0;
  width: 100%;
  color: inherit;
}

/* Focus ring consistent with your buttons/links */
.editable-surface:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Bio contenteditable should behave like a textarea on the same surface */
.bio.editable-surface[contenteditable="true"] {
  display: block;               /* so it can grow full width */
  white-space: pre-wrap;        /* preserve line breaks */
  min-height: 6.5rem;           /* similar to rows="6" */
  text-align: left;
}

/* Placeholder color on white surface (uses your data-empty helper) */
.editable-area[data-empty="true"]::before {
  color: #9ca3af;               /* readable on white */
}

/* Tweak the inline pencil so it sits nicely on the surface */
.editable-wrap.editable-surface .edit-icon,
.bio-wrap .edit-icon {
  flex: 0 0 auto;
  opacity: .65;
}
.editable-wrap.editable-surface:hover .edit-icon,
.editable-wrap.editable-surface:focus-within .edit-icon,
.bio-wrap:hover .edit-icon,
.bio-wrap:focus-within .edit-icon {
  opacity: .95;
}

/* ===============================
   Uniform width for all editors
   =============================== */

/* Single source of truth for editor width */
:root { --editor-width: 520px; }

/* Row wrapper that constrains width and centers each editor block */
.editor-row {
  width: min(100%, var(--editor-width));
  margin-inline: auto;
  margin-bottom: 12px;
}

/* Make all editable “surfaces” fill the row width */
.editor-surface,
.editor-surface-block,
.editor-row .editable-surface {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

/* Bio surface is a block container (text area style) */
.editor-surface-block {
  display: block;
  width: 100%;
}

/* Keep the bio’s contenteditable full-width within its surface */
.editor-surface-block .editable-surface,
.bio.editable-surface[contenteditable="true"] {
  width: 100%;
  box-sizing: border-box;
}

/* Handle row: bring @ inside and space it nicely */
.prefix-at {
  color: #6b7280;
  font-weight: 600;
  margin-right: 6px;
}

/* Make the <h1> wrapper not influence width */
.editor-title {
  margin: 0;
  font: inherit;
}

/* Make link groups the same width as editors */
.editor-row .links,
.editor-row .link-card {
  width: 100%;
  box-sizing: border-box;
  margin-left: auto;
  margin-right: auto;
}

/* On small screens your .links had extra padding; remove so widths match */
.profile-shell .links { padding: 0 !important; }

/* Ensure inline “editable” inputs don’t shrink the surface */
.editor-row .editable-text {
  min-width: 0;   /* allow flex children to shrink properly */
  width: 100%;
}

/* Keep the existing white surface look for all editor surfaces */
.editor-surface,
.editor-surface-block .editable-surface {
  background: #ffffff;
  color: #0b0f19;
  border: 1px solid #e5e7eb;
  border-radius: .75rem;
  padding: .6rem .75rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.03) inset;
}

/* Focus ring */
.editor-surface:focus-within,
.editor-surface-block .editable-surface:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Bio behavior */
.bio.editable-surface[contenteditable="true"] {
  white-space: pre-wrap;
  min-height: 6.5rem;
  text-align: left;
}

/* Placeholder tone on white */
.editable-area[data-empty="true"]::before { color: #9ca3af; }

/* Make the bio surface behave exactly like the other editors */
.editor-bio {
  display: flex;
  align-items: flex-start;   /* so multi-line bio aligns to top */
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

/* Bio content fills the surface width, preserves line breaks */
.editor-bio .editable-area {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  min-height: 6.5rem;
  text-align: left;
  background: transparent;   /* surface bg is on the parent */
  border: 0;
  padding: 0;
}

/* Keep the pencil neatly aligned inside the surface */
.editor-bio .edit-icon {
  align-self: flex-start;
  opacity: .65;
}

/* Neutralize older bio-wrap styles if any remain in the cascade */
.bio-wrap { display: block; width: 100%; }

/* === Fix overflow/length on Display Name + Handle editors === */

/* Make the heading row behave like a normal block container */
.editor-title {
  margin: 0;
  width: 100%;
  display: block;
}

/* Clamp the white surfaces to the row width and prevent horizontal overflow */
.editor-title .editor-surface,
.editor-row > .editor-surface {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;          /* stops the surface from spilling to the right */
}

/* Inputs inside the flex surface must be allowed to shrink */
.editor-row .editable-text {
  min-width: 0;              /* critical for flex children to shrink */
  width: 100%;
}

/* If a ridiculously long word/handle is typed, allow breaking instead of pushing the surface wider */
.editor-row .editable-text,
.editor-row .editable-text::placeholder {
  overflow-wrap: anywhere;   /* modern */
  word-break: normal;        /* avoid nonstandard 'break-word' */
}

/* Keep the inline pencil and the '@' from forcing extra width */
.editor-row .edit-icon { flex: 0 0 auto; }
.prefix-at { flex: 0 0 auto; }

/* === Center text inside handle editor === */

/* Center the handle text and placeholder */
.editor-row [name="handle"].editable-text {
  text-align: center;
}

/* Keep @ prefix visually close and centered */
.editor-row .prefix-at {
  display: inline-block;
  text-align: right;
  min-width: 1ch;
  padding-right: 2px;
  color: #6b7280;
  font-weight: 600;
}

/* Align the overall handle editor content centrally */
.editor-row .editor-surface {
  justify-content: center;
}