    :root {
      color-scheme: dark;
    }
    html, body {
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
      background: #0b0f17;
      color: #e5ecf6;
      font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", Roboto, sans-serif;
      overscroll-behavior: none;
      -webkit-tap-highlight-color: transparent;
    }
    #app {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      height: var(--app-height, auto);
      display: flex;
      overflow: hidden;
    }
    .full-viewport-layer {
      height: var(--app-height, 100%);
    }
    #chat-scroll, #sidebar-sessions {
      -webkit-overflow-scrolling: touch;
      overscroll-behavior-y: contain;
    }
    #chat-scroll {
      display: flex;
      flex-direction: column-reverse;
      overflow-anchor: none;
    }
    #chat-list {
      width: 100%;
      flex: 0 0 auto;
      margin-bottom: auto;
    }
    @supports (content-visibility: auto) {
      #chat-list > [data-item-id],
      #chat-list > details.process-group {
        content-visibility: auto;
        contain-intrinsic-size: auto 100px;
      }
    }
    .safe-top {
      padding-top: max(0.5rem, env(safe-area-inset-top));
    }
    .safe-bottom {
      padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
    }
    .composer-safe-bottom {
      padding-bottom: max(0.55rem, calc(env(safe-area-inset-bottom) * 0.85));
    }

    /* Mobile sidebar keyboard & search focus optimization */
    @media (max-width: 1023px) {
      html.keyboard-open #sidebar-footer,
      #sidebar.sidebar-search-focused #sidebar-footer {
        display: none;
      }
      #sidebar.sidebar-search-focused #sidebar-profile-section,
      #sidebar.sidebar-search-focused #btn-sidebar-new {
        display: none;
      }
      #sidebar.sidebar-search-focused #sidebar-actions-section {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
      }
      #sidebar.sidebar-search-focused #sidebar-search {
        margin-top: 0;
      }
    }

    /* Native precise text selection inside messages */
    .selectable-text {
      -webkit-user-select: text;
      user-select: text;
      -webkit-touch-callout: default;
    }

    /* Markdown Typography */
    .md-body {
      font-size: 15px;
      line-height: 1.65;
      word-break: break-word;
      overflow-wrap: anywhere;
    }
    .md-body p { margin: 0.45em 0; }
    .md-body p:first-child { margin-top: 0; }
    .md-body p:last-child { margin-bottom: 0; }
    .md-body h1, .md-body h2, .md-body h3, .md-body h4 {
      font-weight: 650;
      margin: 0.9em 0 0.4em;
      color: #f8fafc;
      line-height: 1.35;
    }
    .md-body h1 { font-size: 1.25em; }
    .md-body h2 { font-size: 1.12em; }
    .md-body h3 { font-size: 1.03em; }
    .md-body ul, .md-body ol {
      margin: 0.45em 0;
      padding-left: 1.35em;
    }
    .md-body ul { list-style-type: disc; }
    .md-body ol { list-style-type: decimal; }
    .md-body li { margin: 0.2em 0; }
    .md-body blockquote {
      border-left: 3px solid #3b82f6;
      padding-left: 0.85em;
      margin: 0.6em 0;
      color: #94a3b8;
    }
    .md-body a {
      color: #60a5fa;
      text-decoration: underline;
      text-underline-offset: 2px;
    }
    .md-body :not(pre) > code {
      background: #1e293b;
      color: #e2e8f0;
      padding: 0.14em 0.4em;
      border-radius: 5px;
      font-size: 0.88em;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    }
    .md-body table {
      display: block;
      overflow-x: auto;
      border-collapse: collapse;
      margin: 0.6em 0;
      font-size: 0.9em;
    }
    .md-body th, .md-body td {
      border: 1px solid #243047;
      padding: 0.4em 0.65em;
      text-align: left;
    }
    .md-body th { background: #151e2e; }

    /* Code block wrapper */
    .code-wrap {
      position: relative;
      margin: 0.65em 0;
      border-radius: 10px;
      border: 1px solid #243047;
      background: #0d1117;
      overflow: hidden;
    }
    .code-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.35rem 0.65rem;
      background: #141b27;
      border-bottom: 1px solid #222d42;
      font-size: 11px;
      color: #94a3b8;
    }
    .code-wrap pre {
      margin: 0;
      padding: 0.75rem;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      font-size: 12.5px;
      line-height: 1.5;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    }
    .code-wrap pre code {
      background: transparent !important;
      padding: 0 !important;
      white-space: pre;
      word-break: normal;
      overflow-wrap: normal;
    }

    /* Collapsible details cards */
    details.tool-card {
      border: 1px solid #222d42;
      background: rgba(23, 31, 48, 0.72);
      border-radius: 12px;
      overflow: hidden;
    }
    details.tool-card > summary {
      list-style: none;
      cursor: pointer;
      padding: 0.55rem 0.75rem;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 13px;
      color: #cbd5e1;
      user-select: none;
    }
    details.tool-card > summary::-webkit-details-marker {
      display: none;
    }
    details.tool-card > summary .chevron {
      transition: transform 0.16s ease;
      flex-shrink: 0;
    }
    details.tool-card[open] > summary .chevron {
      transform: rotate(90deg);
    }
    .tool-body {
      border-top: 1px solid #222d42;
      padding: 0.65rem 0.75rem;
      background: #0d121d;
      font-size: 12px;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      max-height: 300px;
      overflow-y: auto;
      white-space: pre-wrap;
      word-break: break-word;
      color: #cbd5e1;
    }

    /* Grouped Execution Process Collapsible Container (Remote Control style) */
    details.process-group {
      border: 1px solid rgba(35, 47, 70, 0.72);
      background: rgba(17, 23, 35, 0.58);
      border-radius: 14px;
      overflow: hidden;
    }
    details.process-group > summary {
      list-style: none;
      cursor: pointer;
      padding: 0.52rem 0.75rem;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 12.5px;
      color: #94a3b8;
      user-select: none;
    }
    details.process-group > summary::-webkit-details-marker {
      display: none;
    }
    details.process-group > summary .pg-chevron {
      transition: transform 0.16s ease;
      flex-shrink: 0;
    }
    details.process-group[open] > summary .pg-chevron {
      transform: rotate(90deg);
    }
    .process-group-body {
      padding: 0 0.5rem 0.5rem;
      display: flex;
      flex-direction: column;
      gap: 0.4rem;
    }

    /* Diff viewer lines & collapsible file cards */
    .diff-line-add { background: rgba(34, 197, 94, 0.15); color: #86efac; }
    .diff-line-del { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
    .diff-line-hunk { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
    .diff-line-file { color: #f8fafc; font-weight: 600; }
    details.diff-file-card {
      border: 1px solid rgba(51, 65, 85, 0.7);
      border-radius: 0.75rem;
      background: #0b1120;
      overflow: hidden;
    }
    details.diff-file-card > summary {
      list-style: none;
      cursor: pointer;
      user-select: none;
      -webkit-user-select: none;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.5rem;
      padding: 0.5rem 0.65rem;
      background: rgba(30, 41, 59, 0.55);
      transition: background 0.15s ease;
    }
    details.diff-file-card > summary:hover {
      background: rgba(30, 41, 59, 0.85);
    }
    details.diff-file-card > summary::-webkit-details-marker {
      display: none;
    }
    details.diff-file-card > summary .diff-chevron {
      transition: transform 0.16s ease;
      flex-shrink: 0;
    }
    details.diff-file-card[open] > summary {
      border-bottom: 1px solid rgba(51, 65, 85, 0.55);
    }
    details.diff-file-card[open] > summary .diff-chevron {
      transform: rotate(90deg);
    }
    .diff-file-body {
      padding: 0.25rem 0;
      overflow-x: auto;
    }
    .diff-row {
      display: flex;
      align-items: stretch;
      min-width: max-content;
    }
    .diff-ln {
      width: 2.75rem;
      min-width: 2.75rem;
      padding: 0 0.4rem;
      text-align: right;
      font-size: 11px;
      color: rgba(148, 163, 184, 0.52);
      border-right: 1px solid rgba(51, 65, 85, 0.45);
      user-select: none;
      -webkit-user-select: none;
      font-variant-numeric: tabular-nums;
      flex-shrink: 0;
    }
    .diff-line-add .diff-ln {
      color: rgba(134, 239, 172, 0.6);
      border-right-color: rgba(34, 197, 94, 0.22);
    }
    .diff-line-del .diff-ln {
      color: rgba(252, 165, 165, 0.6);
      border-right-color: rgba(239, 68, 68, 0.22);
    }
    .diff-line-hunk .diff-ln {
      color: rgba(147, 197, 253, 0.55);
      border-right-color: rgba(59, 130, 246, 0.25);
    }
    .diff-code {
      white-space: pre;
      padding: 0 0.5rem;
      flex: 1;
    }

    /* Pulse indicator */
    @keyframes soft-pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.35; }
    }
    .animate-soft-pulse {
      animation: soft-pulse 1.3s ease-in-out infinite;
    }

    /* Elegant quote card inside user message bubbles */
    .user-quote-card {
      position: relative;
      display: flex;
      align-items: stretch;
      gap: 0.5rem;
      padding: 0.42rem 0.62rem;
      border-radius: 0.65rem;
      background: rgba(9, 17, 34, 0.28);
      border: 1px solid rgba(255, 255, 255, 0.12);
      color: rgba(226, 238, 255, 0.88);
      font-size: 12.5px;
      line-height: 1.45;
      transition: background 0.16s ease;
    }
    .user-quote-card.is-expandable {
      cursor: pointer;
    }
    .user-quote-card.is-expandable:hover {
      background: rgba(9, 17, 34, 0.38);
    }
    .user-quote-bar {
      width: 2.5px;
      border-radius: 999px;
      background: rgba(191, 219, 254, 0.82);
      flex-shrink: 0;
    }
    .user-quote-text {
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      word-break: break-word;
    }
    .user-quote-card.is-expanded .user-quote-text {
      display: block;
      -webkit-line-clamp: unset;
      overflow: visible;
    }

    .line-clamp-2 {
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
    }

    @keyframes msg-flash {
      0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.65); }
      40% { box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.55); }
      100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
    }
    .msg-highlight-flash {
      animation: msg-flash 1.1s ease-out;
    }

    /* Clickable local file links in Markdown */
    .md-body a.file-preview-link {
      color: #7dd3fc;
      text-decoration: underline;
      text-decoration-style: dotted;
      text-underline-offset: 3px;
      cursor: pointer;
      transition: color 0.14s ease, background 0.14s ease;
    }
    .md-body a.file-preview-link:hover {
      color: #bae6fd;
      text-decoration-style: solid;
    }

    /* File Preview Code Viewer */
    .fp-code-wrap {
      padding: 0.5rem 0;
      font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
      font-size: 12.5px;
      line-height: 1.55;
      color: #e2e8f0;
      min-width: max-content;
    }
    .fp-code-wrap.fp-wrap-lines {
      min-width: 0;
      width: 100%;
    }
    .fp-row {
      display: flex;
      align-items: stretch;
      min-height: 1.55em;
    }
    .fp-row:hover {
      background: rgba(148, 163, 184, 0.06);
    }
    .fp-row-hl {
      background: rgba(59, 130, 246, 0.18) !important;
      box-shadow: inset 2.5px 0 0 #60a5fa;
    }
    .fp-ln {
      width: 3.3rem;
      min-width: 3.3rem;
      padding: 0 0.6rem 0 0.4rem;
      text-align: right;
      font-size: 11px;
      color: rgba(148, 163, 184, 0.5);
      border-right: 1px solid rgba(51, 65, 85, 0.45);
      user-select: none;
      -webkit-user-select: none;
      font-variant-numeric: tabular-nums;
      flex-shrink: 0;
    }
    .fp-row-hl .fp-ln {
      color: #93c5fd;
      border-right-color: rgba(96, 165, 250, 0.4);
    }
    .fp-code {
      white-space: pre;
      padding: 0 0.85rem;
      flex: 1;
      min-width: 0;
    }
    .fp-code-wrap.fp-wrap-lines .fp-code {
      white-space: pre-wrap;
      word-break: break-word;
      overflow-wrap: anywhere;
    }
