      /* ===== Security hardening ===== */
      img { -webkit-user-drag: none; -webkit-touch-callout: none; user-drag: none; }
      body { -webkit-touch-callout: none; }
      input, textarea, [contenteditable="true"] { -webkit-touch-callout: default; }

      :root {
        --bg-primary: #080b12;
        --bg-secondary: #101621;
        --bg-tertiary: rgba(148, 163, 184, 0.075);
        --bg-glass: rgba(16, 22, 33, 0.82);
        --text-primary: #f5f6f8;
        --text-secondary: #94a3b8;
        --accent-primary: #17f0f1;
        --accent-hover: #17f0f1;
        --accent-light: rgba(23, 240, 241, 0.16);
        --danger: #f43f5e;
        --success: #10b981;
        --warning: #f59e0b;
        --border-color: rgba(148, 163, 184, 0.14);
        --sidebar-width: 290px;
        --canvas-width: 50%;
        --radius-sm: 10px;
        --radius-md: 16px;
        --radius-lg: 20px;
        --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.24);
        --shadow-lg: 0 18px 55px rgba(0, 0, 0, 0.34);
        --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
        --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        --font-code: "JetBrains Mono", "Fira Code", Consolas, Monaco, monospace;
      }
      body.light-theme {
        --bg-primary: #f5f7fb;
        --bg-secondary: rgba(255, 255, 255, 0.94);
        --bg-tertiary: rgba(37, 55, 94, 0.055);
        --bg-glass: rgba(255, 255, 255, 0.86);
        --text-primary: #0f172a;
        --text-secondary: #64748b;
        --accent-primary: #17f0f1;
        --accent-hover: #17f0f1;
        --accent-light: rgba(23, 240, 241, 0.12);
        --border-color: rgba(37, 55, 94, 0.12);
        --shadow-md: 0 8px 28px rgba(37, 55, 94, 0.08);
        --shadow-lg: 0 18px 55px rgba(37, 55, 94, 0.11);
        --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.06);
      }
      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
        -webkit-tap-highlight-color: transparent;
        -webkit-user-drag: none;
      }
      body {
        font-family: var(--font-main);
        background:
          radial-gradient(circle at 85% 5%, rgba(23, 240, 241, 0.09), transparent 30rem),
          radial-gradient(circle at 30% 100%, rgba(43, 214, 190, 0.045), transparent 26rem), var(--bg-primary);
        color: var(--text-primary);
        height: 100vh;
        height: 100dvh;
        display: flex;
        overflow: hidden;
        line-height: 1.6;
        touch-action: manipulation;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
        font-feature-settings: "kern" 1;
      }
      aside,
      body,
      header,
      main {
        transition:
          background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
          color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
          border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
      }
      .canvas-column {
        transition:
          width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
          border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
          background-color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
      }
      ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
      }
      ::-webkit-scrollbar-track {
        background: 0 0;
      }
      ::-webkit-scrollbar-thumb {
        background: var(--bg-tertiary);
        border-radius: var(--radius-sm);
        border: 2px solid transparent;
        background-clip: padding-box;
      }
      ::-webkit-scrollbar-thumb:hover {
        background: var(--text-secondary);
        border: 2px solid transparent;
        background-clip: padding-box;
      }
      #app {
        display: flex;
        width: 100%;
        height: 100%;
        height: 100dvh;
        position: relative;
      }
      [data-tooltip] {
        position: relative;
        overflow: visible;
      }
      [data-tooltip]::after,
      [data-tooltip]::before {
        position: absolute;
        visibility: hidden;
        opacity: 0;
        transform: translate(-50%, 10px) scale(0.9);
        transition:
          opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
          transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 9999;
        pointer-events: none;
      }
      [data-tooltip]::after {
        content: attr(data-tooltip);
        background: var(--text-primary);
        color: var(--bg-primary);
        font-size: 0.75rem;
        font-weight: 600;
        padding: 8px 12px;
        border-radius: var(--radius-sm);
        white-space: nowrap;
        box-shadow: var(--shadow-md);
      }
      [data-tooltip]::before {
        content: "";
        border: 6px solid transparent;
      }
      [data-tooltip]:not([data-tooltip-pos])::after {
        bottom: 130%;
        left: 50%;
      }
      [data-tooltip]:not([data-tooltip-pos]):before {
        border-top-color: var(--text-primary);
        bottom: calc(130% - 12px);
        left: 50%;
      }
      [data-tooltip]:not([data-tooltip-pos]):hover::after,
      [data-tooltip]:not([data-tooltip-pos]):hover::before {
        visibility: visible;
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
      }
      [data-tooltip-pos="bottom"]::after {
        top: 130%;
        left: 50%;
        transform: translate(-50%, -10px) scale(0.9);
      }
      [data-tooltip-pos="bottom"]::before {
        border-bottom-color: var(--text-primary);
        top: calc(130% - 12px);
        left: 50%;
        transform: translate(-50%, -10px) scale(0.9);
      }
      [data-tooltip-pos="bottom"]:hover::after,
      [data-tooltip-pos="bottom"]:hover::before {
        visibility: visible;
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
      }
      [data-tooltip-pos="up-right"]::after {
        bottom: 130%;
        left: 0;
        transform: translate(0, 10px) scale(0.9);
      }
      [data-tooltip-pos="up-right"]::before {
        border-top-color: var(--text-primary);
        bottom: calc(130% - 12px);
        left: 14px;
        transform: translate(0, 10px) scale(0.9);
      }
      [data-tooltip-pos="up-right"]:hover::after,
      [data-tooltip-pos="up-right"]:hover::before {
        visibility: visible;
        opacity: 1;
        transform: translate(0, 0) scale(1);
      }
      [data-tooltip-pos="up-left"]::after {
        bottom: 130%;
        right: 0;
        transform: translate(0, 10px) scale(0.9);
      }
      [data-tooltip-pos="up-left"]::before {
        border-top-color: var(--text-primary);
        bottom: calc(130% - 12px);
        right: 14px;
        transform: translate(0, 10px) scale(0.9);
      }
      [data-tooltip-pos="up-left"]:focus-visible::after,
      [data-tooltip-pos="up-left"]:focus-visible::before,
      [data-tooltip-pos="up-left"]:hover::after,
      [data-tooltip-pos="up-left"]:hover::before {
        visibility: visible;
        opacity: 1;
        transform: translate(0, 0) scale(1);
      }
      .reveal-on-hover .hover-only {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.92);
        transition:
          opacity 0.18s ease,
          transform 0.18s ease;
      }
      .reveal-on-hover.active .hover-only,
      .reveal-on-hover:focus-within .hover-only,
      .reveal-on-hover:has(.hover-only:focus-visible) .hover-only,
      .reveal-on-hover:hover .hover-only {
        opacity: 1;
        pointer-events: all;
        transform: scale(1);
      }
      .reveal-on-hover .hover-only:focus-visible {
        opacity: 1;
        pointer-events: all;
        transform: scale(1);
      }
      @media (hover: none) and (pointer: coarse) {
        .reveal-on-hover .hover-only,
        .reveal-on-hover .hover-only:focus-visible,
        .reveal-on-hover.active .hover-only,
        .reveal-on-hover:focus-within .hover-only,
        .reveal-on-hover:hover .hover-only {
          opacity: 1 !important;
          pointer-events: all !important;
          transform: none !important;
        }
      }
      #sidebar {
        width: var(--sidebar-width);
        background: var(--bg-secondary);
        border-right: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        z-index: 100;
        height: 100%;
        height: 100dvh;
        overflow: hidden;
        transition:
          transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
          width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
          opacity 0.3s ease,
          border-color 0.3s ease;
      }
      #sidebar > * {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
      }
      #sidebar.collapsed {
        transform: translateX(-100%);
        width: 0 !important;
        border-right: 0 solid transparent !important;
        opacity: 0.85;
      }
      .sidebar-header {
        padding: 20px 15px;
        border-bottom: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        gap: 12px;
        flex-shrink: 0;
      }
      .btn {
        background: var(--bg-tertiary);
        color: var(--text-primary);
        border: 1px solid var(--border-color);
        padding: 12px 18px;
        border-radius: var(--radius-sm);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        font-size: 0.9rem;
        transition: var(--transition);
        font-family: var(--font-main);
        font-weight: 600;
        min-height: 44px;
        user-select: none;
      }
      .btn:hover {
        background: var(--bg-glass);
        border-color: var(--text-secondary);
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
      }
      .btn:active {
        transform: translateY(0) scale(0.96);
        transition-duration: 80ms;
      }
      .btn-ripple {
        position: absolute;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.35);
        transform: scale(0);
        animation: btnRipple 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        pointer-events: none;
      }
      @keyframes btnRipple {
        0% {
          transform: scale(0);
          opacity: 0.6;
        }
        100% {
          transform: scale(2.5);
          opacity: 0;
        }
      }
      .btn-primary {
        background: var(--accent-primary);
        border-color: var(--accent-primary);
        color: #fff;
      }
      .btn-primary:hover {
        background: var(--accent-hover);
        border-color: var(--accent-hover);
        box-shadow: 0 4px 15px rgba(76, 177, 190, 0.28);
      }
      .btn-icon {
        padding: 12px;
        background: 0 0;
        border: none;
        color: var(--text-secondary);
        border-radius: var(--radius-sm);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: var(--transition);
        min-width: 44px;
        min-height: 44px;
        user-select: none;
      }
      .btn-icon:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
        transform: scale(1.08);
      }
      .search-container {
        position: relative;
        width: 100%;
      }
      .search-container svg {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-secondary);
        width: 16px;
        height: 16px;
      }
      .input-base {
        width: 100%;
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        padding: 10px 10px 10px 38px;
        border-radius: var(--radius-sm);
        outline: 0;
        font-size: 0.9rem;
        transition: var(--transition);
        box-sizing: border-box;
        min-height: 44px;
      }
      .input-base:focus {
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 3px var(--accent-light);
      }
      .chat-list {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        padding: 12px 10px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        position: relative;
        z-index: 1;
      }
      .chat-item {
        box-sizing: border-box;
        min-height: 48px;
        padding: 8px 14px;
        border-radius: var(--radius-sm);
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 12px;
        color: var(--text-secondary);
        user-select: none;
        position: relative;
        overflow: visible;
        border: 1px solid transparent;
        transition:
          transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
          background 0.2s ease,
          color 0.2s ease,
          border-color 0.2s ease;
      }
      .chat-item.newly-created {
        animation: slideInRight 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      }
      .chat-item.active,
      .chat-item:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
        border-color: var(--border-color);
        transform: translateX(2px);
      }
      .chat-item:active {
        transform: scale(0.98);
      }
      .chat-item::after {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 3px;
        background: var(--accent-primary);
        transform: scaleY(0);
        transform-origin: top center;
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
        border-radius: 0 3px 3px 0;
      }
      .chat-item.active::after {
        transform: scaleY(1);
      }
      .chat-item.newly-created {
        animation: popIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      }
      .chat-item-title {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0.9rem;
        font-weight: 500;
      }
      .chat-item.naming-pulse {
        animation: textPulse 1s infinite alternate;
      }
      @keyframes textPulse {
        from {
          opacity: 0.5;
        }
        to {
          opacity: 1;
        }
      }
      .chat-item-actions {
        display: flex;
        gap: 5px;
        flex: 0 0 auto;
        width: 106px;
        min-width: 106px;
        height: 32px;
        align-items: center;
        justify-content: flex-end;
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
        transition:
          opacity 0.15s ease,
          visibility 0s linear 0.15s;
      }
      .chat-item.active .chat-item-actions,
      .chat-item:focus-within .chat-item-actions,
      .chat-item:hover .chat-item-actions {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transition-delay: 0s;
      }
      .sidebar-footer {
        padding: 15px;
        border-top: 1px solid var(--border-color);
        display: flex;
        justify-content: space-between;
        flex-shrink: 0;
        z-index: 100;
      }
      .workspace-split {
        flex: 1;
        display: flex;
        height: 100%;
        min-width: 0;
        position: relative;
      }
      #main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        position: relative;
        min-width: 0;
        height: 100%;
        height: 100dvh;
      }
      #canvas-tab-handle {
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 50;
        display: none;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 12px 5px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-right: none;
        border-radius: var(--radius-sm) 0 0 var(--radius-sm);
        cursor: pointer;
        color: var(--text-secondary);
        font-size: 0.7rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        transition:
          background 0.15s,
          color 0.15s,
          opacity 0.15s;
        writing-mode: vertical-rl;
        text-orientation: mixed;
        user-select: none;
        opacity: 1;
        pointer-events: auto;
      }
      @media (hover: hover) and (pointer: fine) and (min-width: 1025px) {
        #canvas-tab-handle {
          display: flex;
        }
      }
      @media (hover: none), (pointer: coarse), (max-width: 1024px) {
        #canvas-tab-handle {
          display: none !important;
        }
      }
      #canvas-tab-handle:hover {
        background: var(--bg-tertiary);
        color: var(--accent-primary);
      }
      #canvas-tab-handle svg {
        transform: rotate(90deg);
        flex-shrink: 0;
      }
      #canvas-tab-handle.hidden {
        opacity: 0;
        pointer-events: none;
      }
      .pane-splitter {
        position: relative;
        width: 0;
        height: 100%;
        flex: 0 0 auto;
        z-index: 90;
        pointer-events: none;
      }
      .pane-splitter::after {
        content: "";
        position: absolute;
        top: 0;
        left: -4px;
        width: 8px;
        height: 100%;
        cursor: col-resize;
        pointer-events: auto;
        background: 0 0;
        transition: background 0.15s;
      }
      .pane-splitter.resizing::after,
      .pane-splitter:hover::after {
        background: var(--accent-primary);
        opacity: 0.35;
      }
      .pane-splitter.hidden {
        display: none;
      }
      @media (max-width: 1024px) {
        .pane-splitter {
          display: none !important;
        }
      }
      .canvas-column {
        width: 0;
        background: var(--bg-secondary);
        border-left: 0 solid transparent;
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
        position: relative;
      }
      .canvas-column.open {
        width: var(--canvas-width);
        border-left: 1px solid var(--border-color);
      }
      .canvas-header {
        min-height: 48px;
        padding: 6px 12px;
        display: flex;
        align-items: center;
        gap: 10px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
      }
      .canvas-tabs {
        display: flex;
        gap: 4px;
        background: var(--bg-primary);
        padding: 3px;
        border-radius: 8px;
        margin-right: auto;
      }
      .canvas-toolbar {
        display: flex;
        align-items: center;
        gap: 2px;
        flex-shrink: 0;
      }
      .canvas-tool-btn {
        width: 28px;
        height: 28px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid transparent;
        background: transparent;
        color: var(--text-secondary);
        border-radius: 6px;
        cursor: pointer;
        transition: var(--transition);
      }
      .canvas-tool-btn:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
      }
      .canvas-tabs {
        display: flex;
        gap: 6px;
        background: var(--bg-primary);
        padding: 4px;
        border-radius: var(--radius-sm);
      }
      .canvas-tab {
        background: 0 0;
        color: var(--text-secondary);
        border: none;
        padding: 8px 16px;
        font-size: 0.8rem;
        font-weight: 600;
        cursor: pointer;
        border-radius: 6px;
        transition: var(--transition);
        min-height: 38px;
        user-select: none;
      }
      .canvas-tab.active {
        background: var(--bg-secondary);
        color: var(--text-primary);
        box-shadow: var(--shadow-md);
        animation: tabActivate 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
      }
      @keyframes tabActivate {
        from {
          opacity: 0.6;
          transform: scale(0.96);
        }
        to {
          opacity: 1;
          transform: scale(1);
        }
      }
      .canvas-body {
        flex: 1;
        overflow: hidden;
        position: relative;
        background: var(--bg-primary);
        display: flex;
        flex-direction: column;
      }
      .canvas-pane {
        display: none;
        width: 100%;
        height: 100%;
        overflow-y: auto;
      }
      .canvas-pane.active {
        display: flex;
        flex-direction: column;
        animation: canvasPaneIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
      }
      @keyframes canvasPaneIn {
        from {
          opacity: 0;
          transform: translateY(7px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }
      .canvas-sandbox-iframe {
        width: 100%;
        flex: 1;
        border: none;
        background: #fff;
      }
      .canvas-editor-area {
        width: 100%;
        flex: 1;
        min-height: 0;
        background: #0f131a;
        color: #cbd5e1;
        font-family: var(--font-code);
        font-size: 0.9rem;
        padding: 20px;
        border: none;
        outline: 0;
        resize: none;
        line-height: 1.6;
      }
      .canvas-editor-toolbar {
        height: 36px;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 0 14px;
        border-bottom: 1px solid var(--border-color);
        background: var(--bg-secondary);
        flex-shrink: 0;
      }
      .canvas-editor-meta {
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 0.72rem;
        color: var(--text-secondary);
        font-family: var(--font-code);
        margin-right: auto;
      }
      .canvas-editor-meta span:first-child {
        color: var(--accent-primary);
        font-weight: 800;
      }
      .canvas-editor-actions {
        display: flex;
        align-items: center;
        gap: 4px;
      }
      .canvas-editor-actions button {
        background: var(--bg-tertiary);
        color: var(--text-secondary);
        border: 1px solid var(--border-color);
        border-radius: 6px;
        padding: 4px 8px;
        cursor: pointer;
        font-size: 0.7rem;
        font-weight: 700;
      }
      .canvas-editor-actions button:hover {
        color: var(--text-primary);
        border-color: var(--accent-primary);
      }
      .input-actions { position: relative; z-index: 2; }
      #message-input { padding-bottom: 28px; }
      .canvas-inline-btn {
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 0.72rem;
        cursor: pointer;
        font-family: var(--font-code);
      }
      .canvas-inline-btn:hover {
        color: var(--accent-primary);
      }
      .canvas-document-pane {
        padding: 30px;
        color: var(--text-primary);
        overflow-y: auto;
        height: 100%;
      }
      .top-bar {
        height: 65px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 24px;
        border-bottom: 1px solid var(--border-color);
        background: var(--bg-glass);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        position: sticky;
        top: 0;
        z-index: 10;
        flex-shrink: 0;
        box-shadow: 0 1px 0 rgba(148, 163, 184, 0.04);
      }
      .top-bar-left {
        display: flex;
        align-items: center;
        gap: 15px;
      }
      .top-bar-logo {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        object-fit: cover;
        border: 1.5px solid var(--border-color);
        box-shadow: 0 5px 16px rgba(109, 140, 255, 0.18);
      }
      .current-chat-title {
        font-weight: 700;
        font-size: 0.98rem;
        letter-spacing: -0.01em;
        max-width: min(42vw, 420px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .top-bar-right {
        display: flex;
        align-items: center;
        gap: 14px;
      }
      .canvas-pilot-top-btn {
        background: var(--bg-tertiary);
        color: var(--text-secondary);
        border: 1px solid var(--border-color);
        padding: 8px 16px;
        border-radius: var(--radius-sm);
        font-size: 0.8rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        transition: var(--transition);
        font-family: var(--font-main);
        min-height: 38px;
        user-select: none;
      }
      #canvas-open-top-btn {
        display: none;
      }
      @media (hover: none), (pointer: coarse), (max-width: 1024px) {
        #canvas-open-top-btn {
          display: flex;
        }
      }
      .canvas-pilot-top-btn:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
        transform: translateY(-1px);
      }
      .canvas-pilot-top-btn.active {
        background: rgba(76, 177, 190, 0.15);
        border-color: var(--accent-primary);
        color: var(--accent-primary);
        box-shadow: 0 0 10px rgba(76, 177, 190, 0.2);
      }
      @media (max-width: 640px) {
        .canvas-pilot-top-btn span {
          display: none;
        }
        .canvas-pilot-top-btn {
          padding: 10px;
        }
      }
      #chat-area {
        flex: 1;
        overflow-y: auto;
        padding: 24px 0;
        scroll-behavior: smooth;
        display: flex;
        flex-direction: column;
        min-height: 0;
        position: relative;
      }
      #scroll-bottom-btn {
        position: fixed;
        bottom: 120px;
        right: 30px;
        background: var(--accent-primary);
        color: #fff;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        cursor: pointer;
        box-shadow: var(--shadow-lg);
        opacity: 0;
        pointer-events: none;
        transform: translateY(10px);
        transition:
          opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
          transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 99;
      }
      #scroll-bottom-btn.visible {
        opacity: 1;
        pointer-events: all;
        transform: translateY(0);
      }
      #scroll-bottom-btn:hover {
        background: var(--accent-hover);
        transform: scale(1.1);
      }
      .empty-state {
        margin: auto;
        text-align: center;
        animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
        max-width: 900px;
        width: 95%;
        padding: 28px 20px 40px;
      }
      .empty-state-logo {
        width: 82px;
        height: 82px;
        object-fit: cover;
        border-radius: 50%;
        margin-bottom: 20px;
        border: 2px solid var(--border-color);
        box-shadow: var(--shadow-md);
        animation: logoFloat 4s ease-in-out infinite;
      }
      @keyframes logoFloat {
        0%,
        100% {
          transform: translateY(0);
        }
        50% {
          transform: translateY(-8px);
        }
      }
      .empty-state h1 {
        font-size: clamp(2.1rem, 4vw, 3.15rem);
        margin-bottom: 8px;
        font-weight: 800;
        letter-spacing: -0.02em;
        background: linear-gradient(135deg, var(--text-primary) 0, var(--text-secondary) 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
      .empty-state p {
        color: var(--text-secondary);
        font-size: 1rem;
        margin-bottom: 28px;
        font-weight: 500;
      }
      .empty-state .choice-container {
        animation: softReveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
      }
      .choice-container {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        margin-top: 14px;
        text-align: left;
      }
      @media (max-width: 1024px) {
        .choice-container {
          grid-template-columns: repeat(2, 1fr);
        }
      }
      @media (max-width: 640px) {
        .choice-container {
          grid-template-columns: 1fr;
        }
      }
      .choice-card {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 18px;
        cursor: pointer;
        transition:
          transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
          border-color 0.2s ease,
          box-shadow 0.25s ease,
          background 0.2s ease;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        position: relative;
        min-height: 116px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        user-select: none;
        overflow: hidden;
      }
      .choice-card::before {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(135deg, rgba(76, 177, 190, 0.06), transparent 60%);
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
      }
      .choice-card:hover::before {
        opacity: 1;
      }
      .choice-card:hover {
        border-color: var(--accent-primary);
        transform: translateY(-4px) scale(1.01);
        box-shadow: 0 16px 34px rgba(109, 140, 255, 0.16);
      }
      .choice-card:active {
        transform: translateY(-1px) scale(0.98);
      }
      .choice-card.active {
        border-color: var(--accent-primary);
        background: linear-gradient(135deg, rgba(109, 140, 255, 0.14), rgba(109, 140, 255, 0.035));
        box-shadow: 0 0 18px var(--accent-light);
        animation: modeCardActivate 0.45s cubic-bezier(0.16, 1, 0.3, 1);
      }
      .choice-card.active .choice-card-title svg {
        animation: modeIconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
      }
      .choice-card-title {
        font-size: 1.05rem;
        font-weight: 700;
        color: var(--text-primary) !important;
        margin-bottom: 8px;
        display: flex;
        align-items: center;
        gap: 10px;
      }
      .choice-card-title svg {
        flex-shrink: 0;
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      }
      .choice-card:hover .choice-card-title svg {
        transform: scale(1.15) rotate(5deg);
      }
      .choice-card-desc {
        font-size: 0.78rem;
        color: var(--text-secondary);
        line-height: 1.42;
      }
      .message-wrapper {
        padding: 16px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.02);
      }
      .message-wrapper.is-new {
        animation: messageEnter 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      }
      body.light-theme .message-wrapper {
        border-bottom: 1px solid rgba(0, 0, 0, 0.02);
      }
      .message-wrapper.user {
        background: 0 0;
      }
      .message-wrapper.ai {
        background: var(--bg-tertiary);
      }
      .message {
        max-width: 850px;
        margin: 0 auto;
        display: flex;
        gap: 16px;
      }
      @media (max-width: 640px) {
        .message {
          gap: 14px;
          padding: 0 10px;
        }
      }
      .avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        overflow: hidden;
        box-shadow: var(--shadow-md);
      }
      .avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
      .avatar.user {
        background: var(--accent-primary);
      }
      .avatar.ai {
        background: 0 0;
        border: none;
      }
      .message-content {
        flex: 1;
        min-width: 0;
        color: var(--text-primary);
        font-weight: 400;
        -webkit-font-smoothing: antialiased;
        text-rendering: optimizeLegibility;
      }
      .message-header {
        display: flex;
        justify-content: space-between;
        margin-bottom: 4px;
        font-size: 0.85rem;
        color: var(--text-secondary);
      }
      .message-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 10px;
        opacity: 0;
        transform: translateY(4px);
        transition:
          opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
          transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
      }
      .message-wrapper:hover .message-actions {
        opacity: 1;
        transform: translateY(0);
      }
      @media (max-width: 768px) {
        .message-actions {
          opacity: 1;
          transform: translateY(0);
        }
      }
      .action-btn {
        background: 0 0;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 0.8rem;
        padding: 8px 12px;
        border-radius: var(--radius-sm);
        transition:
          transform 0.15s ease,
          background 0.15s ease,
          color 0.15s ease,
          box-shadow 0.15s ease;
        min-height: 38px;
        user-select: none;
      }
      .copy-action-btn {
        white-space: nowrap;
      }
      .copy-action-btn svg {
        display: block;
        width: 14px;
        height: 14px;
        flex: 0 0 14px;
        overflow: visible;
        stroke: currentColor;
        stroke-width: 1.9;
        stroke-linecap: round;
        stroke-linejoin: round;
      }
      .action-btn:hover {
        color: var(--text-primary);
        background: var(--bg-tertiary);
        transform: translateY(-1px);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
      }
      .action-btn:active {
        transform: translateY(0) scale(0.96);
      }
      .action-btn.playing {
        color: var(--success);
      }
      .interactive-grid-container {
        margin-top: 15px;
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        overflow: hidden;
        display: flex;
        flex-direction: column;
        max-height: 300px;
      }
      .interactive-grid-toolbar {
        padding: 12px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        display: flex;
        gap: 12px;
        align-items: center;
      }
      .grid-filter-input {
        flex: 1;
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        padding: 6px 12px;
        border-radius: var(--radius-sm);
        font-size: 0.8rem;
        outline: 0;
      }
      .interactive-grid-table-wrapper {
        overflow-x: auto;
        overflow-y: auto;
        flex: 1;
      }
      .interactive-grid-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 0.8rem;
        text-align: left;
      }
      .interactive-grid-table th {
        background: var(--bg-secondary);
        padding: 10px 14px;
        border-bottom: 1px solid var(--border-color);
        font-weight: 700;
        color: var(--text-primary);
      }
      .interactive-grid-table td {
        padding: 10px 14px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        color: var(--text-secondary);
      }
      .zip-tree-container {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 14px;
        margin: 10px 0;
        max-height: 300px;
        overflow-y: auto;
        font-family: var(--font-code);
        font-size: 0.8rem;
      }
      .zip-tree-node {
        margin-left: 15px;
        display: flex;
        flex-direction: column;
        gap: 4px;
      }
      .zip-tree-item {
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        padding: 6px 8px;
        border-radius: var(--radius-sm);
        transition: var(--transition);
      }
      .zip-tree-item:hover {
        background: var(--bg-tertiary);
      }
      .branch-navigator {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.75rem;
        color: var(--text-secondary);
        margin-top: 8px;
        background: var(--bg-tertiary);
        padding: 4px 12px;
        border-radius: var(--radius-sm);
        width: fit-content;
        position: relative;
      }
      .branch-btn {
        background: 0 0;
        border: none;
        color: var(--accent-primary);
        cursor: pointer;
        padding: 2px 6px;
        font-weight: 700;
        transition: var(--transition);
      }
      .branch-btn:hover {
        color: var(--accent-hover);
      }
      .branch-btn.branch-regen-btn {
        border-left: 1px solid var(--border-color);
        padding-left: 10px;
        margin-left: 2px;
        font-size: 0.85rem;
      }
      .branch-navigator .branch-label {
        white-space: nowrap;
      }
      .branch-menu-toggle {
        background: 0 0;
        border: none;
        color: var(--text-secondary);
        cursor: pointer;
        font-size: 0.75rem;
        padding: 2px 6px;
        border-radius: 6px;
        display: inline-flex;
        align-items: center;
        gap: 4px;
        white-space: nowrap;
        transition: var(--transition);
      }
      .branch-menu-toggle:hover {
        color: var(--text-primary);
        background: var(--bg-tertiary);
      }
      .branch-caret {
        font-size: 0.65rem;
        opacity: 0.7;
      }
      .branch-menu {
        position: absolute;
        top: calc(100% + 6px);
        left: 0;
        z-index: 80;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow-md);
        padding: 4px;
        min-width: 260px;
        max-width: min(340px, calc(100vw - 48px));
        max-height: 260px;
        overflow-y: auto;
      }
      .branch-menu-row {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        background: 0 0;
        border: none;
        text-align: left;
        padding: 7px 10px;
        border-radius: 7px;
        cursor: pointer;
        color: var(--text-primary);
        font-size: 0.78rem;
        transition: var(--transition);
      }
      .branch-menu-row:hover {
        background: var(--bg-tertiary);
      }
      .branch-menu-row.current {
        background: var(--accent-light);
      }
      .branch-menu-dot {
        flex-shrink: 0;
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--text-secondary);
        opacity: 0.45;
      }
      .branch-menu-dot.saved {
        background: var(--success);
        opacity: 1;
      }
      .branch-menu-label {
        flex-shrink: 0;
        font-weight: 700;
        color: var(--text-secondary);
      }
      .branch-menu-preview {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        color: var(--text-secondary);
      }
      .branch-menu-regen {
        flex-shrink: 0;
        color: var(--accent-primary);
        font-weight: 700;
        padding: 0 4px;
        font-size: 0.9rem;
      }
      .branch-menu-regen:hover {
        color: var(--accent-hover);
      }
      .prose {
        text-rendering: optimizeLegibility;
        -webkit-font-smoothing: antialiased;
      }
      .prose p {
        margin-bottom: 1.25em;
        word-break: break-word;
        overflow-wrap: break-word;
      }
      .prose p:last-child {
        margin-bottom: 0;
      }
      .prose strong {
        color: var(--text-primary);
        font-weight: 700;
      }
      .prose em {
        font-style: italic;
      }
      .prose del {
        text-decoration: line-through;
        opacity: 0.8;
      }
      .prose blockquote {
        border-left: 3px solid var(--accent-primary);
        padding-left: 14px;
        margin: 12px 0;
        color: var(--text-secondary);
        font-style: italic;
      }
      .prose a {
        color: var(--accent-primary);
        text-decoration: none;
      }
      .prose a:hover {
        text-decoration: underline;
      }
      .prose ol,
      .prose ul {
        margin-bottom: 1.25em;
        padding-left: 24px;
      }
      .prose li {
        margin-bottom: 0.4em;
      }
      .prose .md-table {
        width: 100%;
        border-collapse: collapse;
        margin: 1em 0;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        overflow: hidden;
        font-size: 0.95rem;
      }
      .md-table-wrap {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-sm);
        margin: 1em 0;
      }
      .md-table-wrap .md-table {
        margin: 0;
        min-width: max-content;
      }
      @media (max-width: 768px) {
        .prose .md-table td,
        .prose .md-table th {
          padding: 8px 10px;
          font-size: 0.88rem;
          white-space: nowrap;
        }
      }
      .prose .md-table td,
      .prose .md-table th {
        padding: 10px 14px;
        border: 1px solid var(--border-color);
        text-align: left;
      }
      .prose .md-table th {
        background: var(--bg-tertiary);
        font-weight: 700;
        color: var(--text-primary);
      }
      .prose .md-table tr:nth-child(2n) td {
        background: rgba(255, 255, 255, 0.02);
      }
      .prose .md-table tr:hover td {
        background: var(--bg-tertiary);
        transition: background 0.15s ease;
      }
      .prose .md-image {
        max-width: 100%;
        border-radius: var(--radius-sm);
        margin: 8px 0;
        box-shadow: var(--shadow-md);
      }
      .prose .md-hr {
        border: none;
        border-top: 1px solid var(--border-color);
        margin: 1.5em 0;
        opacity: 0.6;
      }
      .prose .md-list {
        margin-bottom: 1.25em;
        padding-left: 24px;
      }
      .prose .md-list li {
        margin-bottom: 0.4em;
        position: relative;
      }
      .prose .md-task {
        display: inline-flex;
        align-items: center;
        margin-right: 8px;
      }
      .prose .md-task input[type="checkbox"] {
        accent-color: var(--accent-primary);
        width: 16px;
        height: 16px;
        cursor: default;
        margin: 0;
      }
      .prose .md-task.checked + * {
        text-decoration: line-through;
        opacity: 0.7;
      }
      .prose mark {
        background: rgba(76, 177, 190, 0.25);
        color: var(--text-primary);
        padding: 0 4px;
        border-radius: 3px;
      }
      .prose blockquote {
        border-left: 3px solid var(--accent-primary);
        padding-left: 14px;
        margin: 12px 0;
        color: var(--text-secondary);
        font-style: italic;
      }
      .prose blockquote p {
        margin-bottom: 0.5em;
      }
      .prose blockquote p:last-child {
        margin-bottom: 0;
      }
      .prose code {
        background: var(--bg-tertiary);
        padding: 0.25em 0.5em;
        border-radius: 6px;
        font-family: var(--font-code);
        font-size: 0.9em;
        color: var(--text-primary);
      }
      .prose h1,
      .prose h2,
      .prose h3 {
        color: var(--text-primary);
        margin-top: 1.6em;
        margin-bottom: 0.6em;
        font-weight: 700;
        letter-spacing: -0.01em;
        line-height: 1.3;
      }
      .prose h1 {
        font-size: 1.8em;
      }
      .prose h2 {
        font-size: 1.5em;
      }
      .prose h3 {
        font-size: 1.3em;
      }
      .prose .math-display {
        display: block;
        width: min(100%, 760px);
        box-sizing: border-box;
        margin: 1.25em auto;
        padding: 14px 18px;
        overflow-x: auto;
        overflow-y: hidden;
        text-align: center;
        color: var(--text-primary);
        background: linear-gradient(135deg, rgba(23, 240, 241, 0.09), rgba(23, 240, 241, 0.025));
        border: 1px solid rgba(23, 240, 241, 0.24);
        border-radius: var(--radius-md);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        -webkit-overflow-scrolling: touch;
      }
      .prose .math-inline {
        white-space: nowrap;
        color: var(--text-primary);
      }
      .prose .math-display mjx-container {
        margin: 0 !important;
        max-width: 100%;
      }
      .prose .math-display mjx-container[display="true"] {
        overflow-x: auto;
        overflow-y: hidden;
        padding: 2px 0;
      }
      @media (max-width: 768px) {
        .prose .math-display {
          margin: 1em 0;
          padding: 12px 10px;
          font-size: 0.92em;
          text-align: left;
        }
      }
      .stream-heading {
        display: block;
        color: var(--text-primary);
        font-weight: 700;
        margin: 0.8em 0 0.4em;
        line-height: 1.3;
        letter-spacing: -0.01em;
      }
      h1.stream-heading {
        font-size: 1.8em;
      }
      h2.stream-heading {
        font-size: 1.5em;
      }
      h3.stream-heading {
        font-size: 1.3em;
      }
      h4.stream-heading {
        font-size: 1.15em;
      }
      h5.stream-heading {
        font-size: 1.05em;
      }
      h6.stream-heading {
        font-size: 0.95em;
      }
      .code-block {
        background: #121620;
        border-radius: var(--radius-md);
        margin: 1.2em 0;
        overflow: hidden;
        border: 1px solid var(--border-color);
      }
      .code-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 18px;
        background: rgba(255, 255, 255, 0.04);
        border-bottom: 1px solid var(--border-color);
        font-size: 0.85rem;
        color: #94a3b8;
        min-height: 44px;
      }
      .code-header .action-btn {
        font-size: 0.78rem;
        padding: 6px 10px;
        min-height: 32px;
      }
      .code-header .lang-label {
        text-transform: uppercase;
        font-weight: 700;
        font-size: 0.75rem;
        letter-spacing: 0.05em;
      }
      .code-block pre {
        margin: 0;
        padding: 18px;
        overflow-x: auto;
      }
      .code-block code {
        font-family: var(--font-code);
        font-size: 0.9rem;
        line-height: 1.6;
        color: #e2e8f0;
        tab-size: 4;
      }
      .token.keyword {
        color: #f472b6;
      }
      .token.string {
        color: #34d399;
      }
      .token.comment {
        color: #64748b;
        font-style: italic;
      }
      .token.number {
        color: #fbbf24;
      }
      .token.function {
        color: #60a5fa;
      }
      .token.operator {
        color: #cbd5e1;
      }
      .token.class {
        color: #a78bfa;
      }
      .analytics-chart-wrapper {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 20px;
        margin: 15px 0;
        max-width: 100%;
        overflow-x: auto;
      }
      .analytics-chart-container {
        position: relative;
        height: 300px;
        width: 100%;
        min-width: 280px;
      }
      .input-container {
        padding: 10px 20px 14px;
        background: linear-gradient(to top, var(--bg-primary) 70%, transparent);
        position: relative;
        flex-shrink: 0;
      }
      .input-box {
        --btn-size: 38px;
        max-width: 850px;
        margin: 0 auto;
        position: relative;
        display: flex;
        align-items: flex-end;
        gap: 8px;
        background: rgba(16, 22, 33, 0.9);
        border: 1px solid rgba(148, 163, 184, 0.18);
        border-radius: var(--radius-lg);
        padding: 10px 10px 10px 12px;
        box-shadow: var(--shadow-lg);
        transition:
          transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
          border-color 0.25s ease,
          box-shadow 0.35s ease;
      }
      .input-box:focus-within {
        border-color: var(--accent-primary);
        box-shadow:
          0 0 0 4px rgba(109, 140, 255, 0.14),
          0 16px 35px rgba(0, 0, 0, 0.24);
        transform: translateY(-2px) scale(1.002);
      }
      body.light-theme .input-box {
        background: #ffffff;
        border-color: rgba(30, 41, 59, 0.15);
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
      }
      body.light-theme #message-input {
        color: #0f172a;
        caret-color: #2563eb;
      }
      body.light-theme #message-input::placeholder {
        color: rgba(15, 23, 42, 0.45);
      }
      #file-drop-overlay {
        position: fixed;
        inset: 0;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px;
        background: rgba(3, 7, 18, 0.72);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition:
          opacity 0.18s ease,
          visibility 0.18s ease;
      }
      #file-drop-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
      }
      .file-drop-card {
        width: min(680px, 100%);
        min-height: 300px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 14px;
        border: 2px dashed var(--accent-primary);
        border-radius: 24px;
        background: color-mix(in srgb, var(--bg-secondary) 94%, var(--accent-primary));
        box-shadow:
          0 24px 80px rgba(0, 0, 0, 0.35),
          0 0 0 8px rgba(76, 177, 190, 0.1);
        color: var(--text-primary);
        text-align: center;
        transform: scale(0.96);
        transition: transform 0.18s ease;
      }
      #file-drop-overlay.active .file-drop-card {
        transform: scale(1);
      }
      .file-drop-icon {
        width: 68px;
        height: 68px;
        display: grid;
        place-items: center;
        border-radius: 20px;
        background: rgba(76, 177, 190, 0.14);
        color: var(--accent-primary);
      }
      .file-drop-card strong {
        font-size: clamp(1.15rem, 2vw, 1.5rem);
      }
      .file-drop-card span {
        color: var(--text-secondary);
        font-size: 0.9rem;
      }
      .input-box.generating {
        border-color: var(--accent-primary);
        animation: inputPulseGlow 1.8s ease-in-out infinite;
        background: linear-gradient(
          135deg,
          var(--bg-secondary) 0,
          rgba(76, 177, 190, 0.06) 50%,
          var(--bg-secondary) 100%
        );
        background-size: 200% 200%;
      }
      .input-box.send-burst::after {
        content: "";
        position: absolute;
        right: 14px;
        bottom: 12px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(76, 177, 190, 0.6) 0, transparent 70%);
        transform: scale(0);
        animation: sendBurst 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        pointer-events: none;
        z-index: 20;
      }
      .input-box.generating #message-input::placeholder {
        opacity: 0.7;
        animation: placeholderShimmer 1.8s linear infinite;
        background: linear-gradient(
          90deg,
          var(--text-secondary) 0,
          var(--accent-primary) 50%,
          var(--text-secondary) 100%
        );
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        background-size: 200% 100%;
      }
      #message-input {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        background: 0 0;
        border: none;
        color: var(--text-primary);
        font-family: var(--font-main);
        font-size: 1rem;
        resize: none;
        outline: 0;
        max-height: 200px;
        min-height: 38px;
        overflow-y: auto;
        line-height: 1.5;
        padding: 7px 4px;
        transition: opacity 0.2s ease;
      }
      #message-input::placeholder {
        color: var(--text-secondary);
        transition:
          opacity 0.2s ease,
          color 0.2s ease;
      }
      .input-box:focus-within #message-input::placeholder {
        opacity: 0.6;
      }
      .input-actions {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        gap: 6px;
      }
      .mic-btn,
      .send-btn,
      .stop-btn {
        position: static;
        width: var(--btn-size);
        height: var(--btn-size);
        border-radius: 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: none;
        cursor: pointer;
        flex: 0 0 auto;
        transition:
          transform 0.15s ease,
          background 0.15s ease,
          color 0.15s ease,
          box-shadow 0.2s ease;
      }
      .send-btn {
        background: var(--text-primary);
        color: var(--bg-primary);
        overflow: hidden;
      }
      .send-btn::after {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(255, 255, 255, 0.35) 0, transparent 70%);
        opacity: 0;
        transform: scale(0.2);
        transition:
          opacity 0.3s ease,
          transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
      }
      .send-btn:hover:not(:disabled) {
        background: var(--accent-primary);
        color: #fff;
        transform: scale(1.14) rotate(-4deg);
        box-shadow: 0 6px 20px rgba(76, 177, 190, 0.36);
      }
      .send-btn:hover:not(:disabled)::after {
        opacity: 1;
        transform: scale(1.2);
      }
      .send-btn:active:not(:disabled) {
        transform: scale(0.92) rotate(0);
      }
      .send-btn:disabled {
        background: var(--bg-tertiary);
        color: var(--text-secondary);
        cursor: not-allowed;
        transform: scale(1);
        box-shadow: none;
        opacity: 0.7;
      }
      .send-btn.sending {
        animation: sendPulse 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      }
      .send-ripple {
        position: absolute;
        right: 10px;
        bottom: 10px;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(76, 177, 190, 0.5);
        pointer-events: none;
        transform: scale(0);
        animation: rippleOut 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        z-index: 10;
      }
      .stop-btn {
        background: var(--bg-tertiary);
        color: var(--text-primary);
        display: none;
      }
      .stop-btn:hover {
        background: var(--danger);
        color: #fff;
      }
      .mic-btn {
        background: var(--bg-tertiary);
        color: var(--text-secondary);
      }
      .mic-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-primary);
        transform: scale(1.1);
      }
      body.light-theme .mic-btn:hover {
        background: rgba(0, 0, 0, 0.05);
      }
      .mic-btn.recording {
        background: var(--danger);
        color: #fff;
        animation: pulse 1.5s infinite;
      }
      @keyframes pulse {
        0% {
          transform: scale(1);
          box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
        }
        70% {
          transform: scale(1.1);
          box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
        }
        100% {
          transform: scale(1);
          box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
        }
      }
      .char-counter {
        font-size: 0.72rem;
        font-weight: 600;
        color: var(--text-secondary);
        opacity: 0.6;
        pointer-events: none;
        font-variant-numeric: tabular-nums;
        margin-left: 6px;
        white-space: nowrap;
      }
      .input-box { position: relative; }
      .model-picker {
        position: relative;
        display: inline-flex;
        align-items: center;
        gap: 2px;
        padding: 3px;
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: 999px;
      }
      .model-pill {
        position: relative;
        z-index: 2;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 0.76rem;
        font-weight: 700;
        font-family: var(--font-main);
        padding: 6px 12px;
        border-radius: 999px;
        cursor: pointer;
        transition: color 0.2s ease;
        white-space: nowrap;
      }
      .model-pill svg {
        width: 13px;
        height: 13px;
      }
      .model-pill:hover {
        color: var(--text-primary);
      }
      .model-pill[aria-pressed="true"] {
        color: #04121a;
      }
      body.light-theme .model-pill[aria-pressed="true"] {
        color: #031018;
      }
      .model-pill-slider {
        position: absolute;
        z-index: 1;
        top: 3px;
        bottom: 3px;
        width: 0;
        border-radius: 999px;
        background: linear-gradient(135deg, var(--accent-primary), #7df9ff);
        box-shadow: 0 4px 14px rgba(76, 177, 190, 0.35);
        transition: left 0.28s cubic-bezier(0.16, 1, 0.3, 1), width 0.28s cubic-bezier(0.16, 1, 0.3, 1);
      }
      .typing-indicator {
        display: inline-flex;
        align-items: center;
        gap: 14px;
        padding: 12px 18px;
        background: var(--bg-tertiary);
        border-radius: var(--radius-lg);
        width: fit-content;
        border: 1px solid var(--border-color);
        overflow: hidden;
        position: relative;
        animation: indicatorIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      }
      .typing-indicator::before {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.12), transparent);
        opacity: 1;
        transform: translateX(-100%);
        animation: statusShimmer 2s infinite;
      }
      @keyframes statusShimmer {
        100% {
          transform: translateX(100%);
        }
      }
      @keyframes indicatorIn {
        from {
          opacity: 0;
          transform: scale(0.96) translateY(8px);
        }
        to {
          opacity: 1;
          transform: scale(1) translateY(0);
        }
      }
      .gemini-thinking {
        position: relative;
        width: 48px;
        height: 48px;
        flex-shrink: 0;
        z-index: 1;
      }
      .gemini-orbit {
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        animation: geminiOrbit 2.4s linear infinite;
      }
      .gemini-orbit.d1 {
        animation-delay: 0s;
      }
      .gemini-orbit.d2 {
        animation-delay: -0.34s;
      }
      .gemini-orbit.d3 {
        animation-delay: -0.69s;
      }
      .gemini-orbit.d4 {
        animation-delay: -1.03s;
      }
      .gemini-orbit.d5 {
        animation-delay: -1.37s;
      }
      .gemini-orbit.d6 {
        animation-delay: -1.71s;
      }
      .gemini-orbit.d7 {
        animation-delay: -2.06s;
      }
      .gemini-dot {
        position: absolute;
        top: -4px;
        left: 14px;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: currentColor;
        animation: geminiPulse 1.6s ease-in-out infinite;
      }
      .gemini-orbit.d1 .gemini-dot {
        animation-duration: 1.35s;
        animation-delay: 0s;
      }
      .gemini-orbit.d2 .gemini-dot {
        animation-duration: 1.85s;
        animation-delay: -0.42s;
      }
      .gemini-orbit.d3 .gemini-dot {
        animation-duration: 1.55s;
        animation-delay: -0.18s;
      }
      .gemini-orbit.d4 .gemini-dot {
        animation-duration: 1.95s;
        animation-delay: -0.73s;
      }
      .gemini-orbit.d5 .gemini-dot {
        animation-duration: 1.45s;
        animation-delay: -0.95s;
      }
      .gemini-orbit.d6 .gemini-dot {
        animation-duration: 1.75s;
        animation-delay: -1.22s;
      }
      .gemini-orbit.d7 .gemini-dot {
        animation-duration: 1.65s;
        animation-delay: -0.56s;
      }
      .gemini-orbit.d1 {
        color: #68b8c4;
      }
      .gemini-orbit.d2 {
        color: #8b5cf6;
      }
      .gemini-orbit.d3 {
        color: #ec4899;
      }
      .gemini-orbit.d4 {
        color: #ef4444;
      }
      .gemini-orbit.d5 {
        color: #f59e0b;
      }
      .gemini-orbit.d6 {
        color: #10b981;
      }
      .gemini-orbit.d7 {
        color: #06b6d4;
      }
      @keyframes geminiOrbit {
        0% {
          transform: rotate(0);
        }
        100% {
          transform: rotate(360deg);
        }
      }
      @keyframes geminiPulse {
        0%,
        100% {
          transform: scale(0.65);
          opacity: 0.65;
        }
        50% {
          transform: scale(1.15);
          opacity: 1;
        }
      }
      .status-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--accent-primary);
        box-shadow: 0 0 0 0 rgba(76, 177, 190, 0.7);
        animation: statusPulse 2s infinite;
        flex-shrink: 0;
      }
      @keyframes statusPulse {
        0% {
          box-shadow: 0 0 0 0 rgba(76, 177, 190, 0.7);
        }
        70% {
          box-shadow: 0 0 0 10px rgba(76, 177, 190, 0);
        }
        100% {
          box-shadow: 0 0 0 0 rgba(76, 177, 190, 0);
        }
      }
      .status-text {
        font-size: 0.85rem;
        color: var(--text-secondary);
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-family: var(--font-main);
        min-width: 140px;
        max-width: min(60ch, 50vw);
        transition:
          opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
          filter 0.3s ease;
      }
      /* On phones the prompt is long enough to overflow; let it wrap to two lines and ellipsis. */
      @media (max-width: 640px) {
        .status-text { white-space: normal; max-width: 70vw; min-width: 0; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; word-break: break-word; }
      }
      .status-text.fade {
        opacity: 0.25;
        filter: blur(1px);
      }
      @keyframes fadeIn {
        from {
          opacity: 0;
          transform: translateY(12px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }
      @keyframes slideInUp {
        from {
          opacity: 0;
          transform: translateY(24px);
        }
        to {
          opacity: 1;
          transform: translateY(0);
        }
      }
      @keyframes slideInRight {
        from {
          opacity: 0;
          transform: translateX(24px);
        }
        to {
          opacity: 1;
          transform: translateX(0);
        }
      }
      @keyframes fadeOut {
        from {
          opacity: 1;
        }
        to {
          opacity: 0;
        }
      }
      @keyframes popIn {
        0% {
          opacity: 0;
          transform: scale(0.94) translateY(8px);
        }
        70% {
          transform: scale(1.01) translateY(-1px);
        }
        100% {
          opacity: 1;
          transform: scale(1) translateY(0);
        }
      }
      @keyframes modeCardActivate {
        0% {
          box-shadow: 0 0 0 0 rgba(76, 177, 190, 0);
        }
        40% {
          box-shadow: 0 0 24px 4px rgba(76, 177, 190, 0.25);
        }
        100% {
          box-shadow: 0 0 18px var(--accent-light);
        }
      }
      @keyframes modeIconPop {
        0% {
          transform: scale(1) rotate(0);
        }
        50% {
          transform: scale(1.3) rotate(-10deg);
        }
        100% {
          transform: scale(1.15) rotate(5deg);
        }
      }
      @keyframes softReveal {
        0% {
          transform: translateY(6px);
        }
        100% {
          transform: translateY(0);
        }
      }
      @keyframes cursorBlink {
        0%,
        100% {
          opacity: 1;
        }
        50% {
          opacity: 0.3;
        }
      }
      @keyframes messageEnter {
        0% {
          opacity: 0;
          transform: translateY(10px);
        }
        100% {
          opacity: 1;
          transform: translateY(0);
        }
      }
      @keyframes messagePopIn {
        0% {
          opacity: 0;
          transform: translateY(14px);
        }
        100% {
          opacity: 1;
          transform: translateY(0);
        }
      }
      @keyframes inputPulseGlow {
        0%,
        100% {
          box-shadow:
            0 0 0 3px rgba(76, 177, 190, 0.12),
            0 6px 20px rgba(76, 177, 190, 0.1);
          border-color: rgba(76, 177, 190, 0.5);
        }
        50% {
          box-shadow:
            0 0 0 5px rgba(76, 177, 190, 0.18),
            0 8px 28px rgba(76, 177, 190, 0.18);
          border-color: rgba(76, 177, 190, 0.8);
        }
      }
      @keyframes placeholderShimmer {
        0% {
          background-position: 200% 0;
        }
        100% {
          background-position: -200% 0;
        }
      }
      @keyframes sendPulse {
        0% {
          transform: scale(1);
        }
        40% {
          transform: scale(1.15);
          box-shadow: 0 0 18px rgba(76, 177, 190, 0.5);
        }
        70% {
          transform: scale(0.95);
        }
        100% {
          transform: scale(1);
          box-shadow: 0 4px 14px rgba(76, 177, 190, 0.35);
        }
      }
      @keyframes rippleOut {
        0% {
          transform: scale(0);
          opacity: 0.7;
        }
        100% {
          transform: scale(6);
          opacity: 0;
        }
      }
      @keyframes sendBurst {
        0% {
          transform: scale(0.2);
          opacity: 1;
        }
        50% {
          opacity: 0.8;
        }
        100% {
          transform: scale(8);
          opacity: 0;
        }
      }
      @keyframes textReveal {
        0% {
          opacity: 0;
        }
        100% {
          opacity: 1;
        }
      }
      @keyframes streamShimmer {
        0% {
          background-position: 200% 0;
        }
        100% {
          background-position: -200% 0;
        }
      }
      .stream-cursor {
        display: inline-block;
        width: 7px;
        height: 1.1em;
        background: var(--accent-primary);
        border-radius: 1px;
        margin-left: 2px;
        vertical-align: text-bottom;
        animation: cursorBlink 0.9s infinite;
        box-shadow: 0 0 8px 1px rgba(76, 177, 190, 0.4);
      }
      .message-body > :last-child .stream-cursor,
      .message-body > p:last-child .stream-cursor {
        animation: cursorBlink 0.9s infinite;
      }
      .message-wrapper.is-streaming .message-body {
        transition: none;
        position: relative;
      }
      .message-wrapper.is-streaming .message-body::after {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(90deg, transparent 0, rgba(76, 177, 190, 0.04) 50%, transparent 100%);
        background-size: 200% 100%;
        animation: streamShimmer 1.6s linear infinite;
        pointer-events: none;
        border-radius: 12px;
        opacity: 0.4;
      }
      .message-wrapper.is-streaming .message-body > div,
      .message-wrapper.is-streaming .message-body > h1,
      .message-wrapper.is-streaming .message-body > h2,
      .message-wrapper.is-streaming .message-body > h3,
      .message-wrapper.is-streaming .message-body > li,
      .message-wrapper.is-streaming .message-body > p,
      .message-wrapper.is-streaming .message-body > pre {
        animation: none;
        opacity: 1;
      }
      .message-wrapper.is-streaming .message-body > li + li,
      .message-wrapper.is-streaming .message-body > p + p,
      .message-wrapper.is-streaming .message-body > pre + pre {
        animation: none;
      }
      .settings-panel {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        width: 90vw;
        max-width: 900px;
        height: 80vh;
        max-height: 700px;
        display: flex;
        flex-direction: column;
        box-shadow: var(--shadow-lg);
        transform: translateY(30px) scale(0.95);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        overflow: hidden;
        flex-shrink: 0;
      }
      .modal-overlay.active .settings-panel {
        transform: translateY(0) scale(1);
      }
      .settings-panel-header {
        padding: 18px 24px;
        border-bottom: 1px solid var(--border-color);
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
      }
      .settings-panel-header h2 {
        font-size: 1.25rem;
        font-weight: 800;
        letter-spacing: -0.01em;
        margin: 0;
      }
      .settings-panel-body {
        display: flex;
        flex: 1;
        min-height: 0;
        overflow: hidden;
      }
      .settings-nav {
        width: 200px;
        min-width: 200px;
        border-right: 1px solid var(--border-color);
        padding: 14px 10px;
        display: flex;
        flex-direction: column;
        gap: 2px;
        flex-shrink: 0;
        overflow-y: auto;
      }
      .settings-nav-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border-radius: var(--radius-sm);
        cursor: pointer;
        color: var(--text-secondary);
        font-size: 0.875rem;
        font-weight: 600;
        transition: var(--transition);
        background: 0 0;
        border: none;
        font-family: var(--font-main);
        text-align: left;
        width: 100%;
        min-height: 42px;
        user-select: none;
        position: relative;
      }
      .settings-nav-item svg {
        flex-shrink: 0;
        opacity: 0.7;
      }
      .settings-nav-item:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
      }
      .settings-nav-item:hover svg {
        opacity: 1;
      }
      .settings-nav-item.active {
        background: var(--accent-light);
        color: var(--accent-primary);
      }
      .settings-nav-item.active svg {
        opacity: 1;
      }
      .settings-nav-item.active::before {
        content: "";
        position: absolute;
        left: 0;
        top: 6px;
        bottom: 6px;
        width: 3px;
        background: var(--accent-primary);
        border-radius: 0 3px 3px 0;
        animation: navIndicator 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
      }
      @keyframes navIndicator {
        from {
          transform: scaleY(0);
          opacity: 0;
        }
        to {
          transform: scaleY(1);
          opacity: 1;
        }
      }
      .settings-content-area {
        flex: 1;
        overflow-y: auto;
        padding: 24px;
        min-height: 0;
      }
      .settings-section {
        display: none;
        flex-direction: column;
        gap: 20px;
        width: 100%;
        min-height: 0;
      }
      .settings-section.active {
        display: flex;
        animation: settingsSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
      }
      .settings-section.settings-exit {
        display: flex;
        animation: settingsSlideOut 0.18s cubic-bezier(0.4, 0, 1, 1) both;
      }
      @keyframes settingsSlideIn {
        from {
          opacity: 0;
          transform: translateX(14px);
        }
        to {
          opacity: 1;
          transform: translateX(0);
        }
      }
      @keyframes settingsSlideOut {
        from {
          opacity: 1;
          transform: translateX(0);
        }
        to {
          opacity: 0;
          transform: translateX(-10px);
        }
      }
      .settings-section-title {
        font-size: 1rem;
        font-weight: 800;
        letter-spacing: -0.01em;
        color: var(--text-primary);
        padding-bottom: 14px;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 2px;
      }
      #s-privacy .privacy-policy-card {
        font-size: 0.84rem;
        line-height: 1.55;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      #s-privacy .privacy-policy-card li,
      #s-privacy .privacy-policy-card p {
        font-size: 0.84rem;
        min-width: 0;
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      #s-privacy .privacy-policy-card ul {
        padding-left: 26px;
        margin: 8px 0 14px;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
      }
      #s-privacy .privacy-policy-card li {
        padding-left: 3px;
        margin-bottom: 6px;
      }
      #s-privacy .privacy-policy-card a,
      #s-privacy .privacy-policy-card code,
      #s-privacy .privacy-policy-card h1,
      #s-privacy .privacy-policy-card h2,
      #s-privacy .privacy-policy-card h3,
      #s-privacy .privacy-policy-card strong {
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      #s-privacy .privacy-policy-card code {
        white-space: normal;
      }
      #s-privacy .privacy-policy-card > div {
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        overflow-wrap: anywhere;
        word-break: break-word;
      }
      #s-privacy .privacy-policy-card h1 {
        font-size: 1.35rem !important;
      }
      #s-privacy .privacy-policy-card h2 {
        font-size: 1.05rem !important;
        margin-top: 18px !important;
      }
      #s-privacy .privacy-policy-card h3 {
        font-size: 0.92rem;
      }
      .settings-panel-footer {
        padding: 14px 24px;
        border-top: 1px solid var(--border-color);
        display: flex;
        justify-content: flex-end;
        gap: 12px;
        flex-shrink: 0;
      }
      .shortcuts-search-wrap {
        position: relative;
      }
      .shortcuts-search-wrap svg {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-secondary);
        pointer-events: none;
      }
      .shortcuts-search-wrap input {
        padding-left: 38px;
      }
      .shortcut-category-label {
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--text-secondary);
        padding: 14px 0 6px 0;
      }
      .shortcut-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 14px;
        border-radius: var(--radius-sm);
        border: 1px solid transparent;
        transition:
          background 0.15s ease,
          border-color 0.15s ease;
      }
      .shortcut-row:hover {
        background: var(--bg-tertiary);
        border-color: var(--border-color);
      }
      .shortcut-desc {
        font-size: 0.875rem;
        color: var(--text-primary);
        font-weight: 500;
      }
      .shortcut-keys {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
      }
      .kbd {
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-bottom-width: 2px;
        border-radius: 5px;
        padding: 3px 8px;
        font-family: var(--font-code);
        font-size: 0.72rem;
        font-weight: 700;
        color: var(--text-primary);
        min-width: 26px;
        text-align: center;
        white-space: nowrap;
      }
      .shortcut-plus {
        color: var(--text-secondary);
        font-size: 0.72rem;
        font-weight: 700;
      }
      @media (max-width: 640px) {
        .settings-panel {
          width: 100vw;
          max-width: 100vw;
          height: 100vh;
          max-height: 100vh;
          border-radius: var(--radius-lg);
        }
        .settings-nav {
          width: 52px;
          min-width: 52px;
          padding: 10px 6px;
        }
        .settings-nav-item span {
          display: none;
        }
        .settings-nav-item {
          justify-content: center;
          padding: 10px;
        }
      }
      .info-card {
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        padding: 18px;
        display: flex;
        flex-direction: column;
        gap: 10px;
      }
      .info-card h3 {
        font-size: 1.05rem;
        color: var(--text-primary);
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 8px;
      }
      .info-card p {
        font-size: 0.85rem;
        color: var(--text-secondary);
        line-height: 1.5;
      }
      .step-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 5px;
        padding-left: 10px;
      }
      .step-item {
        font-size: 0.85rem;
        color: var(--text-secondary);
        line-height: 1.5;
        display: flex;
        gap: 12px;
      }
      .step-num {
        background: var(--bg-tertiary);
        color: var(--accent-primary);
        font-weight: 700;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        font-size: 0.75rem;
      }
      .modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(10px);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
      }
      .modal-overlay.active {
        opacity: 1;
        pointer-events: all;
      }
      .modal {
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        width: 90%;
        max-width: 520px;
        box-shadow: var(--shadow-lg);
        transform: translateY(30px) scale(0.95);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        max-height: 90vh;
        display: flex;
        flex-direction: column;
      }
      .modal-overlay.active .modal {
        transform: translateY(0) scale(1);
      }
      .modal-header {
        padding: 24px;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .modal-header h2 {
        font-size: 1.35rem;
        margin: 0;
        font-weight: 800;
        letter-spacing: -0.01em;
      }
      .modal-body {
        padding: 24px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 18px;
      }
      .form-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
        position: relative;
      }
      .form-group label {
        font-size: 0.9rem;
        color: var(--text-secondary);
        font-weight: 600;
        display: flex;
        justify-content: space-between;
      }
      .form-control {
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        color: var(--text-primary);
        padding: 12px 14px;
        border-radius: var(--radius-sm);
        font-family: var(--font-main);
        font-size: 0.95rem;
        outline: 0;
        width: 100%;
        min-height: 44px;
        transition:
          border-color 0.2s ease,
          box-shadow 0.2s ease,
          transform 0.2s ease,
          background 0.2s ease;
      }
      .form-control:focus {
        border-color: var(--accent-primary);
        box-shadow: 0 0 0 3px var(--accent-light);
        transform: translateY(-1px);
        background: var(--bg-secondary);
      }
      .combobox-container {
        position: relative;
        width: 100%;
      }
      .combobox-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        max-height: 200px;
        overflow-y: auto;
        z-index: 1100;
        display: none;
        box-shadow: var(--shadow-md);
        margin-top: 6px;
      }
      .combobox-dropdown.active {
        display: block;
      }
      .combobox-item {
        padding: 12px;
        cursor: pointer;
        font-size: 0.9rem;
        color: var(--text-primary);
        transition: var(--transition);
      }
      .combobox-item.focused,
      .combobox-item:hover {
        background: var(--accent-primary);
        color: #fff;
      }
      .combobox-item.no-results {
        color: var(--text-secondary);
        cursor: default;
        background: 0 0 !important;
      }
      .slider-container {
        display: flex;
        align-items: center;
        gap: 12px;
      }
      input[type="range"] {
        flex: 1;
        accent-color: var(--accent-primary);
        min-height: 30px;
      }
      .slider-val {
        font-variant-numeric: tabular-nums;
        width: 45px;
        text-align: right;
        font-size: 0.85rem;
        font-weight: 600;
      }
      .modal-footer {
        padding: 20px 24px;
        border-top: 1px solid var(--border-color);
        display: flex;
        justify-content: flex-end;
        gap: 12px;
      }
      .rename-modal {
        width: min(92%, 460px);
        max-width: 460px;
      }
      .rename-modal .modal-header {
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 18px;
      }
      .rename-modal .modal-body {
        padding: 20px 24px 8px;
        gap: 8px;
      }
      .rename-modal .modal-footer {
        padding-top: 18px;
      }
      .rename-modal-label {
        color: var(--text-secondary);
        font-size: 0.88rem;
        line-height: 1.45;
      }
      .rename-modal-input {
        font-size: 1rem;
        font-weight: 600;
      }
      .rename-modal-error {
        min-height: 20px;
        color: var(--danger);
        font-size: 0.8rem;
        line-height: 1.4;
      }
      .rename-modal-meta {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin: -2px 0 8px;
      }
      .rename-char-count {
        color: var(--text-secondary);
        font-size: 0.78rem;
        font-variant-numeric: tabular-nums;
      }
      .rename-char-count.warning {
        color: var(--warning);
      }
      .rename-auto-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border: 1px solid var(--border-color);
        background: var(--bg-tertiary);
        color: var(--text-primary);
        border-radius: 999px;
        padding: 6px 10px;
        font-size: 0.78rem;
        font-weight: 600;
        cursor: pointer;
        transition: var(--transition);
      }
      .rename-auto-btn:hover:not(:disabled) {
        border-color: var(--accent-primary);
        color: var(--accent-primary);
      }
      .rename-auto-btn:disabled {
        opacity: 0.6;
        cursor: wait;
      }
      .rename-suggestions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin: 4px 0 12px;
      }
      .rename-suggestion-chip {
        border: 1px solid var(--border-color);
        background: var(--bg-tertiary);
        color: var(--text-secondary);
        border-radius: 999px;
        padding: 6px 10px;
        font-size: 0.8rem;
        cursor: pointer;
        transition: var(--transition);
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .rename-suggestion-chip:hover {
        border-color: var(--accent-primary);
        color: var(--text-primary);
      }
      .rename-suggestion-chip.active {
        border-color: var(--accent-primary);
        color: var(--accent-primary);
      }
      .rename-suggestions-label {
        width: 100%;
        color: var(--text-secondary);
        font-size: 0.78rem;
        margin-bottom: -2px;
      }
      #toast-container {
        position: fixed;
        bottom: 24px;
        right: 24px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        z-index: 2000;
      }
      .toast {
        background: var(--bg-secondary);
        color: var(--text-primary);
        padding: 14px 24px;
        border-radius: var(--radius-sm);
        border-left: 4px solid var(--accent-primary);
        box-shadow: var(--shadow-lg);
        display: flex;
        align-items: center;
        gap: 12px;
        animation:
          toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards,
          toastOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards 2.7s;
        opacity: 1;
        backdrop-filter: blur(8px);
        transition: transform 0.2s ease;
      }
      .toast:hover {
        transform: translateY(-3px) scale(1.01);
      }
      @keyframes toastIn {
        from {
          opacity: 0;
          transform: translateX(16px);
        }
        to {
          opacity: 1;
          transform: translateX(0);
        }
      }
      @keyframes toastOut {
        from {
          opacity: 1;
          transform: translateX(0);
        }
        to {
          opacity: 0;
          transform: translateX(10px);
        }
      }
      .toast.error {
        border-left-color: var(--danger);
      }
      .toast.success {
        border-left-color: var(--success);
      }
      @media (max-width: 1024px) {
        .canvas-column.open {
          position: absolute;
          top: 0;
          right: 0;
          width: 100%;
          height: 100%;
          z-index: 200;
          border-left: none;
        }
        .canvas-toolbar {
          width: 100%;
          justify-content: flex-start;
          overflow-x: auto;
          flex-wrap: nowrap;
          padding-bottom: 2px;
        }
        .canvas-tabs {
          width: 100%;
        }
      }
      @media (max-width: 640px) {
        .canvas-tool-btn {
          display: none;
        }
        .canvas-header {
          padding: 6px 8px;
        }
      }
      @media (max-width: 768px) {
        #sidebar {
          position: fixed;
          height: 100%;
          height: 100dvh;
          left: 0;
          transform: translateX(-100%);
          transition:
            transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
            box-shadow 0.32s ease;
        }
        #sidebar.open {
          transform: translateX(0);
          box-shadow: 16px 0 40px rgba(0, 0, 0, 0.28);
        }
        .menu-toggle {
          display: block;
        }
        .overlay-mobile {
          position: fixed;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          display: block;
          background: rgba(0, 0, 0, 0.5);
          z-index: 90;
          opacity: 0;
          visibility: hidden;
          pointer-events: none;
          transition:
            opacity 0.28s ease,
            visibility 0s linear 0.28s;
        }
        .overlay-mobile.active {
          opacity: 1;
          visibility: visible;
          pointer-events: auto;
          transition-delay: 0s;
        }
        .message {
          padding: 0 5px;
        }
        .input-box {
          padding-right: 95px;
          padding-left: 68px;
        }
      }
      .status-indicator {
        display: inline-block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background-color: var(--text-secondary);
        margin-right: 5px;
      }
      .status-indicator.connected {
        background-color: var(--success);
      }
      .status-indicator.error {
        background-color: var(--danger);
      }
      #file-previews-container {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        max-width: 850px;
        margin: 0 auto 12px auto;
        max-height: 150px;
        overflow-y: auto;
        padding: 4px;
      }
      .file-preview-pill {
        display: flex;
        align-items: center;
        gap: 8px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        padding: 8px 14px;
        border-radius: var(--radius-sm);
        font-size: 0.8rem;
        animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
        max-width: 250px;
        min-width: 0;
        min-height: 38px;
      }
      .file-preview-name {
        color: var(--text-primary);
        font-weight: 500;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
      .file-preview-size {
        color: var(--text-secondary);
        font-size: 0.7rem;
        flex-shrink: 0;
      }
      .file-preview-remove {
        background: 0 0;
        border: none;
        color: var(--danger);
        cursor: pointer;
        padding: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        transition: var(--transition);
        min-height: 30px;
        min-width: 30px;
      }
      .file-preview-remove:focus-visible,
      .file-preview-remove:hover {
        background: rgba(244, 63, 94, 0.1);
      }
      .file-preview-pill.reveal-on-hover .file-preview-remove {
        margin-left: auto;
      }
      .media-embed-container {
        position: relative;
        width: 100%;
        padding-bottom: 56.25%;
        height: 0;
        margin: 15px 0;
        border-radius: var(--radius-md);
        overflow: hidden;
        border: 1px solid var(--border-color);
      }
      .media-embed-container iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border: none;
      }
      .research-media-embed {
        position: relative;
        margin: 10px 14px 12px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        overflow: hidden;
        background: var(--bg-tertiary);
      }
      .research-media-embed .media-ratio-box {
        position: relative;
        aspect-ratio: 16/9;
        min-height: 150px;
        background: var(--bg-secondary);
        border-radius: var(--radius-sm);
        overflow: hidden;
        border: 1px solid var(--border-color);
      }
      .research-media-embed .media-ratio-box iframe,
      .research-media-embed .media-ratio-box video {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        border: 0;
        display: block;
        background: #000;
        z-index: 3;
      }
      .research-media-embed .media-ratio-box video {
        object-fit: contain;
      }
      .research-media-embed .media-ratio-box::before {
        content: "";
        position: absolute;
        inset: 0;
        background: var(--bg-secondary);
        z-index: 0;
        pointer-events: none;
      }
      .research-media-embed .media-ratio-box::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 32px;
        height: 32px;
        transform: translate(-50%, -50%);
        background: rgba(255, 255, 255, 0.12);
        mask-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27white%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpolygon points=%275 3 19 12 5 21 5 3%27%3E%3C/polygon%3E%3C/svg%3E");
        -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27white%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpolygon points=%275 3 19 12 5 21 5 3%27%3E%3C/polygon%3E%3C/svg%3E");
        mask-size: contain;
        -webkit-mask-size: contain;
        mask-repeat: no-repeat;
        -webkit-mask-repeat: no-repeat;
        mask-position: center;
        -webkit-mask-position: center;
        z-index: 0;
        pointer-events: none;
      }
      .research-media-embed .media-play-overlay {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        cursor: pointer;
        background: rgba(0, 0, 0, 0.35);
        border: none;
        padding: 0;
        z-index: 2;
        transition: background 0.2s ease;
      }
      .research-media-embed .media-play-overlay:hover {
        background: rgba(0, 0, 0, 0.55);
      }
      .research-media-embed .media-play-overlay::after {
        content: "Click to play";
        font-size: 0.72rem;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.9);
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
        pointer-events: none;
      }
      .research-media-embed.is-failed .media-play-overlay,
      .research-media-embed.is-loading .media-play-overlay,
      .research-media-embed.is-playing .media-play-overlay {
        display: none;
      }
      .research-media-embed .media-play-btn {
        width: 62px;
        height: 44px;
        background: rgba(0, 0, 0, 0.72);
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition:
          transform 0.18s ease,
          background 0.18s ease;
        backdrop-filter: blur(2px);
      }
      .research-media-embed .media-play-overlay:hover .media-play-btn {
        transform: scale(1.1);
        background: rgba(0, 0, 0, 0.88);
      }
      .research-media-embed .media-play-btn svg {
        color: #fff;
      }
      .research-media-embed .media-thumb {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        background: var(--bg-secondary);
        z-index: 1;
      }
      .research-media-embed .media-thumb.broken,
      .research-media-embed .media-thumb[hidden] {
        display: none;
      }
      .research-media-embed .media-thumb::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0, rgba(255, 255, 255, 0) 100%);
        pointer-events: none;
      }
      .research-media-embed.is-failed .media-thumb,
      .research-media-embed.is-loading .media-thumb,
      .research-media-embed.is-playing .media-thumb {
        display: none;
      }
      .research-media-gallery {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 12px;
        margin: 14px 0;
      }
      .research-media-gallery .research-image-card,
      .research-media-gallery .research-media-embed {
        margin: 0;
      }
      .research-image-card {
        position: relative;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        overflow: hidden;
        background: var(--bg-tertiary);
        min-height: 150px;
        display: flex;
        flex-direction: column;
      }
      .research-image-card .image-link {
        display: block;
        position: relative;
        aspect-ratio: 16/9;
        overflow: hidden;
        flex: 1;
      }
      .research-image-card img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        background: var(--bg-secondary);
        transition: transform 0.25s ease;
      }
      .research-image-card:hover img {
        transform: scale(1.03);
      }
      .research-image-card .image-caption {
        padding: 8px 10px;
        font-size: 0.75rem;
        color: var(--text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        border-top: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
      }
      .research-image-card .image-caption a {
        color: var(--accent-primary);
        text-decoration: none;
        flex-shrink: 0;
      }
      .research-image-card .image-caption a:hover {
        text-decoration: underline;
      }
      .research-image-card .image-fallback {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text-secondary);
        font-size: 0.8rem;
        text-align: center;
        padding: 12px;
      }
      .research-media-embed .media-embed-fallback {
        padding: 10px 12px;
        font-size: 0.78rem;
        color: var(--text-secondary);
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        border-top: 1px solid var(--border-color);
      }
      .research-media-embed .media-embed-fallback a {
        color: var(--accent-primary);
        text-decoration: none;
        flex-shrink: 0;
      }
      .research-media-embed .media-embed-fallback a:hover {
        text-decoration: underline;
      }
      .canvas-preview-status {
        position: absolute;
        z-index: 2;
        left: 12px;
        right: 12px;
        bottom: 12px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 8px 10px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        background: rgba(18, 22, 31, 0.9);
        color: var(--text-secondary);
        font-size: 0.72rem;
        opacity: 0;
        transform: translateY(5px);
        pointer-events: none;
        transition:
          opacity 0.18s ease,
          transform 0.18s ease;
      }
      .canvas-preview-status.visible {
        opacity: 1;
        transform: translateY(0);
      }
      .canvas-preview-status.error {
        color: #fecdd3;
        border-color: rgba(244, 63, 94, 0.35);
      }
      .canvas-preview-status button {
        border: 0;
        border-radius: 5px;
        padding: 4px 8px;
        background: var(--accent-primary);
        color: #fff;
        cursor: pointer;
        font: inherit;
        font-weight: 600;
      }
      #chat-area,
      .chat-list,
      .modal-body,
      .settings-content-area,
      .settings-nav {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
      }
      body {
        overscroll-behavior: none;
      }
      @media (max-width: 768px) {
        #message-input,
        .form-control,
        .input-base,
        input[type="number"],
        input[type="text"],
        select,
        textarea {
          font-size: 16px !important;
        }
      }
      @media (hover: none) and (pointer: coarse) {
        .chat-item {
          transition:
            transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
            background-color 0.22s ease,
            color 0.22s ease,
            border-color 0.22s ease;
          -webkit-tap-highlight-color: transparent;
        }
        .chat-item-actions {
          transition:
            opacity 0.2s ease,
            visibility 0s linear 0s;
        }
        .chat-item-actions .btn-icon {
          transition:
            transform 0.18s cubic-bezier(0.16, 1, 0.3, 1),
            background-color 0.18s ease,
            color 0.18s ease,
            box-shadow 0.18s ease;
          -webkit-tap-highlight-color: transparent;
        }
        #scroll-bottom-btn:hover,
        .action-btn:hover,
        .branch-btn:hover,
        .btn-icon:hover,
        .btn:hover,
        .canvas-pilot-top-btn:hover,
        .canvas-tab:hover,
        .chat-item:hover,
        .choice-card:hover,
        .mic-btn:hover,
        .research-source-card:hover,
        .send-btn:hover,
        .settings-nav-item:hover,
        .stop-btn:hover,
        .zip-tree-item:hover {
          transform: none !important;
          box-shadow: none !important;
          background: unset;
        }
        .send-btn:hover {
          background: var(--text-primary) !important;
          color: var(--bg-primary) !important;
        }
        .mic-btn:hover {
          background: var(--bg-tertiary) !important;
          color: var(--text-secondary) !important;
        }
        .btn:active {
          background: var(--bg-glass) !important;
          transform: scale(0.97) !important;
        }
        .btn-primary:active {
          background: var(--accent-hover) !important;
          transform: scale(0.97) !important;
        }
        .btn-icon:active {
          background: var(--bg-tertiary) !important;
          color: var(--text-primary) !important;
          transform: scale(0.92) !important;
        }
        .chat-item:active {
          background: var(--bg-tertiary) !important;
          transform: scale(0.985) !important;
        }
        .chat-item-actions .btn-icon:active {
          transform: scale(0.92) !important;
        }
        .choice-card:active {
          border-color: var(--accent-primary) !important;
          transform: scale(0.98) !important;
        }
        .action-btn:active {
          background: var(--bg-tertiary) !important;
          color: var(--text-primary) !important;
        }
        .settings-nav-item:active {
          background: var(--accent-light) !important;
          color: var(--accent-primary) !important;
        }
        .canvas-tab:active {
          background: var(--bg-tertiary) !important;
        }
        .send-btn:not(:disabled):active {
          background: var(--accent-primary) !important;
          color: #fff !important;
          transform: scale(0.95) !important;
        }
        .mic-btn:active {
          background: rgba(255, 255, 255, 0.12) !important;
          transform: scale(0.93) !important;
        }
        .stop-btn:active {
          background: var(--danger) !important;
          color: #fff !important;
        }
        .branch-btn:active {
          color: var(--accent-hover) !important;
        }
        [data-tooltip]::after,
        [data-tooltip]::before {
          display: none !important;
        }
        .message-actions {
          opacity: 1 !important;
          flex-wrap: wrap;
        }
        .chat-item-actions {
          display: flex !important;
          visibility: visible !important;
          opacity: 1 !important;
          pointer-events: auto !important;
        }
        .code-header button:active {
          background: rgba(255, 255, 255, 0.12) !important;
          transform: scale(0.95) !important;
        }
        .file-preview-remove {
          opacity: 1 !important;
          min-width: 36px !important;
          min-height: 36px !important;
        }
        .canvas-pilot-top-btn:active {
          background: var(--bg-tertiary) !important;
          color: var(--text-primary) !important;
        }
        #scroll-bottom-btn:active {
          transform: scale(0.93) !important;
        }
        .zip-tree-item:active {
          background: var(--bg-tertiary) !important;
        }
        .research-source-card:active {
          background: rgba(255, 255, 255, 0.04) !important;
        }
      }
      @supports (padding: env(safe-area-inset-bottom)) {
        .input-container {
          padding-bottom: max(20px, env(safe-area-inset-bottom));
        }
        .sidebar-footer {
          padding-bottom: max(15px, env(safe-area-inset-bottom));
        }
        .top-bar {
          padding-top: max(0px, env(safe-area-inset-top));
          padding-left: max(20px, env(safe-area-inset-left));
          padding-right: max(20px, env(safe-area-inset-right));
        }
        .settings-panel-footer {
          padding-bottom: max(14px, env(safe-area-inset-bottom));
        }
      }
      @media (hover: none) and (pointer: coarse) {
        .settings-nav-item[data-tab="s-shortcuts"] {
          display: none !important;
        }
        #s-shortcuts {
          display: none !important;
        }
        #voice-accent-group {
          display: none !important;
        }
      }
      @media (max-width: 768px) {
        .settings-nav-item[data-tab="s-shortcuts"] {
          display: none !important;
        }
        #s-shortcuts {
          display: none !important;
        }
        #voice-accent-group {
          display: none !important;
        }
      }
      @media (max-width: 768px) {
        .action-btn {
          min-height: 44px;
          padding: 10px 14px;
          font-size: 0.82rem;
        }
        .chat-item {
          height: 52px;
          min-height: 52px;
          max-height: 52px;
          padding: 10px 16px;
        }
        .sidebar-footer .btn-icon {
          min-width: 50px;
          min-height: 50px;
        }
        .top-bar .btn-icon {
          min-width: 48px;
          min-height: 48px;
        }
        .mic-btn,
        .send-btn,
        .stop-btn {
          width: 44px;
          height: 44px;
        }
        .branch-btn {
          min-width: 36px;
          min-height: 36px;
          padding: 6px 10px;
        }
        .top-bar {
          height: 56px;
          padding: 0 12px;
          gap: 8px;
        }
        .top-bar-left {
          gap: 10px;
        }
        .top-bar-right {
          gap: 8px;
        }
        #canvas-pilot-toggle span {
          display: none;
        }
        #canvas-pilot-toggle {
          padding: 10px;
        }
        #connection-status {
          display: none;
        }
        .input-container {
          position: sticky;
          bottom: 0;
          z-index: 10;
          padding: 12px 12px 16px;
          background: linear-gradient(to top, var(--bg-primary) 85%, transparent);
        }
        .input-box {
          --btn-size: 42px;
          padding: 8px 8px 8px 10px;
          gap: 6px;
        }
        #message-input {
          font-size: 16px;
          max-height: 140px;
          min-height: 42px;
          padding: 9px 4px;
        }
        .input-actions {
          gap: 4px;
        }
        #scroll-bottom-btn {
          bottom: 100px;
          right: 16px;
          width: 40px;
          height: 40px;
        }
        .message-wrapper {
          padding: 16px 12px;
        }
        .message-actions {
          gap: 6px;
          margin-top: 10px;
        }
        .action-btn {
          padding: 8px 10px;
          gap: 4px;
        }
        .code-block {
          max-width: 100%;
          border-radius: var(--radius-sm);
        }
        .code-block pre {
          overflow-x: auto;
          -webkit-overflow-scrolling: touch;
          padding: 14px;
        }
        .code-block code {
          font-size: 0.8rem;
          line-height: 1.55;
        }
        .code-header {
          padding: 8px 12px;
          font-size: 0.78rem;
          flex-wrap: wrap;
          gap: 6px;
        }
        .code-header button {
          min-height: 36px;
          min-width: 64px;
          padding: 6px 10px;
          font-size: 0.75rem;
        }
        #file-previews-container {
          display: flex;
          flex-direction: row;
          flex-wrap: nowrap;
          overflow-x: auto;
          -webkit-overflow-scrolling: touch;
          gap: 8px;
          padding: 0 4px 8px;
          scrollbar-width: none;
        }
        #file-previews-container::-webkit-scrollbar {
          display: none;
        }
        .file-preview-pill {
          flex: 0 0 auto;
          max-width: 220px;
        }
        #model-select-wrapper {
          flex: 1;
          min-width: 0;
          overflow: hidden;
        }
        .model-picker {
          max-width: 100%;
          overflow-x: auto;
          scrollbar-width: none;
        }
        .model-picker::-webkit-scrollbar {
          display: none;
        }
        .char-counter {
          font-size: 0.7rem;
          flex-shrink: 0;
        }
        .branch-navigator {
          overflow-x: auto;
          -webkit-overflow-scrolling: touch;
          max-width: 100%;
        }
        .analytics-chart-container {
          height: 200px;
        }
        .research-sources-grid {
          grid-template-columns: 1fr !important;
        }
        .settings-panel {
          width: 100vw !important;
          max-width: 100vw !important;
          height: 100dvh !important;
          max-height: 100dvh !important;
          border-radius: var(--radius-lg) !important;
        }
        .settings-nav {
          width: 56px;
          min-width: 56px;
          padding: 10px 6px;
        }
        .settings-nav-item {
          justify-content: center;
          padding: 12px;
          min-height: 52px;
        }
        .settings-nav-item span {
          display: none;
        }
        .current-chat-title {
          max-width: 140px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        #model-mode-select {
          min-height: 38px !important;
          font-size: 14px !important;
          padding: 6px 14px !important;
        }
        .file-preview-pill {
          max-width: 100%;
          flex: 1 1 auto;
        }
        .choice-card {
          min-height: 80px;
          padding: 16px;
        }
      }
      @media (max-width: 480px) {
        .empty-state h1 {
          font-size: 1.8rem;
        }
        .empty-state p {
          font-size: 0.9rem;
        }
        .choice-container {
          grid-template-columns: 1fr !important;
          gap: 8px;
        }
        .choice-card {
          min-height: 70px;
          padding: 14px 12px;
        }
        .top-bar {
          height: 52px;
          padding: 0 10px;
        }
        .current-chat-title {
          max-width: 90px;
        }
        #quick-theme-btn {
          min-width: 40px !important;
          min-height: 40px !important;
        }
        .input-container {
          padding: 10px 10px 14px;
        }
        .input-box {
          --btn-size: 40px;
          padding: 8px 8px 8px 10px;
          gap: 6px;
        }
        .send-btn,
        .stop-btn,
        .mic-btn {
          width: 40px;
          height: 40px;
        }
        .message-wrapper {
          padding: 14px 10px;
        }
        .message-content {
          font-size: 0.95rem;
          line-height: 1.6;
        }
        .action-btn {
          min-height: 40px;
          padding: 7px 9px;
          font-size: 0.78rem;
        }
        .code-block code {
          font-size: 0.75rem;
        }
        .code-header {
          padding: 6px 10px;
        }
        .input-container > div:first-of-type {
          flex-wrap: wrap;
          gap: 4px;
        }
        .char-counter {
          font-size: 0.68rem;
        }
        .modal {
          border-radius: var(--radius-lg) !important;
          max-width: 100vw !important;
        }
        #scroll-bottom-btn {
          bottom: 88px;
          right: 12px;
          width: 38px;
          height: 38px;
        }
      }
      @media (max-width: 768px) {
        #swipe-edge-hint {
          position: fixed;
          left: 0;
          top: 50%;
          transform: translateY(-50%);
          width: 4px;
          height: 60px;
          background: var(--accent-primary);
          border-radius: 0 4px 4px 0;
          opacity: 0;
          z-index: 50;
          transition: opacity 0.3s ease;
          pointer-events: none;
        }
        #swipe-edge-hint.visible {
          opacity: 0.4;
        }
      }
      .research-panel {
        margin-top: 14px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        overflow: hidden;
        font-family: inherit;
      }
      .research-panel-header {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 10px 14px;
        font-size: 0.8rem;
        font-weight: 700;
        color: var(--accent-primary);
        border-bottom: 1px solid var(--border-color);
        background: rgba(59, 130, 246, 0.05);
      }
      .research-timestamp {
        margin-left: auto;
        font-size: 0.7rem;
        font-weight: 400;
        color: var(--text-muted);
      }
      .research-intent {
        padding: 8px 14px;
        font-size: 0.79rem;
        color: var(--text-secondary);
        font-style: italic;
        border-bottom: 1px solid var(--border-color);
        background: rgba(255, 255, 255, 0.015);
      }
      .research-queries-label,
      .research-sources-label {
        padding: 8px 14px 4px;
        font-size: 0.68rem;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.06em;
      }
      .research-queries {
        padding: 2px 14px 10px;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
      }
      .research-query-badge {
        background: rgba(59, 130, 246, 0.1);
        border: 1px solid rgba(59, 130, 246, 0.22);
        color: var(--accent-primary);
        font-size: 0.72rem;
        padding: 3px 9px;
        border-radius: 20px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .research-sources {
        display: flex;
        flex-direction: column;
        border-top: 1px solid var(--border-color);
      }
      .research-source-card {
        display: flex;
        gap: 10px;
        padding: 10px 14px;
        text-decoration: none;
        transition: background 0.15s;
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
      }
      .research-source-card:last-child {
        border-bottom: none;
      }
      .research-source-card:hover {
        background: rgba(255, 255, 255, 0.03);
      }
      .research-source-num {
        flex-shrink: 0;
        width: 20px;
        height: 20px;
        background: rgba(59, 130, 246, 0.15);
        border-radius: 50%;
        font-size: 0.65rem;
        font-weight: 700;
        color: var(--accent-primary);
        display: flex;
        align-items: center;
        justify-content: center;
        margin-top: 3px;
      }
      .research-source-body {
        flex: 1;
        min-width: 0;
      }
      .research-source-title {
        font-size: 0.83rem;
        font-weight: 600;
        color: var(--text-primary);
        margin-bottom: 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .research-source-snippet {
        font-size: 0.76rem;
        color: var(--text-secondary);
        line-height: 1.45;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        margin-bottom: 6px;
      }
      .research-source-meta {
        display: flex;
        align-items: center;
        gap: 8px;
      }
      .research-source-origin {
        font-size: 0.68rem;
        color: var(--text-muted);
        white-space: nowrap;
      }
      .research-confidence {
        flex: 1;
        height: 3px;
        background: rgba(255, 255, 255, 0.08);
        border-radius: 2px;
        overflow: hidden;
        max-width: 60px;
      }
      .research-confidence-bar {
        height: 100%;
        background: linear-gradient(90deg, var(--accent-primary), var(--success));
        border-radius: 2px;
        transition: width 0.6s ease;
      }
      .research-confidence-label {
        font-size: 0.66rem;
        color: var(--text-muted);
        min-width: 28px;
        text-align: right;
      }
      .research-no-sources {
        padding: 12px 14px;
        font-size: 0.78rem;
        color: var(--text-muted);
        font-style: italic;
      }
      .research-actions {
        display: flex;
        gap: 6px;
        padding: 10px 14px;
        flex-wrap: wrap;
        border-top: 1px solid var(--border-color);
        background: rgba(255, 255, 255, 0.01);
      }
      .research-action-btn {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 4px 10px;
        font-size: 0.7rem;
        min-height: 26px;
        background: rgba(59, 130, 246, 0.1);
        border-color: rgba(59, 130, 246, 0.25);
        color: var(--accent-primary);
        border-radius: var(--radius-sm);
      }
      .research-action-scholar {
        background: rgba(16, 185, 129, 0.1) !important;
        border-color: rgba(16, 185, 129, 0.25) !important;
        color: var(--success) !important;
      }
      .research-action-wiki {
        background: rgba(245, 158, 11, 0.1) !important;
        border-color: rgba(245, 158, 11, 0.25) !important;
        color: var(--warning) !important;
      }

      .media-lazy-card {
        position: relative;
        border-radius: var(--radius-sm);
        overflow: hidden;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        margin: 10px 0;
      }
      .media-lazy-card .media-ratio-box {
        position: relative;
        padding-bottom: 56.25%;
        height: 0;
        background: var(--bg-secondary);
      }
      .media-lazy-card .media-ratio-box iframe,
      .media-lazy-card .media-ratio-box img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border: none;
        object-fit: cover;
      }
      .media-lazy-card .media-card-label {
        padding: 6px 10px;
        font-size: 0.7rem;
        color: var(--text-muted);
        border-top: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        gap: 5px;
      }
      .media-lazy-card .media-card-skeleton {
        position: absolute;
        inset: 0;
        background: linear-gradient(
          90deg,
          var(--bg-tertiary) 25%,
          rgba(255, 255, 255, 0.04) 50%,
          var(--bg-tertiary) 75%
        );
        background-size: 200% 100%;
        animation: skeletonSweep 1.4s infinite;
      }
      @keyframes skeletonSweep {
        0% {
          background-position: 200% 0;
        }
        100% {
          background-position: -200% 0;
        }
      }
      .skip-nav {
        position: absolute;
        top: -100%;
        left: 0;
        background: var(--accent-primary);
        color: #fff;
        padding: 12px 20px;
        font-weight: 700;
        font-size: 0.9rem;
        z-index: 9999;
        border-radius: 0 0 var(--radius-sm) 0;
        text-decoration: none;
        transition: top 0.15s ease;
      }
      .skip-nav:focus {
        top: 0;
      }
      [role="button"]:focus-visible,
      a:focus-visible,
      button:focus-visible {
        outline: 2px solid var(--accent-primary) !important;
        outline-offset: 2px !important;
        box-shadow: 0 0 0 4px var(--accent-light) !important;
        border-radius: var(--radius-sm) !important;
      }
      input:focus-visible,
      select:focus-visible,
      textarea:focus-visible {
        outline: 0 !important;
      }
      :focus:not(:focus-visible) {
        outline: 0 !important;
      }
      @media (prefers-reduced-motion: reduce) {
        *,
        ::after,
        ::before {
          animation-duration: 0s !important;
          animation-iteration-count: 1 !important;
          transition-duration: 0s !important;
          scroll-behavior: auto !important;
        }
      }
      @media (forced-colors: active) {
        .btn,
        .choice-card,
        .code-block,
        .modal,
        .settings-panel,
        .toast {
          border: 2px solid ButtonText !important;
        }
        .btn-primary,
        .choice-card.active {
          background: Highlight !important;
          color: HighlightText !important;
        }
        :focus-visible {
          outline: 3px solid ButtonText !important;
        }
      }
      .speech-visualizer {
        display: none;
        align-items: center;
        gap: 3px;
        height: 20px;
        margin-left: 8px;
      }
      .speech-visualizer.active {
        display: flex;
      }
      .speech-bar {
        width: 3px;
        border-radius: 2px;
        background: var(--accent-primary);
        animation: speechPulse 0.8s ease-in-out infinite;
      }
      .speech-bar:first-child {
        height: 6px;
        animation-delay: 0s;
      }
      .speech-bar:nth-child(2) {
        height: 12px;
        animation-delay: 0.1s;
      }
      .speech-bar:nth-child(3) {
        height: 18px;
        animation-delay: 0.2s;
      }
      .speech-bar:nth-child(4) {
        height: 10px;
        animation-delay: 0.3s;
      }
      .speech-bar:nth-child(5) {
        height: 14px;
        animation-delay: 0.15s;
      }
      @keyframes speechPulse {
        0%,
        100% {
          transform: scaleY(0.35);
          opacity: 0.5;
        }
        50% {
          transform: scaleY(1);
          opacity: 1;
        }
      }
      @media (prefers-reduced-motion: reduce) {
        .speech-bar {
          animation: none !important;
          height: 10px !important;
        }
      }
      /* Screen-reader-only element (aria-announcer) — must stay hidden. */
      .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
      }
      /* Floating "speaking now" badge — fixed so it never affects the layout. */
      .speaker-badge {
        position: fixed;
        top: 16px;
        left: 50%;
        transform: translateX(-50%);
        display: none;
        align-items: center;
        gap: 6px;
        padding: 8px 14px;
        border-radius: var(--radius-md);
        background: var(--bg-glass);
        color: var(--text-primary);
        font-size: 0.85rem;
        font-weight: 600;
        box-shadow: var(--shadow-md);
        backdrop-filter: blur(8px);
        z-index: 2001;
        pointer-events: none;
        max-width: 90vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .speaker-badge.visible {
        display: flex;
      }
      .stt-visualizer {
        display: none;
        flex: 0 0 auto;
        flex-direction: row;
        align-items: flex-end;
        align-self: center;
        gap: 2px;
        width: 18px;
        min-width: 18px;
        max-width: 18px;
        height: 22px;
        margin-left: 2px;
        overflow: hidden;
        pointer-events: none;
      }
      .stt-visualizer.active {
        display: flex;
      }
      .stt-bar {
        width: 3px;
        border-radius: 2px;
        background: var(--danger);
        animation: sttPulse 0.55s ease-in-out infinite alternate;
      }
      .stt-bar:first-child {
        height: 8px;
        animation-delay: 0s;
      }
      .stt-bar:nth-child(2) {
        height: 14px;
        animation-delay: 0.1s;
      }
      .stt-bar:nth-child(3) {
        height: 10px;
        animation-delay: 0.2s;
      }
      .stt-bar:nth-child(4) {
        height: 18px;
        animation-delay: 50ms;
      }
      @keyframes sttPulse {
        from {
          transform: scaleY(0.3);
        }
        to {
          transform: scaleY(1);
        }
      }
      @media (prefers-reduced-motion: reduce) {
        .stt-bar {
          animation: none !important;
        }
      }
      .action-btn,
      .branch-btn,
      .canvas-tab,
      .chat-item,
      .choice-card,
      .file-preview-remove,
      .mic-btn,
      .send-btn,
      .settings-nav-item,
      .stop-btn,
      [role="button"],
      a,
      button,
      label,
      select {
        touch-action: manipulation;
      }
      button,
      img,
      svg {
        -webkit-touch-callout: none;
      }
      .prose {
        word-break: break-word;
        overflow-wrap: break-word;
      }
      .prose code,
      .prose pre {
        white-space: pre;
        overflow-x: auto;
      }
      @media (max-width: 768px) {
        .canvas-column:not(.open) {
          display: none !important;
        }
      }
      @media (max-width: 480px) {
        #toast-container {
          left: 10px !important;
          right: 10px !important;
          bottom: 80px !important;
          align-items: stretch;
        }
        .toast {
          width: 100% !important;
          max-width: none !important;
        }
      }
      @media (max-width: 480px) {
        .status-text { font-size: 0.78rem; min-width: 0; max-width: 78vw; }
      }
      :focus-visible {
        outline: 2px solid var(--accent-primary);
        outline-offset: 2px;
      }
      [role="button"],
      [tabindex]:not([tabindex="-1"]),
      a,
      button,
      input,
      select,
      textarea {
        transition:
          outline-offset 0.15s ease,
          box-shadow 0.15s ease,
          transform 0.15s ease,
          background-color 0.15s ease,
          color 0.15s ease;
      }
      .action-btn:focus-visible,
      .branch-btn:focus-visible,
      .btn-icon:focus-visible,
      .btn:focus-visible,
      .chat-item-actions button:focus-visible,
      .file-preview-remove:focus-visible,
      .mic-btn:focus-visible,
      .send-btn:focus-visible,
      .stop-btn:focus-visible {
        outline: 2px solid var(--accent-primary);
        outline-offset: 2px;
        box-shadow: 0 0 0 4px rgba(76, 177, 190, 0.15);
      }
      .action-btn:active,
      .branch-btn:active,
      .chat-item-actions button:active,
      .file-preview-remove:active {
        transform: scale(0.96);
      }
      .btn-icon:active,
      .btn:active,
      .mic-btn:active,
      .send-btn:not(:disabled):active,
      .stop-btn:active {
        transform: scale(0.96);
      }
      :focus:not(:focus-visible) {
        outline: 0;
      }
      @media (hover: none) and (pointer: coarse) {
        .chat-item,
        .chat-item-actions,
        .chat-item-actions .btn-icon {
          transition-duration: 0.2s;
        }
        .message-wrapper .message-actions {
          opacity: 1 !important;
          transform: none !important;
        }
        .chat-item-actions {
          display: flex !important;
          visibility: visible !important;
          opacity: 1 !important;
          pointer-events: auto !important;
        }
        [data-tooltip]::after,
        [data-tooltip]::before {
          display: none !important;
        }
        :focus-visible {
          outline: 2px solid var(--accent-primary) !important;
        }
      }
      @media (max-width: 768px) {
        .message-wrapper .message-actions {
          opacity: 1 !important;
          transform: none !important;
        }
      }
      @media (max-width: 768px) {
        #sidebar {
          will-change: transform;
          -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
        }
        .overlay-mobile {
          -webkit-tap-highlight-color: transparent;
        }
        #scroll-bottom-btn:focus,
        #scroll-bottom-btn:focus-visible,
        #scroll-bottom-btn:hover {
          background: var(--accent-primary) !important;
          color: #fff !important;
          box-shadow: var(--shadow-lg) !important;
          transform: translateY(0) !important;
        }
        #s-privacy,
        #s-privacy .privacy-policy-card,
        .settings-content-area,
        .settings-section {
          min-width: 0;
          max-width: 100%;
        }
        #s-privacy .privacy-policy-card {
          padding: 14px 12px;
          font-size: 0.82rem;
          line-height: 1.5;
        }
        #s-privacy .privacy-policy-card li,
        #s-privacy .privacy-policy-card p {
          font-size: 0.82rem;
        }
        #s-privacy .privacy-policy-card ul {
          padding-left: 20px;
        }
        #s-privacy .privacy-policy-card h1 {
          font-size: 1.18rem !important;
          line-height: 1.25;
        }
        #s-privacy .privacy-policy-card h2 {
          font-size: 0.98rem !important;
          line-height: 1.35;
          padding-left: 8px !important;
        }
        .modal-overlay {
          align-items: flex-end;
          padding: 12px;
          transition: opacity 0.24s ease-out;
        }
        .modal-overlay .modal,
        .modal-overlay.active .modal {
          width: 100%;
          max-width: none;
          transform: translateY(0) scale(1);
          transition:
            transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
            opacity 0.22s ease-out;
        }
        .modal-overlay:not(.active) .modal {
          transform: translateY(28px) scale(0.98);
          opacity: 0;
        }
        .rename-modal {
          width: 100%;
          max-width: 460px;
          margin: 0 auto;
          border-radius: var(--radius-lg);
          padding-bottom: env(safe-area-inset-bottom);
        }
        .rename-modal .modal-header {
          padding: 20px 18px 16px;
        }
        .rename-modal .modal-body {
          padding: 18px 18px 4px;
        }
        .rename-modal .modal-footer {
          padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
        }
        .action-btn,
        .branch-btn,
        .btn,
        .btn-icon,
        .canvas-tab,
        .chat-item,
        .chat-item-actions .btn-icon,
        .choice-card,
        .mic-btn,
        .send-btn,
        .settings-nav-item,
        .stop-btn {
          transition:
            transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
            background-color 0.2s ease,
            border-color 0.2s ease,
            color 0.2s ease,
            box-shadow 0.2s ease,
            opacity 0.2s ease !important;
          -webkit-tap-highlight-color: transparent;
        }
        .action-btn:active,
        .branch-btn:active,
        .btn-icon:active,
        .btn:active,
        .canvas-tab:active,
        .chat-item:active,
        .choice-card:active,
        .mic-btn:active,
        .send-btn:not(:disabled):active,
        .settings-nav-item:active,
        .stop-btn:active {
          transition-duration: 0.12s !important;
        }
        .chat-item-actions .btn-icon:active,
        .rename-modal .btn-icon:active,
        .rename-modal .btn:active {
          transform: scale(0.94) !important;
        }
      }
      @media (max-width: 768px) {
        #sidebar {
          position: fixed !important;
          left: 0 !important;
          width: var(--sidebar-width) !important;
          max-width: 88vw;
          transform: translate3d(-100%, 0, 0) !important;
          opacity: 1 !important;
          transition: transform 360ms cubic-bezier(0.16, 1, 0.3, 1) !important;
          will-change: transform;
        }
        #sidebar.open {
          transform: translate3d(0, 0, 0) !important;
        }
        #sidebar.collapsed {
          width: var(--sidebar-width) !important;
          transform: translate3d(-100%, 0, 0) !important;
          opacity: 1 !important;
        }
        .overlay-mobile {
          display: block !important;
          opacity: 0;
          visibility: hidden;
          pointer-events: none;
          transition:
            opacity 280ms ease,
            visibility 0s linear 280ms !important;
        }
        .overlay-mobile.active {
          opacity: 1;
          visibility: visible;
          pointer-events: auto;
          transition-delay: 0s !important;
        }
      }
      html.zorax-twa,
      html.zorax-twa body {
        width: 100%;
        height: var(--zorax-app-height, 100dvh);
        min-height: var(--zorax-app-height, 100dvh);
        overscroll-behavior: none;
        -webkit-text-size-adjust: 100%;
      }
      html.zorax-twa #app,
      html.zorax-twa #main-content,
      html.zorax-twa #sidebar,
      html.zorax-twa .canvas-column {
        height: var(--zorax-app-height, 100dvh);
        min-height: 0;
      }
      html.zorax-twa #main-content {
        overflow: hidden;
      }
      html.zorax-twa #chat-area,
      html.zorax-twa .canvas-document-pane,
      html.zorax-twa .chat-list,
      html.zorax-twa .settings-content-area {
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
      }
      html.zorax-twa .input-container {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
      }
      html.zorax-twa .top-bar {
        padding-top: max(0px, env(safe-area-inset-top));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
      }
      @media (max-width: 768px) {
        html.zorax-twa #message-input,
        html.zorax-twa #search-input,
        html.zorax-twa .form-control {
          font-size: 16px !important;
        }
        html.zorax-twa .input-container {
          padding-left: max(10px, env(safe-area-inset-left));
          padding-right: max(10px, env(safe-area-inset-right));
        }
      }
      @media (max-width: 560px) {
        .model-pill span {
          display: none;
        }
        .model-pill {
          padding: 7px 10px;
        }
      }
      body.is-tablet #canvas-tab-handle,
      body.is-phone #canvas-tab-handle,
      body.is-touch.is-coarse #canvas-tab-handle {
        display: none !important;
      }
      body.is-tablet #canvas-open-top-btn,
      body.is-phone #canvas-open-top-btn,
      body.is-touch.is-coarse #canvas-open-top-btn {
        display: flex !important;
      }
      body.is-tablet #voice-accent-group,
      body.is-phone #voice-accent-group {
        display: none !important;
      }
      body.is-tablet .settings-nav-item[data-tab="s-shortcuts"],
      body.is-phone .settings-nav-item[data-tab="s-shortcuts"],
      body.is-tablet #s-shortcuts,
      body.is-phone #s-shortcuts {
        display: none !important;
      }
      [data-tooltip]::after,
      [data-tooltip]::before {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
      }
      #zorax-tooltip-layer {
        font-family: var(--font-main, system-ui, sans-serif);
        line-height: 1.35;
      }
      .thinking-toggle {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        cursor: pointer;
        user-select: none;
        font-size: 0.78rem;
        font-weight: 600;
        color: var(--text-secondary);
        padding: 4px 6px 4px 8px;
        border-radius: 999px;
        margin-left: auto;
        transition: color .2s, background .2s;
      }
      .top-bar-row:has(.thinking-toggle) { gap: 10px; }
      .thinking-toggle:hover { color: var(--text-primary); background: var(--bg-tertiary); }
      .thinking-toggle input {
        position: absolute;
        opacity: 0;
        width: 1px;
        height: 1px;
        margin: 0;
        padding: 0;
        pointer-events: none;
      }
      .thinking-toggle-track {
        width: 34px; height: 20px; border-radius: 999px;
        background: var(--bg-tertiary);
        border: 1px solid var(--border-color);
        position: relative; flex: 0 0 auto;
        transition: background .2s, border-color .2s;
        cursor: pointer;
      }
      .thinking-toggle-thumb {
        position: absolute; top: 2px; left: 2px;
        width: 14px; height: 14px; border-radius: 50%;
        background: var(--text-secondary);
        transition: transform .2s ease, background .2s ease;
      }
.thinking-toggle.is-on .thinking-toggle-track,
      .thinking-toggle input:checked ~ .thinking-toggle-track {
        background: rgba(23,240,241,.22);
        border-color: var(--accent-primary);
      }
      .thinking-toggle.is-on .thinking-toggle-thumb,
      .thinking-toggle input:checked ~ .thinking-toggle-track .thinking-toggle-thumb {
        transform: translateX(14px);
        background: var(--accent-primary);
      }
      .thinking-toggle-icon { color: var(--accent-primary); opacity: .55; }
      .thinking-toggle input:checked ~ .thinking-toggle-icon { opacity: 1; }
      /* ---------- Reasoning ("thinking") box ---------- */
      .thinking-block {
        --think-bg: rgba(23, 240, 241, 0.035);
        --think-border: rgba(23, 240, 241, 0.14);
        --think-label: rgba(125, 232, 236, 0.92);
        --think-shine: #ffffff;
        --think-muted: rgba(148, 163, 184, 0.75);
        --think-text: rgba(203, 213, 225, 0.8);
        --think-accent: var(--accent-primary);
        margin: 0 0 14px;
        border: 1px solid var(--think-border);
        border-radius: 14px;
        background: var(--think-bg);
        overflow: hidden;
        animation: thinkIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
        transition: border-color 0.3s ease, background-color 0.3s ease;
      }
      body.light-theme .thinking-block {
        --think-bg: rgba(8, 145, 178, 0.05);
        --think-border: rgba(8, 145, 178, 0.2);
        --think-label: #0e7490;
        --think-shine: #67e8f9;
        --think-muted: #64748b;
        --think-text: #475569;
        --think-accent: #0891b2;
      }
      @keyframes thinkIn {
        from { opacity: 0; transform: translateY(4px); }
        to { opacity: 1; transform: none; }
      }
      .thinking-head {
        all: unset;
        box-sizing: border-box;
        width: 100%;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 14px;
        cursor: pointer;
        font-family: var(--font-main);
        font-size: 0.82rem;
        font-weight: 600;
        color: var(--think-label);
        user-select: none;
        -webkit-tap-highlight-color: transparent;
      }
      .thinking-head:hover .think-chevron { color: var(--think-label); }
      .thinking-head:focus-visible { outline: 2px solid var(--think-accent); outline-offset: -2px; border-radius: 14px; }
      .think-icon {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        border-radius: 50%;
        position: relative;
      }
      /* finished: small lightbulb-style dot */
      .think-icon::before {
        content: "";
        position: absolute;
        inset: 3px;
        border-radius: 50%;
        background: var(--think-accent);
        opacity: 0.7;
        transition: opacity 0.3s ease;
      }
      /* live: smooth spinning ring */
      .thinking-block.live .think-icon {
        border: 2px solid color-mix(in srgb, var(--think-accent) 22%, transparent);
        border-top-color: var(--think-accent);
        animation: thinkSpin 0.9s linear infinite;
      }
      .thinking-block.live .think-icon::before { opacity: 0; }
      @keyframes thinkSpin { to { transform: rotate(360deg); } }
      .think-label { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
      /* label + count share a shrinking group so a long "Reasoned for ..." can't push the chevron off-screen */
      .think-label-group { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; overflow: hidden; white-space: nowrap; }
      .think-count { white-space: nowrap; flex-shrink: 0; }
      .thinking-block.live .think-label {
        background: linear-gradient(90deg, var(--think-label) 0%, var(--think-label) 35%, var(--think-shine) 50%, var(--think-label) 65%, var(--think-label) 100%);
        background-size: 250% 100%;
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        animation: thinkShimmer 2s linear infinite;
      }
      @keyframes thinkShimmer {
        from { background-position: 100% 0; }
        to { background-position: -150% 0; }
      }
      .think-count {
        color: var(--think-muted);
        font-weight: 500;
        font-size: 0.76rem;
        font-variant-numeric: tabular-nums;
      }
      .think-chevron {
        width: 16px;
        height: 16px;
        margin-left: auto;
        flex-shrink: 0;
        color: var(--think-muted);
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s ease;
      }
      .thinking-block.open .think-chevron { transform: rotate(180deg); }
      /* smooth open/close: animate the row height from 0 to its content */
      .thinking-body {
        display: grid;
        grid-template-rows: 0fr;
        transition: grid-template-rows 0.4s cubic-bezier(0.16, 1, 0.3, 1);
      }
      .thinking-block.open .thinking-body { grid-template-rows: 1fr; }
      .thinking-clip { min-height: 0; overflow: hidden; }
      .thinking-scroll {
        max-height: 260px;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 0 14px 12px;
        border-top: 1px solid var(--think-border);
        scrollbar-width: thin;
        scrollbar-color: var(--think-border) transparent;
        -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 100%);
        mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 100%);
      }
      .thinking-scroll::-webkit-scrollbar { width: 4px; }
      .thinking-scroll::-webkit-scrollbar-track { background: transparent; }
      .thinking-scroll::-webkit-scrollbar-thumb { background: var(--think-border); border-radius: 4px; }
      .thinking-scroll-inner {
        padding-top: 12px;
        font-size: 0.84rem;
        line-height: 1.6;
        color: var(--think-text);
        overflow-wrap: anywhere;
      }
      .thinking-scroll-inner p { margin: 0 0 0.55em; }
      .thinking-scroll-inner p:last-child { margin-bottom: 0; }
      .think-para + .think-para { margin-top: 0.55em; }
      /* blinking caret after the newest reasoning text while it is being written */
      .thinking-block.live .think-para:last-child .prose > :is(p, h1, h2, h3, h4, blockquote):last-child::after,
      .thinking-block.live .think-para:last-child .prose > :is(ul, ol):last-child > li:last-child::after {
        content: "";
        display: inline-block;
        width: 2px;
        height: 1em;
        margin-left: 3px;
        vertical-align: -0.15em;
        border-radius: 1px;
        background: var(--think-accent);
        animation: thinkCaret 1s steps(2, start) infinite;
      }
      @keyframes thinkCaret { to { visibility: hidden; } }
      .thinking-scroll-inner ul, .thinking-scroll-inner ol { margin: 0.2em 0 0.55em; padding-left: 1.2em; }
      .thinking-scroll-inner code { font-size: 0.8em; }
      .thinking-scroll-inner a { color: var(--think-label); }
      @media (max-width: 768px) {
        .thinking-scroll { max-height: 200px; }
        .thinking-head { padding: 10px 12px; }
      }
      @media (prefers-reduced-motion: reduce) {
        .thinking-block, .thinking-body, .think-chevron { animation: none; transition: none; }
        .thinking-block.live .think-icon { animation-duration: 2.5s; }
        .thinking-block.live .think-label { animation: none; -webkit-text-fill-color: currentColor; background: none; }
      }
      .canvas-empty-placeholder {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        color: var(--text-secondary);
        text-align: center;
        padding: 24px;
        pointer-events: none;
      }
      .canvas-empty-placeholder svg { opacity: .5; }
      .canvas-empy-placeholder .ph-title { font-weight: 700; color: var(--text-primary); }
      .canvas-empty-placeholder .ph-sub { font-size: .85rem; max-width: 320px; line-height: 1.5; }
      .chat-item-menu-btn { opacity: 0; transition: opacity .15s; color: var(--text-secondary); padding: 4px; border-radius: 6px; }
      .chat-item:hover .chat-item-menu-btn, .chat-item.active .chat-item-menu-btn, .chat-item:focus-within .chat-item-menu-btn { opacity: .7; }
      .chat-item-menu-btn:hover { opacity: 1 !important; background: var(--bg-tertiary); color: var(--text-primary); }
      /* Touch devices have no persistent hover, so the 3-dots button would
         stay invisible forever on a non-active chat — making Delete and Rename
         unreachable. Always show it (at low opacity so it doesn't clutter),
         and reveal fully while the user is actively pressing the row. */
      @media (hover: none) {
        .chat-item-menu-btn { opacity: 0.4; }
        .chat-item.active .chat-item-menu-btn,
        .chat-item:focus-within .chat-item-menu-btn,
        .chat-item:active .chat-item-menu-btn { opacity: 1; }
      }
      .chat-item-menu {
        position: fixed;
        min-width: 180px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        box-shadow: 0 16px 40px rgba(0,0,0,.55);
        padding: 6px;
        z-index: 99999;
        display: none;
        flex-direction: column;
        gap: 2px;
      }
      .chat-item-menu.open { display: flex; animation: menuIn .14s ease; }
      @keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
      .chat-menu-item {
        display: flex; align-items: center; gap: 10px;
        width: 100%;
        padding: 8px 10px;
        background: transparent;
        border: none;
        border-radius: 6px;
        color: var(--text-primary);
        font-size: .86rem;
        text-align: left;
        cursor: pointer;
      }
      .chat-menu-item:hover { background: var(--bg-tertiary); }
      .chat-menu-item.danger { color: var(--danger); }
      .chat-menu-item.danger:hover { background: rgba(239,68,68,.12); }
      .chat-menu-divider { height: 1px; background: var(--border-color); margin: 4px 2px; }
      .top-controls { margin-bottom: 0 !important; padding-bottom: 0 !important; }
      .composer-wrap, .input-container { padding-top: 6px !important; }
      .settings-panel textarea { resize: none; }
      .settings-section .form-group textarea { min-height: 80px; height: 80px; }
      #global-chat-menu {
        position: fixed !important;
        z-index: 2147483000 !important;
      }
.chat-item {
  flex-wrap: nowrap;
  overflow: hidden;
}
.chat-item .chat-item-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}
.chat-item-menu-btn.btn-icon {
  flex: 0 0 auto;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 4px;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-item-menu-btn svg {
  display: block;
  width: 16px;
  height: 16px;
}
.chat-menu-item svg {
  flex: 0 0 auto;
}
.choice-card[data-mode="research"] .choice-card-title svg {
  color: var(--accent-primary);
}
.research-panel-header {
  gap: 8px;
}
.research-panel-header::before {
  content: "Deep Research";
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(23,240,241,0.12);
  color: var(--accent-primary);
  border: 1px solid rgba(23,240,241,0.25);
}

      /* ---------- First-visit tip: Power User Playbook ---------- */
      .playbook-tip {
        position: fixed;
        top: 76px;
        right: 20px;
        z-index: 1200;
        width: min(360px, calc(100vw - 32px));
        display: flex;
        gap: 12px;
        padding: 16px 40px 16px 16px;
        border-radius: 16px;
        background: var(--bg-secondary, #0f1117);
        border: 1px solid rgba(23, 240, 241, 0.3);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(23, 240, 241, 0.06);
        color: var(--text-primary);
        font-family: var(--font-main);
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
        transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        pointer-events: none;
      }
      .playbook-tip.show { opacity: 1; transform: none; pointer-events: auto; }
      body.light-theme .playbook-tip {
        background: #ffffff;
        border-color: rgba(8, 145, 178, 0.3);
        box-shadow: 0 18px 50px rgba(15, 23, 42, 0.15);
      }
      .playbook-tip-icon {
        flex-shrink: 0;
        width: 38px;
        height: 38px;
        border-radius: 11px;
        display: grid;
        place-items: center;
        color: var(--accent-primary);
        background: rgba(23, 240, 241, 0.1);
      }
      body.light-theme .playbook-tip-icon { color: #0891b2; background: rgba(8, 145, 178, 0.1); }
      .playbook-tip-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
      .playbook-tip p { margin: 0 0 12px; font-size: 0.85rem; line-height: 1.5; color: var(--text-secondary); }
      .playbook-tip p strong { color: var(--text-primary); }
      .playbook-tip-actions { display: flex; gap: 8px; flex-wrap: nowrap; align-items: center; }
      .playbook-tip-actions > * { width: auto; margin: 0; white-space: nowrap; flex: 0 0 auto; }
      .playbook-tip-open {
        display: inline-flex;
        align-items: center;
        padding: 8px 14px;
        border-radius: 10px;
        background: var(--accent-primary);
        color: #041014;
        font-weight: 700;
        font-size: 0.82rem;
        text-decoration: none;
        transition: transform 0.15s ease, filter 0.15s ease;
      }
      .playbook-tip-open:hover { transform: translateY(-1px); filter: brightness(1.05); }
      .playbook-tip-later {
        padding: 8px 12px;
        border-radius: 10px;
        border: 1px solid var(--border-color);
        background: transparent;
        color: var(--text-secondary);
        font-size: 0.82rem;
        font-weight: 600;
        cursor: pointer;
      }
      .playbook-tip-later:hover { color: var(--text-primary); }
      .playbook-tip-close {
        position: absolute;
        top: 10px;
        right: 10px;
        width: 26px;
        height: 26px;
        display: grid;
        place-items: center;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: var(--text-secondary);
        cursor: pointer;
      }
      .playbook-tip-close:hover { background: rgba(127, 127, 127, 0.12); color: var(--text-primary); }
      @media (max-width: 768px) {
        .playbook-tip { top: 68px; right: 16px; left: 16px; width: auto; }
      }
      @media (prefers-reduced-motion: reduce) { .playbook-tip { transition: none; } }
      /* ---------- First-visit tip: Join the Discord ---------- */
      .discord-tip {
        position: fixed;
        top: 64px;
        left: 50%;
        transform: translate(-50%, -120%);
        z-index: 1200;
        display: flex;
        align-items: center;
        gap: 14px;
        width: min(720px, calc(100vw - 32px));
        padding: 12px 14px 12px 16px;
        border-radius: 14px;
        background: linear-gradient(135deg, #5865F2 0%, #4752C4 100%);
        color: #ffffff;
        font-family: var(--font-main);
        box-shadow: 0 14px 38px rgba(88, 101, 242, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
        opacity: 0;
        transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        pointer-events: none;
      }
      .discord-tip.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
      .discord-tip-icon {
        flex-shrink: 0;
        width: 36px;
        height: 36px;
        border-radius: 10px;
        display: grid;
        place-items: center;
        background: rgba(255, 255, 255, 0.18);
      }
      .discord-tip-text { flex: 1 1 auto; min-width: 0; }
      .discord-tip-title { font-weight: 700; font-size: 0.95rem; line-height: 1.25; margin-bottom: 2px; }
      .discord-tip-brand { color: #ffffff; text-decoration: none; font-weight: 800; }
      .discord-tip-brand:hover { text-decoration: underline; }
      .discord-tip p { margin: 0; font-size: 0.82rem; line-height: 1.4; opacity: 0.92; }
      .discord-tip-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
      .discord-tip-actions > * { width: auto; margin: 0; white-space: nowrap; flex: 0 0 auto; }
      .discord-tip-join {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 14px;
        border-radius: 999px;
        background: #ffffff;
        color: #5865F2;
        font-weight: 700;
        font-size: 0.85rem;
        text-decoration: none;
        transition: transform 0.15s ease, background-color 0.15s ease;
      }
      .discord-tip-join:hover { background: #f0f1ff; transform: translateY(-1px); }
      .discord-tip-later {
        padding: 8px 10px;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: rgba(255, 255, 255, 0.85);
        font-size: 0.82rem;
        font-weight: 500;
        cursor: pointer;
      }
      .discord-tip-later:hover { color: #ffffff; background: rgba(255, 255, 255, 0.12); }
      .discord-tip-close {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 24px;
        height: 24px;
        display: grid;
        place-items: center;
        border: 0;
        border-radius: 7px;
        background: transparent;
        color: rgba(255, 255, 255, 0.75);
        cursor: pointer;
      }
      .discord-tip-close:hover { background: rgba(255, 255, 255, 0.18); color: #ffffff; }
      @media (max-width: 640px) {
        .discord-tip { top: 60px; flex-wrap: wrap; padding: 10px 12px; gap: 8px 10px; }
        .discord-tip-icon { width: 32px; height: 32px; }
        .discord-tip-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 0; }
        .discord-tip-title { font-size: 0.88rem; white-space: normal; }
        .discord-tip p { font-size: 0.78rem; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
        .discord-tip-actions { width: 100%; justify-content: flex-end; padding-right: 24px; }
        .discord-tip-join { padding: 6px 12px; font-size: 0.78rem; }
        .discord-tip-later { padding: 6px 8px; font-size: 0.78rem; }
      }
      @media (prefers-reduced-motion: reduce) { .discord-tip { transition: opacity 0.2s ease; transform: translate(-50%, 0); } }
