/* =========================================================
       1. TOKENS
       ========================================================= */
    :root {
      color-scheme: light;
      --primary: #15383B; --primary-hover: #1D4A4E; --primary-soft: #EEF7D3; --primary-ink: #FFFFFF;
      --accent: #C6E86C; --accent-ink: #15383B;
      --ink: #18373A; --muted: #536761; --background: #F5F8F4; --bg: var(--background); --surface: #FFFFFF; --surface-2: #FAFCF9; --border: #DCE5DF;
      --success: #176544; --success-bg: #E8F5EC; --warning: #7A5410; --warning-bg: #FFF4D6;
      --danger: #A53027; --danger-bg: #FDECE8; --info: #245C73; --info-bg: #E5F1F6;
      --focus: #286B78; --header: #15383B; --header-text: #F7FBF8; --header-muted: #D0E0D8;
      --header-line: rgba(255,255,255,.16); --surface-tint: #EDF2EE; --shadow-rgb: 21,56,59; --placeholder: #687B76;
      --teal: var(--header); --teal-2: var(--primary-hover); --lime: var(--accent); --lime-hover: #B7DB59;
      --lime-soft: var(--primary-soft); --card: var(--surface); --card-2: var(--surface-2); --text: var(--ink);
      --ok: var(--success); --ok-bg: var(--success-bg); --warn: var(--warning); --warn-bg: var(--warning-bg);
      --err: var(--danger); --err-bg: var(--danger-bg); --ring: var(--focus);

      --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
      --r-sm: 5px; --r-md: 8px; --r-lg: 12px;
      --shadow-sm: 0 1px 2px rgba(var(--shadow-rgb),.06);
      --shadow-md: 0 6px 18px rgba(var(--shadow-rgb),.09);
      --gutter: clamp(14px, 3vw, 32px);
      --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
      --font-display: Manrope, "DM Sans", system-ui, sans-serif;
      --font: var(--font-body);
    }
    :root[data-theme="dark"] { color-scheme: dark;
      --primary: #A9C5C1; --primary-hover: #C5DEDA; --primary-soft: #263E3D; --primary-ink: #13211F;
      --accent: #C6E86C; --accent-ink: #15383B;
      --ink: #E6EFEB; --muted: #B7C9C2; --background: #141C1C; --bg: var(--background); --surface: #1C2928; --surface-2: #22312F; --border: #3A4B48;
      --success: #8AD6AE; --success-bg: #1E392F; --warning: #F2C66D; --warning-bg: #3A3020;
      --danger: #FF9D91; --danger-bg: #422725; --info: #A8C3FF; --info-bg: #25334D;
      --focus: #A9D2CC; --header: #102A2B; --header-text: #F2F7F5; --header-muted: #C0D2CB;
      --header-line: rgba(255,255,255,.1); --surface-tint: #293345; --shadow-rgb: 0,0,0; --placeholder: #A9B8B4;
    }
    @media (prefers-color-scheme: dark) {
      :root:not([data-theme="light"]) { color-scheme: dark;
        --primary: #A9C5C1; --primary-hover: #C5DEDA; --primary-soft: #263E3D; --primary-ink: #13211F;
        --accent: #C6E86C; --accent-ink: #15383B;
        --ink: #E6EFEB; --muted: #B7C9C2; --background: #141C1C; --bg: var(--background); --surface: #1C2928; --surface-2: #22312F; --border: #3A4B48;
        --success: #8AD6AE; --success-bg: #1E392F; --warning: #F2C66D; --warning-bg: #3A3020;
        --danger: #FF9D91; --danger-bg: #422725; --info: #A8C3FF; --info-bg: #25334D;
        --focus: #A9D2CC; --header: #102A2B; --header-text: #F2F7F5; --header-muted: #C0D2CB;
        --header-line: rgba(255,255,255,.1); --surface-tint: #293345; --shadow-rgb: 0,0,0; --placeholder: #A9B8B4;
      }
    }

    /* =========================================================
       2. BASE
       ========================================================= */
    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
    body {
      margin: 0;
      color: var(--ink);
      background: var(--bg);
      font: 14px/1.55 var(--font);
      -webkit-font-smoothing: antialiased;
    }
    h1, h2, h3, h4, p { margin: 0; }
    h1, h2, h3, h4 { font-family: var(--font-display); }
    h1 { font-size: clamp(22px, 3.2vw, 28px); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
    h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
    h3 { font-size: 16px; font-weight: 700; line-height: 1.35; }
    a { color: inherit; }
    img { max-width: 100%; display: block; }
    button { font: inherit; color: inherit; cursor: pointer; }
    .icon { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .icon-sm { width: 15px; height: 15px; flex-basis: 15px; }
    .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
    :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

    /* =========================================================
       3. APP SHELL
       ========================================================= */
    .shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
    .skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); border-radius: var(--r-sm); color: var(--ink); background: var(--surface); box-shadow: var(--shadow-md); }
    .skip-link:focus { transform: translateY(0); }
    .main { grid-column: 2; min-width: 0; padding: var(--s5) var(--gutter) var(--s6); }
    .container { max-width: 1120px; margin: 0 auto; }

    /* ---- sidebar ---- */
    .sidebar {
      position: sticky; top: 0; z-index: 40; align-self: start; height: 100vh; min-height: 100vh;
      display: flex; flex-direction: column; gap: 18px;
      padding: 22px 14px max(18px, env(safe-area-inset-bottom)); color: var(--header-text); background: var(--header);
      overflow-x: hidden; overflow-y: auto; box-shadow: var(--shadow-sm);
    }
    .brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; font-weight: 700; font-size: 15px; white-space: nowrap; }
    .brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: var(--accent-ink); background: var(--accent); }
    .brand small { display: block; font-weight: 500; font-size: 11px; color: var(--header-muted); line-height: 1.2; }
    .nav { display: flex; flex: 1 1 auto; flex-direction: column; align-items: stretch; gap: 3px; min-width: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.35) transparent; padding: 0 0 8px; }
    .nav-label { display: block; padding: 10px 10px 5px; color: var(--header-muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
    .nav-item {
      display: flex; flex: 0 0 auto; align-items: center; gap: 10px; width: 100%;
      min-height: 44px; padding: 9px 10px;
      border: 0; border-radius: var(--r-md);
      background: transparent; color: var(--header-muted); text-align: left; font-weight: 550;
      white-space: nowrap; transition: background .15s, color .15s;
    }
    .nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
    .nav-item[aria-current="page"] { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
    .nav-count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 11px; background: rgba(255,255,255,.14); font-size: 11px; font-weight: 650; line-height: 20px; text-align: center; }
    .nav-item[aria-current="page"] .nav-count { background: rgba(21,56,59,.14); }
    .nav-count[data-zero="true"] { display: none; }

    .side-foot { display: grid; gap: 8px; margin-top: auto; }
    .auto-card { min-width: 0; padding: 12px; border-radius: var(--r-md); background: rgba(255,255,255,.07); border: 1px solid var(--header-line); transition: border-color .15s, background .15s; }
    .auto-card[data-on="true"] { border-color: var(--accent); background: rgba(198,232,108,.12); }
    .auto-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .auto-card strong { font-size: 13px; }
    .auto-card p { margin-top: 6px; font-size: 11.5px; line-height: 1.4; color: var(--header-muted); }
    .theme-toggle { min-height: 40px; display: inline-flex; align-items: center; justify-content: flex-start; gap: 7px; padding: 7px 10px; border: 1px solid var(--header-line); border-radius: var(--r-md); color: var(--header-text); background: transparent; font-weight: 600; white-space: nowrap; }
    .theme-toggle:hover { background: rgba(255,255,255,.08); }
    .cal-link { display: flex; align-items: center; gap: 8px; padding: 8px 10px; color: var(--header-muted); font-size: 12.5px; text-decoration: none; border-radius: var(--r-sm); white-space: nowrap; }
    .cal-link:hover { color: #fff; background: rgba(255,255,255,.07); }

    /* ---- switch ---- */
    .switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 42px; }
    .switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
    .switch-track { position: absolute; inset: 0; border-radius: 12px; background: var(--muted); transition: background .18s; }
    .switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .18s; }
    .switch input:checked + .switch-track { background: var(--primary); }
    .switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--primary-ink); }
    .switch input:focus-visible + .switch-track { outline: 3px solid var(--ring); outline-offset: 2px; }
    .switch input:disabled { cursor: wait; }
    .switch-lg { width: 52px; height: 30px; flex-basis: 52px; }
    .switch-lg .switch-track { border-radius: 15px; background: var(--border); }
    .switch-lg .switch-track::after { top: 3px; left: 3px; width: 24px; height: 24px; }
    .switch-lg input:checked + .switch-track::after { transform: translateX(22px); }
    .switch-lg input:checked + .switch-track { background: var(--primary); }
    .switch-lg input:checked + .switch-track::after { background: var(--primary-ink); }

    /* =========================================================
       4. PAGE HEADER + STATS
       ========================================================= */
    .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s4); }
    .eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: .02em; }
    .eyebrow::before { content: ""; width: 9px; height: 9px; border-radius: 2px 7px 2px 7px; background: var(--accent); transform: rotate(-8deg); }
    .intro { margin-top: 6px; max-width: 62ch; color: var(--muted); }
    .stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
    .stat {
      display: flex; flex-direction: column; gap: 2px; text-align: left;
      padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-lg);
      background: var(--card); box-shadow: var(--shadow-sm);
      transition: border-color .15s, box-shadow .15s;
    }
    .stat:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
    .stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 600; }
    .stat strong { font-size: 24px; line-height: 1.15; letter-spacing: -.02em; }
    .stat[data-tone="ok"] .stat-top .icon { color: var(--ok); }
    .stat[data-tone="err"] .stat-top .icon { color: var(--err); }
    .stat[data-tone="warn"] .stat-top .icon { color: #b8860b; }

    /* =========================================================
       5. BUTTONS + FORM CONTROLS
       ========================================================= */
    .btn {
      display: inline-flex; align-items: center; justify-content: center; gap: 8px;
      min-height: 40px; padding: 8px 16px;
      border: 1px solid transparent; border-radius: var(--r-md);
      font-weight: 650; line-height: 1.2; text-decoration: none; white-space: nowrap;
      transition: background .15s, border-color .15s, transform .05s;
    }
    .btn:active:not(:disabled) { transform: translateY(1px); }
    .btn:disabled { opacity: .55; cursor: not-allowed; }
    .btn-primary { background: var(--accent); color: var(--accent-ink); }
    .btn-primary:hover:not(:disabled) { background: var(--lime-hover); }
    .btn-secondary { background: var(--surface); border-color: var(--border); color: var(--ink); }
    .btn-secondary:hover:not(:disabled) { background: var(--primary-soft); border-color: var(--primary); }
    .btn-dark { background: var(--header); color: var(--header-text); }
    .btn-dark:hover:not(:disabled) { background: var(--header); filter: brightness(1.12); }
    .btn-danger { background: var(--danger); color: #fff; }
    .btn-ghost { background: transparent; color: var(--muted); padding: 6px 10px; min-height: 34px; }
    .btn-ghost:hover:not(:disabled) { background: var(--primary-soft); color: var(--ink); }
    .btn-block { width: 100%; }
    .btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13px; }
    .spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
    @keyframes spin { to { transform: rotate(360deg); } }

    .field { margin-top: var(--s4); }
    .field:first-child { margin-top: 0; }
    .field > label, .field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-weight: 650; font-size: 13px; }
    .req { color: var(--err); font-size: 11.5px; font-weight: 600; }
    .opt { color: var(--muted); font-size: 11.5px; font-weight: 500; }
    .input, input[type="text"], input[type="url"], input[type="date"], input[type="time"], input[type="search"], textarea, select {
      display: block; width: 100%; min-height: 42px; padding: 9px 12px;
      border: 1px solid var(--border); border-radius: var(--r-md);
      background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
      transition: border-color .15s, box-shadow .15s;
    }
    @media (min-width: 821px) { .input, input[type="text"], input[type="url"], input[type="date"], input[type="time"], input[type="search"], textarea, select { font-size: 14px; } }
    textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
    input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
    input:hover, textarea:hover, select:hover { border-color: #c3d2c9; }
    input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent); }
    [aria-invalid="true"] { border-color: var(--err) !important; }
    input[type="file"] { padding: 7px 10px; min-height: 42px; font-size: 13px; }
    input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--primary); flex: 0 0 18px; }
    .help { margin-top: 6px; color: var(--muted); font-size: 12px; }
    .field-error { margin-top: 6px; color: var(--err); font-size: 12.5px; font-weight: 600; }
    .counter { color: var(--muted); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
    .counter.over { color: var(--err); }

    /* =========================================================
       6. CARDS / PANELS / BADGES
       ========================================================= */
    .panel { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow-sm); }
    .panel-pad { padding: clamp(16px, 2.4vw, 24px); }
    .panel + .panel { margin-top: var(--s4); }
    .panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
    .panel-head p { margin-top: 3px; color: var(--muted); font-size: 13px; }
    .section-num { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 8px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; }

    .badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--surface-tint); color: var(--ink); }
    .badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
    .badge[data-s="Draft"] { background: var(--warning-bg); color: var(--warning); }
    .badge[data-s="Approved"] { background: var(--info-bg); color: var(--info); }
    .badge[data-s="Generating"], .badge[data-s="Scheduled"] { background: var(--info-bg); color: var(--info); }
    .badge[data-s="Not started"] { background: var(--surface-tint); color: var(--muted); }
    .badge[data-s="Posted"] { background: var(--success-bg); color: var(--success); }
    .badge[data-s="Failed"] { background: var(--danger-bg); color: var(--danger); }
    .chip { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
    .chip strong { color: var(--text); font-weight: 600; }

    .notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: var(--r-md); font-size: 13px; font-weight: 550; }
    .notice.success { color: var(--ok); background: var(--ok-bg); }
    .notice.error { color: var(--err); background: var(--err-bg); }
    .notice.warn { color: var(--warn); background: var(--warn-bg); }
    .notice .icon { margin-top: 2px; }

    .empty { display: grid; place-items: center; gap: 8px; padding: 44px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--r-lg); background: var(--card-2); }
    .empty .icon { width: 28px; height: 28px; color: var(--muted); }
    .empty strong { color: var(--text); font-size: 15px; }
    .skeleton { height: 78px; margin-top: var(--s3); border-radius: var(--r-lg); background: var(--surface-tint); animation: shimmer 1.3s linear infinite; }
    @keyframes shimmer { to { background-position: -200% 0; } }

    /* =========================================================
       7. QUEUE + POST CARDS
       ========================================================= */
    .toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 200px auto; gap: var(--s2); margin-bottom: var(--s3); }
    .search-wrap { position: relative; }
    .search-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
    .search-wrap input { padding-left: 38px; }
    .queue-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: var(--s2); color: var(--muted); font-size: 12.5px; }

    .post { margin-top: var(--s3); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--card); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
    .post:hover { box-shadow: var(--shadow-md); }
    .post[data-dirty="true"] { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(127,181,170,.3); }
    .post-head { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); }
    .thumb { width: 64px; height: 64px; border-radius: var(--r-md); object-fit: cover; background: var(--bg); border: 1px solid var(--border); }
    .thumb-empty { display: grid; place-items: center; color: var(--muted); }
    .post-title { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
    .post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 5px; }
    .post-side { display: flex; align-items: center; gap: var(--s2); }
    .toggle-btn .icon { transition: transform .2s; }
    .toggle-btn[aria-expanded="true"] .icon { transform: rotate(180deg); }
    .post-body { padding: var(--s4); border-top: 1px solid var(--border); background: var(--card-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
    .review-grid { display: grid; grid-template-columns: minmax(300px, .75fr) minmax(0, 1.25fr); gap: 24px; align-items: start; }
    .review-media .preview { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--bg); }
    .review-media .no-image { display: grid; place-items: center; gap: 6px; aspect-ratio: 1; padding: 12px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--r-md); background: var(--surface); font-size: 13px; }
    .review-media .no-image .icon { width: 26px; height: 26px; }
    .gen-time { margin-top: 8px; color: var(--muted); font-size: 12px; }
    .prompt-box { margin-top: var(--s3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
    .prompt-box summary { padding: 9px 12px; cursor: pointer; font-weight: 600; font-size: 13px; list-style: none; display: flex; align-items: center; justify-content: space-between; }
    .prompt-box summary::-webkit-details-marker { display: none; }
    .prompt-box summary::after { content: "+"; color: var(--muted); font-size: 18px; line-height: 1; }
    .prompt-box[open] summary::after { content: "\2212"; }
    .prompt-box pre { margin: 0; padding: 0 12px 12px; max-height: 200px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
    .prompt-workspace { overflow: hidden; }
    .prompt-workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--border); }
    .prompt-workspace-head > div:first-child { display: grid; gap: 3px; min-width: 0; }
    .prompt-workspace-head strong { font-size: 13px; }
    .prompt-workspace-head span { color: var(--muted); font-size: 11px; line-height: 1.4; }
    .prompt-tabs { display: flex; flex: 0 0 auto; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); }
    .prompt-tab { min-height: 32px; padding: 4px 9px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 650; }
    .prompt-tab[aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }
    .prompt-pane { padding: 10px 12px 12px; }
    .post-image-prompt { display: block; width: 100%; min-height: 148px; resize: vertical; padding: 10px; border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--ink); background: var(--surface); font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
    .prompt-save-hint { margin: 6px 0 0; }
    .prompt-output { padding: 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); }
    .prompt-output > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
    .prompt-box .prompt-preview { max-height: 280px; margin: 0; padding: 0; color: var(--ink); }
    .prompt-empty { margin: 0; color: var(--muted); font-size: 12px; }
    .upload-field { margin-top: var(--s3); }
    .row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
    .checklist { display: grid; gap: 8px; margin-top: var(--s4); padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
    .checklist-title { font-size: 12px; font-weight: 700; color: var(--muted); }
    .checklist label { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 550; cursor: pointer; }
    .notes-box { margin-top: var(--s3); }
    .post-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border); }
    .post-actions .status-line { flex: 1 1 200px; order: 3; color: var(--muted); font-size: 12.5px; min-height: 18px; }
    .post-actions .status-line.bad { color: var(--err); font-weight: 600; }
    .revision-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
    .revision-tools .revision-label { flex: 1 1 100%; color: var(--muted); font-size: 12px; font-weight: 650; }
    .revision-state { flex: 1 1 100%; margin: 0; color: var(--muted); font-size: 12px; }
    .post-error { margin-bottom: var(--s3); }
    .posted-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--ok); text-decoration: none; }
    .posted-link:hover { text-decoration: underline; }

    .fail-list { margin-top: var(--s5); }
    .fail-list h2 { margin-bottom: var(--s3); }
    .fail-row { display: grid; gap: 4px; padding: 12px 14px; margin-top: var(--s2); border: 1px solid var(--danger-bg); border-left: 3px solid var(--err); border-radius: var(--r-md); background: var(--surface); }
    .fail-row strong { font-size: 13.5px; }
    .fail-row .when { color: var(--muted); font-size: 12px; }
    .fail-row p { color: var(--err); font-size: 13px; overflow-wrap: anywhere; }
    .fail-row .fix { color: var(--muted); }

    /* =========================================================
       8. CREATE POST
       ========================================================= */
    .create-wrap { max-width: 920px; }
    .ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s3); margin-top: var(--s3); }
    .idea { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--card-2); }
    .idea .kind { align-self: flex-start; padding: 2px 8px; border-radius: 999px; background: var(--lime-soft); color: var(--accent-ink); font-size: 11px; font-weight: 700; }
    .idea h3 { font-size: 13.5px; font-weight: 600; }
    .idea .src { color: var(--muted); font-size: 12px; }
    .idea-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
    .ideas-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
    .adv { margin-top: var(--s4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--card-2); }
    .adv > summary { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; cursor: pointer; font-weight: 650; list-style: none; }
    .adv > summary::-webkit-details-marker { display: none; }
    .adv > summary::after { content: "+"; font-size: 20px; color: var(--muted); line-height: 1; }
    .adv[open] > summary::after { content: "\2212"; }
    .adv-body { padding: 0 14px 16px; }
    .choice-source { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
    .choice-rail { display: flex; flex-wrap: nowrap; gap: 8px; max-width: 100%; overflow-x: auto; padding: 2px 2px 9px; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: thin; }
    .choice-chip { flex: 0 0 auto; min-height: 38px; padding: 6px 13px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); font-size: 13px; font-weight: 600; scroll-snap-align: start; transition: background .15s, border-color .15s; }
    .choice-chip:hover { background: var(--lime-soft); }
    .choice-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
    .form-actions { margin-top: var(--s5); display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
    .form-actions .btn-primary { min-width: 200px; }

    /* =========================================================
       9. PROFILE + SETTINGS
       ========================================================= */
    .narrow { max-width: 860px; }
    .profile-section { margin-top: var(--s3); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--card); }
    .profile-section > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; cursor: pointer; font-weight: 650; list-style: none; }
    .profile-section > summary::-webkit-details-marker { display: none; }
    .profile-section > summary::after { content: "+"; font-size: 20px; font-weight: 400; color: var(--muted); line-height: 1; }
    .profile-section[open] > summary::after { content: "\2212"; }
    .profile-section[open] > summary { border-bottom: 1px solid var(--border); }
    .profile-count { margin-left: auto; margin-right: 10px; color: var(--muted); font-size: 12px; font-weight: 500; }
    .profile-fields { padding: 4px 16px 16px; }
    .profile-field { margin-top: var(--s4); }
    .profile-field label { display: block; margin-bottom: 6px; font-weight: 650; font-size: 13px; }
    .profile-field textarea { min-height: 76px; }
    .savebar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s4); padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-md); }
    .savebar p { flex: 1 1 220px; color: var(--muted); font-size: 12.5px; }

    .auto-hero { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: clamp(16px, 2.4vw, 24px); border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--card); }
    .auto-hero[data-on="true"] { border-color: var(--warning); background: var(--warning-bg); }
    .auto-hero h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
    .state-pill { padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-tint); color: var(--muted); }
    .auto-hero[data-on="true"] .state-pill { background: var(--accent); color: var(--accent-ink); }
    .auto-hero p { margin-top: 6px; color: var(--muted); max-width: 58ch; }
    .flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--s3); margin-top: var(--s4); }
    .flow-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--card); }
    .flow-card .icon { color: var(--primary); margin-bottom: 8px; width: 22px; height: 22px; }
    .flow-card h3 { margin-bottom: 4px; }
    .flow-card p { color: var(--muted); font-size: 13px; }

    .foot { margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

    /* ---- toast + dialog ---- */
    .toast-host { position: fixed; z-index: 90; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(calc(100vw - 32px), 380px); pointer-events: none; }
    .toast { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: var(--r-md); color: var(--header-text); background: var(--header); box-shadow: 0 8px 24px rgba(var(--shadow-rgb),.25); font-size: 13px; font-weight: 600; animation: toast-in .18s ease-out; }
    .toast.success { background: var(--ok); }
    .toast.error { background: var(--err); }
    @keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
    dialog { width: min(calc(100vw - 32px), 440px); padding: 0; border: 0; border-radius: var(--r-lg); color: var(--text); box-shadow: 0 20px 60px rgba(21,56,59,.35); }
    dialog::backdrop { background: rgba(21,56,59,.5); }
    .dlg { padding: 22px; }
    .dlg h3 { font-size: 17px; margin-bottom: 8px; }
    .dlg p { color: var(--muted); }
    .dlg-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s5); flex-wrap: wrap; }

    /* =========================================================
       10. RESPONSIVE
       ========================================================= */
    @media (max-width: 1100px) {
      .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    }
    @media (max-width: 820px) {
      .input, input[type="text"], input[type="url"], input[type="date"], input[type="time"], input[type="search"], textarea, select { min-height: 44px; font-size: 16px; }
    }
    @media (max-width: 1023px) {
      .shell { grid-template-columns: minmax(0, 1fr); }
      .main { grid-column: 1; }
      .sidebar { position: sticky; top: 0; z-index: 40; height: auto; min-height: 0; max-height: none; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto auto; gap: 6px 12px; align-items: center; padding: 9px var(--gutter) 7px; overflow: visible; }
      .brand { grid-column: 1; grid-row: 1; padding: 0; }
      .side-foot { display: contents; }
      .auto-card { grid-column: 2; grid-row: 1; min-width: 0; padding: 0; border: 0; background: transparent; }
      .auto-card p { display: block; max-width: 32ch; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
      .auto-card strong { font-size: 12.5px; }
      .theme-toggle { grid-column: 1; grid-row: 3; min-height: 36px; padding: 4px 8px; }
      .cal-link { grid-column: 2; grid-row: 3; justify-self: end; padding: 4px 0; }
      .nav { grid-column: 1 / -1; grid-row: 2; flex: none; flex-direction: row; gap: 4px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: thin; padding: 0 2px 4px; mask-image: linear-gradient(90deg, transparent, #000 10px, #000 calc(100% - 16px), transparent); }
      .nav-label { display: none; }
      .nav-item { flex: 0 0 auto; width: auto; min-height: 44px; padding: 7px 11px; }
      .nav-count { margin-left: 2px; }
      .btn, .btn-sm { min-height: 44px; }
    }
    @media (max-width: 760px) {
      .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
      .toolbar { grid-template-columns: 1fr 1fr; }
      .toolbar .search-wrap { grid-column: 1 / -1; }
      .auto-hero { flex-direction: column; align-items: flex-start; }
      .main { padding-top: var(--s4); }
      .sidebar { gap: 5px 10px; }
      .nav-item { min-height: 44px; }
    }
    @media (max-width: 560px) {
      .prompt-workspace-head { align-items: flex-start; flex-direction: column; }
      .prompt-tabs { width: 100%; }
      .prompt-tab { flex: 1 1 0; min-height: 44px; }
      .post-head { grid-template-columns: 52px minmax(0, 1fr); grid-template-areas: "thumb info" "side side"; }
      .post-head > .thumb, .post-head > .thumb-empty { grid-area: thumb; width: 52px; height: 52px; }
      .post-head > .post-info { grid-area: info; }
      .post-head > .post-side { grid-area: side; justify-content: space-between; }
      .row-2 { grid-template-columns: 1fr 1fr; gap: 8px; }
      .post-actions .btn { flex: 1 1 140px; }
      .form-actions .btn-primary { width: 100%; }
      .ideas { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: min(80vw, 270px); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; overscroll-behavior-x: contain; }
      .idea { scroll-snap-align: start; }
      .btn { min-height: 44px; }
      .btn-sm { min-height: 44px; }
      .editor-tab, .choice-chip { min-height: 44px; }
      .toast-host { left: 16px; right: 16px; width: auto; }
      .auto-card p { display: none; }
      .cal-link { justify-self: end; }
    }
    @media (max-width: 380px) {
      .stats { gap: 8px; }
      .stat { padding: 10px; }
      .stat strong { font-size: 21px; }
      .brand small { display: none; }
      .toolbar { grid-template-columns: 1fr; }
      .brand { font-size: 14px; }
      .auto-card strong { font-size: 12px; }
      .nav-item { padding-inline: 8px; font-size: 12.5px; }
      .row-2 { grid-template-columns: 1fr; }
    }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
    }

    /* =========================================================
       11. NAVIGATION AND REVIEW POLISH
       ========================================================= */
    .nav-item { flex-shrink: 0; }
    .nav-item:focus-visible { outline-color: var(--accent); outline-offset: 1px; }
    .nav-count, .stat strong { font-variant-numeric: tabular-nums; }
    .page-head, .post { scroll-margin-top: 150px; }
    .post:focus-within { border-color: var(--primary); }
    .post-head, .post-side { min-width: 0; }
    .post-title { line-height: 1.4; }
    .post-actions .btn-primary { box-shadow: var(--shadow-sm); }
    .revision-tools .btn { white-space: normal; text-align: center; }
    .revision-tools .revision-label { color: var(--ink); }
    .ideas-head h3 { min-height: 40px; }
    .choice-rail { scrollbar-color: #9eb7ad transparent; }
    .choice-chip:focus-visible, .idea:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
    .field-error:empty { display: none; }
    .savebar { backdrop-filter: blur(8px); }
    .revision-state { display: flex; align-items: center; gap: 7px; }
    .revision-state::before { content: ""; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--info); }
    .btn-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-bg); }
    .btn-warning:hover:not(:disabled) { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
    .editor-tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; padding: 4px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
    .editor-tab { min-height: 36px; padding: 6px 13px; border: 0; border-radius: var(--r-sm); color: var(--muted); background: transparent; font-weight: 650; }
    .editor-tab[aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }
    .editor-tabs .counter { margin-left: auto; padding-inline: 8px; }
    .linkedin-preview { max-width: 650px; margin: 0 auto 16px; padding: 16px; border: 1px solid var(--border); border-radius: var(--r-lg); color: var(--ink); background: var(--surface); }
    .linkedin-preview-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
    .linkedin-preview-head > div { display: grid; line-height: 1.3; }
    .linkedin-preview-head > div span { color: var(--muted); font-size: 12px; }
    .preview-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--primary); background: var(--primary-soft); }
    .preview-copy { min-height: 80px; white-space: pre-wrap; overflow-wrap: anywhere; }
    .preview-empty-copy { color: var(--muted); font-style: italic; }
    .preview-more { margin-top: 6px; padding: 0; border: 0; color: var(--muted); background: transparent; font-weight: 650; }
    .preview-image-slot { margin: 14px -16px -16px; overflow: hidden; background: var(--surface-2); }
    .preview-image-slot img { width: 100%; max-height: 420px; object-fit: cover; }
    .profile-progress-wrap { margin-top: 16px; }
    .profile-progress-copy { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
    .profile-progress-copy strong { color: var(--ink); }
    .profile-progress-wrap progress { display: block; width: 100%; height: 8px; overflow: hidden; border: 0; border-radius: 8px; accent-color: var(--primary); background: var(--surface-tint); }
    .profile-progress-wrap progress::-webkit-progress-bar { border-radius: 8px; background: var(--surface-tint); }
    .profile-progress-wrap progress::-webkit-progress-value, .profile-progress-wrap progress::-moz-progress-bar { border-radius: 8px; background: var(--primary); }
    .nav-label { padding: 12px 10px 5px; color: var(--header-muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
    .nav-item[aria-current="page"] .nav-count { background: rgba(21,56,59,.14); }
    .stat strong, .nav-count { font-variant-numeric: tabular-nums; }
    .auto-hero[data-on="true"] { border-color: var(--warning); background: var(--warning-bg); }
    .auto-hero[data-on="true"] .state-pill { background: var(--warning-bg); color: var(--warning); }
    .auto-hero[data-on="true"] p { color: var(--ink); }
    .auto-hero[data-on="true"] .switch-lg input:checked + .switch-track { background: var(--warning); }
    .post { scroll-margin-top: 150px; }
    .page-head { scroll-margin-top: 150px; }
    .post:focus-within { border-color: var(--primary); }
    @media (max-width: 560px) {
      .sidebar { padding-top: 8px; }
      .nav-item { gap: 7px; padding-inline: 10px; }
      .post-side { flex-wrap: wrap; }
      .revision-tools { align-items: stretch; }
      .revision-tools .btn { flex: 1 1 145px; }
      .savebar { bottom: env(safe-area-inset-bottom); margin-inline: -4px; padding: 10px; }
      .theme-toggle { min-height: 44px; }
    }
    
    /* =========================================================
       12. REVIEW WORKSPACE ALIGNMENT
       ========================================================= */
    .review-media, .review-edit { min-width: 0; }
    .review-media .preview, .review-media .no-image { max-width: 360px; }
    .review-media .preview { cursor: zoom-in; }
    .image-workflow { grid-column: 1 / -1; display: grid; gap: 8px; margin-top: 9px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
    .image-workflow-actions { display: flex; flex-wrap: wrap; gap: 8px; }
    .image-workflow .btn-primary { width: auto; flex: 1 1 280px; }
    .image-workflow-actions .btn-secondary { flex: 1 1 260px; }
    .image-steps { display: flex; flex-wrap: wrap; gap: 6px; }
    .image-step { padding: 4px 7px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 11px; }
    .image-step[data-state="active"] { color: var(--primary); border-color: var(--primary); font-weight: 700; }
    .image-step[data-state="done"] { color: var(--success); }
    .image-job-message { min-height: 18px; color: var(--muted); font-size: 12px; }
    .image-compare, .image-history { display: flex; align-items: center; gap: 8px; overflow-x: auto; }
    .image-compare img, .image-history img { width: 84px; height: 58px; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; cursor: zoom-in; }
    .image-history button { padding: 0; border: 0; background: none; }
    .prompt-tools, .content-tools, .alt-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 8px; }
    .prompt-tools .btn, .content-tools .btn, .alt-tools .btn { min-height: 36px; }
    .prompt-dirty, .unsaved-badge { display: inline-flex; padding: 3px 7px; border-radius: 5px; background: var(--warning-bg); color: var(--warning); font-size: 11px; font-weight: 700; }
    .prompt-counter, .tool-meta { color: var(--muted); font-size: 11px; }
    .prompt-structured { display: grid; gap: 8px; }
    .prompt-section { padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
    .prompt-section strong { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
    .prompt-section p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
    .prompt-scene { border-color: var(--primary); background: var(--primary-soft); }
    .prompt-tips { margin: 8px 0 0; }
    .prompt-tips summary { cursor: pointer; color: var(--muted); font-size: 12px; }
    .prompt-warning { margin: 8px 0 0; color: var(--warning); font-size: 11px; }
    .preview-image-slot { aspect-ratio: 1.91 / 1; overflow: hidden; border-radius: var(--r-md); background: var(--surface-2); }
    .preview-image-slot img { width: 100%; height: 100%; object-fit: cover; }
    .linkedin-preview-head strong { display: block; }
    .linkedin-preview-head span.preview-meta { display: block; color: var(--muted); font-size: 11px; }
    .card-discard { margin-left: auto; color: var(--warning); }
    .review-grid .post-date, .review-grid .post-time { height: 44px; min-height: 44px; }
    @media (max-width: 900px) {
      .review-grid { grid-template-columns: 1fr; gap: 16px; }
      .image-workflow { grid-column: 1; }
    }
    @media (max-width: 760px) {
      .review-media .preview, .review-media .no-image { max-width: 280px; }
      .image-workflow-actions .btn { flex: 1 1 100%; }
      .post-actions { position: sticky; bottom: env(safe-area-inset-bottom); z-index: 4; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); margin: 0 -12px; background: var(--surface); box-shadow: 0 -4px 16px rgba(var(--shadow-rgb), .08); }
      .post-actions .status-line { order: 5; flex-basis: 100%; }
    }
    @media (prefers-reduced-motion: reduce) {
      .image-step, .review-media .preview { transition: none !important; }
    }
