/* ─── Tokens: light by default, dark from the system or the theme toggle ─── */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --accent: #e8a317;          /* brand gold */
  --accent-hover: #d4930f;
  --accent-text: #1c1300;
  --accent-soft: #fdf3dc;
  --accent-ink: #92600a;      /* gold that reads on white */
  --ok: #15803d;   --ok-soft: #e7f6ec;
  --warn: #b45309; --warn-soft: #fef3e2;
  --err: #c62828;  --err-soft: #fdecec;
  --info: #1d4ed8; --info-soft: #e8efff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d11; --surface: #13161c; --surface-2: #1a1e26; --surface-3: #232833;
    --border: #252a34; --border-strong: #343b48;
    --text: #eceef2; --text-2: #c5cad3; --muted: #8b93a3;
    --accent: #f0b429; --accent-hover: #f5c450; --accent-text: #1c1300; --accent-soft: #2b2310; --accent-ink: #f0b429;
    --ok: #4ade80; --ok-soft: #12261a; --warn: #fbbf24; --warn-soft: #2a2110;
    --err: #f87171; --err-soft: #2c1414; --info: #7aa2ff; --info-soft: #141d33;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d11; --surface: #13161c; --surface-2: #1a1e26; --surface-3: #232833;
  --border: #252a34; --border-strong: #343b48;
  --text: #eceef2; --text-2: #c5cad3; --muted: #8b93a3;
  --accent: #f0b429; --accent-hover: #f5c450; --accent-text: #1c1300; --accent-soft: #2b2310; --accent-ink: #f0b429;
  --ok: #4ade80; --ok-soft: #12261a; --warn: #fbbf24; --warn-soft: #2a2110;
  --err: #f87171; --err-soft: #2c1414; --info: #7aa2ff; --info-soft: #141d33;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ─── Base ─── */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14.5px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border-radius: 5px; padding: 1px 5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--err); min-height: 1.2em; margin: 0; font-size: 13px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }

/* ─── Login ─── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; display: grid; gap: 12px; box-shadow: var(--shadow-lg); text-align: center; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 0; }
.logo-mark { width: 52px; height: 52px; margin: 0 auto 4px; border-radius: 14px; background: #111; color: #f0b429; display: grid; place-items: center; font-weight: 700; font-size: 18px; letter-spacing: .02em; box-shadow: inset 0 0 0 2px #f0b429; }
.logo-mark.sm { width: 34px; height: 34px; margin: 0; border-radius: 10px; font-size: 13px; }

/* ─── Shell: sidebar on desktop, top bar + tab bar on phones ─── */
.shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 12px; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand b { display: block; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: var(--text-2); font: inherit; font-weight: 500; padding: 9px 10px; border-radius: 10px; cursor: pointer; text-align: left; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item .count { margin-left: auto; min-width: 22px; text-align: center; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--accent); color: var(--accent-text); }
.nav-item .count.err { background: var(--err); color: #fff; }
.nav-item .count:empty { display: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }

.main-col { margin-left: var(--sidebar); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .brand { padding: 0; }
.topbar-actions { display: flex; gap: 8px; margin-left: auto; }
.view { max-width: 1180px; margin: 0 auto; padding: 24px 28px 120px; }
.mobile-only { display: none !important; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main-col { margin-left: 0; }
  .mobile-only { display: flex !important; }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; } /* clears the phone status bar when installed */
  .view { padding: 16px 16px 110px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tab { position: relative; display: grid; justify-items: center; gap: 2px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 500; padding: 6px 2px; cursor: pointer; border-radius: 10px; }
  .tab.active { color: var(--accent-ink); }
  .tab .count { position: absolute; top: 0; left: 50%; margin-left: 6px; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 99px; background: var(--accent); color: var(--accent-text); }
  .tab .count:empty { display: none; }
}

/* ─── Page header ─── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 500; cursor: pointer; padding: 0; margin-bottom: 10px; }
.back:hover { color: var(--text); }

/* ─── Cards & sections ─── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.section + .section { margin-top: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.section-head h2 { font-size: 15px; font-weight: 600; }
.section-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.section-body { padding: 18px 20px; }
.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }

/* ─── Forms ─── */
input, textarea, select { width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px; font: inherit; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .grid-4 { grid-template-columns: 1fr 1fr; } .grid-2 { grid-template-columns: 1fr; } }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px; height: 44px; font-size: 15px; }

/* Toggle chips (checkbox look-alikes) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 500; cursor: pointer; user-select: none; margin: 0; }
.chip input { display: none; }
.chip:hover { border-color: var(--muted); }
.chip:has(input:checked), .chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.chip:has(input:disabled) { opacity: .6; cursor: default; }
.chip .tick { width: 15px; height: 15px; border-radius: 5px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; }
.chip:has(input:checked) .tick { background: var(--accent); border-color: var(--accent); }
.chip:has(input:checked) .tick::after { content: ''; width: 7px; height: 4px; border: 2px solid var(--accent-text); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 21px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 99px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

/* ─── Buttons ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.btn .spin { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 99px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ─── Status badges ─── */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.draft { background: var(--info-soft); color: var(--info); }
.badge.published, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.partial, .badge.publishing, .badge.approved, .badge.warn, .badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.failed, .badge.rejected, .badge.error, .badge.err { background: var(--err-soft); color: var(--err); }
.badge.duplicate, .badge.skipped { background: var(--surface-2); color: var(--muted); }

/* ─── Toolbar (filters) ─── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button .n { color: var(--muted); font-weight: 500; margin-left: 4px; }

/* ─── Post cards (Inbox) ─── */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.post-card { display: flex; flex-direction: column; overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.post-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.post-cover { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; }
.post-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.post-cover .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.post-cover .tl { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; }
.post-cover .tr { position: absolute; right: 10px; top: 10px; }
.glass { background: rgba(10, 12, 16, .66); color: #fff; backdrop-filter: blur(4px); font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; display: inline-flex; align-items: center; gap: 5px; }
.post-body { padding: 14px 16px 12px; display: grid; gap: 6px; flex: 1; }
.post-title { font-weight: 600; font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-price { font-weight: 700; font-size: 16px; }
.post-price s { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 6px; }
.post-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.post-meta span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.post-note { font-size: 12.5px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 6px 9px; }
.post-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; padding: 12px 16px 14px; border-top: 1px solid var(--border); }

/* ─── History rows ─── */
.rows { display: grid; }
.row-item { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--surface-2); }
.row-thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--surface-2); object-fit: cover; display: grid; place-items: center; color: var(--muted); }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; }
.row-sub span { display: inline-flex; align-items: center; gap: 5px; }
.row-side { display: grid; justify-items: end; gap: 6px; }
.plats { display: flex; gap: 4px; }
.plat-dot { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.plat-dot svg { width: 13px; height: 13px; }
.plat-dot.ok { background: var(--ok-soft); color: var(--ok); }
.plat-dot.error { background: var(--err-soft); color: var(--err); }
@media (max-width: 560px) { .row-item { grid-template-columns: 48px minmax(0, 1fr); } .row-thumb { width: 48px; height: 48px; } .row-side { grid-column: 2; justify-items: start; grid-auto-flow: column; align-items: center; } }

/* ─── Empty states ─── */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .em-icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty p { margin: 0 auto; max-width: 380px; }

/* ─── Editor ─── */
.editor { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.editor .side { position: sticky; top: 76px; }
.editor > * { min-width: 0; }
@media (max-width: 1080px) { .editor { grid-template-columns: minmax(0, 1fr); } .editor .side { position: static; } }
.ed-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 16px; }
.ed-head h1 { font-size: 21px; font-weight: 700; flex-basis: 100%; }
.source-box { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.source-box .src-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--info-soft); color: var(--info); display: grid; place-items: center; flex-shrink: 0; }
.source-box b { font-weight: 600; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 13px; background: var(--warn-soft); color: var(--warn); margin-top: 12px; }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice svg { margin-top: 1px; }
.raw { white-space: pre-wrap; font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 12px; max-height: 220px; overflow: auto; margin: 0; }
details.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary svg { transition: transform .15s; }
details.fold[open] > summary svg { transform: rotate(90deg); }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.cover { border: 2px solid var(--accent); }
.photo .tag { position: absolute; left: 6px; top: 6px; background: var(--accent); color: var(--accent-text); font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.photo .tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: center; gap: 4px; padding: 6px; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); opacity: 0; transition: opacity .15s; }
.photo:hover .tools, .photo:focus-within .tools { opacity: 1; }
@media (hover: none) { .photo .tools { opacity: 1; } }
.photo .tools button { width: 28px; height: 28px; border-radius: 8px; border: 0; background: rgba(255, 255, 255, .92); color: #111; display: grid; place-items: center; cursor: pointer; }
.photo .tools button:hover { background: #fff; }
.photo .tools button.rm { color: #c62828; }
.photo .tools svg { width: 15px; height: 15px; }
.photo-add { aspect-ratio: 1; border-radius: 12px; border: 1.5px dashed var(--border-strong); display: grid; place-items: center; align-content: center; gap: 4px; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600; background: none; }
.photo-add:hover { border-color: var(--accent); color: var(--accent-ink); }

/* Destinations picker */
.dest-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.dest-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 12px; cursor: pointer; margin: 0; font-size: 13.5px; font-weight: 500; }
.dest-opt input { display: none; }
.dest-opt .pi { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.dest-opt .check-ring { margin-left: auto; width: 18px; height: 18px; border-radius: 99px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; }
.dest-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.dest-opt:has(input:checked) .check-ring { background: var(--accent); border-color: var(--accent); }
.dest-opt:has(input:checked) .check-ring::after { content: ''; width: 8px; height: 4px; border: 2px solid var(--accent-text); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.dest-opt:has(input:disabled) { cursor: default; opacity: .7; }
.pi.website { background: #0f766e; } .pi.telegram { background: #229ed9; } .pi.discord { background: #5865f2; }
.pi.instagram { background: linear-gradient(45deg, #f9a825, #e1306c 55%, #833ab4); } .pi.whatsapp { background: #25d366; }
.pi svg { width: 16px; height: 16px; }

/* Preview panel */
.pv-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 14px; }
.pv-tabs button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; padding: 7px 11px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.pv-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.pv-tabs button svg { width: 15px; height: 15px; }
.preview-stage { background: var(--surface-2); border-radius: 12px; padding: 14px; display: grid; justify-items: center; min-height: 160px; }
.cap-edit { margin-top: 14px; }
.cap-edit textarea { margin-top: 10px; font-size: 13px; }

/* Results */
.results { display: grid; gap: 8px; }
.result { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); }
.result .pi { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.result .r-main { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; }
.result .r-err { color: var(--err); font-size: 12.5px; font-weight: 400; margin-top: 2px; word-break: break-word; }
.result a { font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

/* Sticky action bar */
.actionbar { position: sticky; bottom: 16px; z-index: 15; margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-radius: 16px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.actionbar .grow { flex: 1; }
.actionbar .btn.primary { min-width: 170px; }
@media (max-width: 860px) {
  .actionbar { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .actionbar .btn { flex: 1; }
  .actionbar .grow { display: none; }
  .actionbar .btn.primary { flex-basis: 100%; }
}

/* ─── Settings pages ─── */
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-row .lr-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.list-row .lr-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
  .list-row { flex-wrap: wrap; }
  .list-row .lr-main { flex-basis: calc(100% - 52px); }
  .list-row .lr-sub { white-space: normal; }
  .list-row .lr-side { width: 100%; justify-content: flex-start; padding-left: 50px; }
}
.svc-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; flex-shrink: 0; background: var(--surface-3); }
.svc-ic.ai { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.svc-ic.bot { background: #229ed9; } .svc-ic.extract { background: #0ea5e9; }
.qr-box { display: flex; gap: 18px; align-items: center; padding: 16px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.qr { background: #fff; padding: 10px; border-radius: 12px; width: 190px; }
.overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; }

/* ─── Modal ─── */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(8, 10, 14, .6); backdrop-filter: blur(3px); animation: fade .15s; }
.modal-box { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px; animation: pop .18s; }
.modal-box.wide { width: min(760px, 100%); padding: 16px; }
.modal-box h3 { font-size: 17px; margin-bottom: 6px; }
.modal-box p { margin: 0 0 18px; color: var(--text-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.crop-area { height: min(62vh, 560px); background: #000; border-radius: 12px; overflow: hidden; }
.crop-area img { display: block; max-width: 100%; }
.crop-tools { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.crop-tools .on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }

/* ─── Toasts ─── */
.toasts { position: fixed; z-index: 80; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
@media (max-width: 860px) { .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); } }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; background: #111827; color: #f9fafb; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .2s; }
.toast.err svg { color: #f87171; } .toast.ok svg { color: #4ade80; }

/* ─── Platform previews (mock-ups of each app) ─── */
.pv { border-radius: 12px; padding: 12px; font-size: 14px; line-height: 1.4; width: 100%; max-width: 420px; }
.pv img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pv-text { white-space: pre-wrap; word-break: break-word; padding-top: 6px; }
.pv-text a { color: inherit; text-decoration: underline; }
.pv-note { font-size: 12px; margin: 10px 0 0; color: var(--muted); text-align: center; }
.pv-grid { display: grid; gap: 2px; border-radius: 8px; overflow: hidden; position: relative; }
.pv-grid img { aspect-ratio: 1; }
.pv-grid.g1 { grid-template-columns: 1fr; } .pv-grid.g1 img { aspect-ratio: 4/3; }
.pv-grid.g2 { grid-template-columns: 1fr 1fr; }
.pv-grid.g3, .pv-grid.g4 { grid-template-columns: repeat(3, 1fr); }
.pv-more, .pv-count { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 99px; }
.pv-count { top: 8px; bottom: auto; }
.pv-tg { background: #0e1621; display: grid; gap: 6px; }
.pv-tg-bubble { background: #182533; color: #f5f5f5; border-radius: 12px; padding: 4px 4px 8px; }
.pv-tg-bubble .pv-text { padding: 6px 8px 0; }
.pv-tg-bubble a { color: #6ab3f3; }
.pv-wa { background: #0b141a; }
.pv-wa-bubble { background: #005c4b; color: #e9edef; border-radius: 10px; padding: 4px 4px 8px; max-width: 330px; }
.pv-wa-bubble img { border-radius: 8px; aspect-ratio: 4/3; }
.pv-wa-bubble .pv-text { padding: 6px 6px 0; } .pv-wa-bubble a { color: #53bdeb; }
.pv-ig { background: #000; color: #f5f5f5; padding: 0 0 12px; overflow: hidden; }
.pv-ig-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.pv-ig-av { width: 28px; height: 28px; border-radius: 99px; background: linear-gradient(45deg, #f9ce34, #ee2a7b, #6228d7); }
.pv-ig-img { position: relative; aspect-ratio: 1; background: #111; }
.pv-ig .pv-text { padding: 10px 12px 0; } .pv-ig a { color: #e0f1ff; text-decoration: none; }
.pv-dc { background: #313338; color: #dbdee1; display: grid; grid-template-columns: 40px 1fr; gap: 10px; }
.pv-dc-av { width: 40px; height: 40px; border-radius: 99px; background: #5865f2; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.pv-dc-tag { background: #5865f2; color: #fff; font-size: 10px; padding: 1px 4px; border-radius: 3px; vertical-align: 1px; }
.pv-dc .pv-grid { margin-top: 8px; max-width: 360px; } .pv-dc a { color: #00a8fc; }
.pv-web { background: #fff; color: #111; padding: 0; overflow: hidden; border: 1px solid #e3e3e3; }
.pv-web-img { position: relative; aspect-ratio: 16/10; background: #eee; }
.pv-web-body { padding: 12px 14px 14px; }
.pv-web-title { font-weight: 700; font-size: 16px; }
.pv-web-desc { color: #555; margin-top: 2px; }
.pv-web-price { margin-top: 8px; font-size: 18px; color: #0a7d32; } .pv-web-price s { color: #999; font-size: 14px; }
.pv-web-cat { display: inline-block; margin-top: 6px; font-size: 11px; background: #f1f1f1; border-radius: 99px; padding: 2px 8px; color: #555; }
.pv-web-full { white-space: pre-wrap; margin-top: 10px; font-size: 13px; color: #333; border-top: 1px solid #eee; padding-top: 10px; }
.missing { display: grid; place-items: center; color: var(--muted); background: var(--surface-2); width: 100%; height: 100%; }
.post-cover .missing, .photo .missing { position: absolute; inset: 0; }

/* ─── Phone layout (the client mostly works from his phone / the Telegram Mini App) ─── */
/* clip (not hidden) so sticky bars keep working */
html, body { overflow-x: clip; }
.ed-tabs { width: 100%; margin-bottom: 14px; }
.ed-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
@media (max-width: 860px) {
  body { font-size: 15px; }
  /* 16px fields stop iOS from zooming in when typing */
  input, textarea, select { font-size: 16px; padding: 11px 12px; }
  .btn { min-height: 44px; }
  .btn.sm { min-height: 38px; padding: 6px 12px; }
  .topbar #newPostBtn { display: none; }
  .page-head { margin-bottom: 14px; align-items: center; flex-wrap: nowrap; }
  .page-head h1 { font-size: 22px; }
  .page-head p { font-size: 13.5px; }
  .page-head .lbl { display: none; }
  .page-head .btn { min-width: 44px; padding: 8px 10px; }
  .card { border-radius: 16px; }
  .section-head, .section-body { padding-left: 16px; padding-right: 16px; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 8px 10px; }

  /* Inbox: one big card per row, roomy buttons */
  .post-grid { grid-template-columns: 1fr; gap: 14px; }
  .post-cover { aspect-ratio: 16 / 9; }
  .post-actions { grid-template-columns: 1fr 1fr 48px; padding: 12px 14px 14px; }
  .post-actions .btn { min-height: 44px; }

  /* History */
  .row-item { padding: 12px 14px; gap: 12px; }

  /* Editor: Details / Preview switch, no tab bar, one-row action bar */
  .editor[data-pane="edit"] .side { display: none; }
  .editor[data-pane="preview"] .main { display: none; }
  body[data-page="post"] .tabbar { display: none; }
  body[data-page="post"] .view { padding-bottom: 110px; }
  .ed-head h1 { font-size: 19px; }
  .photos { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .photo .tools button { width: 34px; height: 34px; }
  .dest-pick { grid-template-columns: 1fr; }
  .dest-opt { padding: 12px; min-height: 52px; }
  .chip { padding: 8px 13px; }
  .actionbar { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; border-radius: 18px 18px 0 0; border-width: 1px 0 0; flex-wrap: nowrap; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .actionbar .btn { flex: 0 0 auto; width: 46px; padding: 0; }
  .actionbar .btn .lbl { display: none; }
  .actionbar .btn.primary { flex: 1; width: auto; min-width: 0; padding: 0 14px; }
  .actionbar .grow { display: none; }
  body:not([data-page="post"]) .actionbar { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .preview-stage { padding: 10px; }

  /* Dialogs become bottom sheets; the cropper takes the whole screen */
  .modal { place-items: end center; padding: 0; }
  .modal-box { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); animation: sheet .22s ease-out; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .modal-box.wide { height: 100vh; max-height: 100vh; border-radius: 0; display: flex; flex-direction: column; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
  .modal-box.wide .crop-area { flex: 1; height: auto; min-height: 0; }
  .modal-box.wide .modal-actions { flex-direction: row; }
  .modal-box.wide .modal-actions .btn { flex: 1; }
  .crop-tools { overflow-x: auto; flex-wrap: nowrap; }
  .tabbar { padding-top: 8px; }
  .tab { font-size: 11.5px; gap: 3px; min-height: 48px; }
  .tab svg { width: 21px; height: 21px; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
.crop-tools, .seg, .pv-tabs { scrollbar-width: none; }
.crop-tools::-webkit-scrollbar, .seg::-webkit-scrollbar { display: none; }
@media (max-width: 860px) {
  .seg button { min-height: 38px; }
  .back { min-height: 40px; padding-right: 12px; }
}
/* Laptop: the preview panel scrolls on its own when it is taller than the window, above the action bar */
@media (min-width: 1081px) {
  .editor .side { max-height: calc(100vh - 176px); overflow-y: auto; border-radius: var(--radius); scrollbar-width: thin; }
}
@media (max-width: 860px) {
  .seg { flex-wrap: wrap; overflow: visible; }
  .seg button { flex: 1 1 auto; }
}
@media (max-width: 520px) {
  .page-head { flex-wrap: wrap; }
}
