/* Social Mockups — mobile first */
:root {
  --bg: #f0f2f5;
  --panel: #fff;
  --ink: #1c1e21;
  --muted: #65676b;
  --line: #dfe1e5;
  --accent: #2f6fed;
  --accent-ink: #fff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { text-decoration: none; font-size: 22px; line-height: 1; color: var(--ink); padding: 2px 6px 2px 0; }

/* ---------- buttons + forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font: inherit; font-size: 15px; font-weight: 600;
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.field { margin-bottom: 14px; }
.field > label, .label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=email], textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font: inherit; font-size: 16px; /* 16px stops iOS zooming */ color: var(--ink);
}
textarea { min-height: 120px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; min-height: 44px; }
.switch input { width: 22px; height: 22px; }

.seg { display: flex; background: #e4e6eb; border-radius: 10px; padding: 3px; gap: 3px; }
.seg button, .seg label {
  flex: 1; border: 0; background: transparent; border-radius: 8px; min-height: 36px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.seg .on, .seg input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.seg label { padding: 0; }
.seg label input { display: none; }
.seg label span { width: 100%; height: 100%; min-height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }

.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; border: 1px solid var(--line); }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: #fde8e8; color: #991b1b; }
.alert-ok { background: #e6f6ec; color: #14532d; }
.alert-warn { background: #fef3c7; color: #78350f; }

.wrap { max-width: 720px; margin: 0 auto; padding: 14px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: 100%; max-width: 360px; }
.login h1 { font-size: 22px; margin: 0 0 18px; text-align: center; }

/* ---------- dashboard ---------- */
.m-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.m-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; gap: 12px; align-items: flex-start; }
.m-thumb { width: 56px; height: 56px; border-radius: 10px; background: #dde3ec center/cover no-repeat; flex: none; }
.m-info { flex: 1; min-width: 0; }
.m-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; color: var(--ink); display: block; }
.m-meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #e4e6eb; color: var(--muted); }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-off { background: #fee2e2; color: #991b1b; }
.m-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.fab-row { display: flex; gap: 8px; margin-bottom: 14px; }

/* ---------- editor ---------- */
.editor-layout { padding-bottom: calc(76px + var(--safe-b)); }
.editor-pane { padding: 14px; }
.preview-pane { padding: 14px; display: none; }
.editor-layout.show-preview .editor-pane { display: none; }
.editor-layout.show-preview .preview-pane { display: block; }
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: 8px; padding: 10px 14px calc(10px + var(--safe-b));
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px);
}
.bottombar .btn { flex: 1; }

.post-editor { position: relative; }
.post-editor .post-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.post-editor .post-head strong { flex: 1; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 16px; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.icon-btn.danger { color: var(--danger); }
.img-pick { display: flex; gap: 12px; align-items: center; }
.img-pick .thumb { width: 72px; height: 72px; border-radius: 10px; background: #e4e6eb center/cover no-repeat; flex: none; display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }
.img-pick .thumb.round { border-radius: 50%; }
.img-pick .controls { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.img-pick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ad-fields { border-left: 3px solid var(--accent); padding-left: 12px; margin-top: 6px; }
.copy-box { display: flex; gap: 8px; }
.copy-box input { flex: 1; font-size: 14px; }

@media (min-width: 980px) {
  .editor-layout { display: grid; grid-template-columns: minmax(380px, 460px) 1fr; padding-bottom: 0; }
  .editor-layout .editor-pane { display: block !important; max-height: calc(100vh - 57px); overflow-y: auto; border-right: 1px solid var(--line); background: #f7f8fa; padding-bottom: 90px; }
  .editor-layout .preview-pane { display: block !important; max-height: calc(100vh - 57px); overflow-y: auto; }
  .bottombar { position: fixed; left: 0; right: auto; width: min(460px, 100%); }
  .bottombar .preview-toggle { display: none; }
}

/* ---------- client view ---------- */
.view-head { position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 14px; }
.view-head .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.view-head .brand .avatar { width: 36px; height: 36px; }
.view-head .brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.view-head .brand-sub { font-size: 12px; color: var(--muted); }
.view-head .seg { max-width: 360px; }
.feed { max-width: 520px; margin: 0 auto; padding: 12px 0 calc(32px + var(--safe-b)); }
.feed-item { margin-bottom: 18px; }
.feed-count { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 14px 6px; }
.pair { display: grid; gap: 12px; }

.view-foot { text-align: center; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .01em; padding: 4px 14px calc(30px + var(--safe-b)); }
.view-foot a { color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; }
@media (min-width: 560px) {
  .feed { padding-top: 20px; }
}

/* ======================================================================
   Post cards
   ====================================================================== */
.card { width: 100%; background: #fff; color: #050505; overflow: hidden; font-size: 15px; }
@media (min-width: 560px) { .card { border-radius: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.18); } }
.ic { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-sm { width: 12px; height: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; background: #c9ccd1 center/cover no-repeat; }
.avatar-initials { background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; border: 2px solid #fff; }
.dots { margin-left: auto; color: var(--muted); font-size: 20px; letter-spacing: 1px; line-height: 1; }
.media { width: 100%; position: relative; background: #e9edf3; overflow: hidden; }
.media img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.media-empty { display: grid; place-items: center; color: #8a8d91; font-size: 14px; background: linear-gradient(135deg, #d5dde9, #ecdfea); }
.r-landscape { aspect-ratio: 1.91 / 1; }
.r-square { aspect-ratio: 1 / 1; }
.r-portrait { aspect-ratio: 4 / 5; }
.tag { color: #385898; }

/* FB multi-photo grid */
.fbg { display: grid; gap: 2px; aspect-ratio: 1 / 1; background: #fff; }
.fbg .cell { position: relative; overflow: hidden; background: #e9edf3; }
.fbg .cell img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fbg .more { position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 30px; font-weight: 700; display: grid; place-items: center; }
.fbg-2 { grid-template-columns: 1fr 1fr; }
.fbg-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 3fr 2fr; }
.fbg-3 .cell:first-child { grid-column: 1 / -1; }
.fbg-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.fbg-5 { grid-template-columns: repeat(6, 1fr); grid-template-rows: 1fr 1fr; }
.fbg-5 .cell { grid-column: span 2; }
.fbg-5 .cell:nth-child(-n+2) { grid-column: span 3; }

/* IG carousel */
.ig-car .ig-track { position: absolute; inset: 0; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.ig-car .ig-track::-webkit-scrollbar { display: none; }
.ig-slide { flex: 0 0 100%; height: 100%; position: relative; scroll-snap-align: start; scroll-snap-stop: always; }
.ig-slide img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ig-count { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; pointer-events: none; }
.ig-nav { display: none; position: absolute; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(255,255,255,.85); color: #000; font-size: 18px; line-height: 1; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.ig-nav.prev { left: 10px; } .ig-nav.next { right: 10px; }
.ig-nav.off { visibility: hidden; }
@media (hover: hover) { .ig-nav { display: grid; place-items: center; } }
.ig-actions { position: relative; }
.ig-dots { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
.ig-dots i { width: 6px; height: 6px; border-radius: 50%; background: #c7c7c7; }
.ig-dots i.on { background: #0095f6; }

/* editor photo gallery */
.gallery { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.g-item, .g-add { flex: 0 0 92px; height: 92px; border-radius: 10px; position: relative; }
.g-item { background: #e4e6eb center/cover no-repeat; }
.g-item.busy { opacity: .5; }
.g-item:first-child::after { content: 'Cover'; position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.g-btn { position: absolute; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; line-height: 1; display: grid; place-items: center; cursor: pointer; padding: 0; }
.g-del { top: 4px; right: 4px; }
.g-left { bottom: 4px; right: 34px; }
.g-right { bottom: 4px; right: 4px; }
.g-item:first-child .g-left { display: none; }
.g-item:nth-last-child(2) .g-right { display: none; }
.g-add { border: 2px dashed var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; background: #fafbfc; }
.g-add .plus { font-size: 22px; line-height: 1; }
.g-add input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* FB-style */
.fb-head { display: flex; gap: 10px; align-items: center; padding: 12px 14px 0; }
.fb-name { font-weight: 600; font-size: 15px; }
.fb-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.fb-text { padding: 10px 14px 12px; line-height: 1.34; white-space: pre-wrap; overflow-wrap: anywhere; }
.fb-gap { height: 10px; }
.fb-cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: #f0f2f5; }
.fb-cta-text { min-width: 0; }
.fb-domain { font-size: 12px; color: var(--muted); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-headline { font-weight: 600; font-size: 15px; }
.fb-btn { background: #e4e6eb; border-radius: 6px; padding: 8px 12px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.fb-stats { display: flex; justify-content: space-between; gap: 8px; padding: 10px 14px; font-size: 14px; color: var(--muted); }
.fb-react { display: flex; align-items: center; }
.rb { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; border: 2px solid #fff; margin-right: -4px; }
.rb svg { width: 10px; height: 10px; fill: #fff; }
.rb.like { background: #3b82f6; }
.rb.love { background: #ef4444; margin-right: 6px; }
.fb-actions { display: flex; border-top: 1px solid var(--line); margin: 0 10px; padding: 2px 0; }
.fb-actions div { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 0; color: var(--muted); font-weight: 600; font-size: 14px; }
.fb-actions .ic { width: 19px; height: 19px; }

/* IG-style */
.ig { color: #000; }
.ig-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.ig-ring { padding: 2px; border-radius: 50%; background: linear-gradient(45deg, #f5b041, #e84393, #8e44ad); }
.ig-user { font-weight: 600; font-size: 14px; line-height: 1.2; }
.ig-sub { font-size: 12px; color: #737373; }
.ig-head .dots { color: #000; font-size: 18px; }
.ig-cta { display: flex; justify-content: space-between; align-items: center; padding: 11px 12px; border-bottom: 1px solid #efefef; font-weight: 600; font-size: 14px; color: #0095f6; }
.ig-actions { display: flex; align-items: center; gap: 14px; padding: 10px 12px 6px; }
.ig-actions .ic { width: 25px; height: 25px; }
.ig-save { margin-left: auto; display: flex; }
.ig-body { padding: 0 12px 14px; font-size: 14px; line-height: 1.4; }
.ig-likes { font-weight: 600; margin-bottom: 4px; }
.ig-caption { white-space: pre-wrap; overflow-wrap: anywhere; }
.ig-caption b { font-weight: 600; }
.ig-caption .tag { color: #00376b; }
.ig-comments { color: #737373; margin-top: 4px; }
.ig-time { color: #737373; font-size: 11px; text-transform: uppercase; margin-top: 6px; letter-spacing: .02em; }

/* full-screen photo viewer */
.card [data-gallery] img { cursor: zoom-in; }
html.lb-open, html.lb-open body { overflow: hidden; }
.lb { position: fixed; inset: 0; z-index: 1000; background: #000; }
.lb-track { position: absolute; inset: 0; display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain; }
.lb-track::-webkit-scrollbar { display: none; }
.lb-slide { flex: 0 0 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; display: flex; align-items: center; justify-content: center; }
.lb-slide img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-close { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 18px; cursor: pointer; }
.lb-count { position: absolute; top: calc(22px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); color: #fff; font-size: 14px; font-weight: 600; pointer-events: none; }
.lb-nav { display: none; position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 24px; cursor: pointer; }
.lb-nav.prev { left: 16px; } .lb-nav.next { right: 16px; }
.lb-nav.off { visibility: hidden; }
@media (hover: hover) { .lb-nav { display: grid; place-items: center; } }
