    /* CSS Variables for Dark & Light Themes */
    :root[data-theme="dark"] {
      --bg-page: #0a0d14;
      --bg-sidebar: #0f141f;
      --bg-header: #121824;
      --bg-card: #161e2d;
      --bg-bubble-ai: #141c2b;
      --bg-bubble-user: #2563eb;
      --bg-input: #121824;
      --border: #222d42;
      --border-focus: #3b82f6;
      --text-primary: #f8fafc;
      --text-secondary: #94a3b8;
      --text-muted: #64748b;
      --accent: #3b82f6;
      --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
      --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
      --code-bg: #090c15;
      --code-bar: #141b2a;
      --table-stripe: #111724;
      --hover-bg: #1c2638;
      --status-color: #10b981;
    }

    :root[data-theme="light"] {
      --bg-page: #f8fafc;
      --bg-sidebar: #f1f5f9;
      --bg-header: #ffffff;
      --bg-card: #ffffff;
      --bg-bubble-ai: #ffffff;
      --bg-bubble-user: #2563eb;
      --bg-input: #ffffff;
      --border: #e2e8f0;
      --border-focus: #2563eb;
      --text-primary: #0f172a;
      --text-secondary: #475569;
      --text-muted: #94a3b8;
      --accent: #2563eb;
      --accent-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
      --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
      --code-bg: #1e293b;
      --code-bar: #0f172a;
      --table-stripe: #f8fafc;
      --hover-bg: #e2e8f0;
      --status-color: #10b981;
    }

    * { 
      box-sizing: border-box; 
      margin: 0; 
      padding: 0; 
      scrollbar-width: thin;
      scrollbar-color: rgba(59, 130, 246, 0.45) transparent;
    }

    /* Modern Thin Blue Scrollbar (Chrome, Edge, Safari, WebKit) */
    ::-webkit-scrollbar {
      width: 5px;
      height: 5px;
    }

    ::-webkit-scrollbar-track {
      background: transparent;
    }

    ::-webkit-scrollbar-thumb {
      background: rgba(59, 130, 246, 0.35);
      border-radius: 9999px;
      transition: background 0.2s ease;
    }

    ::-webkit-scrollbar-thumb:hover {
      background: #3b82f6;
    }

    ::-webkit-scrollbar-thumb:active {
      background: #1d4ed8;
    }

    ::-webkit-scrollbar-corner {
      background: transparent;
    }

    ::-webkit-scrollbar-button {
      display: none;
      width: 0;
      height: 0;
    }

    html, body {
      height: 100%;
      height: 100dvh;
      max-height: 100dvh;
      overflow: hidden;
      width: 100%;
      position: relative;
    }

    body {
      font-family: 'Plus Jakarta Sans', sans-serif;
      background: var(--bg-page);
      color: var(--text-primary);
      display: flex;
    }

    /* Sidebar */
    aside {
      width: 280px;
      background: var(--bg-sidebar);
      border-right: 1px solid var(--border);
      display: flex;
      flex-direction: column;
      flex-shrink: 0;
      z-index: 20;
    }

    .sidebar-top {
      padding: 16px;
      display: flex;
      flex-direction: column;
      gap: 10px;
      border-bottom: 1px solid var(--border);
    }

    .btn-new-chat {
      width: 100%;
      background: var(--accent-gradient);
      border: none;
      color: #fff;
      padding: 12px 16px;
      border-radius: 10px;
      font-weight: 600;
      font-size: 14px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
      transition: transform 0.15s, opacity 0.15s;
    }

    .btn-new-chat:hover {
      opacity: 0.95;
      transform: translateY(-1px);
    }

    .history-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 16px 6px;
    }

    .history-title {
      font-size: 11.5px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--text-muted);
    }

    .session-list {
      flex: 1;
      overflow-y: auto;
      padding: 6px 10px;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .session-item {
      padding: 9px 12px;
      border-radius: 8px;
      font-size: 13px;
      color: var(--text-secondary);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      transition: all 0.15s;
    }

    .session-item-content {
      display: flex;
      align-items: center;
      gap: 8px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      flex: 1;
    }

    .session-item span {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .session-item:hover, .session-item.active {
      background: var(--hover-bg);
      color: var(--text-primary);
      font-weight: 500;
    }

    .btn-delete-session {
      background: transparent;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 13px;
      padding: 2px 4px;
      border-radius: 4px;
      opacity: 0;
      transition: opacity 0.2s, color 0.2s;
    }

    .session-item:hover .btn-delete-session {
      opacity: 1;
    }

    .btn-delete-session:hover {
      color: #ef4444;
    }

    .empty-history-text {
      padding: 20px 16px;
      font-size: 12.5px;
      color: var(--text-muted);
      text-align: center;
    }

    /* AI Agents Section */
    .agents-section {
      padding: 10px 10px 6px;
      border-bottom: 1px solid var(--border);
    }
    .agents-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 4px 6px 8px;
    }
    .agents-title {
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--text-muted);
    }
    .btn-create-agent {
      background: rgba(59, 130, 246, 0.12);
      border: 1px solid rgba(59, 130, 246, 0.35);
      color: #60a5fa;
      font-size: 11px;
      font-weight: 600;
      padding: 3px 8px;
      border-radius: 6px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 4px;
      transition: all 0.15s;
    }
    .btn-create-agent:hover {
      background: var(--accent);
      color: #fff;
    }
    .agents-list {
      display: flex;
      flex-direction: column;
      gap: 3px;
      max-height: 175px;
      overflow-y: auto;
    }
    .agent-item {
      padding: 7px 10px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
      font-size: 13px;
      color: var(--text-secondary);
      transition: all 0.15s;
      border: 1px solid transparent;
    }
    .agent-item:hover {
      background: var(--hover-bg);
      color: var(--text-primary);
    }
    .agent-item.active {
      background: rgba(59, 130, 246, 0.15);
      color: #60a5fa;
      border-color: rgba(59, 130, 246, 0.35);
      font-weight: 600;
    }
    .agent-item-left {
      display: flex;
      align-items: center;
      gap: 8px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      flex: 1;
    }
    .agent-emoji-icon {
      font-size: 15px;
      width: 22px;
      text-align: center;
      flex-shrink: 0;
    }
    .agent-meta-text {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      line-height: 1.25;
    }
    .agent-name-line {
      font-size: 12.5px;
      display: block;
    }
    .agent-tagline {
      font-size: 10.5px;
      color: var(--text-muted);
      display: block;
    }
    .btn-delete-agent {
      background: transparent;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 12px;
      padding: 2px 4px;
      border-radius: 4px;
      opacity: 0;
      transition: opacity 0.2s, color 0.2s;
    }
    .agent-item:hover .btn-delete-agent {
      opacity: 1;
    }
    .btn-delete-agent:hover {
      color: #ef4444;
    }

    /* Modal Backdrop & Card */
    .agent-modal-backdrop {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.7);
      backdrop-filter: blur(6px);
      z-index: 100;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }
    .agent-modal-backdrop.show {
      display: flex;
    }
    .agent-modal-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 16px;
      width: 100%;
      max-width: 520px;
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
      display: flex;
      flex-direction: column;
      max-height: 90vh;
      overflow: hidden;
      animation: modalFadeIn 0.2s ease-out;
    }
    @keyframes modalFadeIn {
      from { opacity: 0; transform: scale(0.96); }
      to { opacity: 1; transform: scale(1); }
    }
    .agent-modal-header {
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .agent-modal-title {
      font-size: 17px;
      font-weight: 700;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .btn-close-modal {
      background: transparent;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 18px;
      padding: 4px;
    }
    .btn-close-modal:hover { color: var(--text-primary); }
    .agent-modal-body {
      padding: 20px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 14px;
    }
    .form-group-label {
      font-size: 12.5px;
      font-weight: 600;
      color: var(--text-secondary);
      margin-bottom: 6px;
      display: block;
    }
    .form-input, .form-textarea {
      width: 100%;
      background: var(--bg-input);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text-primary);
      padding: 9px 12px;
      font-size: 13.5px;
      font-family: inherit;
      outline: none;
      transition: border-color 0.2s;
    }
    .form-input:focus, .form-textarea:focus {
      border-color: var(--accent);
    }
    .form-textarea {
      min-height: 85px;
      resize: vertical;
      line-height: 1.45;
    }
    .template-pills-row {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      margin-bottom: 6px;
    }
    .template-pill {
      background: var(--hover-bg);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      padding: 4px 9px;
      border-radius: 6px;
      font-size: 11.5px;
      cursor: pointer;
      transition: all 0.15s;
    }
    .template-pill:hover {
      border-color: var(--accent);
      color: var(--accent);
    }
    .emoji-picker-grid {
      display: grid;
      grid-template-columns: repeat(8, 1fr);
      gap: 6px;
      margin-top: 6px;
    }
    .emoji-choice-btn {
      background: var(--hover-bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      font-size: 18px;
      padding: 6px 0;
      cursor: pointer;
      text-align: center;
      transition: all 0.15s;
    }
    .emoji-choice-btn:hover, .emoji-choice-btn.selected {
      border-color: var(--accent);
      background: rgba(59, 130, 246, 0.2);
    }
    .capability-checkbox-row {
      display: flex;
      align-items: center;
      gap: 10px;
      background: var(--hover-bg);
      padding: 10px 12px;
      border-radius: 8px;
      border: 1px solid var(--border);
      cursor: pointer;
    }
    .capability-checkbox-row input {
      accent-color: var(--accent);
      width: 16px;
      height: 16px;
      cursor: pointer;
    }
    .agent-modal-footer {
      padding: 14px 20px;
      border-top: 1px solid var(--border);
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      background: var(--hover-bg);
    }
    .btn-modal-cancel {
      background: transparent;
      border: 1px solid var(--border);
      color: var(--text-secondary);
      padding: 8px 16px;
      border-radius: 8px;
      cursor: pointer;
      font-weight: 500;
      font-size: 13px;
    }
    .btn-modal-submit {
      background: var(--accent-gradient);
      border: none;
      color: #fff;
      padding: 8px 20px;
      border-radius: 8px;
      cursor: pointer;
      font-weight: 600;
      font-size: 13px;
      box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
    }

    /* AI Image Studio Nav Button */
    .btn-image-studio-nav {
      width: 100%;
      background: rgba(139, 92, 246, 0.12);
      border: 1px solid rgba(139, 92, 246, 0.35);
      color: #c084fc;
      padding: 10px 14px;
      border-radius: 10px;
      font-weight: 600;
      font-size: 13.5px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      transition: all 0.15s ease;
    }
    .btn-image-studio-nav:hover {
      background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
      color: #fff;
      border-color: transparent;
      transform: translateY(-1px);
    }

    /* Notes & Document Studio Nav Button */
    .btn-notes-studio-nav {
      width: 100%;
      background: rgba(14, 165, 233, 0.12);
      border: 1px solid rgba(14, 165, 233, 0.35);
      color: #38bdf8;
      padding: 10px 14px;
      border-radius: 10px;
      font-weight: 600;
      font-size: 13.5px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      margin-top: 6px;
      transition: all 0.15s ease;
    }
    .btn-notes-studio-nav:hover {
      background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
      color: #fff;
      border-color: transparent;
      transform: translateY(-1px);
    }

    /* Input Tool Button */
    .btn-input-tool {
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      cursor: pointer;
      width: 34px;
      height: 34px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.15s ease;
      flex-shrink: 0;
      margin-bottom: 2px;
    }
    .btn-input-tool:hover {
      background: var(--hover-bg);
      color: var(--text-primary);
      border-color: var(--accent);
      transform: scale(1.05);
    }

    /* Image Studio Modal */
    .image-studio-backdrop {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.75);
      backdrop-filter: blur(8px);
      z-index: 110;
      align-items: center;
      justify-content: center;
      padding: 16px;
    }
    .image-studio-backdrop.show {
      display: flex;
    }
    .image-studio-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 18px;
      width: 100%;
      max-width: 620px;
      box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
      display: flex;
      flex-direction: column;
      max-height: 92vh;
      overflow: hidden;
      animation: modalFadeIn 0.2s ease-out;
    }
    .style-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      margin-top: 6px;
    }
    .style-pill-card {
      background: var(--hover-bg);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 8px 10px;
      cursor: pointer;
      text-align: center;
      font-size: 12px;
      font-weight: 600;
      color: var(--text-secondary);
      transition: all 0.15s;
      user-select: none;
    }
    .style-pill-card:hover, .style-pill-card.selected {
      background: rgba(139, 92, 246, 0.18);
      border-color: #8b5cf6;
      color: #c084fc;
    }
    .ratio-pills-row {
      display: flex;
      gap: 8px;
      margin-top: 6px;
    }
    .ratio-pill-btn {
      flex: 1;
      background: var(--hover-bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 7px 10px;
      cursor: pointer;
      text-align: center;
      font-size: 12px;
      font-weight: 500;
      color: var(--text-secondary);
      transition: all 0.15s;
      user-select: none;
    }
    .ratio-pill-btn:hover, .ratio-pill-btn.selected {
      background: rgba(59, 130, 246, 0.2);
      border-color: var(--accent);
      color: #60a5fa;
    }
    .studio-preview-box {
      margin-top: 10px;
      border-radius: 12px;
      border: 1px dashed var(--border);
      background: rgba(0, 0, 0, 0.18);
      min-height: 220px;
      max-height: 320px;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      position: relative;
    }
    .studio-preview-img {
      max-width: 100%;
      max-height: 300px;
      border-radius: 10px;
      object-fit: contain;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
      display: none;
    }
    .studio-preview-img.loaded {
      display: block;
    }
    .studio-loading-state {
      display: none;
      flex-direction: column;
      align-items: center;
      gap: 12px;
      color: var(--text-muted);
      font-size: 13px;
    }
    .studio-loading-state.active {
      display: flex;
    }
    .studio-placeholder-text {
      color: var(--text-muted);
      font-size: 13px;
      text-align: center;
      padding: 20px;
    }
    .studio-img-actions {
      display: none;
      gap: 8px;
      margin-top: 12px;
      flex-wrap: wrap;
    }
    .studio-img-actions.show {
      display: flex;
    }
    .btn-studio-action {
      flex: 1;
      background: var(--hover-bg);
      border: 1px solid var(--border);
      color: var(--text-primary);
      padding: 8px 12px;
      border-radius: 8px;
      font-size: 12.5px;
      font-weight: 600;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      transition: all 0.15s;
    }
    .btn-studio-action:hover {
      background: rgba(59, 130, 246, 0.15);
      border-color: var(--accent);
      color: #60a5fa;
    }
    .btn-studio-generate {
      background: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
      color: #fff;
      border: none;
      padding: 10px 24px;
      border-radius: 10px;
      font-size: 13.5px;
      font-weight: 600;
      cursor: pointer;
      box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
      transition: opacity 0.15s, transform 0.15s;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .btn-studio-generate:hover {
      opacity: 0.95;
      transform: translateY(-1px);
    }

    /* ChatGPT & Gemini Style Image Generation Animation Canvas */
    .ai-img-gen-card {
      margin: 14px 0;
      border-radius: 16px;
      overflow: hidden;
      border: 1px solid rgba(59, 130, 246, 0.35);
      background: radial-gradient(circle at 50% 40%, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.95) 100%);
      box-shadow: 0 14px 40px -10px rgba(0, 0, 0, 0.5), 0 0 25px rgba(59, 130, 246, 0.15);
      position: relative;
    }

    .ai-img-gen-canvas {
      position: relative;
      width: 100%;
      min-height: 280px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 30px 20px;
      overflow: hidden;
    }

    /* Ambient animated beam / aurora shimmer */
    .ai-img-gen-canvas::before {
      content: '';
      position: absolute;
      top: -50%;
      left: -50%;
      width: 200%;
      height: 200%;
      background: conic-gradient(
        from 0deg at 50% 50%,
        rgba(59, 130, 246, 0) 0deg,
        rgba(59, 130, 246, 0.12) 60deg,
        rgba(139, 92, 246, 0.18) 120deg,
        rgba(236, 72, 153, 0.15) 180deg,
        rgba(59, 130, 246, 0.12) 240deg,
        rgba(59, 130, 246, 0) 360deg
      );
      animation: auroraSpin 12s linear infinite;
      pointer-events: none;
    }

    @keyframes auroraSpin {
      from { transform: rotate(0deg); }
      to { transform: rotate(360deg); }
    }

    /* Pulsating Gemini-style aperture / orb */
    .ai-gen-orb-wrapper {
      position: relative;
      width: 80px;
      height: 80px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 20px;
      z-index: 2;
    }

    .ai-gen-orb-ring {
      position: absolute;
      inset: 0;
      border-radius: 50%;
      border: 2px solid transparent;
      border-top-color: #3b82f6;
      border-right-color: #8b5cf6;
      animation: spinRing 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    }

    .ai-gen-orb-ring-inner {
      position: absolute;
      inset: 8px;
      border-radius: 50%;
      border: 2px solid transparent;
      border-bottom-color: #ec4899;
      border-left-color: #60a5fa;
      animation: spinRingReverse 2.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    }

    .ai-gen-orb-core {
      width: 44px;
      height: 44px;
      border-radius: 50%;
      background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 0 25px rgba(139, 92, 246, 0.65), inset 0 0 10px rgba(255, 255, 255, 0.5);
      animation: pulseCore 2.2s ease-in-out infinite alternate;
      font-size: 20px;
    }

    @keyframes spinRing {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }

    @keyframes spinRingReverse {
      0% { transform: rotate(360deg); }
      100% { transform: rotate(0deg); }
    }

    @keyframes pulseCore {
      0% { transform: scale(0.92); box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); }
      100% { transform: scale(1.08); box-shadow: 0 0 35px rgba(236, 72, 153, 0.8); }
    }

    /* Status text & progress */
    .ai-gen-info-box {
      z-index: 2;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      width: 100%;
      max-width: 380px;
      text-align: center;
    }

    .ai-gen-status-text {
      font-size: 13.5px;
      font-weight: 600;
      color: #f1f5f9;
      display: flex;
      align-items: center;
      gap: 6px;
      min-height: 24px;
      transition: opacity 0.3s ease;
    }

    .ai-gen-subtext {
      font-size: 11px;
      color: var(--text-muted);
      letter-spacing: 0.3px;
    }

    /* Progress bar */
    .ai-gen-progress-track {
      width: 100%;
      height: 6px;
      background: rgba(255, 255, 255, 0.1);
      border-radius: 10px;
      overflow: hidden;
      position: relative;
    }

    .ai-gen-progress-fill {
      height: 100%;
      width: 0%;
      background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
      border-radius: 10px;
      transition: width 0.3s linear;
      box-shadow: 0 0 10px rgba(139, 92, 246, 0.7);
    }

    .ai-gen-timer-badge {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.12);
      padding: 3px 10px;
      border-radius: 20px;
      font-size: 11.5px;
      font-family: 'JetBrains Mono', monospace;
      color: #93c5fd;
    }

    .ai-gen-skip-btn {
      background: rgba(59, 130, 246, 0.2);
      border: 1px solid rgba(59, 130, 246, 0.4);
      color: #93c5fd;
      padding: 2px 8px;
      border-radius: 12px;
      font-size: 11px;
      cursor: pointer;
      transition: all 0.15s ease;
    }
    .ai-gen-skip-btn:hover {
      background: var(--accent);
      color: #fff;
    }

    /* Completed Final Image inside Canvas */
    .ai-gen-final-img {
      display: none;
      width: 100%;
      height: auto;
      max-height: 520px;
      object-fit: contain;
      border-radius: 14px;
      opacity: 0;
      transform: scale(0.98);
      transition: opacity 0.6s ease, transform 0.6s ease;
      cursor: zoom-in;
    }

    .ai-gen-final-img.revealed {
      display: block;
      opacity: 1;
      transform: scale(1);
    }

    .ai-gen-toolbar {
      display: none;
      padding: 10px 14px;
      background: rgba(15, 23, 42, 0.85);
      border-top: 1px solid rgba(255, 255, 255, 0.08);
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      flex-wrap: wrap;
    }

    .ai-gen-toolbar.revealed {
      display: flex;
    }

    .ai-gen-prompt-tag {
      font-size: 11.5px;
      color: var(--text-muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 220px;
    }

    .ai-gen-tool-btns {
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .ai-gen-btn {
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.14);
      color: #f1f5f9;
      padding: 5px 10px;
      border-radius: 6px;
      font-size: 11.5px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      transition: all 0.15s ease;
    }

    .ai-gen-btn:hover {
      background: rgba(59, 130, 246, 0.25);
      border-color: #60a5fa;
      color: #93c5fd;
    }

    /* User Profile Box */
    .user-profile-box {
      padding: 14px 16px;
      border-top: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    .user-info {
      display: flex;
      align-items: center;
      gap: 10px;
      overflow: hidden;
    }

    .user-avatar-circle {
      width: 34px;
      height: 34px;
      border-radius: 50%;
      background: var(--accent);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 700;
      font-size: 14px;
      flex-shrink: 0;
    }

    .user-text {
      overflow: hidden;
    }

    .user-name {
      font-size: 13.5px;
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .user-storage-tag {
      font-size: 11px;
      color: var(--text-muted);
    }

    .btn-logout {
      background: transparent;
      border: 1px solid var(--border);
      color: var(--text-muted);
      border-radius: 6px;
      padding: 4px 8px;
      font-size: 11.5px;
      cursor: pointer;
      text-decoration: none;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .btn-logout:hover {
      background: rgba(239, 68, 68, 0.1);
      color: #ef4444;
      border-color: rgba(239, 68, 68, 0.3);
    }

    /* Main Area */
    .app-main {
      flex: 1 1 0%;
      min-width: 0;
      min-height: 0;
      display: flex;
      flex-direction: column;
      height: 100%;
      height: 100dvh;
      max-height: 100dvh;
      overflow: hidden;
      position: relative;
    }

    header {
      background: var(--bg-header);
      border-bottom: 1px solid var(--border);
      padding: 12px 24px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      z-index: 10;
      flex-shrink: 0;
    }

    .brand-section {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .brand-logo {
      width: 40px;
      height: 40px;
      border-radius: 12px;
      background: var(--accent-gradient);
      display: flex;
      align-items: center;
      justify-content: center;
      color: #fff;
      font-size: 20px;
      box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
    }

    .brand-text h1 {
      font-size: 17px;
      font-weight: 700;
      letter-spacing: -0.3px;
    }

    .brand-meta {
      font-size: 12px;
      color: var(--text-muted);
      display: flex;
      align-items: center;
      gap: 6px;
    }

    .brand-meta .meta-short {
      display: none;
    }

    .brand-meta .meta-full {
      display: inline;
    }

    .status-indicator {
      width: 7px;
      height: 7px;
      background: var(--status-color);
      border-radius: 50%;
      box-shadow: 0 0 8px var(--status-color);
    }

    .creator-tag {
      color: var(--accent);
      font-weight: 600;
    }

    .header-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .icon-btn {
      background: var(--bg-card);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      height: 36px;
      padding: 0 12px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      gap: 6px;
      cursor: pointer;
      font-size: 13px;
      font-family: inherit;
      text-decoration: none;
    }

    .icon-btn:hover {
      background: var(--hover-bg);
      color: var(--text-primary);
    }

    .mobile-menu-btn {
      display: none;
      background: var(--bg-card);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      width: 36px;
      height: 36px;
      border-radius: 8px;
      align-items: center;
      justify-content: center;
      cursor: pointer;
    }

    /* Chat Viewport */
    .chat-viewport {
      flex: 1 1 0%;
      min-height: 0;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      padding: 24px 28px 16px;
      display: flex;
      flex-direction: column;
      width: 100%;
      max-width: 100%;
      margin: 0;
      gap: 20px;
      scrollbar-width: thin;
      scrollbar-color: rgba(59, 130, 246, 0.45) transparent;
    }

    /* Welcome Hero */
    .hero-welcome {
      text-align: center;
      margin: auto auto;
      padding: 30px 16px;
      max-width: 820px;
      width: 100%;
    }

    .hero-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 14px;
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 30px;
      font-size: 12.5px;
      color: var(--accent);
      font-weight: 600;
      margin-bottom: 16px;
    }

    .hero-welcome h2 {
      font-size: 32px;
      font-weight: 800;
      letter-spacing: -0.5px;
      margin-bottom: 10px;
    }

    .hero-welcome p {
      color: var(--text-secondary);
      font-size: 15px;
      max-width: 520px;
      margin: 0 auto 28px;
      line-height: 1.5;
    }

    .hero-cards {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
      gap: 12px;
      max-width: 820px;
      margin: 0 auto;
    }

    .hero-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      padding: 14px;
      border-radius: 12px;
      text-align: left;
      font-size: 13.5px;
      color: var(--text-primary);
      cursor: pointer;
      line-height: 1.4;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .hero-card:hover {
      border-color: var(--accent);
      transform: translateY(-2px);
      box-shadow: var(--shadow);
    }

    .hero-card .icon { font-size: 20px; }

    .hero-actions-bar {
      display: none;
    }

    /* Message Bubbles */
    .message-row {
      display: flex;
      gap: 14px;
      animation: fadeIn 0.2s ease-out;
      max-width: 820px;
      width: 100%;
      margin: 0 auto;
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(6px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .message-row.user { flex-direction: row-reverse; }

    .msg-avatar {
      width: 34px;
      height: 34px;
      border-radius: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      flex-shrink: 0;
      font-weight: bold;
    }

    .msg-avatar.user { background: var(--accent); color: #fff; }
    .msg-avatar.ai { background: var(--accent-gradient); color: #fff; }

    .msg-content-wrapper {
      max-width: 86%;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .msg-bubble {
      padding: 14px 18px;
      border-radius: 16px;
      font-size: 15px;
      line-height: 1.65;
      word-break: break-word;
      box-shadow: var(--shadow);
    }

    .user .msg-bubble {
      background: var(--bg-bubble-user);
      color: #ffffff;
      border-top-right-radius: 4px;
    }

    .ai .msg-bubble {
      background: var(--bg-bubble-ai);
      border: 1px solid var(--border);
      color: var(--text-primary);
      border-top-left-radius: 4px;
    }

    .web-search-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 11.5px;
      font-weight: 600;
      color: #38bdf8;
      background: rgba(56, 189, 248, 0.1);
      border: 1px solid rgba(56, 189, 248, 0.25);
      padding: 3px 10px;
      border-radius: 14px;
      margin-bottom: 6px;
      width: fit-content;
      animation: fadeIn 0.3s ease;
    }

    .msg-bubble p:not(:last-child) { margin-bottom: 12px; }
    .msg-bubble ul, .msg-bubble ol { margin-left: 22px; margin-bottom: 12px; }
    .msg-bubble li { margin-bottom: 6px; line-height: 1.5; }
    .msg-bubble h1, .msg-bubble h2, .msg-bubble h3 { margin: 14px 0 8px; font-weight: 700; color: var(--text-primary); }

    .msg-bubble blockquote {
      border-left: 3.5px solid var(--accent);
      background: rgba(37, 99, 235, 0.08);
      padding: 8px 14px;
      border-radius: 0 8px 8px 0;
      margin: 12px 0;
      color: var(--text-primary);
      font-size: 14px;
      line-height: 1.5;
    }

    .msg-bubble table {
      width: 100%;
      border-collapse: collapse;
      margin: 14px 0;
      font-size: 13.5px;
      border: 1px solid var(--border);
      border-radius: 8px;
      overflow: hidden;
    }
    .msg-bubble th, .msg-bubble td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
    .msg-bubble th { background: var(--hover-bg); font-weight: 600; }
    .msg-bubble tr:nth-child(even) td { background: var(--table-stripe); }

    .msg-bubble img {
      max-width: 100%;
      height: auto;
      border-radius: 12px;
      margin: 12px 0;
      border: 1px solid var(--border);
      box-shadow: var(--shadow);
      display: block;
      cursor: zoom-in;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    .msg-bubble img:hover {
      transform: scale(1.015);
      box-shadow: 0 10px 25px rgba(59, 130, 246, 0.25);
    }

    .code-container {
      margin: 14px 0;
      border-radius: 10px;
      border: 1px solid var(--border);
      overflow: hidden;
      background: var(--code-bg);
    }
    .code-header {
      background: var(--code-bar);
      padding: 8px 14px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 12px;
      font-family: 'JetBrains Mono', monospace;
      color: #94a3b8;
      border-bottom: 1px solid var(--border);
    }
    .code-copy-btn {
      background: transparent;
      border: none;
      color: #94a3b8;
      cursor: pointer;
      font-size: 12px;
      display: flex;
      align-items: center;
      gap: 4px;
    }
    .code-copy-btn:hover { color: #fff; }
    .msg-bubble pre {
      margin: 0 !important;
      padding: 14px !important;
      background: transparent !important;
      border: none !important;
      overflow-x: auto;
    }
    .msg-bubble code { font-family: 'JetBrains Mono', monospace; font-size: 13.5px; }
    .msg-bubble :not(pre) > code {
      background: rgba(37, 99, 235, 0.12);
      color: var(--accent);
      padding: 2px 6px;
      border-radius: 4px;
    }

    .msg-actions {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 2px 4px;
    }

    .btn-action {
      background: transparent;
      border: none;
      color: var(--text-muted);
      font-size: 12px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 4px 6px;
      border-radius: 4px;
    }

    .btn-action:hover {
      color: var(--text-primary);
      background: var(--hover-bg);
    }

    .typing-cursor {
      display: inline-block;
      width: 7px;
      height: 15px;
      background: var(--accent);
      margin-left: 3px;
      vertical-align: middle;
      animation: blink 0.8s infinite;
    }
    @keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

    .typing-dots { display: inline-flex; gap: 5px; padding: 8px 4px; }
    .dot {
      width: 7px;
      height: 7px;
      background: var(--text-muted);
      border-radius: 50%;
      animation: dotPulse 1.2s infinite ease-in-out;
    }
    .dot:nth-child(2) { animation-delay: 0.2s; }
    .dot:nth-child(3) { animation-delay: 0.4s; }
    @keyframes dotPulse {
      0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
      40% { transform: translateY(-6px); opacity: 1; }
    }

    /* Bottom Input */
    .input-wrapper {
      flex-shrink: 0;
      padding: 10px 24px calc(14px + env(safe-area-inset-bottom, 0px));
      width: 100%;
      max-width: 100%;
      margin: 0;
      background: linear-gradient(180deg, transparent 0%, var(--bg-page) 35%);
      position: relative;
      z-index: 10;
    }

    .input-box {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 28px;
      padding: 8px 10px 8px 14px;
      display: flex;
      align-items: flex-end;
      gap: 10px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.05);
      max-width: 820px;
      width: 100%;
      margin: 0 auto;
      transition: all 0.2s ease;
    }

    .input-box:focus-within {
      border-color: rgba(59, 130, 246, 0.6);
      box-shadow: 0 10px 36px rgba(0, 0, 0, 0.35), 0 0 0 2px rgba(59, 130, 246, 0.25);
    }

    textarea {
      flex: 1;
      background: transparent;
      border: none;
      outline: none;
      color: var(--text-primary);
      font-family: inherit;
      font-size: 15px;
      line-height: 1.45;
      resize: none;
      max-height: 160px;
      min-height: 24px;
      padding: 7px 4px;
    }

    textarea::placeholder { color: var(--text-muted); }

    /* Voice Input Button */
    .btn-voice {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      flex-shrink: 0;
      transition: all 0.2s ease;
      margin-bottom: 2px;
    }

    .btn-voice:hover {
      background: var(--hover-bg);
      color: var(--text-primary);
      border-color: rgba(59, 130, 246, 0.5);
      transform: scale(1.06);
    }

    .btn-voice.listening {
      background: rgba(239, 68, 68, 0.18) !important;
      border-color: #ef4444 !important;
      color: #ef4444 !important;
      animation: micPulse 1.4s infinite ease-in-out;
      box-shadow: 0 0 14px rgba(239, 68, 68, 0.45);
    }

    @keyframes micPulse {
      0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
      }
      50% {
        transform: scale(1.08);
        box-shadow: 0 0 0 7px rgba(239, 68, 68, 0);
      }
      100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
      }
    }

    .btn-send {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: var(--accent);
      border: none;
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      flex-shrink: 0;
      box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
      transition: all 0.15s ease;
      margin-bottom: 2px;
    }

    .btn-send:hover:not(:disabled) {
      transform: scale(1.08);
      background: #1d4ed8;
      box-shadow: 0 4px 14px rgba(37, 99, 235, 0.5);
    }
    .btn-send:disabled {
      opacity: 0.35;
      cursor: not-allowed;
      transform: none;
    }

    
    /* Send Button Stop / Pause State */
    .btn-send.stop-mode {
      background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
      box-shadow: 0 4px 14px rgba(239, 68, 68, 0.45) !important;
    }

    .btn-send.stop-mode:hover {
      transform: scale(1.08);
      background: #dc2626 !important;
    }

    .stopped-indicator {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      font-size: 11px;
      color: #fca5a5;
      background: rgba(239, 68, 68, 0.12);
      border: 1px solid rgba(239, 68, 68, 0.25);
      border-radius: 12px;
      padding: 2px 8px;
      margin-top: 4px;
      width: fit-content;
      user-select: none;
    }

    .app-disclaimer {
      text-align: center;
      font-size: 11.5px;
      color: var(--text-muted);
      margin-top: 6px;
    }

    .sidebar-backdrop {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.65);
      backdrop-filter: blur(4px);
      z-index: 21;
      opacity: 0;
      transition: opacity 0.25s ease;
    }

    @media (max-width: 768px) {
      .app-main {
        height: 100%;
        height: 100dvh;
        max-height: 100dvh;
        min-height: 0;
      }
      aside {
        position: fixed;
        left: -290px;
        top: 0;
        bottom: 0;
        width: 285px;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 25;
      }
      aside.open {
        transform: translateX(290px);
      }
      .sidebar-backdrop.active {
        display: block;
        opacity: 1;
      }
      .mobile-menu-btn {
        display: flex;
        width: 32px;
        height: 32px;
        font-size: 16px;
        border-radius: 8px;
        flex-shrink: 0;
      }
      header {
        padding: 8px 12px;
        min-height: 50px;
        height: 50px;
        flex-shrink: 0;
        align-items: center;
      }
      .brand-section {
        gap: 8px;
        min-width: 0;
        flex: 1 1 auto;
      }
      .brand-logo {
        width: 30px;
        height: 30px;
        font-size: 15px;
        border-radius: 8px;
        flex-shrink: 0;
      }
      .brand-text {
        min-width: 0;
        overflow: hidden;
      }
      .brand-text h1 {
        font-size: 14.5px;
        font-weight: 700;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .brand-meta {
        font-size: 11px;
        line-height: 1.2;
        gap: 5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .brand-meta .meta-full {
        display: none !important;
      }
      .brand-meta .meta-short {
        display: inline !important;
        font-weight: 500;
        color: var(--status-color, #10b981);
      }
      .status-indicator {
        width: 6px;
        height: 6px;
        flex-shrink: 0;
      }
      .header-actions {
        gap: 5px;
        flex-shrink: 0;
      }
      .header-actions .icon-btn {
        width: 32px;
        height: 32px;
        padding: 0;
        border-radius: 8px;
        font-size: 13.5px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      .header-actions .icon-btn span {
        display: none;
      }
      .chat-viewport {
        flex: 1 1 0%;
        min-height: 0;
        padding: 12px 10px 6px;
        gap: 12px;
      }
      .message-row {
        gap: 8px;
      }
      .msg-avatar {
        width: 28px;
        height: 28px;
        font-size: 13px;
        border-radius: 7px;
      }
      .msg-content-wrapper {
        max-width: 92%;
      }
      .msg-bubble {
        padding: 10px 13px;
        font-size: 14px;
        line-height: 1.5;
      }
      .msg-actions {
        gap: 6px;
      }
      .btn-action {
        padding: 4px 7px;
        font-size: 11.5px;
      }
      .input-wrapper {
        flex-shrink: 0;
        padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px));
        background: var(--bg-page);
        border-top: 1px solid var(--border);
      }
      .input-box {
        padding: 6px 10px;
        border-radius: 14px;
      }
      textarea {
        font-size: 16px; /* Prevents auto-zoom on mobile iOS/Android */
        padding: 5px 3px;
        max-height: 110px;
      }
      .btn-send, .btn-voice {
        width: 36px;
        height: 36px;
      }
      
    .app-disclaimer {
        font-size: 10px;
        margin-top: 3px;
      }
      .hero-welcome {
        padding: 8px 4px 6px;
        margin: auto 0;
      }
      .hero-welcome .hero-badge {
        font-size: 11px;
        padding: 3px 10px;
        margin-bottom: 6px;
      }
      .hero-welcome h2 {
        font-size: 20px;
        line-height: 1.25;
        margin-bottom: 4px;
        padding: 0 6px;
      }
      .hero-welcome p {
        display: none; /* Hide bulky text paragraph on phones to eliminate clutter */
      }
      .hero-actions-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        max-width: 440px;
        margin: 10px auto 6px;
        padding: 0 4px;
      }
      .hero-actions-title {
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-muted);
        display: flex;
        align-items: center;
        gap: 4px;
      }
      .btn-toggle-suggestions {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border);
        color: var(--text-secondary);
        font-size: 10.5px;
        padding: 2px 8px;
        border-radius: 12px;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 3px;
        transition: all 0.2s;
      }
      .btn-toggle-suggestions:hover,
      .btn-toggle-suggestions:active {
        background: var(--bg-hover);
        color: var(--text-primary);
      }
      .hero-cards {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        max-width: 440px;
        margin: 0 auto;
      }
      .hero-cards.collapsed {
        display: none !important;
      }
      .hero-card {
        padding: 7px 9px;
        border-radius: 10px;
        background: var(--bg-card);
        border: 1px solid var(--border);
        font-size: 11px;
        line-height: 1.22;
        flex-direction: row;
        align-items: center;
        gap: 7px;
        min-height: 42px;
        box-shadow: none;
      }
      .hero-card:active {
        background: var(--bg-hover);
        border-color: var(--accent);
      }
      .hero-card .icon {
        font-size: 15px;
        width: 26px;
        height: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 7px;
        flex-shrink: 0;
      }
      .hero-card strong {
        font-size: 11px;
        font-weight: 600;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        word-break: break-word;
      }
      .hero-card small {
        display: none; /* Hide heavy subtitle text on mobile screens */
      }
    }

    /* ========================================================
       Academic Notes & Document Studio Modal (A4 PDF, Word, Excel)
       ======================================================== */
    .doc-studio-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(4, 7, 14, 0.78);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 16px;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s ease;
    }
    .doc-studio-backdrop.active {
      opacity: 1;
      pointer-events: auto;
    }
    .doc-studio-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 18px;
      width: 100%;
      max-width: 760px;
      max-height: 92vh;
      display: flex;
      flex-direction: column;
      box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
      transform: translateY(18px) scale(0.98);
      transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      overflow: hidden;
    }
    .doc-studio-backdrop.active .doc-studio-card {
      transform: translateY(0) scale(1);
    }

    /* Stepper & Progress Tracker */
    .doc-stepper-box {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 14px 16px;
      margin-top: 4px;
    }
    .doc-stepper-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 12.5px;
      font-weight: 600;
      color: var(--text-primary);
      margin-bottom: 8px;
    }
    .doc-progress-bar {
      width: 100%;
      height: 7px;
      background: rgba(255, 255, 255, 0.08);
      border-radius: 999px;
      overflow: hidden;
      margin-bottom: 10px;
    }
    .doc-progress-fill {
      height: 100%;
      background: linear-gradient(90deg, #0ea5e9, #2563eb, #6366f1);
      border-radius: 999px;
      transition: width 0.35s ease;
    }
    .doc-topics-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .topic-chip {
      font-size: 11px;
      padding: 4px 9px;
      border-radius: 6px;
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid var(--border);
      color: var(--text-muted);
      display: inline-flex;
      align-items: center;
      gap: 5px;
      transition: all 0.2s ease;
    }
    .topic-chip.active {
      background: rgba(14, 165, 233, 0.16);
      border-color: #0ea5e9;
      color: #38bdf8;
      font-weight: 600;
      animation: pulseChip 1.5s infinite;
    }
    .topic-chip.done {
      background: rgba(16, 185, 129, 0.12);
      border-color: rgba(16, 185, 129, 0.35);
      color: #34d399;
    }
    @keyframes pulseChip {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.65; }
    }

    /* Live Notes Preview Pane */
    .doc-preview-pane {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 16px;
      max-height: 240px;
      overflow-y: auto;
      font-size: 13px;
      line-height: 1.6;
      color: var(--text-primary);
    }
    .doc-preview-pane h1, .doc-preview-pane h2 {
      color: #38bdf8;
      font-size: 15px;
      margin-top: 12px;
      margin-bottom: 6px;
      font-weight: 700;
    }
    .doc-preview-pane h3 {
      font-size: 13.5px;
      color: #93c5fd;
      margin-top: 8px;
    }
    .doc-preview-pane table {
      width: 100%;
      border-collapse: collapse;
      margin: 10px 0;
      font-size: 11.5px;
    }
    .doc-preview-pane th {
      background: rgba(37, 99, 235, 0.25);
      color: #fff;
      padding: 6px 8px;
      text-align: left;
      border: 1px solid var(--border);
    }
    .doc-preview-pane td {
      padding: 6px 8px;
      border: 1px solid var(--border);
    }
    .doc-preview-pane blockquote {
      border-left: 3.5px solid #0ea5e9;
      background: rgba(14, 165, 233, 0.08);
      padding: 6px 10px;
      border-radius: 0 6px 6px 0;
      margin: 8px 0;
      color: #7dd3fc;
    }
    .doc-preview-empty {
      color: var(--text-muted);
      font-size: 12.5px;
      text-align: center;
      padding: 24px 12px;
    }

    /* Export Toolbar & 1-Click Download Buttons */
    .doc-export-toolbar {
      background: rgba(14, 165, 233, 0.08);
      border: 1px solid rgba(14, 165, 233, 0.3);
      border-radius: 12px;
      padding: 12px 14px;
      margin-top: 4px;
    }
    .doc-export-toolbar-title {
      font-size: 12px;
      font-weight: 700;
      color: #38bdf8;
      margin-bottom: 8px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    .doc-export-btn-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
      gap: 8px;
    }
    .btn-doc-download {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 9px;
      padding: 8px 10px;
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      text-align: left;
      transition: all 0.15s ease;
      color: var(--text-primary);
    }
    .btn-doc-download:hover {
      border-color: #0ea5e9;
      background: var(--bg-hover);
      transform: translateY(-1px);
    }
    .btn-doc-download span {
      font-size: 20px;
      flex-shrink: 0;
    }
    .btn-doc-download strong {
      display: block;
      font-size: 12px;
      line-height: 1.2;
    }
    .btn-doc-download small {
      font-size: 10px;
      color: var(--text-muted);
    }
    .btn-doc-download.pdf:hover {
      border-color: #ef4444;
      box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
    }
    .btn-doc-download.word:hover {
      border-color: #2563eb;
      box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
    }
    .btn-doc-download.excel:hover {
      border-color: #10b981;
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
    }
    .btn-doc-download.ppt:hover {
      border-color: #f97316;
      box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
    }

    /* In-Chat Message Document Export Pills */
    .btn-action.btn-doc-export {
      background: rgba(255, 255, 255, 0.04);
      border: 1px solid var(--border);
      color: var(--text-secondary);
      font-size: 11px;
      font-weight: 500;
      padding: 4px 8px;
      border-radius: 6px;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      transition: all 0.15s ease;
    }
    .btn-action.btn-doc-export:hover {
      background: var(--bg-hover);
      color: #38bdf8;
      border-color: rgba(14, 165, 233, 0.4);
    }
