:root {
            --bg: #080c0a;
            --surface: #0e1712;
            --surface2: #141f18;
            --border: #1e2e22;
            --accent-green: #22c55e;
            --accent-red: #ef4444;
            --accent-amber: #f59e0b;
            --text: #e8f0ea;
            --text-muted: #6b8570;
            --text-dim: #3d5244;
        }

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

        body {
            font-family: 'DM Sans', sans-serif;
            background: var(--bg);
            color: var(--text);
            min-height: 100vh;
            overflow-x: hidden;
        }

        body::before {
            content: '';
            position: fixed;
            inset: 0;
            background-image: 
                radial-gradient(ellipse 80% 60% at 20% 10%, rgba(34,197,94,0.04) 0%, transparent 60%),
                radial-gradient(ellipse 60% 80% at 80% 90%, rgba(239,68,68,0.03) 0%, transparent 60%);
            pointer-events: none;
            z-index: 0;
        }

        .page-wrapper { position: relative; z-index: 1; }

        /* ─── HEADER ─── */
        header {
            padding: 20px 48px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid var(--border);
            backdrop-filter: blur(8px);
            position: sticky;
            top: 0;
            z-index: 100;
            background: rgba(8,12,10,0.95);
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 14px;
        }

        .logo-svg {
            flex-shrink: 0;
            filter: drop-shadow(0 0 6px rgba(118,255,3,0.35)) drop-shadow(0 0 14px rgba(34,197,94,0.2));
            transition: filter 0.3s ease;
        }

        .logo-svg:hover {
            filter: drop-shadow(0 0 10px rgba(118,255,3,0.6)) drop-shadow(0 0 24px rgba(34,197,94,0.35));
        }

        .logo-wordmark { display: flex; flex-direction: column; }

        .logo-text {
            font-family: 'Bebas Neue', sans-serif;
            font-size: 26px;
            letter-spacing: 3px;
            line-height: 1;
            background: linear-gradient(90deg, #e8f0ea 60%, #76ff03 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .logo-dot {
            color: #76ff03;
            -webkit-text-fill-color: #76ff03;
        }

        .logo-sub {
            font-size: 10px;
            color: var(--text-muted);
            letter-spacing: 3.5px;
            text-transform: uppercase;
            margin-top: 1px;
            font-family: 'Space Mono', monospace;
        }

        /* Nav tabs */
        .nav-tabs {
            display: flex;
            gap: 4px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 4px;
        }

        .nav-tab {
            padding: 8px 20px;
            border-radius: 8px;
            border: none;
            background: transparent;
            color: var(--text-muted);
            font-family: 'DM Sans', sans-serif;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .nav-tab:hover { color: var(--text); }
        .nav-tab.active {
            background: var(--surface2);
            color: var(--accent-green);
            border: 1px solid var(--border);
        }

        .nav-tab .tab-badge {
            background: var(--accent-green);
            color: #000;
            font-size: 10px;
            font-weight: 700;
            padding: 1px 6px;
            border-radius: 100px;
            min-width: 18px;
            text-align: center;
        }

        .header-badge {
            display: flex;
            align-items: center;
            gap: 8px;
            background: var(--surface);
            border: 1px solid var(--border);
            padding: 8px 16px;
            border-radius: 100px;
            font-size: 12px;
            color: var(--text-muted);
            font-family: 'Space Mono', monospace;
        }

        .header-badge::before {
            content: '';
            width: 8px; height: 8px;
            border-radius: 50%;
            background: var(--accent-green);
            box-shadow: 0 0 8px var(--accent-green);
            animation: pulse 2s infinite;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.4; }
        }

        /* ─── PAGES ─── */
        .page { display: none; }
        .page.active { display: block; }

        /* ─── UPLOAD ZONE ─── */
        .upload-section {
            padding: 64px 48px;
            max-width: 900px;
            margin: 0 auto;
            text-align: center;
        }

        .upload-title {
            font-family: 'Bebas Neue', sans-serif;
            font-size: clamp(48px, 8vw, 80px);
            letter-spacing: 3px;
            line-height: 1;
            margin-bottom: 16px;
        }

        .upload-title span { color: var(--accent-green); }

        .upload-subtitle {
            font-size: 16px;
            color: var(--text-muted);
            margin-bottom: 48px;
            font-weight: 300;
        }

        .upload-area {
            border: 2px dashed var(--border);
            border-radius: 20px;
            padding: 60px 40px;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            background: var(--surface);
        }

        .upload-area::before {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(135deg, rgba(34,197,94,0.05), transparent);
            opacity: 0;
            transition: opacity 0.3s;
        }

        .upload-area:hover, .upload-area.dragover {
            border-color: var(--accent-green);
            transform: translateY(-2px);
            box-shadow: 0 20px 60px rgba(34,197,94,0.08);
        }

        .upload-area:hover::before, .upload-area.dragover::before { opacity: 1; }

        .upload-icon { font-size: 56px; margin-bottom: 20px; display: block; }
        .upload-text-main { font-size: 20px; font-weight: 500; margin-bottom: 8px; }
        .upload-text-sub { font-size: 14px; color: var(--text-muted); }

        #imageInput { display: none; }

        .btn-analyze {
            margin-top: 28px;
            padding: 16px 48px;
            background: linear-gradient(135deg, #22c55e, #16a34a);
            color: #fff;
            border: none;
            border-radius: 100px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            letter-spacing: 0.5px;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 10px;
            font-family: 'DM Sans', sans-serif;
        }

        .btn-analyze:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(34,197,94,0.3); }
        .btn-analyze:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

        /* ─── LOADING ─── */
        .loading-overlay {
            display: none;
            flex-direction: column;
            align-items: center;
            gap: 20px;
            padding: 60px;
        }

        .loading-overlay.active { display: flex; }

        .dna-loader { width: 60px; height: 60px; position: relative; }

        .dna-loader::before, .dna-loader::after {
            content: '';
            position: absolute;
            width: 16px; height: 16px;
            border-radius: 50%;
            animation: dna 1.2s ease-in-out infinite;
        }

        .dna-loader::before { background: var(--accent-green); top: 0; left: 50%; transform: translateX(-50%); animation-delay: 0s; }
        .dna-loader::after { background: var(--accent-amber); bottom: 0; left: 50%; transform: translateX(-50%); animation-delay: 0.6s; }

        @keyframes dna {
            0%, 100% { transform: translateX(-50%) scale(1); opacity: 1; }
            50% { transform: translateX(-50%) scale(0.4); opacity: 0.4; }
        }

        .loading-text {
            font-family: 'Space Mono', monospace;
            font-size: 13px;
            color: var(--text-muted);
            letter-spacing: 2px;
            animation: flicker 1.5s infinite;
        }

        @keyframes flicker {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }

        /* ─── RESULT SECTION ─── */
        #resultSection {
            display: none;
            padding: 0 48px 80px;
            max-width: 1400px;
            margin: 0 auto;
            animation: fadeUp 0.6s ease forwards;
        }

        #resultSection.active { display: block; }

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

        .result-header {
            display: flex;
            align-items: center;
            gap: 20px;
            margin-bottom: 40px;
            padding-bottom: 24px;
            border-bottom: 1px solid var(--border);
        }

        .result-count { font-family: 'Bebas Neue', sans-serif; font-size: 64px; line-height: 1; color: var(--accent-green); }
        .result-count-label { font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; }

        .result-scan-info {
            margin-left: auto;
            text-align: right;
            font-family: 'Space Mono', monospace;
            font-size: 11px;
            color: var(--text-dim);
        }

        .btn-reset {
            padding: 10px 24px;
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-muted);
            border-radius: 8px;
            cursor: pointer;
            font-size: 13px;
            transition: all 0.2s;
            font-family: 'DM Sans', sans-serif;
        }

        .btn-reset:hover { border-color: var(--accent-green); color: var(--accent-green); }

        /* ─── SNAKE CARD ─── */
        .snake-card {
            display: grid;
            grid-template-columns: 1fr 1.2fr;
            gap: 0;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 20px;
            overflow: hidden;
            margin-bottom: 32px;
            position: relative;
            transition: transform 0.3s ease;
        }

        .snake-card:hover { transform: translateY(-3px); }

        .snake-card.venomous { border-color: rgba(239,68,68,0.3); box-shadow: 0 0 40px rgba(239,68,68,0.05); }
        .snake-card.safe { border-color: rgba(34,197,94,0.2); box-shadow: 0 0 40px rgba(34,197,94,0.03); }

        .snake-card.venomous::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--accent-red), #f97316); }
        .snake-card.safe::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--accent-green), #3b82f6); }

        .info-panel {
            padding: 40px;
            display: flex;
            flex-direction: column;
            gap: 24px;
            border-right: 1px solid var(--border);
        }

        .danger-badge {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 16px;
            border-radius: 100px;
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 1.5px;
            text-transform: uppercase;
            width: fit-content;
        }

        .danger-badge.venomous { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
        .danger-badge.safe { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.25); color: #4ade80; }
        .danger-badge .dot { width: 7px; height: 7px; border-radius: 50%; }
        .danger-badge.venomous .dot { background: #ef4444; animation: pulse 1s infinite; }
        .danger-badge.safe .dot { background: #22c55e; }

        .snake-name-en { font-family: 'Bebas Neue', sans-serif; font-size: 40px; letter-spacing: 1px; line-height: 1.1; }
        .snake-name-th { font-size: 18px; color: var(--text-muted); font-weight: 300; margin-top: 4px; }

        .confidence-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; }
        .confidence-label span:first-child { color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
        .confidence-label span:last-child { font-family: 'Space Mono', monospace; font-size: 14px; font-weight: 700; }

        .confidence-bar { height: 6px; background: var(--border); border-radius: 100px; overflow: hidden; }
        .confidence-fill { height: 100%; border-radius: 100px; transition: width 1s cubic-bezier(0.4,0,0.2,1); width: 0; }
        .venomous .confidence-fill { background: linear-gradient(90deg, #ef4444, #f97316); }
        .safe .confidence-fill { background: linear-gradient(90deg, #22c55e, #3b82f6); }

        .divider { border: none; border-top: 1px solid var(--border); }

        .info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
        .info-item-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 4px; }
        .info-item-value { font-size: 14px; color: var(--text); font-weight: 500; }

        .snake-description { font-size: 14px; line-height: 1.7; color: var(--text-muted); font-weight: 300; }

        .first-aid-box { background: rgba(239,68,68,0.07); border: 1px solid rgba(239,68,68,0.2); border-radius: 12px; padding: 16px 20px; }
        .first-aid-box.safe-box { background: rgba(34,197,94,0.06); border-color: rgba(34,197,94,0.15); }
        .first-aid-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; color: #f87171; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
        .first-aid-box.safe-box .first-aid-title { color: #4ade80; }
        .first-aid-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
        .first-aid-list li { font-size: 13px; color: var(--text-muted); display: flex; align-items: flex-start; gap: 8px; line-height: 1.5; }
        .first-aid-list li::before { content: '→'; color: #f87171; flex-shrink: 0; font-size: 12px; margin-top: 1px; }
        .first-aid-box.safe-box .first-aid-list li::before { color: #4ade80; }

        .image-panel { position: relative; min-height: 480px; background: var(--surface2); overflow: hidden; }
        .canvas-wrapper { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
        .canvas-wrapper canvas { max-width: 100%; max-height: 560px; width: 100%; height: auto; object-fit: contain; border-radius: 8px; }

        .detection-tag { position: absolute; top: 16px; right: 16px; background: rgba(8,12,10,0.85); border: 1px solid var(--border); backdrop-filter: blur(8px); padding: 8px 14px; border-radius: 8px; font-family: 'Space Mono', monospace; font-size: 11px; color: var(--text-muted); }

        .no-result { text-align: center; padding: 80px 40px; background: var(--surface); border: 1px dashed var(--border); border-radius: 20px; }
        .no-result-icon { font-size: 48px; margin-bottom: 16px; }
        .no-result-text { font-size: 16px; color: var(--text-muted); }

        #previewThumb { max-width: 200px; max-height: 150px; border-radius: 10px; margin: 16px auto 0; display: none; object-fit: cover; }

        /* ─── HISTORY PAGE ─── */
        .history-page {
            padding: 48px;
            max-width: 1200px;
            margin: 0 auto;
        }

        .page-title {
            font-family: 'Bebas Neue', sans-serif;
            font-size: 52px;
            letter-spacing: 2px;
            margin-bottom: 8px;
        }

        .page-title span { color: var(--accent-green); }

        .page-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 40px; }

        .history-empty {
            text-align: center;
            padding: 80px 40px;
            background: var(--surface);
            border: 1px dashed var(--border);
            border-radius: 20px;
        }

        .history-empty-icon { font-size: 48px; margin-bottom: 16px; }
        .history-empty-text { font-size: 16px; color: var(--text-muted); }

        .history-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 20px;
        }

        .history-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 16px;
            overflow: hidden;
            cursor: pointer;
            transition: all 0.25s;
        }

        .history-card:hover { transform: translateY(-4px); border-color: var(--accent-green); box-shadow: 0 12px 40px rgba(34,197,94,0.1); }

        .history-card.venomous { border-color: rgba(239,68,68,0.25); }
        .history-card.venomous:hover { border-color: var(--accent-red); box-shadow: 0 12px 40px rgba(239,68,68,0.1); }

        .history-card-stripe { height: 3px; }
        .history-card.venomous .history-card-stripe { background: linear-gradient(90deg, var(--accent-red), #f97316); }
        .history-card.safe .history-card-stripe { background: linear-gradient(90deg, var(--accent-green), #3b82f6); }

        .history-thumb {
            width: 100%;
            height: 160px;
            object-fit: cover;
            background: var(--surface2);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 48px;
        }

        .history-thumb img { width: 100%; height: 160px; object-fit: cover; }

        .history-card-body { padding: 16px; }

        .history-card-name { font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 1px; margin-bottom: 4px; }
        .history-card-th { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }

        .history-card-meta { display: flex; justify-content: space-between; align-items: center; }

        .history-badge {
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 1px;
            text-transform: uppercase;
            padding: 3px 10px;
            border-radius: 100px;
        }

        .history-badge.venomous { background: rgba(239,68,68,0.12); color: #f87171; }
        .history-badge.safe { background: rgba(34,197,94,0.1); color: #4ade80; }

        .history-confidence { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--text-muted); }
        .history-time { font-family: 'Space Mono', monospace; font-size: 10px; color: var(--text-dim); margin-top: 8px; }

        .history-clear-btn {
            padding: 10px 20px;
            background: transparent;
            border: 1px solid rgba(239,68,68,0.3);
            color: #f87171;
            border-radius: 8px;
            cursor: pointer;
            font-size: 13px;
            transition: all 0.2s;
            font-family: 'DM Sans', sans-serif;
            margin-bottom: 28px;
        }

        .history-clear-btn:hover { background: rgba(239,68,68,0.08); }

        /* ─── ENCYCLOPEDIA PAGE ─── */
        .encyclopedia-page {
            padding: 48px;
            max-width: 1400px;
            margin: 0 auto;
        }

        .enc-controls {
            display: flex;
            gap: 16px;
            margin-bottom: 32px;
            flex-wrap: wrap;
            align-items: center;
        }

        .enc-search {
            flex: 1;
            min-width: 240px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 10px;
            color: var(--text);
            padding: 12px 16px;
            font-size: 14px;
            font-family: 'DM Sans', sans-serif;
            outline: none;
            transition: border-color 0.2s;
        }

        .enc-search:focus { border-color: var(--accent-green); }
        .enc-search::placeholder { color: var(--text-dim); }

        .enc-filter-group { display: flex; gap: 8px; }

        .enc-filter-btn {
            padding: 10px 18px;
            border-radius: 8px;
            border: 1px solid var(--border);
            background: transparent;
            color: var(--text-muted);
            font-size: 13px;
            cursor: pointer;
            transition: all 0.2s;
            font-family: 'DM Sans', sans-serif;
        }

        .enc-filter-btn:hover { border-color: var(--accent-green); color: var(--text); }
        .enc-filter-btn.active.all { background: var(--surface2); border-color: var(--accent-green); color: var(--accent-green); }
        .enc-filter-btn.active.venomous { background: rgba(239,68,68,0.1); border-color: var(--accent-red); color: #f87171; }
        .enc-filter-btn.active.safe { background: rgba(34,197,94,0.08); border-color: var(--accent-green); color: #4ade80; }

        .enc-count { font-family: 'Space Mono', monospace; font-size: 12px; color: var(--text-muted); white-space: nowrap; }

        .enc-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 20px;
        }

        .enc-card {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 16px;
            padding: 24px;
            cursor: pointer;
            transition: all 0.25s;
            position: relative;
            overflow: hidden;
        }

        .enc-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
        .enc-card.venomous::before { background: linear-gradient(90deg, #ef4444, #f97316); }
        .enc-card.safe::before { background: linear-gradient(90deg, #22c55e, #3b82f6); }

        .enc-card:hover { transform: translateY(-3px); box-shadow: 0 16px 48px rgba(0,0,0,0.3); }
        .enc-card.venomous:hover { border-color: rgba(239,68,68,0.3); }
        .enc-card.safe:hover { border-color: rgba(34,197,94,0.2); }

        .enc-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }

        .enc-name-en { font-family: 'Bebas Neue', sans-serif; font-size: 26px; letter-spacing: 1px; line-height: 1.1; }
        .enc-name-th { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

        .enc-venom-icon { font-size: 24px; }

        .enc-family { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 12px; font-family: 'Space Mono', monospace; }

        .enc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

        .enc-tag {
            font-size: 11px;
            padding: 3px 10px;
            border-radius: 100px;
            background: var(--surface2);
            border: 1px solid var(--border);
            color: var(--text-muted);
        }

        .enc-desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

        .enc-danger { margin-top: 12px; font-size: 12px; font-weight: 600; }
        .enc-card.venomous .enc-danger { color: #f87171; }
        .enc-card.safe .enc-danger { color: #4ade80; }

        /* Modal for enc detail */
        .modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.8);
            backdrop-filter: blur(4px);
            z-index: 1000;
            align-items: center;
            justify-content: center;
            padding: 24px;
        }

        .modal-overlay.active { display: flex; }

        .modal-box {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 20px;
            max-width: 680px;
            width: 100%;
            max-height: 90vh;
            overflow-y: auto;
            animation: fadeUp 0.3s ease;
        }

        .modal-header {
            padding: 28px 32px 20px;
            border-bottom: 1px solid var(--border);
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            position: sticky;
            top: 0;
            background: var(--surface);
            z-index: 1;
        }

        .modal-close { background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 18px; transition: all 0.2s; }
        .modal-close:hover { color: var(--text); border-color: var(--accent-green); }

        .modal-body { padding: 28px 32px; display: flex; flex-direction: column; gap: 24px; }

        .modal-info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

        /* ─── CLAUDE CHAT ─── */
        .chat-popup {
            position: fixed;
            bottom: 24px;
            right: 24px;
            width: 400px;
            max-height: 600px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 20px;
            box-shadow: 0 24px 80px rgba(0,0,0,0.6);
            display: flex;
            flex-direction: column;
            z-index: 500;
            overflow: hidden;
            transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
            transform-origin: bottom right;
        }

        .chat-popup.collapsed {
            max-height: 60px;
        }

        /* Minimized — floating icon only */
        .chat-popup.minimized {
            width: 56px;
            max-height: 56px;
            border-radius: 50%;
            border-color: rgba(34,197,94,0.4);
            box-shadow: 0 8px 32px rgba(34,197,94,0.25), 0 0 0 1px rgba(34,197,94,0.15);
            overflow: hidden;
            cursor: pointer;
        }

        .chat-popup.minimized .chat-header {
            padding: 0;
            border-bottom: none;
            background: linear-gradient(135deg, #22c55e, #16a34a);
            width: 56px;
            height: 56px;
            border-radius: 50%;
            justify-content: center;
            cursor: pointer;
        }

        .chat-popup.minimized .chat-header-icon {
            background: transparent;
            width: auto;
            height: auto;
            border-radius: 0;
        }

        .chat-popup.minimized .chat-header-info,
        .chat-popup.minimized .chat-header-actions {
            display: none;
        }

        .chat-popup.minimized .chat-unread-dot {
            display: flex;
        }

        /* Unread notification dot */
        .chat-unread-dot {
            display: none;
            position: absolute;
            top: 2px;
            right: 2px;
            width: 14px;
            height: 14px;
            background: #ef4444;
            border: 2px solid var(--bg);
            border-radius: 50%;
            animation: pulse 1.5s infinite;
            z-index: 10;
        }

        /* Minimize button */
        .chat-minimize {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            font-size: 14px;
            padding: 4px 6px;
            transition: all 0.2s;
            line-height: 1;
            border-radius: 6px;
            flex-shrink: 0;
        }
        .chat-minimize:hover {
            color: var(--text);
            background: rgba(255,255,255,0.06);
        }

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

        .chat-header {
            padding: 14px 18px;
            background: linear-gradient(135deg, var(--surface2), var(--surface));
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            flex-shrink: 0;
        }

        .chat-header-icon {
            width: 34px; height: 34px;
            background: linear-gradient(135deg, #22c55e, #16a34a);
            border-radius: 10px;
            display: flex; align-items: center; justify-content: center;
            font-size: 16px;
            flex-shrink: 0;
        }

        .chat-header-info { flex: 1; }
        .chat-header-title { font-size: 14px; font-weight: 600; }
        .chat-header-sub { font-size: 11px; color: var(--text-muted); }

        .chat-toggle { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 4px; transition: transform 0.3s; }
        .chat-popup.collapsed .chat-toggle { transform: rotate(180deg); }

        .chat-powered {
            font-size: 10px;
            color: var(--text-dim);
            font-family: 'Space Mono', monospace;
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .chat-powered::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-green); }

        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
            display: flex;
            flex-direction: column;
            gap: 12px;
            min-height: 0;
        }

        .chat-messages::-webkit-scrollbar { width: 4px; }
        .chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

        .chat-msg {
            display: flex;
            gap: 10px;
            animation: fadeUp 0.25s ease;
        }

        .chat-msg.user { flex-direction: row-reverse; }

        .chat-avatar {
            width: 28px; height: 28px;
            border-radius: 8px;
            display: flex; align-items: center; justify-content: center;
            font-size: 14px;
            flex-shrink: 0;
        }

        .chat-msg.bot .chat-avatar { background: linear-gradient(135deg, #22c55e22, #16a34a22); border: 1px solid rgba(34,197,94,0.2); }
        .chat-msg.user .chat-avatar { background: var(--surface2); border: 1px solid var(--border); }

        .chat-bubble {
            max-width: 280px;
            padding: 10px 14px;
            border-radius: 12px;
            font-size: 13px;
            line-height: 1.55;
            word-break: break-word;
        }

        .chat-msg.bot .chat-bubble { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
        .chat-msg.user .chat-bubble { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; }

        .chat-typing { display: flex; align-items: center; gap: 6px; padding: 10px 14px; }
        .chat-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: bounce 1.2s infinite; }
        .chat-dot:nth-child(2) { animation-delay: 0.2s; }
        .chat-dot:nth-child(3) { animation-delay: 0.4s; }

        @keyframes bounce {
            0%, 60%, 100% { transform: translateY(0); }
            30% { transform: translateY(-6px); }
        }

        .chat-input-area {
            padding: 12px;
            border-top: 1px solid var(--border);
            display: flex;
            gap: 8px;
            flex-shrink: 0;
        }

        .chat-input {
            flex: 1;
            background: var(--surface2);
            border: 1px solid var(--border);
            border-radius: 10px;
            color: var(--text);
            padding: 10px 14px;
            font-size: 13px;
            font-family: 'DM Sans', sans-serif;
            outline: none;
            transition: border-color 0.2s;
        }

        .chat-input:focus { border-color: var(--accent-green); }
        .chat-input::placeholder { color: var(--text-dim); }

        .chat-send {
            width: 38px; height: 38px;
            background: linear-gradient(135deg, #22c55e, #16a34a);
            border: none;
            border-radius: 10px;
            color: #fff;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.2s;
            flex-shrink: 0;
            display: flex; align-items: center; justify-content: center;
        }

        .chat-send:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(34,197,94,0.3); }
        .chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

        .quick-questions {
            padding: 8px 16px 4px;
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }

        .quick-btn {
            font-size: 11px;
            padding: 5px 10px;
            border-radius: 100px;
            border: 1px solid var(--border);
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            transition: all 0.2s;
            font-family: 'DM Sans', sans-serif;
        }

        .quick-btn:hover { border-color: var(--accent-green); color: var(--accent-green); }

        /* ─── CAMERA MODAL ─── */
        .camera-modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.92);
            backdrop-filter: blur(8px);
            z-index: 2000;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            gap: 20px;
        }
        .camera-modal-overlay.active { display: flex; }

        .camera-box {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 20px;
            overflow: hidden;
            width: min(680px, 95vw);
            position: relative;
        }

        .camera-header {
            padding: 16px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid var(--border);
        }

        .camera-title { font-family: 'Bebas Neue', sans-serif; font-size: 22px; letter-spacing: 1px; }
        .camera-close { background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px; transition: all 0.2s; }
        .camera-close:hover { color: var(--text); border-color: var(--accent-red); }

        .camera-video-wrap {
            position: relative;
            background: #000;
        }

        #cameraVideo { width: 100%; display: block; max-height: 420px; object-fit: cover; }

        .camera-scan-line {
            position: absolute;
            left: 10%; right: 10%;
            height: 2px;
            background: linear-gradient(90deg, transparent, var(--accent-green), transparent);
            box-shadow: 0 0 12px var(--accent-green);
            animation: scanLine 2s ease-in-out infinite;
            display: none;
        }
        .camera-scanning .camera-scan-line { display: block; }

        @keyframes scanLine {
            0% { top: 10%; }
            50% { top: 85%; }
            100% { top: 10%; }
        }

        .camera-corner {
            position: absolute;
            width: 40px; height: 40px;
            border-color: var(--accent-green);
            border-style: solid;
            opacity: 0.8;
        }
        .camera-corner.tl { top: 16px; left: 16px; border-width: 3px 0 0 3px; }
        .camera-corner.tr { top: 16px; right: 16px; border-width: 3px 3px 0 0; }
        .camera-corner.bl { bottom: 16px; left: 16px; border-width: 0 0 3px 3px; }
        .camera-corner.br { bottom: 16px; right: 16px; border-width: 0 3px 3px 0; }

        .camera-actions {
            padding: 16px 20px;
            display: flex;
            gap: 12px;
            justify-content: center;
        }

        .btn-capture {
            padding: 12px 32px;
            background: linear-gradient(135deg, #22c55e, #16a34a);
            color: #fff;
            border: none;
            border-radius: 100px;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            font-family: 'DM Sans', sans-serif;
            transition: all 0.2s;
        }
        .btn-capture:hover { box-shadow: 0 8px 24px rgba(34,197,94,0.35); transform: translateY(-1px); }
        .btn-capture:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

        .btn-cam-outline {
            padding: 12px 24px;
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-muted);
            border-radius: 100px;
            font-size: 14px;
            cursor: pointer;
            font-family: 'DM Sans', sans-serif;
            transition: all 0.2s;
        }
        .btn-cam-outline:hover { border-color: var(--accent-green); color: var(--text); }

        .camera-status {
            font-family: 'Space Mono', monospace;
            font-size: 11px;
            color: var(--text-muted);
            text-align: center;
            padding: 0 20px 12px;
            letter-spacing: 1px;
        }

        /* ─── MAP MODAL ─── */
        .map-modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.88);
            backdrop-filter: blur(6px);
            z-index: 2000;
            align-items: center;
            justify-content: center;
            padding: 24px;
        }
        .map-modal-overlay.active { display: flex; }

        .map-box {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 20px;
            width: min(780px, 95vw);
            max-height: 90vh;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            animation: fadeUp 0.3s ease;
        }

        .map-header {
            padding: 20px 24px;
            border-bottom: 1px solid var(--border);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }

        .map-title-block .map-snake-name { font-family: 'Bebas Neue', sans-serif; font-size: 28px; letter-spacing: 1px; }
        .map-title-block .map-snake-th { font-size: 14px; color: var(--text-muted); }

        .map-close { background: var(--surface2); border: 1px solid var(--border); color: var(--text-muted); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 16px; transition: all 0.2s; }
        .map-close:hover { color: var(--text); }

        .map-svg-wrap {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .map-legend {
            display: flex;
            gap: 16px;
            flex-wrap: wrap;
        }

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

        .map-legend-dot {
            width: 10px; height: 10px;
            border-radius: 50%;
        }

        #mapSvg {
            width: 100%;
            border-radius: 12px;
            background: #0a1a0e;
            border: 1px solid var(--border);
        }

        /* Thailand region highlight */
        .region-path {
            fill: #1a2e1e;
            stroke: #2a4a30;
            stroke-width: 1px;
            transition: fill 0.2s;
        }
        .region-path.highlighted { fill: #1e4d2a; stroke: var(--accent-green); }
        .region-path.danger { fill: #3d1515; stroke: var(--accent-red); }

        /* ─── SHARE CARD OVERLAY ─── */
        .share-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.88);
            backdrop-filter: blur(6px);
            z-index: 2000;
            align-items: center;
            justify-content: center;
            padding: 24px;
            flex-direction: column;
            gap: 20px;
        }
        .share-overlay.active { display: flex; }

        #shareCanvas {
            border-radius: 16px;
            box-shadow: 0 24px 80px rgba(0,0,0,0.8);
            max-width: min(480px, 90vw);
            width: 100%;
        }

        .share-actions {
            display: flex;
            gap: 12px;
        }

        .btn-share-download {
            padding: 12px 28px;
            background: linear-gradient(135deg, #22c55e, #16a34a);
            color: #fff;
            border: none;
            border-radius: 100px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            font-family: 'DM Sans', sans-serif;
            transition: all 0.2s;
        }
        .btn-share-download:hover { box-shadow: 0 8px 24px rgba(34,197,94,0.35); }

        .btn-share-close {
            padding: 12px 24px;
            background: transparent;
            border: 1px solid rgba(255,255,255,0.15);
            color: rgba(255,255,255,0.6);
            border-radius: 100px;
            font-size: 14px;
            cursor: pointer;
            font-family: 'DM Sans', sans-serif;
            transition: all 0.2s;
        }
        .btn-share-close:hover { border-color: rgba(255,255,255,0.3); color: #fff; }

        /* Share and Map buttons on result card */
        .card-action-row {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .btn-card-action {
            padding: 8px 16px;
            border-radius: 8px;
            border: 1px solid var(--border);
            background: transparent;
            color: var(--text-muted);
            font-size: 12px;
            cursor: pointer;
            font-family: 'DM Sans', sans-serif;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .btn-card-action:hover { border-color: var(--accent-green); color: var(--accent-green); }

        /* Camera button in upload section */
        .upload-actions {
            display: flex;
            gap: 12px;
            justify-content: center;
            flex-wrap: wrap;
            margin-top: 28px;
        }

        .btn-camera {
            padding: 16px 32px;
            background: transparent;
            border: 1px solid var(--border);
            color: var(--text-muted);
            border-radius: 100px;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 10px;
            font-family: 'DM Sans', sans-serif;
            transition: all 0.3s ease;
        }
        .btn-camera:hover { border-color: var(--accent-green); color: var(--accent-green); transform: translateY(-2px); }

        /* ─── RESPONSIVE ─── */
        @media (max-width: 900px) {
            header { padding: 16px 20px; flex-wrap: wrap; gap: 12px; }
            .header-badge { display: none; }
            .upload-section { padding: 40px 20px; }
            #resultSection, .history-page, .encyclopedia-page { padding: 20px; }
            .snake-card { grid-template-columns: 1fr; }
            .info-panel { border-right: none; border-bottom: 1px solid var(--border); }
            .image-panel { min-height: 300px; }
            .chat-popup { width: calc(100vw - 32px); right: 16px; }
            .modal-info-grid { grid-template-columns: 1fr 1fr; }
        }

        /* ─── LANG TOGGLE ─── */
        .lang-toggle {
            display: flex;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
        }

        .lang-btn {
            padding: 7px 14px;
            background: transparent;
            border: none;
            color: var(--text-muted);
            font-family: 'Space Mono', monospace;
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 1px;
            cursor: pointer;
            transition: all 0.2s;
            position: relative;
        }

        .lang-btn:hover { color: var(--text); }

        .lang-btn.active {
            background: linear-gradient(135deg, rgba(34,197,94,0.15), rgba(118,255,3,0.08));
            color: #76ff03;
            box-shadow: inset 0 0 12px rgba(118,255,3,0.1);
        }

        .lang-btn.active::after {
            content: '';
            position: absolute;
            bottom: 0; left: 10%; right: 10%;
            height: 2px;
            background: linear-gradient(90deg, #76ff03, #22c55e);
            border-radius: 2px 2px 0 0;
        }
