        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        :root {
            --bg: #000;
            --card: #111;
            --input: #1a1a1a;
            --border: #333;
            --text: #eee;
            --muted: #777;
            --accent: #0af;
            --user: #0af;
            --ai: #a5f;
        }

        html,
        body {
            height: 100%;
            background: var(--bg);
            color: var(--text);
            font: 12px/1.4 -apple-system, system-ui, sans-serif;
            overflow: hidden;
            -webkit-tap-highlight-color: transparent;
        }

        /* Layout */
        .app {
            display: flex;
            flex-direction: column;
            height: 100%;
            max-width: 500px;
            margin: 0 auto;
        }

        /* Header */
        .hdr {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            background: var(--card);
            border-bottom: 1px solid var(--border);
        }

        .hdr-back {
            background: none;
            border: none;
            color: var(--muted);
            font-size: 18px;
            cursor: pointer;
            padding: 4px;
        }

        .hdr-info {
            flex: 1;
            min-width: 0;
            cursor: pointer;
        }

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

        .hdr-status {
            font-size: 10px;
            color: var(--muted);
        }

        .hdr-btn {
            background: none;
            border: none;
            color: var(--muted);
            font-size: 16px;
            cursor: pointer;
            padding: 6px;
            border-radius: 50%;
        }

        .hdr-btn:active {
            background: var(--border);
        }

        .hdr-btn.on {
            color: var(--accent);
        }

        /* Views */
        .view {
            display: none;
            flex-direction: column;
            flex: 1;
            overflow: hidden;
        }

        .view.active {
            display: flex;
        }

        /* Chat History List */
        .history {
            flex: 1;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }

        .history-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 12px;
            border-bottom: 1px solid var(--border);
            cursor: pointer;
            transition: background 0.1s;
        }

        .history-item:active {
            background: var(--input);
        }

        .history-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--ai);
            color: #000;
            font-weight: 700;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            flex-shrink: 0;
        }

        .history-info {
            flex: 1;
            min-width: 0;
        }

        .history-name {
            font-weight: 600;
            font-size: 13px;
            margin-bottom: 2px;
        }

        .history-preview {
            font-size: 11px;
            color: var(--muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .history-meta {
            text-align: right;
            flex-shrink: 0;
        }

        .history-time {
            font-size: 10px;
            color: var(--muted);
        }

        .history-count {
            font-size: 9px;
            color: var(--muted);
            margin-top: 2px;
        }

        /* Unread badge */
        .unread-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 20px;
            height: 20px;
            padding: 0 6px;
            border-radius: 10px;
            background: var(--accent);
            color: #000;
            font-size: 11px;
            font-weight: 700;
            margin-top: 2px;
        }

        .history-item.has-unread .history-name {
            color: #fff;
            font-weight: 700;
        }

        .history-item.has-unread .history-preview {
            color: var(--text);
        }

        .history-item.has-unread .history-time {
            color: var(--accent);
        }

        .history-item.has-unread .history-avatar {
            box-shadow: 0 0 0 2px var(--accent);
        }

        /* New Chat Button */
        .new-chat-btn {
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 56px;
            height: 56px;
            border-radius: 50%;
            background: var(--accent);
            border: none;
            color: #000;
            font-size: 24px;
            cursor: pointer;
            box-shadow: 0 2px 10px rgba(0, 170, 255, 0.3);
            z-index: 10;
        }

        .new-chat-btn:active {
            transform: scale(0.95);
        }

        /* Agent Picker */
        .picker {
            padding: 12px;
            display: flex;
            flex-direction: column;
            height: 100%;
        }

        .picker-title {
            font-size: 11px;
            color: var(--muted);
            margin-bottom: 8px;
            text-transform: uppercase;
        }

        .picker-search {
            width: 100%;
            padding: 8px 12px;
            background: var(--card);
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            font-size: 13px;
            margin-bottom: 10px;
            outline: none;
        }

        .picker-search:focus {
            border-color: var(--accent);
        }

        .picker-search::placeholder {
            color: var(--muted);
        }

        .picker-grid {
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 6px;
            -webkit-overflow-scrolling: touch;
        }

        .picker-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            background: var(--card);
            border: 1px solid var(--border);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.15s;
        }

        .picker-item:active {
            background: var(--accent);
            color: #000;
            border-color: var(--accent);
        }

        .picker-item .avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: var(--border);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 600;
            flex-shrink: 0;
        }

        .picker-item .picker-info {
            flex: 1;
            min-width: 0;
        }

        .picker-item .name {
            font-size: 13px;
            font-weight: 600;
        }

        .picker-item .picker-meta {
            display: flex;
            gap: 6px;
            margin-top: 3px;
        }

        .picker-item .picker-model {
            font-size: 9px;
            color: var(--accent);
            background: rgba(0,122,255,0.1);
            padding: 1px 6px;
            border-radius: 4px;
            font-weight: 600;
        }

        .picker-item .picker-bounce {
            font-size: 9px;
            color: #a855f7;
            background: rgba(168,85,247,0.1);
            padding: 1px 6px;
            border-radius: 4px;
            font-weight: 600;
        }

        .picker-item .desc {
            font-size: 11px;
            color: var(--muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .picker-item .picker-type {
            font-size: 9px;
            color: var(--accent);
            background: rgba(0,122,255,0.1);
            padding: 2px 6px;
            border-radius: 4px;
            flex-shrink: 0;
        }

        .picker-item.on {
            border-color: var(--accent);
            background: rgba(0,122,255,0.08);
        }

        /* Chat View */
        .chat {
            flex: 1;
            overflow-y: auto;
            padding: 8px;
            -webkit-overflow-scrolling: touch;
        }

        .msg {
            max-width: 82%;
            margin-bottom: 6px;
            animation: fadeIn 0.15s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(4px);
            }
        }

        .msg.user {
            margin-left: auto;
        }

        .msg.ai {
            margin-right: auto;
        }

        .msg-name {
            font-size: 9px;
            color: var(--ai);
            margin-bottom: 2px;
            padding-left: 8px;
            font-weight: 500;
        }

        .msg-bubble {
            padding: 8px 12px;
            border-radius: 16px;
            font-size: 13px;
            line-height: 1.35;
            word-wrap: break-word;
        }

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

        .ai .msg-bubble {
            background: var(--card);
            border: 1px solid var(--border);
            border-bottom-left-radius: 4px;
        }

        .msg-time {
            font-size: 9px;
            color: var(--muted);
            margin-top: 2px;
            padding: 0 8px;
        }

        .msg.user .msg-time {
            text-align: right;
        }

        .ai .msg-bubble .s {
            cursor: pointer;
        }

        .ai .msg-bubble .s:active {
            background: rgba(255, 255, 255, 0.08);
            border-radius: 4px;
        }

        .eval-badge {
            display: inline-block;
            background: #2d2d4e;
            color: #a78bfa;
            font-size: 9px;
            padding: 1px 5px;
            border-radius: 8px;
            cursor: pointer;
            margin-left: 4px;
            border: 1px solid #5b4f9e;
        }

        .eval-panel {
            margin-top: 6px;
            padding: 8px;
            background: #1a1a2e;
            border: 1px solid #333;
            border-radius: 8px;
            font-size: 11px;
            line-height: 1.4;
        }

        /* Typing */
        .typing {
            display: none;
            padding: 8px 12px;
        }

        .typing.show {
            display: flex;
            gap: 4px;
            align-items: center;
        }

        .typing span {
            font-size: 10px;
            color: var(--muted);
        }

        .dot {
            width: 6px;
            height: 6px;
            background: var(--muted);
            border-radius: 50%;
            animation: bounce 1s infinite;
        }

        .dot:nth-child(2) {
            animation-delay: 0.15s;
        }

        .dot:nth-child(3) {
            animation-delay: 0.3s;
        }

        @keyframes bounce {

            0%,
            60%,
            100% {
                transform: translateY(0);
            }

            30% {
                transform: translateY(-4px);
            }
        }

        /* Input */
        .input-wrap {
            display: flex;
            gap: 6px;
            padding: 8px 10px;
            background: var(--card);
            border-top: 1px solid var(--border);
        }

        .input {
            flex: 1;
            background: var(--input);
            border: 1px solid var(--border);
            border-radius: 20px;
            padding: 10px 14px;
            color: var(--text);
            font-size: 13px;
            resize: none;
            min-height: 38px;
            max-height: 80px;
            outline: none;
        }

        .input:focus {
            border-color: var(--accent);
        }

        .input::placeholder {
            color: var(--muted);
        }

        .send {
            width: 38px;
            height: 38px;
            border-radius: 50%;
            background: var(--accent);
            border: none;
            color: #000;
            font-size: 16px;
            cursor: pointer;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .send:active {
            opacity: 0.8;
        }

        .send:disabled {
            background: var(--border);
        }

        /* Voice bar - tappable stop zone */
        .voice-bar {
            display: none;
            align-items: center;
            gap: 8px;
            padding: 10px 12px;
            background: rgba(170, 85, 255, 0.2);
            border-bottom: 1px solid var(--ai);
            font-size: 11px;
            color: var(--ai);
            cursor: pointer;
            user-select: none;
            -webkit-user-select: none;
        }

        .voice-bar.show {
            display: flex;
        }

        .voice-bar .voice-label {
            opacity: 0.6;
            font-size: 9px;
            flex: 1;
        }

        .voice-bar .stop-btn {
            background: rgba(255, 255, 255, 0.15);
            border: 1px solid var(--ai);
            color: var(--ai);
            border-radius: 14px;
            padding: 4px 14px;
            font-size: 11px;
            font-weight: 600;
            cursor: pointer;
            white-space: nowrap;
            transition: all 0.15s;
        }

        .voice-bar .stop-btn:active {
            background: var(--ai);
            color: #000;
        }

        /* Mic bar */
        .mic-bar {
            display: none;
            align-items: center;
            gap: 8px;
            padding: 6px 12px;
            background: rgba(255, 50, 50, 0.15);
            border-bottom: 1px solid #f55;
            font-size: 10px;
            color: #f55;
        }

        .mic-bar.show {
            display: flex;
        }

        .mic-bar .stop {
            margin-left: auto;
            cursor: pointer;
        }

        @keyframes pulse-mic {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.4;
            }
        }

        .mic-bar .mic-dot {
            width: 8px;
            height: 8px;
            background: #f55;
            border-radius: 50%;
            animation: pulse-mic 1s infinite;
        }

        /* Toast */
        .toast {
            position: fixed;
            bottom: 80px;
            left: 50%;
            transform: translateX(-50%) translateY(50px);
            background: var(--card);
            border: 1px solid var(--border);
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 11px;
            opacity: 0;
            transition: all 0.2s;
            z-index: 100;
        }

        .toast.show {
            transform: translateX(-50%) translateY(0);
            opacity: 1;
        }

        /* Empty */
        .empty {
            text-align: center;
            padding: 60px 20px;
            color: var(--muted);
        }

        .empty-icon {
            font-size: 48px;
            margin-bottom: 12px;
        }

        .empty-text {
            font-size: 14px;
        }

        .empty-sub {
            font-size: 11px;
            margin-top: 8px;
        }
