  /* ═══════════════════════════════════════════
     APPLE HIG — Design System
     ═══════════════════════════════════════════ */

  /* --- Apple System Colors --- */
  [data-theme="dark"] {
    --system-blue: #0A84FF;
    --system-green: #30D158;
    --system-orange: #FF9F0A;
    --system-red: #FF453A;
    --system-purple: #BF5AF2;
    --system-pink: #FF375F;
    --system-teal: #64D2FF;
    --system-yellow: #FFD60A;

    --label: #FFFFFF;
    --label-secondary: rgba(255, 255, 255, 0.55);
    --label-tertiary: rgba(255, 255, 255, 0.25);

    --background: #1E1E1E;
    --background-secondary: #2C2C2E;
    --background-tertiary: #3A3A3C;

    --separator: rgba(255, 255, 255, 0.1);
    --separator-thin: rgba(255, 255, 255, 0.05);

    --fill: rgba(255, 255, 255, 0.08);
    --fill-hover: rgba(255, 255, 255, 0.12);

    --sidebar-bg: #181818;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: #0A84FF;

    --toolbar-bg: rgba(30, 30, 30, 0.82);
    --card-bg: #2C2C2E;
    --card-border: rgba(255, 255, 255, 0.06);

    --input-bg: rgba(255, 255, 255, 0.1);
    --input-border: rgba(255, 255, 255, 0.15);

    --shadow: rgba(0, 0, 0, 0.4);
  }

  [data-theme="light"] {
    --system-blue: #007AFF;
    --system-green: #34C759;
    --system-orange: #FF9500;
    --system-red: #FF3B30;
    --system-purple: #AF52DE;
    --system-pink: #FF2D55;
    --system-teal: #5AC8FA;
    --system-yellow: #FFCC00;

    --label: #1D1D1F;
    --label-secondary: rgba(0, 0, 0, 0.5);
    --label-tertiary: rgba(0, 0, 0, 0.25);

    --background: #F5F5F7;
    --background-secondary: #FFFFFF;
    --background-tertiary: #FAFAFA;

    --separator: rgba(0, 0, 0, 0.12);
    --separator-thin: rgba(0, 0, 0, 0.06);

    --fill: rgba(0, 0, 0, 0.06);
    --fill-hover: rgba(0, 0, 0, 0.1);

    --sidebar-bg: rgba(245, 245, 247, 0.85);
    --sidebar-hover: rgba(0, 0, 0, 0.06);
    --sidebar-active: #007AFF;

    --toolbar-bg: rgba(245, 245, 247, 0.82);
    --card-bg: #FFFFFF;
    --card-border: rgba(0, 0, 0, 0.08);

    --input-bg: rgba(0, 0, 0, 0.06);
    --input-border: rgba(0, 0, 0, 0.15);

    --shadow: rgba(0, 0, 0, 0.1);
  }

  :root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'JetBrains Mono', monospace;
    --sidebar-width: 240px;

    /* 8pt grid */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

    --radius-sm: 5px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 999px;
  }

  /* ═══════════════════════════════════════════
     RESET + BASE
     ═══════════════════════════════════════════ */
  *, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    font-family: var(--font);
    background: var(--background);
    color: var(--label);
    font-size: 13px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    height: 100vh;
    display: flex;
  }

  /* ═══════════════════════════════════════════
     SIDEBAR — Apple macOS style
     ═══════════════════════════════════════════ */
  .sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-right: 0.5px solid var(--separator-thin);
    display: flex;
    flex-direction: column;
    padding: var(--sp-3);
    flex-shrink: 0;
    z-index: 10;
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3) var(--sp-5);
    border-bottom: 0.5px solid var(--separator-thin);
    margin-bottom: var(--sp-2);
  }

  .sidebar-logo-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--system-blue), var(--system-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
  }

  .sidebar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--label);
    letter-spacing: -0.1px;
    line-height: 1.2;
  }

  .sidebar-subtitle {
    font-size: 10px;
    font-weight: 500;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }


  .sidebar-avatar {
    padding: 8px 12px;
    display: flex;
    justify-content: center;
  }
  .sidebar-avatar .avatar-img {
    width: 100%;
    max-width: 220px;
    height: auto;
    aspect-ratio: 1/1;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--separator);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
  }
  .sidebar-avatar .avatar-img:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  }

  .sidebar-section {
    font-size: 10px;
    font-weight: 600;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: var(--sp-3) var(--sp-3) var(--sp-1);
    margin-top: var(--sp-1);
  }

  .sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px var(--sp-3);
    height: 30px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--label);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: var(--font);
    width: 100%;
    text-align: left;
    line-height: 1;
    white-space: nowrap;
  }

  .nav-item:hover {
    background: var(--sidebar-hover);
  }

  .nav-item.active {
    background: var(--sidebar-active);
    color: white;
  }

  .nav-item.active .nav-icon {
    color: white;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--label-secondary);
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1;
  }

  .sidebar-footer {
    margin-top: auto;
    padding: var(--sp-2) var(--sp-2) 0;
    border-top: 0.5px solid var(--separator-thin);
  }

  .sidebar-social {
    display: flex;
    gap: 6px;
    padding: 6px var(--sp-3);
    flex-wrap: wrap;
  }

  .social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    color: var(--label-secondary);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    letter-spacing: 0.5px;
    transition: all 0.15s;
  }

  .social-link:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
  }

  .sidebar-social .social-link:nth-child(1) { color: #0077FF; }
  .sidebar-social .social-link:nth-child(2) { color: #E4405F; }
  .sidebar-social .social-link:nth-child(3) { color: #0088CC; }
  .sidebar-social .social-link:nth-child(4) { color: #0088CC; }

  .sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px var(--sp-3);
    border-radius: var(--radius-sm);
  }

  .sidebar-user-avatar {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--system-blue), var(--system-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 9px;
    font-weight: 600;
    flex-shrink: 0;
  }

  .sidebar-user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--label);
    line-height: 1.2;
  }

  .sidebar-user-email {
    font-size: 10px;
    color: var(--label-secondary);
  }

  /* ═══════════════════════════════════════════
     MAIN LAYOUT
     ═══════════════════════════════════════════ */
  .main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
  }

  /* --- Toolbar (macOS unified) --- */
  .page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-5);
    height: 50px;
    background: var(--toolbar-bg);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-bottom: 0.5px solid var(--separator-thin);
    flex-shrink: 0;
    gap: var(--sp-4);
  }

  .page-header-left {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    min-width: 0;
  }

  .page-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--label);
    white-space: nowrap;
  }

  .page-header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
  }

  /* --- Content area --- */
  .content-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-6);
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
  }

  .content-area::-webkit-scrollbar {
    width: 6px;
  }
  .content-area::-webkit-scrollbar-track {
    background: transparent;
  }
  .content-area::-webkit-scrollbar-thumb {
    background: var(--fill);
    border-radius: 3px;
  }
  .content-area::-webkit-scrollbar-thumb:hover {
    background: var(--fill-hover);
  }

  /* ═══════════════════════════════════════════
     TABS
     ═══════════════════════════════════════════ */
  .tab-content {
    display: none;
  }

  .tab-content.active {
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
  }

  /* ═══════════════════════════════════════════
     APPLE CARDS
     ═══════════════════════════════════════════ */
  .panel, .card {
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-md);
    overflow: hidden;
  }

  .panel h3, .card h3 {
    font-size: 13px;
    font-weight: 600;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 0.5px solid var(--separator-thin);
    margin: 0;
  }

  .panel h3:not(:first-child) {
    border-top: 0.5px solid var(--separator-thin);
    border-bottom: none;
  }

  .panel > *:not(h3):not(.card-header):not(.card-body):not(.card-footer):not(.plan-tabs) {
    padding: var(--sp-5);
  }

  .result-box {
    padding: var(--sp-5);
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
  }

  .social-caption-box {
    margin-top: 12px;
    border-left: 3px solid var(--system-teal, #30d158);
    background: rgba(48, 209, 88, 0.04);
  }
  .social-caption-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--label-secondary);
    margin-bottom: 6px;
  }
  .social-caption-text {
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
  }

  /* ═══════════════════════════════════════════
     FORM ELEMENTS
     ═══════════════════════════════════════════ */
  .form-row {
    display: flex;
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
    align-items: flex-end;
  }

  .form-row:last-child {
    margin-bottom: 0;
  }

  .form-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
  }

  .form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    height: 28px;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-sm);
    border: 0.5px solid var(--input-border);
    background: var(--input-bg);
    color: var(--label);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    transition: all 0.15s ease;
    width: 100%;
    -webkit-appearance: auto;
    appearance: auto;
  }
  select option {
    background: var(--background-secondary);
    color: var(--label);
  }

  .form-group textarea {
    height: auto;
    padding: var(--sp-2) var(--sp-3);
    line-height: 1.5;
    resize: vertical;
  }

  .form-group input:focus,
  .form-group textarea:focus,
  .form-group select:focus {
    border-color: var(--system-blue);
    box-shadow: 0 0 0 2px rgba(10, 132, 255, 0.2);
  }

  .form-group input::placeholder,
  .form-group textarea::placeholder {
    color: var(--label-tertiary);
  }

  /* ═══════════════════════════════════════════
     APPLE BUTTONS
     ═══════════════════════════════════════════ */
  .btn, button.btn, a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 28px;
    padding: 0 var(--sp-4);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
  }

  .btn:active {
    transform: scale(0.98);
  }

  .btn-ai, .btn-primary {
    background: var(--system-blue);
    color: white;
  }

  .btn-ai:hover, .btn-primary:hover {
    filter: brightness(1.1);
  }

  .btn-primary {
    background: var(--system-blue);
  }

  .btn-sm {
    height: 22px;
    padding: 0 var(--sp-3);
    font-size: 11px;
    background: var(--fill);
    color: var(--label);
  }

  .btn-sm:hover {
    background: var(--fill-hover);
  }

  .btn-revise {
    background: var(--fill);
    color: var(--label);
  }

  .btn-revise:hover {
    background: var(--fill-hover);
  }

  .btn-idea {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff; border: none; cursor: pointer; font-weight: 500;
  }
  .btn-idea:hover { filter: brightness(1.1); }
  .btn-idea:active { filter: brightness(0.95); }
  .btn-idea.loading { opacity: 0.7; pointer-events: none; }

  /* ── Apple-style toggle switch ── */
  .toggle-switch {
    display: inline-flex; align-items: center; gap: 10px;
    cursor: pointer; user-select: none; font-size: 13px;
    color: var(--label-secondary); font-weight: 500;
    transition: color 0.2s;
  }
  .toggle-switch.active { color: var(--label); }
  .toggle-track {
    position: relative; width: 44px; height: 24px; flex-shrink: 0;
    background: #3a3d44; border-radius: 12px;
    transition: background 0.2s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
  }
  .toggle-track .toggle-knob {
    position: absolute; top: 2px; left: 2px;
    width: 20px; height: 20px; border-radius: 50%;
    background: white; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    transition: transform 0.25s ease;
  }
  .toggle-switch input { display: none; }
  .toggle-switch input:checked + .toggle-track { background: var(--system-green); }
  .toggle-switch input:checked + .toggle-track .toggle-knob { transform: translateX(20px); }

  #idea-results {
    display: grid; gap: 6px; animation: fadeSlideIn 0.25s ease;
  }
  #idea-results .idea-item {
    background: var(--fill); border: 1px solid var(--separator);
    border-radius: var(--radius); padding: 10px 14px;
    cursor: pointer; transition: all 0.15s;
  }
  #idea-results .idea-item:hover {
    border-color: var(--tint-color); background: var(--fill-hover);
  }
  #idea-results .idea-item .idea-title {
    font-weight: 600; font-size: 0.95rem; color: var(--label);
  }
  #idea-results .idea-item .idea-desc {
    font-size: 0.8rem; color: var(--label-dim); margin-top: 2px;
  }
  #idea-results .idea-item .idea-meta {
    font-size: 0.75rem; color: var(--label-dim); margin-top: 4px;
    display: flex; gap: 8px;
  }
  #idea-results .idea-error {
    padding: 10px 14px; background: var(--fill-critical); border-radius: var(--radius);
    color: var(--label-critical); font-size: 0.85rem;
  }
  @keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* ═══════════════════════════════════════════
     CUSTOM SELECT (Profile Picker)
     ═══════════════════════════════════════════ */
  .profile-picker {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
  }

  .profile-picker > label {
    font-size: 11px;
    font-weight: 600;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-right: 4px;
  }

  .profile-select-apple {
    appearance: auto;
    -webkit-appearance: auto;
    background: var(--background-secondary);
    border: 0.5px solid var(--separator);
    border-radius: var(--radius-md);
    color: var(--label);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 20px 4px 8px;
    min-width: 100px;
    cursor: pointer;
    font-family: var(--font);
    outline: none;
  }
  .profile-select-apple:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
  }

  .custom-select {
    position: relative;
    display: inline-block;
  }

  .custom-select-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-sm);
    background: var(--fill);
    color: var(--label);
    border: none;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
  }

  .custom-select-trigger:hover {
    background: var(--fill-hover);
  }

  .custom-select-arrow {
    font-size: 8px;
    color: var(--label-tertiary);
  }

  .custom-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 180px;
    margin-top: 4px;
    background: var(--background-secondary);
    border: 0.5px solid var(--separator);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px var(--shadow);
    z-index: 1000;
    display: none;
    overflow: hidden;
    padding: 4px;
  }

  .custom-select-dropdown.open {
    display: block;
  }

  .custom-select-dropdown div {
    padding: 6px var(--sp-3);
    border-radius: 4px;
    font-size: 13px;
    color: var(--label);
    cursor: pointer;
    transition: background 0.1s;
  }

  .custom-select-dropdown div:hover {
    background: var(--system-blue);
    color: white;
  }

  /* ═══════════════════════════════════════════
     THEME TOGGLE
     ═══════════════════════════════════════════ */
  .theme-toggle {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--label-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s;
  }

  .theme-toggle:hover {
    background: var(--fill);
    color: var(--label);
  }

  /* ═══════════════════════════════════════════
     NOTIFICATIONS
     ═══════════════════════════════════════════ */
  #notifications {
    position: fixed;
    top: 56px;
    right: var(--sp-5);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
  }

  .notification {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    box-shadow: 0 4px 16px var(--shadow);
    font-size: 13px;
    font-weight: 500;
    color: var(--label);
    pointer-events: auto;
    animation: slideIn 0.25s ease;
    max-width: 360px;
  }

  .notification.success { border-left: 3px solid var(--system-green); }
  .notification.error { border-left: 3px solid var(--system-red); }
  .notification.info { border-left: 3px solid var(--system-blue); }

  @keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
  }

  /* ═══════════════════════════════════════════
     TOOLTIP / LABEL SHOWCASE
     ═══════════════════════════════════════════ */
  .tag {
    display: inline-flex;
    align-items: center;
    padding: 0 var(--sp-2);
    height: 20px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    background: var(--fill);
    color: var(--label-secondary);
  }

  /* ═══════════════════════════════════════════
     AGENT PLAN — 2×2 form grid
     ═══════════════════════════════════════════ */

  /* ═══════════════════════════════════════════
     CONTENT PLAN GRID
     ═══════════════════════════════════════════ */
  .plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-4);
  }

  .plan-card {
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
  }

  .plan-card h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
  }

  .plan-card p {
    font-size: 12px;
    color: var(--label-secondary);
  }

  /* ═══════════════════════════════════════════
     HISTORY TABLE
     ═══════════════════════════════════════════ */
  .history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }

  .history-table th {
    font-size: 10px;
    font-weight: 600;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    text-align: left;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 0.5px solid var(--separator-thin);
  }

  .history-table td {
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 0.5px solid var(--separator-thin);
    vertical-align: top;
  }

  .history-table tr:hover td {
    background: var(--fill);
  }

  /* ═══════════════════════════════════════════
     PIPELINE
     ═══════════════════════════════════════════ */
  .pipeline-step {
    padding: var(--sp-4);
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-3);
    transition: all 0.2s;
  }

  .pipeline-step.active {
    border-color: var(--system-blue);
  }

  .pipeline-step.done {
    border-color: var(--system-green);
  }

  /* drag and drop */
  .dragging {
    opacity: 0.5;
  }

  .drag-over {
    border-color: var(--system-blue) !important;
    background: rgba(10, 132, 255, 0.05);
  }

  /* ═══════════════════════════════════════════
     QUICK FIXES FOR LEGACY ELEMENTS
     ═══════════════════════════════════════════ */
  select, input, textarea, button { font-family: inherit; }

  .mermaid svg { max-width: 100%; }

  /* ═══════════════════════════════════════════
     BUTTON VARIANTS
     ═══════════════════════════════════════════ */
  .btn-outline {
    background: transparent;
    color: var(--label);
    border: 0.5px solid var(--separator);
  }
  .btn-outline:hover {
    background: var(--fill);
    border-color: var(--label-tertiary);
  }

  .btn-copy, .btn-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--label-secondary);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
    flex-shrink: 0;
  }
  .btn-copy:hover, .btn-delete:hover {
    background: var(--fill);
    color: var(--label);

  /* ── Voice Input Button ── */
  .voice-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border: 0.5px solid var(--separator);
    border-radius: 50%;
    background: transparent;
    color: var(--label-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    vertical-align: middle;
    margin-left: 8px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
  }
  .voice-btn:hover {
    background: var(--fill);
    color: var(--label);
    border-color: var(--label-tertiary);
  }
  .voice-btn.recording {
    background: #ff3b30;
    color: #fff;
    border-color: #ff3b30;
    animation: voice-pulse 1s ease-in-out infinite;
  }
  .voice-btn.recording:hover {
    background: #ff453a;
  }
  .voice-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
  @keyframes voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(255,59,48,0); }
  }
  }
  .btn-delete:hover { color: var(--system-red); }

  /* ═══════════════════════════════════════════
     BADGE
     ═══════════════════════════════════════════ */
  .badge {
    display: inline-flex;
    align-items: center;
    padding: 0 6px;
    height: 18px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    background: var(--fill);
    color: var(--label-secondary);
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ═══════════════════════════════════════════
     HISTORY ITEMS
     ═══════════════════════════════════════════ */
  .history-item {
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s;
    overflow: hidden;
  }
  .history-item:hover { border-color: var(--separator); }

  .history-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    flex-wrap: nowrap;
  }

  .history-meta-right {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    flex-shrink: 0;
  }

  .history-author {
    width: 110px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--label-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .history-badge {
    width: 160px;
    flex-shrink: 0;
    text-align: center;
    word-break: break-word;
    white-space: normal;
    line-height: 1.3;
  }
  .history-meta-theme {
    word-break: break-word;
    flex-shrink: 1;
    min-width: 0;
  }

  .rating-btns {
    display: inline-flex;
    gap: 1px;
    margin-right: 4px;
  }
  .rating-btns button {
    background: none;
    border: none;
    font-size: 13px;
    padding: 1px 3px;
    cursor: pointer;
    border-radius: 4px;
    opacity: 0.35;
    transition: all 0.15s;
    line-height: 1;
  }
  .rating-btns button:hover { opacity: 0.8; background: var(--fill); }
  .rating-btns button.active { opacity: 1; }
  .rating-btns .btn-like.active { background: rgba(48,209,88,0.15); }
  .rating-btns .btn-dislike.active { background: rgba(255,59,48,0.15); }

  /* Plan history meta — grid layout for aligned columns */
  .plan-meta {
    display: grid;
    grid-template-columns: 16px 150px 1fr 120px 100px auto;
    gap: 8px;
    align-items: center;
  }
  .plan-meta .history-toggle { width: auto; }
  .plan-meta-theme {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
  }
  .plan-meta-author { justify-self: center; }
  .plan-meta-counts {
    font-size: 11px;
    color: var(--label-tertiary);
    white-space: nowrap;
  }

  .history-toggle {
    font-size: 8px;
    color: var(--label-tertiary);
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.15s;
  }
  .history-toggle.open { transform: rotate(90deg); }

  .history-date {
    font-size: 11px;
    color: var(--label-tertiary);
    flex-shrink: 0;
    min-width: 60px;
  }

  .history-preview {
    font-size: 12px;
    color: var(--label-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
  }

  .history-content {
    display: none;
    padding: 0 12px 12px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--label);
    white-space: pre-wrap;
    border-top: 0.5px solid var(--separator-thin);
    user-select: text;
    -webkit-user-select: text;
    cursor: auto;
  }
  .history-content.open { display: block; }

  .history-caption {
    display: none;
    padding: 8px 12px 12px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--label-secondary);
    white-space: pre-wrap;
    border-top: 0.5px solid var(--separator-thin);
    background: rgba(48, 209, 88, 0.03);
    user-select: text;
    -webkit-user-select: text;
    cursor: auto;
  }
  .history-content.open ~ .history-caption,
  .history-caption.open { display: block; }
  .history-caption-label {
    font-weight: 600;
    color: var(--label-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }

  /* ═══════════════════════════════════════════
     PAGINATION
     ═══════════════════════════════════════════ */
  .pagination {
    display: flex;
    gap: 4px;
    padding: 12px 0;
    flex-wrap: wrap;
  }

  /* ═══════════════════════════════════════════
     SPINNER
     ═══════════════════════════════════════════ */
  .spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid var(--separator);
    border-top-color: var(--system-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ═══════════════════════════════════════════
     CONTENT PLAN ITEMS
     ═══════════════════════════════════════════ */
  .plan-week {
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
  }
  .plan-week h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--system-blue);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 0.5px solid var(--separator-thin);
  }

  .plan-item {
    padding: 8px 0;
    border-bottom: 0.5px solid var(--separator-thin);
  }
  .plan-item:last-child { border-bottom: none; }

  .plan-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--label);
    margin-bottom: 2px;
  }

  .plan-desc {
    font-size: 12px;
    color: var(--label-secondary);
    line-height: 1.4;
  }

  /* ═══════════════════════════════════════════
     PLAN HISTORY — rendered cards
     ═══════════════════════════════════════════ */
  .plan-history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-4);
    padding: var(--sp-4);
  }

  .plan-history-week {
    background: var(--background-secondary);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-md);
    overflow: hidden;
  }

  .plan-history-week-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px var(--sp-4);
    font-size: 13px;
    font-weight: 700;
    color: var(--label);
    background: var(--fill);
    border-bottom: 0.5px solid var(--separator-thin);
  }

  .plan-history-post {
    padding: 10px var(--sp-4);
    border-bottom: 0.5px solid var(--separator-thin);
  }
  .plan-history-post:last-child { border-bottom: none; }

  .plan-history-post-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--label);
    margin-bottom: 4px;
  }

  .plan-history-post-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 6px;
  }

  .plan-history-post-desc {
    font-size: 12px;
    color: var(--label-secondary);
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    max-height: 120px;
    overflow-y: auto;
  }

  .plan-tag {
    display: inline-flex;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    height: 18px;
    align-items: center;
  }
  .plan-tag.rubric { background: rgba(10,132,255,0.12); color: var(--system-blue); }
  .plan-tag.format { background: rgba(255,159,10,0.12); color: var(--system-orange); }
  .plan-tag.cta { background: rgba(48,209,88,0.12); color: var(--system-green); }

  .history-content pre {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.5;
    padding: var(--sp-4);
  }

  /* ═══════════════════════════════════════════
     PIPELINE PROGRESS BAR
     ═══════════════════════════════════════════ */
  .pipe-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
  }

  .pipe-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--fill);
    border-radius: 2px;
    overflow: hidden;
  }

  .pipe-progress-fill {
    height: 100%;
    background: var(--system-blue);
    border-radius: 2px;
    transition: width 0.5s ease;
  }
  .pipe-progress-fill.active { background: linear-gradient(90deg, var(--system-blue), var(--system-teal)); }
  .pipe-progress-fill.done { background: var(--system-green); }

  .pipe-progress-text {
    font-size: 11px;
    color: var(--label-secondary);
    min-width: 40px;
    text-align: right;
  }

  /* ═══════════════════════════════════════════
     PIPELINE MODE TOGGLE
     ═══════════════════════════════════════════ */
  .pipeline-mode {
    display: flex;
    gap: 0;
    background: var(--fill);
    border-radius: var(--radius-md);
    padding: 2px;
    align-self: flex-start;
  }

  .mode-btn {
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--label-secondary);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
  }
  .mode-btn.active {
    background: var(--card-bg);
    color: var(--label);
    box-shadow: 0 1px 3px var(--shadow);
  }
  .mode-btn:hover:not(.active) { color: var(--label); }

  /* ═══════════════════════════════════════════
     REVISION SIDEBAR / DROPZONE
     ═══════════════════════════════════════════ */
  .revision-sidebar {
    width: 360px;
    flex-shrink: 0;
  }

  .revision-dropzone {
    border: 2px dashed var(--separator);
    border-radius: var(--radius-md);
    padding: 32px 20px;
    text-align: center;
    color: var(--label-secondary);
    transition: all 0.15s;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .revision-dropzone.drag-over {
    border-color: var(--system-blue);
    background: rgba(10,132,255,0.05);
  }

  .revision-editor { display: none; }

  .revision-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
  }

  .revision-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
  }

  .revision-sidebar label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
    margin-top: 12px;
  }

  /* ═══════════════════════════════════════════
     HISTORY TOOLBAR
     ═══════════════════════════════════════════ */
  .history-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    flex-wrap: wrap;
    align-items: center;
  }
  .history-toolbar input {
    height: 28px;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-sm);
    border: 0.5px solid var(--input-border);
    background: var(--input-bg);
    color: var(--label);
    font-family: var(--font);
    font-size: 13px;
    outline: none;
    flex: 1;
    min-width: 120px;
  }
  .history-toolbar input:focus { border-color: var(--system-blue); }
  .history-toolbar select {
    height: 28px;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-sm);
    border: 0.5px solid var(--input-border);
    background: var(--input-bg);
    color: var(--label);
    font-family: var(--font);
    font-size: 12px;
    outline: none;
  }

  /* ═══════════════════════════════════════════
     CLIP MATCHING UI
     ═══════════════════════════════════════════ */
  .clip-scene-row {
    padding: 12px;
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
  }
  .clip-scene-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
  }
  .clip-timing {
    font-size: 11px;
    color: var(--label-tertiary);
    font-family: var(--font-mono);
  }
  .clip-count-badge {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: var(--fill);
    color: var(--label-secondary);
  }
  .clip-scene-visual, .clip-scene-text {
    font-size: 12px;
    color: var(--label-secondary);
    margin-bottom: 4px;
    line-height: 1.4;
  }
  .clip-label { font-weight: 600; color: var(--label); }
  .clip-scene-select { margin-top: 8px; }
  .clip-scene-select select {
    width: 100%;
    height: 28px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    border: 0.5px solid var(--input-border);
    background: var(--input-bg);
    color: var(--label);
    font-family: var(--font);
    font-size: 12px;
    outline: none;
  }

  /* ═══════════════════════════════════════════
     VIDEO SUCCESS
     ═══════════════════════════════════════════ */
  .video-success {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(48,209,88,0.08);
    border: 0.5px solid rgba(48,209,88,0.2);
    color: var(--system-green);
    font-weight: 600;
    font-size: 13px;
  }
  .video-success a {
    color: var(--system-blue);
    text-decoration: none;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    background: rgba(10,132,255,0.1);
  }
  .video-success a:hover { background: rgba(10,132,255,0.2); }

  /* ═══════════════════════════════════════════
     SCHEMA TAB — Full pipeline artifact diagram
     ═══════════════════════════════════════════ */
  .schema-pipeline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-5) 0;
  }

  .schema-node {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    min-width: 200px;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--label);
  }
  .schema-node.start { background: linear-gradient(135deg, var(--system-blue), var(--system-purple)); color: white; border: none; }
  .schema-node.stage { border-left: 3px solid var(--system-blue); }
  .schema-node.stage.mkt { border-left-color: var(--system-purple); }
  .schema-node.stage.copy { border-left-color: var(--system-orange); }
  .schema-node.stage.prod { border-left-color: var(--system-green); }
  .schema-node.result { background: rgba(48,209,88,0.1); border-color: var(--system-green); }

  .schema-arrow-down {
    font-size: 16px;
    color: var(--label-tertiary);
    line-height: 1;
    padding: 2px 0;
  }

  .schema-artifact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
    margin-top: var(--sp-4);
  }

  .schema-artifact {
    padding: var(--sp-4);
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-md);
  }
  .schema-artifact h4 {
    font-size: 11px;
    font-weight: 600;
    color: var(--label-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 0.5px solid var(--separator-thin);
  }
  .schema-artifact ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  .schema-artifact li {
    padding: 5px 0;
    font-size: 12px;
    color: var(--label);
    border-bottom: 0.5px solid var(--separator-thin);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .schema-artifact li:last-child { border-bottom: none; }
  .schema-artifact li::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .schema-artifact.mkt li::before { background: var(--system-purple); }
  .schema-artifact.copy li::before { background: var(--system-orange); }
  .schema-artifact.prod li::before { background: var(--system-green); }

  /* ═══════════════════════════════════════════
     LIGHT THEME FIXES
     ═══════════════════════════════════════════ */
  [data-theme="light"] {
    --fill: rgba(0, 0, 0, 0.08);
    --fill-hover: rgba(0, 0, 0, 0.14);
    --input-bg: rgba(0, 0, 0, 0.05);
    --input-border: rgba(0, 0, 0, 0.2);
    --separator: rgba(0, 0, 0, 0.15);
  }

  [data-theme="light"] .btn-ai:hover,
  [data-theme="light"] .btn-primary:hover {
    filter: brightness(0.9);
  }

  [data-theme="light"] .btn-outline {
    border-color: var(--separator);
    background: var(--card-bg);
  }
  [data-theme="light"] .btn-outline:hover {
    background: var(--fill);
  }

  [data-theme="light"] .history-item {
    border-color: var(--separator);
  }

  /* ═══════════════════════════════════════════
     RESPONSIVE
     ═══════════════════════════════════════════ */
  @media (max-width: 768px) {
    .sidebar { width: 200px; }
    .page-header { padding: 0 var(--sp-4); }
    .content-area { padding: var(--sp-4); }
    .form-row { flex-direction: column; }
  }

  @media (max-width: 600px) {
    .sidebar { display: none; }
    .profile-picker > label { display: none; }
  }
