@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Geist:wght@500;600&display=swap');

/* ============================================================
   Post Studio — SocialAIO design system (dark-only)
   Tokens/fonts adopted from local's style-kit so Post Studio
   visually matches SocialAIO. DOM + JS bindings unchanged.
   ============================================================ */
:root {
  --ground: #0a0a0a;          /* page background */
  --surface: #131313;         /* cards / panels */
  --elevated: #1d1b20;        /* raised: secondary buttons, chips, hovers */
  --line: #2a2a2a;            /* all borders */
  --line-soft: #201f22;       /* subtle dividers */

  --accent: #8b5cf6;          /* primary violet: buttons, focus, active */
  --accent-bright: #d0bcff;   /* lavender highlight: brand accents, text */
  --primary2: #7c3aed;        /* primary button hover */
  --teal: #d0bcff;            /* repurposed to lavender (kit has no teal) */

  --text: #e5e2e1;
  --muted: #a9a3b3;
  --faint: #7f7789;

  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 16px;

  --shadow: 0 12px 34px -18px rgba(0, 0, 0, 0.8);
  --glow: 0 8px 22px -10px rgba(139, 92, 246, 0.5);

  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: 'Geist', ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --sidebar-w: 280px;
}
:root { color-scheme: dark; }

/* ============================================================
   Light theme — dedicated design tokens (NOT an inversion).
   Activated by <html data-theme="light">. Because the whole app
   is tokenized, this re-themes every surface in one place.
   ============================================================ */
:root[data-theme="light"] {
  color-scheme: light;
  --ground: #f3f2f7;          /* page background */
  --surface: #ffffff;         /* cards / panels / assistant bubbles */
  --elevated: #ecebf3;        /* raised: user bubble, chips, secondary buttons */
  --line: #e2dfea;            /* all borders */
  --line-soft: #eeecf4;       /* subtle dividers */

  --accent: #7c3aed;          /* primary violet — deepened for contrast on light */
  --accent-bright: #6d28d9;   /* highlight/brand text — dark enough to read on light */
  --primary2: #6d28d9;
  --teal: #7c3aed;

  --text: #1b1926;            /* near-black, faint violet cast */
  --muted: #5b5570;
  --faint: #8a8498;

  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.10);

  --shadow: 0 14px 34px -20px rgba(40, 25, 70, 0.22);
  --glow: 0 8px 22px -12px rgba(124, 58, 237, 0.30);
}
/* Rules that can't be a plain token swap (fixed-colour overlays). */
:root[data-theme="light"] .topbar { background: rgba(255, 255, 255, 0.78); }
:root[data-theme="light"] .msg-assistant .bubble.kind-error { color: #b91c1c; }
/* Smooth, non-jarring theme switch. */
html, body, .sidebar, .topbar, .card, .bubble, .msg-avatar, .btn, .btn-primary,
.btn-ghost, .chip, .nav-btn, .composer, .input, .conv-item, .tab-toggle {
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
/* Theme toggle: show the icon of the theme you'd switch TO (sun in dark, moon in light). */
.theme-toggle .ic-sun, .theme-toggle .ic-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
:root[data-theme="light"] .theme-toggle .ic-moon { display: block; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}

#app-root { height: 100vh; height: 100dvh; }

button { font-family: inherit; cursor: pointer; }
input, textarea, button { font-family: inherit; font-size: 1rem; color: inherit; }
a { color: var(--teal); }

.hidden { display: none !important; }

/* Ambient circuit glow used on auth + empty states */
.aura {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.aura::before, .aura::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
}
.aura::before {
  width: 460px; height: 460px;
  background: radial-gradient(circle, var(--accent), transparent 70%);
  top: -140px; right: -120px;
}
.aura::after {
  width: 380px; height: 380px;
  background: radial-gradient(circle, var(--teal), transparent 70%);
  bottom: -160px; left: -120px;
  opacity: 0.32;
}

/* ---------- Brand mark ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-glyph {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  display: grid; place-items: center;
  box-shadow: var(--glow);
  flex: none;
}
.brand-glyph svg { width: 17px; height: 17px; display: block; }
.brand-name { font-weight: 700; letter-spacing: -0.01em; font-size: 1.05rem; }
.brand-name .dot { color: var(--accent-bright); }

/* ============================================================
   Auth
   ============================================================ */
.auth-screen {
  position: relative;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 34px 30px;
  box-shadow: var(--shadow);
}
.auth-card .brand { justify-content: center; margin-bottom: 8px; }
.auth-title { text-align: center; font-size: 1.35rem; font-weight: 700; margin: 14px 0 4px; letter-spacing: -0.02em; }
.auth-sub { text-align: center; color: var(--muted); font-size: 0.9rem; margin-bottom: 24px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--faint);
}
.input {
  width: 100%;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-weight: 600;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--primary2); }
.btn-primary:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }

.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 20;
}
.sidebar-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line-soft); }
.new-chat {
  width: 100%;
  margin-top: 14px;
  background: var(--elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.new-chat:hover { border-color: var(--accent); background: rgba(139,92,246,0.12); }
.nav-btn {
  width: 100%;
  margin-top: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--muted);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.nav-btn:hover { border-color: var(--line); background: var(--elevated); color: var(--text); }
.nav-btn.active { border-color: var(--accent); background: rgba(139,92,246,0.14); color: var(--text); }

.conv-list { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.conv-item {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 0.12s, color 0.12s;
}
.conv-item:hover { background: var(--elevated); color: var(--text); }
.conv-item.active { background: var(--elevated); color: var(--text); border-color: var(--line); }

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.who { display: flex; flex-direction: column; min-width: 0; }
.who-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role { font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint); }
.icon-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 9px;
  width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); flex: none;
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- Main pane ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(10px);
}
.topbar .title { font-weight: 600; letter-spacing: -0.01em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hamburger { display: none; }
.tab-toggle { display: flex; gap: 4px; background: var(--elevated); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tab-toggle button {
  background: transparent; border: none; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
}
.tab-toggle button.active { background: var(--accent); color: #fff; }

/* ============================================================
   Chat
   ============================================================ */
.chat { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; }
.chat-inner { max-width: 760px; margin: 0 auto; padding: 24px 18px 8px; display: flex; flex-direction: column; gap: 18px; }

.empty-state {
  position: relative;
  flex: 1; display: grid; place-items: center; padding: 24px; text-align: center;
}
.empty-inner { position: relative; z-index: 1; max-width: 420px; }
.empty-inner .brand-glyph { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 18px; }
.empty-inner .brand-glyph svg { width: 28px; height: 28px; }
.empty-inner h2 { font-size: 1.4rem; letter-spacing: -0.02em; margin: 0 0 8px; text-wrap: balance; }
.empty-inner p { color: var(--muted); margin: 0; }

.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg-avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 700;
}
.msg-assistant .msg-avatar { background: linear-gradient(135deg, var(--accent), var(--teal)); color: #fff; }
.msg-user { flex-direction: row-reverse; }
.msg-user .msg-avatar { background: var(--elevated); border: 1px solid var(--line); color: var(--muted); }

.msg-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; max-width: 78%; }
.msg-user .msg-body { align-items: flex-end; }
.bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg-user .bubble { background: var(--elevated); border-color: var(--line); }
.msg-assistant .bubble.kind-error { border-color: rgba(239,68,68,0.4); background: var(--danger-soft); color: #fecaca; }

.msg-img {
  max-width: 340px; width: 100%;
  border-radius: var(--radius); border: 1px solid var(--line);
  display: block; background: var(--ground);
}

.quick-replies { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--elevated);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 0.88rem; font-weight: 600;
  transition: border-color 0.14s, background 0.14s, transform 0.1s;
}
.chip:hover { border-color: var(--accent); background: rgba(139,92,246,0.12); }
.chip:active { transform: translateY(1px); }
.chip:disabled { opacity: 0.45; cursor: default; }

/* typing/working dots */
.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent-bright);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* caption copy affordance */
.caption-actions { margin-top: 2px; }
.copy-link { background: none; border: none; color: var(--teal); font-size: 0.78rem; padding: 2px 0; font-family: var(--mono); letter-spacing: 0.04em; }
.copy-link:hover { text-decoration: underline; }

/* ---------- Composer ---------- */
.composer-wrap { border-top: 1px solid var(--line-soft); padding: 12px 18px 16px; background: var(--ground); }
.composer {
  max-width: 760px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 8px;
  display: flex; align-items: flex-end; gap: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,92,246,0.16); }
.composer textarea {
  flex: 1; background: transparent; border: none; resize: none;
  padding: 8px 6px; max-height: 160px; line-height: 1.4;
}
.composer textarea:focus { outline: none; }
.attach-preview {
  max-width: 760px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 0.85rem; color: var(--muted);
}
.attach-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 7px; }
.attach-preview .rm { margin-left: auto; }
.round-btn {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; border: 1px solid var(--line); background: var(--elevated); color: var(--muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.round-btn:hover { border-color: var(--accent); color: var(--text); }
.round-btn svg { width: 18px; height: 18px; }
.send-btn { background: var(--accent); color: #fff; border-color: transparent; }
.send-btn:hover:not(:disabled) { background: var(--primary2); }
.send-btn:disabled { opacity: 0.4; box-shadow: none; cursor: default; }
.composer-hint { max-width: 760px; margin: 8px auto 0; font-size: 0.72rem; color: var(--faint); text-align: center; }

/* ============================================================
   Admin
   ============================================================ */
.admin { flex: 1; overflow-y: auto; min-height: 0; }
.admin-inner { max-width: 920px; margin: 0 auto; padding: 26px 18px 60px; display: flex; flex-direction: column; gap: 30px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.panel-head h3 { margin: 0; font-size: 1.05rem; letter-spacing: -0.01em; flex: 1; }
.eyebrow { font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--faint); margin-bottom: 3px; }

.member-row {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px 0; border-top: 1px solid var(--line-soft);
}
.member-row:first-of-type { border-top: none; }
.member-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.avatar-lg {
  width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: var(--elevated); border: 1px solid var(--line); font-weight: 700; color: var(--accent-bright);
}
.member-meta { flex: 1; min-width: 120px; }
.member-meta .nm { font-weight: 600; }
.member-meta .un { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
.role-pill {
  font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line);
}
.role-pill.admin { color: var(--teal); border-color: rgba(208,188,255,0.4); }
.role-pill.member { color: var(--muted); }
.role-pill.inactive { color: var(--danger); border-color: rgba(239,68,68,0.4); }

.assign-label { font-family: var(--mono); font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint); }
.assign-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.assign-chip {
  background: var(--ground); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 13px; font-size: 0.82rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; transition: all 0.14s;
}
.assign-chip.on { background: rgba(139,92,246,0.16); border-color: var(--accent); color: var(--text); }
.assign-chip .tick { opacity: 0; }
.assign-chip.on .tick { opacity: 1; }

.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 140px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gcard { background: var(--ground); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.gcard img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface); }
.gcard .cap { padding: 8px 10px; font-size: 0.74rem; color: var(--muted); }
.gcard .cap b { color: var(--text); font-weight: 600; }

/* Member gallery: richer cards that show the whole post + caption */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.post-card { background: var(--ground); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.post-card a.thumb { display: block; background: var(--surface); }
.post-card img { width: 100%; max-height: 300px; object-fit: contain; display: block; }
.post-card .meta { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.post-card .meta b { font-weight: 600; }
.post-card .ratio-tag { font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.06em; color: var(--teal); border: 1px solid rgba(208,188,255,0.35); border-radius: 999px; padding: 2px 8px; }
.post-card .cap-text { padding: 0 12px 6px; font-size: 0.82rem; color: var(--muted); white-space: pre-wrap; max-height: 6.4em; overflow: hidden; position: relative; }
.post-card .foot { padding: 8px 12px 12px; margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.post-card .foot .save-post-btn { padding: 6px 11px; font-size: 0.78rem; }
.muted-note { color: var(--muted); font-size: 0.9rem; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--elevated); border: 1px solid var(--accent); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font-size: 0.88rem; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Edit-image affordance on chat results ---------- */
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 2px; }
.edit-image-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--elevated); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 7px 13px; font-size: 0.82rem; font-weight: 600;
  transition: border-color 0.14s, background 0.14s;
}
.edit-image-btn:hover { border-color: var(--accent); background: rgba(139,92,246,0.12); }
.edit-image-btn svg { width: 15px; height: 15px; }

/* Chat preference-memory button (topbar) + modal */
.memory-btn {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  background: var(--elevated); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 0.78rem; font-weight: 600;
  transition: border-color 0.14s, color 0.14s, background 0.14s;
}
.memory-btn:hover { border-color: var(--accent); color: var(--text); }
.memory-btn svg { width: 14px; height: 14px; }
.memory-card { max-width: 460px; }
.memory-body { display: flex; flex-direction: column; gap: 8px; }
.memory-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.memory-list li { color: var(--text); font-size: 0.9rem; line-height: 1.4; }
.memory-list li::marker { color: var(--accent-bright); }
.memory-empty { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* Retry button under an error message */
.retry-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--danger-soft); border: 1px solid rgba(239,68,68,0.4); color: var(--danger);
  border-radius: 999px; padding: 7px 13px; font-size: 0.82rem; font-weight: 600;
  transition: border-color 0.14s, background 0.14s, opacity 0.14s;
}
.retry-btn:hover:not(:disabled) { border-color: var(--danger); background: rgba(239,68,68,0.2); }
.retry-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.retry-btn svg { width: 15px; height: 15px; }

/* Save Post -> SocialAIO (mirrors edit-image-btn) */
.save-post-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--elevated); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 7px 13px; font-size: 0.82rem; font-weight: 600;
  transition: border-color 0.14s, background 0.14s, opacity 0.14s;
}
.save-post-btn:hover:not(:disabled) { border-color: var(--teal); background: rgba(139,92,246,0.14); }
.save-post-btn svg { width: 15px; height: 15px; }
.save-post-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.save-post-btn.is-saved {
  color: var(--teal); border-color: var(--teal); background: rgba(139,92,246,0.14); cursor: pointer; opacity: 1;
}

/* ---------- Mask editor overlay ---------- */
.editor-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 18px;
}
.editor-card {
  width: 100%; max-width: 560px; max-height: 96vh; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.editor-head { display: flex; align-items: flex-start; gap: 12px; flex: none; }
.editor-head h3 { margin: 0; font-size: 1.1rem; letter-spacing: -0.01em; }
.editor-head > div:first-child { flex: 1; }
.editor-hint { margin: 0; color: var(--muted); font-size: 0.85rem; flex: none; }
/* The stage flexes to fill the space left by the head/hint/tools, so the canvas below
   fits the FULL image (any aspect) without being hidden under the tools. */
.editor-stage {
  background: var(--ground); border: 1px solid var(--line); border-radius: var(--radius);
  display: grid; place-items: center; overflow: hidden; padding: 8px;
  flex: 1 1 auto; min-height: 0;
}
/* Fit within the flexed stage in BOTH dimensions -> vertical/tall images show fully.
   max-width + max-height preserve the canvas's aspect (no object-fit, so the element box
   equals the rendered image and the brush coordinate math stays exact). */
#editor-canvas { max-width: 100%; max-height: 100%; touch-action: none; cursor: crosshair; border-radius: 6px; }
.editor-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; flex: none; }
.swatches { display: flex; gap: 7px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.swatch.active { border-color: var(--text); }
.brush-size { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.brush-size input { accent-color: var(--accent); }
.editor-actions { display: flex; gap: 8px; margin-left: auto; }

@media (max-width: 480px) {
  .editor-actions { margin-left: 0; width: 100%; }
  .editor-actions .btn { flex: 1; }
}

/* Drawer backdrop (mobile) */
.backdrop { display: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 82%; max-width: 320px;
    transform: translateX(-100%); transition: transform 0.22s ease;
  }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 15;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
  }
  .app.drawer-open .backdrop { opacity: 1; pointer-events: auto; }
  .hamburger { display: grid; }
  .msg-body { max-width: 84%; }
  .chat-inner, .composer, .composer-hint, .attach-preview { max-width: 100%; }
}

/* ============================================================
   Embedded mode (inside the SocialAIO iframe) — body.embedded.
   Scoped so the standalone app at the direct host is untouched.
   ============================================================ */
/* FIX 2 — hide Post Studio's own account footer (logout + username);
   the parent SocialAIO provides Logout + user menu top-right. Session stays valid. */
body.embedded .sidebar-foot { display: none; }

/* FIX 1 — fill the full iframe width: drop the centered max-width columns so the
   main content spans the frame instead of leaving a large empty area to the side. */
body.embedded .chat-inner,
body.embedded .composer,
body.embedded .composer-hint,
body.embedded .attach-preview,
body.embedded .admin-inner { max-width: 100%; }

/* FIX 1b — the empty-state welcome hero: fill the main area (top-aligned, full width,
   left-aligned) instead of a small centered card, so a wide iframe has no big gutter.
   Kept intentional: glyph/heading top-left, paragraph capped for readability. */
body.embedded .empty-state { place-items: start stretch; padding: 40px 32px; text-align: left; }
body.embedded .empty-inner { max-width: none; width: 100%; margin: 0; }
body.embedded .empty-inner .brand-glyph { margin: 0 0 18px; }
body.embedded .empty-inner p { max-width: 640px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

*:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
