      :root {
        --bg: #0f172a;
        --sidebar: #111827;
        --panel: #1e293b;
        --panel-soft: #334155;
        --border: #334155;
        --text: #f8fafc;
        --muted: #a5f3fc;
        --primary: #22d3ee;
        --primary-strong: #06b6d4;
        --bubble-ai: #1e293b;
        --bubble-user: #0891b2;
        --danger: #ff6f7d;
      }

      * {
        box-sizing: border-box;
      }

      body {
        margin: 0;
        height: 100vh;
        font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        color: var(--text);
        background: var(--bg);
        overflow: hidden;
      }

      body.light-mode {
        --bg: #f3fbfd;
        --sidebar: #e5f7fb;
        --panel: #ffffff;
        --panel-soft: #e6f7fb;
        --border: #bfe8f0;
        --text: #0f172a;
        --muted: #0e7490;
        --primary: #0891b2;
        --primary-strong: #0e7490;
        --bubble-ai: #ecfeff;
        --bubble-user: #0891b2;
        --danger: #d44758;
      }

      body.light-mode {
        background-image: none;
      }

      .app {
        height: 100vh;
        display: grid;
        grid-template-columns: 280px minmax(0, 1fr);
      }

      .sidebar {
        background: var(--sidebar);
        border-right: 1px solid var(--border);
        padding: 14px 12px;
        display: grid;
        grid-template-rows: auto auto auto minmax(0, 1fr);
        gap: 12px;
        min-height: 0;
        overflow: hidden;
      }

      .chat-shell {
        min-height: 0;
        padding: 10px 18px 14px;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        gap: 8px;
        overflow: hidden;
        width: 100%;
        max-width: 980px;
        justify-self: center;
      }

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

      .logo {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        display: block;
        object-fit: cover;
      }

      .brand strong {
        letter-spacing: 0.01em;
      }

      #current-chat-label {
        color: var(--muted);
        font-size: 0.82rem;
      }

      .cta {
        display: grid;
        gap: 10px;
      }

      .cta-role-row {
        display: block;
      }

      .theme-row {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
      }

      .theme-toggle {
        flex: 1;
        text-align: left;
      }

      .language-toggle {
        min-width: 92px;
      }

      .logout-sidebar-button {
        width: 100%;
      }

      .button {
        appearance: none;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 9px 11px;
        font-weight: 600;
        font-size: 0.88rem;
        cursor: pointer;
        transition: background 0.2s ease, border-color 0.2s ease;
      }

      .button.primary {
        background: var(--primary);
        border-color: transparent;
        color: #f7f9ff;
      }

      .button.secondary {
        background: transparent;
        color: var(--text);
      }

      .button:hover {
        border-color: var(--primary-strong);
        background: var(--panel-soft);
      }

      .button.primary:hover {
        background: var(--primary-strong);
        border-color: transparent;
      }

      .button.primary.cancel-mode {
        background: var(--danger);
      }

      .button.primary.cancel-mode:hover {
        background: var(--danger);
        opacity: 0.85;
      }

      .saved-chats {
        border: 1px solid var(--border);
        border-radius: 10px;
        background: var(--panel);
        padding: 8px;
        display: grid;
        gap: 8px;
        align-content: start;
        min-height: 0;
        overflow: hidden;
      }

      .saved-chats h3 {
        margin: 0;
        font-size: 0.82rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--muted);
      }

      .saved-chats-list {
        display: grid;
        gap: 8px;
        align-content: start;
        overflow-y: auto;
      }

      .saved-chat-item {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        align-items: start;
      }

      .saved-chat-open,
      .saved-chat-delete,
      .saved-chat-rename {
        border: 1px solid var(--border);
        background: var(--panel-soft);
        color: var(--text);
        border-radius: 8px;
        cursor: pointer;
      }

      .saved-chat-actions {
        display: grid;
        grid-template-columns: auto auto;
        gap: 6px;
      }

      .saved-chat-open {
        text-align: left;
        padding: 8px;
        display: grid;
        gap: 2px;
        min-width: 0;
      }

      .saved-chat-open.active {
        border-color: #22d3ee;
        background: #0e7490;
      }

      body.light-mode .saved-chat-open.active {
        border-color: #0891b2;
        background: #cffafe;
        color: #0f172a;
      }

      .saved-chat-name {
        font-size: 0.84rem;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .saved-chat-role {
        font-size: 0.68rem;
        color: var(--muted);
        opacity: 0.85;
      }

      .saved-chat-time {
        font-size: 0.72rem;
        color: var(--muted);
      }

      .saved-chat-delete,
      .saved-chat-rename {
        width: 30px;
        height: 30px;
        padding: 0;
        font-size: 0.95rem;
      }

      .saved-chat-empty {
        margin: 0;
        font-size: 0.82rem;
        color: var(--muted);
      }

      .chat-header {
        border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
        border-radius: 14px;
        background:
          radial-gradient(circle at 8% -30%, color-mix(in srgb, var(--primary) 25%, transparent), transparent 46%),
          color-mix(in srgb, var(--panel) 86%, transparent);
        padding: 10px 12px;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        align-items: center;
        box-shadow: 0 10px 26px color-mix(in srgb, var(--bg) 74%, transparent);
      }

      .chat-header-meta {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        min-width: 0;
      }

      .chat-header-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: flex-end;
      }

      .header-chip {
        display: inline-flex;
        align-items: center;
        min-height: 28px;
        padding: 5px 10px;
        border-radius: 999px;
        border: 1px solid color-mix(in srgb, var(--border) 74%, transparent);
        background: color-mix(in srgb, var(--panel-soft) 62%, transparent);
        font-size: 0.74rem;
        letter-spacing: 0.01em;
        color: var(--text);
        white-space: nowrap;
      }

      .header-chip-role {
        border-color: color-mix(in srgb, #22d3ee 60%, transparent);
      }

      .header-chip-user {
        border-color: color-mix(in srgb, #14b8a6 58%, transparent);
      }

      .header-chip-token,
      .header-chip-duration,
      .header-chip-words,
      .header-chip-neuro {
        font-variant-numeric: tabular-nums;
      }

      .header-chip-neuro {
        border-color: color-mix(in srgb, #f59e0b 62%, transparent);
        background: color-mix(in srgb, #78350f 28%, var(--panel-soft));
      }

      .chat-copy-button {
        padding: 6px 9px;
        font-size: 0.76rem;
      }

      .roles-select {
        width: 100%;
        min-width: 0;
        max-width: none;
        background: var(--panel-soft);
        color: var(--text);
        text-align: center;
        text-align-last: center;
      }

      .chat-title {
        font-size: 0.86rem;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: 0.08em;
      }

      .chat-main {
        border: 0;
        border-radius: 0;
        background: transparent;
        display: grid;
        grid-template-rows: minmax(0, 1fr) auto auto;
        gap: 10px;
        padding: 0;
        min-height: 0;
      }

      .chat-main.chat-empty .messages-wrap {
        display: none;
      }

      .chat-main.chat-empty {
        display: flex;
        flex-direction: column;
        justify-content: center;
      }

      .chat-main.chat-empty .input-row {
        margin-top: auto;
        margin-bottom: auto;
      }

      .chat-main.chat-empty .input-row textarea {
        min-height: calc(var(--input-font-size) * var(--input-line-height) * 5);
        max-height: calc(var(--input-font-size) * var(--input-line-height) * 5);
      }

      .chat-main.chat-empty .chat-footer {
        margin-top: 0;
      }

      .messages-wrap {
        display: block;
        min-height: 0;
      }

      .messages {
        display: grid;
        gap: 14px;
        align-content: start;
        height: 100%;
        min-height: 0;
        overflow-y: scroll;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
        scrollbar-width: thin;
        scrollbar-color: #0891b2 transparent;
        padding: 0 2px;
        scroll-behavior: smooth;
      }

      .messages-scrollbar {
        display: none;
      }

      .messages-scroll-thumb {
        width: 100%;
        height: 32px;
        border-radius: 999px;
        background: #0891b2;
        transition: transform 0.12s linear, opacity 0.2s ease;
        opacity: 0.95;
      }

      .messages::-webkit-scrollbar {
        width: 10px;
      }

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

      .messages::-webkit-scrollbar-thumb {
        background: #0891b2;
        border-radius: 999px;
        border: 2px solid transparent;
        background-clip: padding-box;
      }

      .messages::-webkit-scrollbar-thumb:hover {
        background: #06b6d4;
        background-clip: padding-box;
      }

      body.light-mode .messages {
        scrollbar-color: #0e7490 transparent;
      }

      body.light-mode .messages::-webkit-scrollbar-thumb {
        background: #0e7490;
        background-clip: padding-box;
      }

      body.light-mode .messages::-webkit-scrollbar-thumb:hover {
        background: #0891b2;
        background-clip: padding-box;
      }

      body.light-mode .messages-scrollbar {
        background: rgba(14, 116, 144, 0.25);
      }

      body.light-mode .messages-scroll-thumb {
        background: #0e7490;
      }

      .bubble {
        max-width: 100%;
        padding: 12px 14px;
        border-radius: 12px;
        font-size: 0.92rem;
        line-height: 1.4;
        white-space: pre-wrap;
        word-break: normal;
        overflow-wrap: break-word;
      }

      .bubble-content {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: break-word;
        word-break: normal;
      }

      .bubble-content > * {
        max-width: 100%;
      }

      .bubble-copy-button {
        justify-self: start;
        border: 1px solid #06b6d4;
        background: rgba(8, 145, 178, 0.25);
        color: #d7e4ff;
        border-radius: 7px;
        font-size: 0.75rem;
        line-height: 1;
        padding: 5px 8px;
        cursor: pointer;
      }

      .bubble-copy-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
      }

      .bubble-copy-button:hover {
        background: rgba(8, 145, 178, 0.4);
      }

      body.light-mode .bubble-copy-button {
        border-color: #67e8f9;
        background: #ecfeff;
        color: #0f172a;
      }

      .bubble-copy-button + .bubble-feedback-button {
        margin-left: 6px;
      }

      .bubble-feedback-button {
        border: 1px solid transparent;
        background: none;
        font-size: 1.1rem;
        line-height: 1;
        padding: 3px 6px;
        cursor: pointer;
        border-radius: 6px;
        opacity: 0.5;
        transition: opacity 0.15s, background 0.15s;
      }

      .bubble-feedback-button:hover {
        opacity: 1;
        background: rgba(8, 145, 178, 0.2);
      }

      .bubble-feedback-button.active {
        opacity: 1;
        font-size: 1.3rem;
        border-color: #06b6d4;
        background: rgba(8, 145, 178, 0.35);
        box-shadow: 0 0 6px rgba(6, 182, 212, 0.4);
      }

      body.light-mode .bubble-feedback-button:hover {
        background: rgba(14, 116, 144, 0.12);
      }

      body.light-mode .bubble-feedback-button.active {
        border-color: #0891b2;
        background: rgba(14, 116, 144, 0.22);
        box-shadow: 0 0 6px rgba(14, 116, 144, 0.3);
      }

      .bubble-feedback-comment {
        display: flex;
        align-items: center;
        gap: 4px;
        margin-top: 4px;
      }

      .bubble-feedback-comment input {
        flex: 1;
        border: 1px solid #334155;
        background: rgba(15, 23, 42, 0.5);
        color: #ecf2ff;
        border-radius: 6px;
        padding: 4px 8px;
        font-size: 0.78rem;
      }

      body.light-mode .bubble-feedback-comment input {
        border-color: #cbd5e1;
        background: #f1f5f9;
        color: #0f172a;
      }

      .bubble-feedback-comment button {
        border: 1px solid #06b6d4;
        background: rgba(8, 145, 178, 0.25);
        color: #d7e4ff;
        border-radius: 6px;
        font-size: 0.72rem;
        padding: 4px 8px;
        cursor: pointer;
      }

      .bubble-feedback-comment button:hover {
        background: rgba(8, 145, 178, 0.4);
      }

      body.light-mode .bubble-feedback-comment button {
        border-color: #67e8f9;
        background: #ecfeff;
        color: #0f172a;
      }

      .bubble-feedback-saved-comment {
        font-size: 0.75rem;
        color: #94a3b8;
        font-style: italic;
        margin-top: 2px;
      }

      body.light-mode .bubble-feedback-saved-comment {
        color: #64748b;
      }

      .bubble p,
      .bubble ul,
      .bubble ol,
      .bubble pre,
      .bubble blockquote,
      .bubble h1,
      .bubble h2,
      .bubble h3,
      .bubble h4 {
        margin: 0.5em 0;
      }

      .bubble p:first-child,
      .bubble ul:first-child,
      .bubble ol:first-child,
      .bubble pre:first-child,
      .bubble blockquote:first-child,
      .bubble h1:first-child,
      .bubble h2:first-child,
      .bubble h3:first-child,
      .bubble h4:first-child {
        margin-top: 0;
      }

      .bubble p:last-child,
      .bubble ul:last-child,
      .bubble ol:last-child,
      .bubble pre:last-child,
      .bubble blockquote:last-child,
      .bubble h1:last-child,
      .bubble h2:last-child,
      .bubble h3:last-child,
      .bubble h4:last-child {
        margin-bottom: 0;
      }

      .bubble pre {
        max-width: 100%;
        overflow-x: auto;
        padding: 10px 12px;
        border-radius: 10px;
        background: rgba(11, 15, 23, 0.45);
      }

      .bubble code {
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
          "Courier New", monospace;
      }

      .bubble :not(pre) > code {
        padding: 2px 6px;
        border-radius: 6px;
        background: rgba(11, 15, 23, 0.4);
      }

      .bubble a {
        color: #67e8f9;
        text-decoration: underline;
      }

      body.light-mode .bubble a {
        color: #0891b2;
      }

      .bubble.user {
        justify-self: end;
        max-width: min(82%, 760px);
        min-width: 40%;
        background: var(--bubble-user);
        color: #ffffff;
      }

      .bubble.ai {
        display: grid;
        gap: 8px;
        background: var(--bubble-ai);
        border: 1px solid #334155;
        color: #ecf2ff;
      }

      body.light-mode .bubble.ai {
        border-color: #bae6fd;
        color: #0f172a;
      }

      .bubble-metrics {
        display: inline-block;
        font-size: 0.72rem;
        line-height: 1.3;
        color: #cbd5e1;
        border: 1px solid rgba(148, 163, 184, 0.35);
        border-radius: 999px;
        padding: 4px 10px;
        width: fit-content;
        background: rgba(15, 23, 42, 0.32);
      }

      body.light-mode .bubble-metrics {
        color: #334155;
        border-color: rgba(51, 65, 85, 0.2);
        background: rgba(226, 232, 240, 0.62);
      }

      .bubble.error {
        background: rgba(127, 35, 53, 0.42);
        border: 1px solid rgba(255, 111, 125, 0.55);
        color: #ffd7dc;
      }

      .bubble.canceled {
        opacity: 0.7;
        border-style: dashed;
      }

      .bubble-canceled-label {
        display: inline-block;
        font-size: 0.72rem;
        line-height: 1.3;
        color: #fbbf24;
        border: 1px solid rgba(251, 191, 36, 0.4);
        border-radius: 999px;
        padding: 4px 10px;
        width: fit-content;
      }

      body.light-mode .bubble-canceled-label {
        color: #92400e;
        border-color: rgba(146, 64, 14, 0.35);
      }

      .bubble-delete-button {
        border: 1px solid #ef4444;
        background: rgba(239, 68, 68, 0.15);
        color: #fca5a5;
        border-radius: 7px;
        font-size: 0.75rem;
        line-height: 1;
        padding: 5px 8px;
        cursor: pointer;
        margin-left: auto;
      }

      .bubble-delete-button:hover {
        background: rgba(239, 68, 68, 0.35);
      }

      body.light-mode .bubble-delete-button {
        border-color: #dc2626;
        background: #fef2f2;
        color: #991b1b;
      }

      body.light-mode .bubble-delete-button:hover {
        background: #fee2e2;
      }

      .input-row {
        --input-font-size: 1.08rem;
        --input-line-height: 1.35;
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        align-items: flex-end;
        justify-content: flex-start;
        padding: 10px 12px;
        border-radius: 20px;
        background: #0f172a;
        border: 1px solid var(--border);
        width: 100%;
        max-width: 860px;
        justify-self: center;
      }

      body.light-mode .input-row {
        background: #ffffff;
      }

      .input-row textarea {
        flex: 1;
        width: 100%;
        min-width: 0;
        border: none;
        font-size: var(--input-font-size);
        font-family: inherit;
        text-align: left;
        line-height: var(--input-line-height);
        resize: none;
        overflow-y: hidden;
        min-height: 2.2em;
        max-height: 8.5em;
        background: transparent;
        color: var(--text);
      }

      .input-row textarea::placeholder {
        color: #9ca3af;
      }

      body.light-mode .input-row textarea::placeholder {
        color: #64748b;
      }

      .input-row textarea:focus {
        outline: none;
      }

      .input-row .button {
        padding: 8px 12px;
        font-size: 0.9rem;
        border-radius: 999px;
      }

      .chat-start-hint {
        flex-basis: 100%;
        font-size: 0.82rem;
        line-height: 1.25;
        color: #fbbf24;
        margin-top: -4px;
        margin-left: 24px;
      }

      body.light-mode .chat-start-hint {
        color: #b45309;
      }

      .input-row span {
        font-size: 0.9rem;
        color: var(--muted);
      }

      .dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--primary);
        align-self: flex-start;
        margin-top: calc((var(--input-font-size) * var(--input-line-height) - 8px) / 2);
        animation: pulse 1.6s ease-in-out infinite;
      }

      .status {
        min-height: 1.2em;
        font-size: 0.85rem;
        color: var(--muted);
        flex: 1;
        min-width: 220px;
      }

      .chat-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        flex-wrap: wrap;
      }

      .chat-status-inline {
        display: grid;
        align-content: start;
        gap: 4px;
        min-width: 260px;
      }

      .chat-version {
        display: inline-block;
        font-size: 0.72rem;
        line-height: 1.25;
        color: var(--muted);
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
          "Courier New", monospace;
      }

      .chat-powered {
        font-size: 0.72rem;
        line-height: 1.25;
        color: var(--muted);
      }

      .chat-powered a {
        color: var(--primary);
        text-decoration: none;
      }

      .chat-powered a:hover {
        text-decoration: underline;
      }

      .chat-metrics {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 7px;
        flex-wrap: wrap;
      }

      .chat-loaded-summary {
        display: inline-block;
        border-radius: 999px;
        border: 1px solid color-mix(in srgb, var(--border) 74%, transparent);
        background: color-mix(in srgb, var(--panel-soft) 62%, transparent);
        color: var(--text);
        font-size: 0.72rem;
        line-height: 1.3;
        padding: 4px 10px;
        font-variant-numeric: tabular-nums;
      }

      .waiting-overlay {
        position: fixed;
        inset: 0;
        z-index: 999;
        display: grid;
        place-items: center;
        background: color-mix(in srgb, var(--bg) 68%, transparent);
        backdrop-filter: blur(2px);
      }

      .waiting-overlay[hidden] {
        display: none !important;
      }

      .waiting-dialog {
        width: min(460px, calc(100vw - 28px));
        display: grid;
        gap: 12px;
        padding: 16px;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: var(--panel);
      }

      .waiting-wheel {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        border: 3px solid var(--border);
        border-top-color: var(--primary);
        justify-self: center;
        animation: waiting-spin 0.9s linear infinite;
      }

      .waiting-label {
        font-size: 0.9rem;
        color: var(--muted);
        text-align: center;
      }

      .waiting-progress {
        position: relative;
        width: 100%;
        height: 9px;
        border-radius: 999px;
        overflow: hidden;
        border: 1px solid var(--border);
        background: rgba(15, 24, 43, 0.5);
      }

      body.light-mode .waiting-progress {
        background: #e2f7fb;
      }

      .waiting-progress-bar {
        width: 45%;
        height: 100%;
        border-radius: 999px;
        background: linear-gradient(90deg, #06b6d4 0%, #22d3ee 50%, #0891b2 100%);
        background-size: 200% 100%;
        animation: waiting-slide 1.2s ease-in-out infinite, waiting-shimmer 1.6s linear infinite;
      }

      .waiting-cancel-button {
        justify-self: center;
        padding: 7px 10px;
        font-size: 0.82rem;
      }

      .role-change-overlay {
        position: fixed;
        inset: 0;
        z-index: 1000;
        display: grid;
        place-items: center;
        background: color-mix(in srgb, var(--bg) 68%, transparent);
        backdrop-filter: blur(2px);
      }

      .role-change-overlay[hidden] {
        display: none !important;
      }

      .role-change-dialog {
        width: min(520px, calc(100vw - 28px));
        display: grid;
        gap: 10px;
        padding: 16px;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: var(--panel);
      }

      .role-change-title {
        font-size: 0.95rem;
      }

      .role-change-message {
        margin: 0;
        color: var(--muted);
        font-size: 0.88rem;
        line-height: 1.4;
      }

      .role-change-existing {
        display: grid;
        gap: 4px;
      }

      .role-change-existing[hidden] {
        display: none !important;
      }

      .role-change-existing-label {
        font-size: 0.82rem;
        color: var(--muted);
      }

      .role-change-chat-list {
        list-style: none;
        margin: 0;
        padding: 0;
        max-height: 160px;
        overflow-y: auto;
        display: grid;
        gap: 2px;
      }

      .role-change-chat-list button {
        width: 100%;
        text-align: left;
        padding: 6px 10px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--bg);
        color: var(--fg);
        font-size: 0.85rem;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
      }

      .role-change-chat-list button:hover {
        background: var(--border);
      }

      .role-change-chat-list .chat-time {
        font-size: 0.75rem;
        color: var(--muted);
        white-space: nowrap;
      }

      .role-change-actions {
        display: flex;
        gap: 8px;
        justify-content: flex-end;
        flex-wrap: wrap;
      }

      .copy-toast {
        position: fixed;
        left: 50%;
        bottom: 22px;
        transform: translate(-50%, 10px);
        opacity: 0;
        pointer-events: none;
        background: rgba(11, 15, 23, 0.9);
        color: #f1f5ff;
        border: 1px solid #06b6d4;
        border-radius: 8px;
        padding: 7px 12px;
        font-size: 0.82rem;
        transition: opacity 0.22s ease, transform 0.22s ease;
        z-index: 999;
      }

      .copy-toast.visible {
        opacity: 1;
        transform: translate(-50%, 0);
      }

      body.light-mode .copy-toast {
        background: rgba(255, 255, 255, 0.95);
        color: #0f172a;
        border-color: #67e8f9;
      }

      @media (max-width: 700px) {
        .app {
          grid-template-columns: 1fr;
        }

        .chat-shell {
          max-width: none;
          padding: 8px 10px 10px;
          gap: 6px;
        }

        .roles-select {
          min-width: 170px;
          max-width: none;
        }

        .input-row textarea {
          flex: 1;
          width: 100%;
        }

        .sidebar {
          min-height: auto;
          border-right: 0;
          border-bottom: 1px solid var(--border);
        }

        .bubble {
          max-width: 100%;
        }

        .chat-copy-button {
          font-size: 0.74rem;
        }

        .chat-header {
          grid-template-columns: 1fr;
          gap: 8px;
        }

        .chat-header-actions {
          justify-content: flex-start;
        }

        .header-chip {
          font-size: 0.7rem;
          min-height: 26px;
          padding: 4px 9px;
        }

        .chat-footer {
          align-items: flex-start;
          gap: 8px;
        }

        .chat-status-inline {
          min-width: 0;
        }

        .chat-metrics {
          justify-content: flex-start;
        }

        .chat-loaded-summary {
          font-size: 0.67rem;
          padding: 4px 8px;
        }
      }

      @keyframes pulse {
        0%,
        100% {
          transform: scale(1);
          opacity: 0.7;
        }
        50% {
          transform: scale(1.2);
          opacity: 1;
        }
      }

      @keyframes waiting-slide {
        0% {
          transform: translateX(-100%);
        }
        100% {
          transform: translateX(260%);
        }
      }

      @keyframes waiting-shimmer {
        0% {
          background-position: 0% 0;
        }
        100% {
          background-position: 200% 0;
        }
      }

      @keyframes waiting-spin {
        0% {
          transform: rotate(0deg);
        }
        100% {
          transform: rotate(360deg);
        }
      }
