/* Light, modern white & gray theme */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e4e6eb;
  --border-strong: #d3d6dd;
  --text: #16181d;
  --text-2: #5b606b;
  --text-3: #8b909a;
  --accent: #1f2329;
  --accent-text: #ffffff;
  --danger: #d93a3a;
  --ok: #1f9d55;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, .04), 0 16px 40px rgba(16, 24, 40, .10);
  --font: 'Inter', 'IBM Plex Sans Arabic', 'Noto Sans Armenian', 'Noto Sans Georgian', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: inherit; }
h1 { font-size: 24px; margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; letter-spacing: -.005em; }
.muted { color: var(--text-2); }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
.grow { flex: 1; min-width: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: #33373f; border-color: #33373f; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field.inline { margin: 0; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s; min-height: 42px;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #9aa0ab; box-shadow: 0 0 0 4px rgba(31, 35, 41, .07); }
input[type=range] { padding: 0; border: 0; min-height: 0; accent-color: var(--accent); background: transparent; box-shadow: none; }
input[type=color] { padding: 4px; width: 56px; height: 42px; cursor: pointer; }
.lang-select { width: auto; min-height: 36px; padding: 6px 10px; border-radius: 10px; font-size: 13px; background: var(--surface); }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: rgba(255, 255, 255, .8); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; font-size: 17px; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; transform: rotate(90deg); }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav form { margin: 0; }
[dir=rtl] .topnav .fa-arrow-right-from-bracket { transform: scaleX(-1); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.alert { background: #fdecec; color: #a32020; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.notice { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; color: var(--text-2); }
.notice textarea { margin-top: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

/* Home / auth */
.hero { min-height: calc(100vh - 62px); display: grid; place-items: center; padding: 24px 16px; }
.hero-card { max-width: 560px; text-align: center; }
.hero-card h1 { font-size: clamp(30px, 6vw, 46px); line-height: 1.1; margin: 18px 0 14px; letter-spacing: -.02em; }
.hero-card p { color: var(--text-2); font-size: 17px; margin: 0 0 28px; }
.hero-chip {
  width: 76px; height: 76px; margin: 0 auto 8px; border-radius: 24px; display: grid; place-items: center;
  background: linear-gradient(145deg, #ffffff, #e9ebef); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 28px; color: var(--text-2);
}
.hero-chip i { transform: rotate(90deg); }
.auth { display: grid; place-items: center; padding: 40px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { margin-bottom: 18px; }
.auth-card p { margin: 14px 0 0; }

/* ---------- Public profile ---------- */
body.public { background: radial-gradient(1200px 500px at 50% -10%, #ffffff 0%, var(--bg) 60%); min-height: 100vh; }
.public-wrap { max-width: 480px; margin: 0 auto; padding: 36px 16px 24px; }
.pf { text-align: center; }
.pf-photo { width: 124px; height: 124px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 16px; border: 4px solid #fff; box-shadow: var(--shadow-lg); background: var(--surface-2); }
.pf-photo-ph { display: grid; place-items: center; color: var(--text-3); font-size: 44px; }
.pf-name { margin: 0 0 4px; line-height: 1.2; font-weight: 700; word-break: break-word; }
.pf-sub { margin: 0 0 10px; color: var(--text-2); }
.pf-bio { margin: 0 auto 18px; color: var(--text-2); max-width: 400px; white-space: normal; word-break: break-word; }
.pf-save {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; margin-bottom: 22px;
  background: var(--accent); color: #fff; border-radius: 999px; text-decoration: none; font-weight: 600; font-size: 14px; box-shadow: var(--shadow);
}
.pf-icons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 20px 12px; box-shadow: var(--shadow); margin-bottom: 14px; }
.pf-icon { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; min-width: 0; }
.pf-icon-badge { width: 56px; height: 56px; border-radius: 17px; display: grid; place-items: center; font-size: 26px; box-shadow: 0 4px 12px rgba(0, 0, 0, .10); transition: transform .15s; }
.pf-icon:hover .pf-icon-badge { transform: translateY(-2px) scale(1.04); }
.pf-icon-label { font-size: 11.5px; color: var(--text-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-customs { display: flex; flex-direction: column; gap: 10px; }
.pf-custom {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; text-decoration: none; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
[dir=rtl] .pf-custom { padding: 10px 10px 10px 14px; }
.pf-custom:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.pf-custom img, .pf-custom-ph { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface-2); }
.pf-custom-ph { display: grid; place-items: center; color: var(--text-3); }
.pf-custom-title { flex: 1; font-weight: 600; text-align: start; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-ext { color: var(--text-3); font-size: 13px; }
[dir=rtl] .pf-ext { transform: scaleX(-1); }
.pf-empty { color: var(--text-3); }
.public-foot { margin-top: 36px; text-align: center; font-size: 13px; color: var(--text-3); display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.public-foot a { color: var(--text-3); text-decoration: none; }
.public-foot .lang-select { background: transparent; border-color: transparent; color: var(--text-3); padding: 4px; min-height: 0; }

/* ---------- Dashboard ---------- */
body.dash-body { transition: background-color .3s; }
.dash { max-width: 1180px; margin: 0 auto; padding: 20px 16px 110px; }
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 14px; color: var(--text-2); padding: 8px 14px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .15); flex: none; }
.edit-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; margin-bottom: 16px; font-weight: 600; border: 1px solid rgba(0, 0, 0, .06); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.sec-head .muted { font-size: 13px; }
.preview-col { position: sticky; top: 78px; }
.phone { background: var(--bg); border: 10px solid #1f2329; border-radius: 42px; height: 720px; overflow: auto; box-shadow: var(--shadow-lg); scrollbar-width: none; }
.phone::-webkit-scrollbar { display: none; }
.phone .public-wrap { padding-top: 30px; }
.preview-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.photo-row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.photo-row img, .photo-row .ph { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); font-size: 30px; border: 1px solid var(--border); flex: none; }
.size-row { display: flex; align-items: center; gap: 10px; }
.size-row output { min-width: 42px; font-size: 13px; color: var(--text-2); text-align: center; font-variant-numeric: tabular-nums; }

.link-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); margin-bottom: 10px; }
.link-item .badge { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; flex: none; }
.link-item .body { flex: 1; min-width: 0; }
.link-item .body .name { font-weight: 600; font-size: 14px; margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
.link-item .body .url { font-size: 12px; color: var(--text-3); margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }
.link-item .actions { display: flex; gap: 2px; flex: none; }
.phone-input { display: grid; grid-template-columns: 150px 1fr; gap: 8px; }
.empty { text-align: center; color: var(--text-3); padding: 18px; border: 1px dashed var(--border-strong); border-radius: 14px; font-size: 14px; }

.custom-item { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 10px; align-items: start; }
.custom-icon { width: 64px; height: 64px; border-radius: 14px; border: 1px dashed var(--border-strong); background: var(--surface-2); display: grid; place-items: center; cursor: pointer; overflow: hidden; color: var(--text-3); padding: 0; }
.custom-icon img { width: 100%; height: 100%; object-fit: cover; }
.custom-item .field { margin-bottom: 8px; }

.mode-opts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.mode-opt { border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; background: var(--surface); text-align: center; font-weight: 600; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mode-opt i { font-size: 18px; color: var(--text-2); }
.mode-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 35, 41, .08); }
.status-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; }

.chip-list { display: flex; flex-direction: column; gap: 8px; }
.chip-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; font-size: 14px; }
.chip-row code { font-family: ui-monospace, Menlo, monospace; }

.savebar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow-lg); width: calc(100% - 32px); max-width: 520px;
}
[dir=rtl] .savebar { padding: 8px 16px 8px 8px; }
.savebar .msg { flex: 1; font-size: 14px; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.savebar .msg.dirty { color: var(--text); font-weight: 600; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 22, 26, .45); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--surface); border-radius: 20px; width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow: auto; padding: 20px; box-shadow: var(--shadow-lg); }
.modal h2 { margin-bottom: 14px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 12px; }
.picker-grid button { border: 1px solid var(--border); background: var(--surface); border-radius: 14px; padding: 12px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; font: inherit; font-size: 12px; color: var(--text-2); }
.picker-grid button:hover { background: var(--surface-2); }
.picker-grid .badge { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; }
.crop-stage { position: relative; width: 100%; aspect-ratio: 1; background: #111; border-radius: 14px; overflow: hidden; touch-action: none; cursor: grab; user-select: none; }
.crop-stage canvas { width: 100%; height: 100%; display: block; }
.crop-stage.dragging { cursor: grabbing; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Admin */
.admin { max-width: 1100px; margin: 0 auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 16px; }
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: start; white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2); }
.pill-on { background: #e6f6ec; color: var(--ok); }

@media (max-width: 960px) {
  .dash-grid { grid-template-columns: 1fr; }
  .preview-col { position: static; order: 2; }
  .phone { height: auto; max-height: 640px; border-width: 8px; border-radius: 34px; }
}
@media (max-width: 560px) {
  .topbar { padding: 10px 16px; }
  .brand span:last-child { display: none; }
  .nav-label { display: none; }
  .topnav .btn { padding: 0 10px; }
  .lang-select { max-width: 110px; }
  .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 18px 16px; }
  .phone-input { grid-template-columns: 1fr; }
  .mode-opts { grid-template-columns: 1fr 1fr 1fr; }
  .mode-opt { padding: 10px 4px; font-size: 13px; }
  .custom-item { grid-template-columns: 56px 1fr; }
  .custom-item .actions { grid-column: 1 / -1; justify-content: flex-end; display: flex; }
  .custom-icon { width: 56px; height: 56px; }
  .pf-icons { gap: 14px 4px; }
  .pf-icon-badge { width: 52px; height: 52px; font-size: 24px; }
}

/* Loading + toast */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--text-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); }
.nav-label { margin-inline-start: 2px; }
[dir=rtl] .topnav .fa-arrow-right-from-bracket { transform: scaleX(-1); }
.btn-google { height: 48px; font-size: 15px; gap: 10px; margin-top: 8px; }
.auth-card .hero-chip { margin-bottom: 16px; }

/* ---------- Inline editor (dashboard) ---------- */
body.dash-body { min-height: 100vh; transition: background-color .3s; }
button.pf-icon, button.pf-custom, .pf-photo-btn { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button.pf-custom { width: 100%; background: var(--surface); border: 1px solid var(--border); padding: 10px 14px 10px 10px; text-align: start; }
.ed-top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; background: rgba(255, 255, 255, .82); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.ed-tabs { display: flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 4px; min-width: 0; }
.ed-tab { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 13.5px; color: var(--text-2); padding: 7px 11px; border-radius: 10px; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.ed-tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.ed-swatch { width: 30px; height: 30px; border-radius: 9px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong), var(--shadow); cursor: pointer; flex: none; margin-inline-start: 2px; }
.ed-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn { width: 38px; height: 38px; border-radius: 11px; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; cursor: pointer; font-size: 17px; text-decoration: none; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.save-state { font-size: 12.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.save-state.saved i { color: var(--ok); }
.save-state.error { color: var(--danger); }
.spinner.sm { width: 12px; height: 12px; border-width: 2px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(31, 157, 85, .18); flex: none; display: inline-block; }
.ed-hint { text-align: center; font-size: 13px; color: var(--text-2); margin: 14px 16px 0; }

.editing { padding-top: 22px; padding-bottom: 60px; }
.editing .ed-target { cursor: pointer; border-radius: 12px; outline: 1.5px dashed transparent; outline-offset: 4px; transition: outline-color .15s, background .15s; }
.editing .ed-target:hover { outline-color: rgba(0, 0, 0, .22); }
.editing .ed-about { padding: 2px 6px; margin: 0 auto 18px; max-width: 420px; min-height: 24px; }
.editing .ed-about .pf-bio { margin-bottom: 0; }
.editing .ph { color: var(--text-3) !important; font-weight: 500; }
.editing .pf-bio.ph { font-size: 14px !important; }
.pf-photo-btn { position: relative; display: block; margin: 0 auto 16px; width: 124px; }
.pf-photo-btn .pf-photo { margin: 0; }
.pf-photo-btn .cam { position: absolute; bottom: 2px; inset-inline-end: 2px; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; border: 3px solid #fff; }
.pf-save.inert { opacity: .45; pointer-events: none; }
.pf-icon.add .pf-icon-badge { background: var(--surface-2); color: var(--text-2); border: 2px dashed var(--border-strong); box-shadow: none; font-size: 22px; }
.pf-icon.incomplete .pf-icon-badge { opacity: .4; }

/* Sheets */
.modal.sheet { padding: 0; max-width: 480px; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px 20px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
[dir=rtl] .sheet-head { padding: 14px 20px 6px 14px; }
.sheet-head h2 { margin: 0; }
.sheet-body { padding: 8px 20px 20px; }
.sheet-sub { font-size: 14px; margin: 18px 0 10px; }
.sheet-body > .sheet-sub:first-child { margin-top: 4px; }
.sheet-actions { margin-top: 6px; }
.picker-search { margin-bottom: 4px; }
.picker-grid { max-height: 44vh; overflow: auto; padding: 2px; }
.picker-grid .pf-icon-badge { width: 44px; height: 44px; border-radius: 13px; font-size: 21px; }
.link-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.link-head .pf-icon-badge { width: 48px; height: 48px; border-radius: 14px; font-size: 23px; flex: none; }
.link-url { font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 8px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.link-url.bad { color: var(--text-3); }
.btn-danger { color: var(--danger); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches button, .swatch-custom { width: 44px; height: 44px; border-radius: 13px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.swatches button.on { box-shadow: 0 0 0 2px var(--accent); }
.swatch-custom { position: relative; display: grid; place-items: center; background: conic-gradient(#f87171, #fbbf24, #34d399, #60a5fa, #a78bfa, #f472b6, #f87171); color: #fff; overflow: hidden; }
.swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.custom-edit { display: flex; gap: 14px; align-items: flex-start; }
.custom-edit .custom-icon { width: 72px; height: 72px; flex: none; margin-top: 22px; }
.status-pill { margin: 4px 0 0; }

@media (max-width: 560px) {
  .modal-bg:has(.sheet) { place-items: end stretch; padding: 0; }
  .modal.sheet { max-width: none; border-radius: 22px 22px 0 0; max-height: 88vh; padding-bottom: env(safe-area-inset-bottom); }
  .ed-top { padding: 8px 10px; }
  .ed-tab { padding: 7px 9px; font-size: 13px; }
  .save-state span + *, .save-state { font-size: 0; gap: 0; }
  .save-state i, .save-state .spinner { font-size: 13px; }
  .icon-btn { width: 36px; height: 36px; }
}
.sheet .lang-select { max-width: none; width: 100%; min-height: 42px; }

/* ---------- Social links board: layouts × themes ---------- */
.pf-links { container-type: inline-size; margin-bottom: 14px; }
.lk-grid { display: grid; }
.lk { text-decoration: none; color: inherit; position: relative; min-width: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.lk-badge { display: grid; place-items: center; flex: none; }
.lk-text { display: flex; flex-direction: column; min-width: 0; }
.lk-label, .lk-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.lk-sub { font-size: 12px; opacity: .75; }
.lk.incomplete { opacity: .45; }

/* Themes set a skin; each layout decides where the skin goes. */
.theme-color .lk, .theme-circle .lk { --sk-bg: var(--b); --sk-fg: var(--f); --sk-bd: transparent; }
.theme-circle .lk { --sk-r: 50%; }
.theme-soft .lk { --sk-bg: color-mix(in srgb, var(--c) 14%, #fff); --sk-fg: var(--c); --sk-bd: transparent; }
.theme-outline .lk { --sk-bg: #fff; --sk-fg: var(--c); --sk-bd: color-mix(in srgb, var(--c) 55%, #fff); }
.theme-dark .lk { --sk-bg: #16181d; --sk-fg: #fff; --sk-bd: transparent; }
.theme-light .lk { --sk-bg: #fff; --sk-fg: #16181d; --sk-bd: var(--border-strong); }
.pf-links .lk.lk-add { --sk-bg: var(--surface-2); --sk-fg: var(--text-2); --sk-bd: var(--border-strong); }
.layout-grid .lk-add .lk-badge, .layout-list .lk-add .lk-badge, .layout-widgets .lk-add { border-style: dashed !important; box-shadow: none !important; }

/* Grid: 4 in a row */
.layout-grid .lk-grid { grid-template-columns: repeat(4, 1fr); gap: 16px 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 20px 12px; box-shadow: var(--shadow); }
.layout-grid .lk { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.layout-grid .lk-badge { width: 56px; height: 56px; border-radius: var(--sk-r, 17px); background: var(--sk-bg); color: var(--sk-fg); border: 1.5px solid var(--sk-bd); font-size: 26px; box-shadow: 0 4px 12px rgba(0, 0, 0, .08); transition: transform .15s; }
.layout-grid a.lk:hover .lk-badge { transform: translateY(-2px) scale(1.04); }
.layout-grid .lk-text { align-items: center; max-width: 100%; }
.layout-grid .lk-label { font-size: 11.5px; color: var(--text-2); }
.layout-grid .lk-sub { display: none; }

/* List */
.layout-list .lk-grid { gap: 10px; }
.layout-list .lk { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); text-align: start; }
[dir=rtl] .layout-list .lk { padding: 10px 10px 10px 14px; }
.layout-list .lk-badge { width: 46px; height: 46px; border-radius: var(--sk-r, 13px); background: var(--sk-bg); color: var(--sk-fg); border: 1.5px solid var(--sk-bd); font-size: 22px; }
.layout-list .lk-text { flex: 1; }
.layout-list .lk-label { font-weight: 600; font-size: 15px; }
.layout-list .lk-sub { color: var(--text-2); opacity: 1; }
.lk-arrow { color: var(--text-3); font-size: 12px; }
[dir=rtl] .lk-arrow { transform: scaleX(-1); }

/* Widgets: iPhone-style tiles with sizes */
.layout-widgets .lk-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; grid-auto-rows: calc((100cqw - 36px) / 4); grid-auto-flow: dense; }
.layout-widgets .lk { background: var(--sk-bg); color: var(--sk-fg); border: 1.5px solid var(--sk-bd); border-radius: 22px; padding: 12px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, .08); overflow: hidden; text-align: start; transition: transform .15s; }
.layout-widgets a.lk:hover { transform: translateY(-2px); }
.theme-circle.layout-widgets .lk { border-radius: 26px; }
.layout-widgets .lk-badge { font-size: 26px; line-height: 1; }
.layout-widgets .lk-label { font-weight: 600; font-size: 13px; }
.layout-widgets .s-1x1 { align-items: center; justify-content: center; padding: 8px; }
.layout-widgets .s-1x1 .lk-text { align-items: center; max-width: 100%; }
.layout-widgets .s-1x1 .lk-label { font-size: 10.5px; font-weight: 500; }
.layout-widgets .s-1x1 .lk-sub { display: none; }
.layout-widgets .s-2x1, .layout-widgets .s-4x1 { grid-column: span 2; flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; }
.layout-widgets .s-4x1 { grid-column: span 4; padding: 12px 16px; }
.layout-widgets .s-2x1 .lk-badge, .layout-widgets .s-4x1 .lk-badge { font-size: 28px; }
.layout-widgets .s-4x1 .lk-label { font-size: 15px; }
.layout-widgets .s-1x2 { grid-row: span 2; }
.layout-widgets .s-1x2 .lk-badge { font-size: 30px; }
.layout-widgets .s-2x2 { grid-column: span 2; grid-row: span 2; padding: 16px; }
.layout-widgets .s-2x2 .lk-badge { font-size: 40px; }
.layout-widgets .s-2x2 .lk-label { font-size: 17px; }
.layout-widgets .s-2x2 .lk-sub { font-size: 13px; }

/* Arrange mode */
.board-bar { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; font-size: 12.5px; }
.arranging .lk { animation: jiggle .28s ease-in-out infinite alternate; touch-action: none; cursor: grab; user-select: none; }
.arranging .lk:nth-child(2n) { animation-delay: -.14s; }
@keyframes jiggle { from { transform: rotate(-1.3deg); } to { transform: rotate(1.3deg); } }
.lk.dragging { opacity: .2; }
.lk-del, .lk-size { position: absolute; width: 26px; height: 26px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 11px; border: 2px solid #fff; z-index: 2; cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, .2); }
.lk-del { top: -8px; inset-inline-start: -8px; background: #6b7079; }
.lk-size { bottom: -8px; inset-inline-end: -8px; background: var(--accent); }
.layout-grid .lk-del { inset-inline-start: 2px; }
.lk-ghost { position: fixed; z-index: 100; pointer-events: none; margin: 0; container-type: normal; }
.lk-ghost > .lk { width: 100%; height: 100%; transform: scale(1.06); box-shadow: var(--shadow-lg); }
.lk-ghost.layout-grid > .lk .lk-badge { box-shadow: var(--shadow-lg); }

/* Style + size pickers */
.theme-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-pick button { border: 1.5px solid var(--border); background: var(--surface); border-radius: 16px; padding: 12px 8px; cursor: pointer; }
.theme-pick button.on, .mode-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 35, 41, .08); }
.theme-pick .pf-links { margin: 0; display: block; }
.theme-pick .lk-grid { display: flex; justify-content: center; gap: 8px; background: none; border: 0; box-shadow: none; padding: 0; }
.theme-pick .lk-badge { width: 40px !important; height: 40px !important; font-size: 19px !important; border-radius: var(--sk-r, 12px) !important; box-shadow: none !important; }
.size-pick { display: flex; gap: 8px; }
.size-pick button { width: 52px; height: 44px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.size-pick button.on { border-color: var(--accent); }
.sz { display: block; background: var(--text-2); border-radius: 3px; }
.sz-1x1 { width: 10px; height: 10px; } .sz-2x1 { width: 22px; height: 10px; } .sz-1x2 { width: 10px; height: 22px; }
.sz-2x2 { width: 22px; height: 22px; } .sz-4x1 { width: 34px; height: 10px; }

/* Sheets that keep the page visible */
.modal-bg.clear { background: transparent; backdrop-filter: none; place-items: end center; pointer-events: none; }
.modal-bg.clear .modal { pointer-events: auto; box-shadow: 0 -4px 40px rgba(16, 24, 40, .18); max-height: 55vh; }
@media (max-width: 560px) { .modal-bg.clear .modal { max-height: 60vh; } }
body.sheet-open .editing { padding-bottom: 65vh; }
.arranging.layout-widgets .lk { overflow: visible; }

/* ---------- Profile photo frames ---------- */
.pf-photo-frame { position: relative; overflow: hidden; margin: 0 auto 16px; background: var(--surface-2); border: 4px solid #fff; box-shadow: var(--shadow-lg); box-sizing: content-box; flex: none; }
.pf-photo-frame img { position: absolute; max-width: none; display: block; }
.pf-photo-frame img.cover { inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pf-photo-frame.ph { display: grid; place-items: center; color: var(--text-3); }
.shape-circle, .shape-oval { border-radius: 50%; }
.shape-square { border-radius: 10px; }
.shape-rounded { border-radius: 30%; }
.shape-arch { border-radius: 999px 999px 20px 20px; }
.shape-hexagon { border: 0; box-shadow: none; clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0% 50%); }
.pf-photo-btn { width: auto; display: table; margin: 0 auto 16px; }
.pf-photo-btn .cam { bottom: 0; inset-inline-end: -4px; }
.shape-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.shape-pick button { border: 1.5px solid var(--border); background: var(--surface); border-radius: 12px; padding: 8px 2px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.shape-pick button.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 35, 41, .08); }
.shape-pick .shp { margin: 0; border-width: 2px; box-shadow: none; background: var(--text-3); }
.shape-pick .shape-hexagon { background: var(--text-3); }
.shape-pick small { font-size: 10.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.size-seg { width: 100%; }
.size-seg .ed-tab { flex: 1; justify-content: center; }
.size-seg .ed-tab.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
@media (max-width: 400px) { .shape-pick { grid-template-columns: repeat(3, 1fr); } }

/* Themed mini badges (picker, link sheet) + icon colour editor */
.pf-links.mini { display: inline-block; margin: 0; container-type: normal; vertical-align: middle; }
.pf-links.mini .lk { display: block; cursor: inherit; }
.pf-links.mini .lk-badge { width: 44px; height: 44px; border-radius: var(--sk-r, 13px); background: var(--sk-bg); color: var(--sk-fg); border: 1.5px solid var(--sk-bd); font-size: 21px; }
.link-head .pf-links.mini .lk-badge { width: 52px; height: 52px; font-size: 25px; border-radius: var(--sk-r, 15px); }
.pf-links .lk.custom { --sk-bg: var(--x-bg); --sk-fg: var(--x-fg); --sk-bd: transparent; }
#cedit { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.c-row { display: flex; align-items: center; gap: 8px; }
.c-row.wrap { flex-wrap: wrap; }
.c-row small { font-size: 12px; color: var(--text-2); min-width: 64px; }
.cs { width: 32px; height: 32px; border-radius: 10px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; position: relative; flex: none; display: grid; place-items: center; background: var(--surface); color: var(--text-2); }
.cs.on { box-shadow: 0 0 0 2px var(--accent); }
.cs-pick { overflow: hidden; }
.cs-pick::after { content: '\f1fb'; font: var(--fa-font-solid); font-size: 12px; color: #fff; mix-blend-mode: difference; }
.cs-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; min-height: 0; }
.cs-dir { font-size: 16px; font-weight: 700; }
.sheet .modal-actions { position: sticky; bottom: 0; background: var(--surface); padding: 10px 0 4px; margin-top: 8px; z-index: 1; }
