/* ─── Premium Dark Theme CSS Variables ─────────────────────────────── */
        :root {
            /* Core palette matching reference */
            --bg: #05070c;
            --surface: #0d121f;
            --surface-2: #07090e;
            --surface-3: #1e293b;
            --border: #1e293b;
            --border-strong: #334155;

            /* Text */
            --text: #ffffff;
            --text-2: #94a3b8;
            --text-3: #64748b;

            /* Brand / accent */
            --accent: #2563eb;
            --accent-hover: #1d4ed8;
            --accent-light: rgba(37, 99, 235, 0.1);
            --accent-glow: rgba(37, 99, 235, 0.25);

            /* Risk / semantic */
            --green: #10b981;
            --green-bg: rgba(16, 185, 129, 0.1);
            --green-light: rgba(16, 185, 129, 0.2);
            --yellow: #f59e0b;
            --yellow-bg: rgba(245, 158, 11, 0.1);
            --yellow-light: rgba(245, 158, 11, 0.2);
            --orange: #f97316;
            --orange-bg: rgba(249, 115, 22, 0.1);
            --orange-light: rgba(249, 115, 22, 0.2);
            --red: #ef4444;
            --red-bg: rgba(239, 68, 68, 0.1);
            --red-light: rgba(239, 68, 68, 0.2);
            --purple: #8b5cf6;
            --purple-bg: rgba(139, 92, 246, 0.1);
            --purple-light: rgba(139, 92, 246, 0.2);

            /* Elevation / surfaces */
            --nav-bg: rgba(7, 9, 14, 0.85);
            --nav-border: rgba(255, 255, 255, 0.08);
            --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
            --shadow-sm: 0 4px 12px rgba(0,0,0,0.4);
            --shadow-md: 0 8px 24px rgba(0,0,0,0.5);
            --shadow-lg: 0 16px 40px rgba(0,0,0,0.6);
            --shadow-xl: 0 24px 50px rgba(0,0,0,0.7);
            --shadow-nav: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 0.5px rgba(255, 255, 255, 0.05);

            /* Radii — Custom rounded corners */
            --radius-xs: 8px;
            --radius-sm: 12px;
            --radius-md: 16px;
            --radius-lg: 20px;
            --radius-xl: 24px;
            --radius-pill: 999px;

            /* Typography */
            --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
            --font-display: 'Outfit', sans-serif;
            --easing-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
            --easing-standard: cubic-bezier(0.4, 0, 0.2, 1);
        }

        /* ─── Reset & Base ─────────────────────────────────────────────────── */
        * { margin: 0; padding: 0; box-sizing: border-box; }

        html, body {
            height: 100%;
            overflow: hidden;
        }

        body {
            font-family: var(--font);
            background: var(--bg);
            color: var(--text);
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }

        /* ─── App Shell — Native Android app layout ────────────────────────── */
        .app {
            display: flex;
            flex-direction: column;
            height: 100vh;
            height: 100dvh;
            max-width: 520px;
            margin: 0 auto;
            background: var(--bg);
            position: relative;
            overflow: hidden;
            box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
            border-left: 1px solid rgba(255, 255, 255, 0.03);
            border-right: 1px solid rgba(255, 255, 255, 0.03);
        }

        /* ─── Topbar ────────────────────────────────────────────────────────── */
        .topbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 16px 20px;
            padding-top: max(16px, env(safe-area-inset-top));
            position: relative;
            z-index: 10;
        }

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

        .topbar-title {
            font-family: var(--font-display);
            font-size: 18px;
            font-weight: 800;
            color: var(--text);
            letter-spacing: -0.3px;
        }

        .topbar-brand {
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
            min-width: 0;
        }

        .topbar-shield {
            width: 42px;
            height: 42px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            overflow: hidden;
        }

        .topbar-shield img { 
            width: 100%; 
            height: 100%; 
            object-fit: contain;
        }

        .topbar-title {
            font-family: var(--font-display);
            font-size: 19px;
            font-weight: 800;
            color: var(--text);
            letter-spacing: -0.4px;
            line-height: 1.1;
        }

        .topbar-subtitle {
            font-size: 11px;
            font-weight: 600;
            color: var(--text-3);
            letter-spacing: 0.03em;
            margin-top: 1px;
        }

        .topbar-right {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-shrink: 0;
        }

        .topbar-history-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 16px;
            background: transparent;
            border: 1.5px solid var(--accent);
            border-radius: var(--radius-pill);
            color: var(--text);
            font-family: var(--font);
            font-size: 13px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s var(--easing-standard);
        }

        .topbar-history-btn:hover {
            background: var(--accent-light);
            box-shadow: 0 0 12px rgba(37, 99, 235, 0.25);
            transform: translateY(-1px);
        }

        .topbar-history-btn:active {
            transform: scale(0.96) translateY(0);
        }

        .topbar-history-btn.active {
            background: var(--accent);
            color: white;
            border-color: var(--accent);
            box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
        }

        .topbar-history-btn svg { width: 14px; height: 14px; }

        /* ─── Content area ──────────────────────────────────────────────────── */
        .content {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 20px 18px 110px;
            -webkit-overflow-scrolling: touch;
            overscroll-behavior: contain;
        }

        /* ─── Tab content panels ────────────────────────────────────────────── */
        .tab-panel {
            display: none;
            animation: fadeSlideIn 0.3s var(--easing-standard);
        }

        .tab-panel.active { display: block; }

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

        /* ─── Section labels ────────────────────────────────────────────────── */
        .section-label {
            font-size: 11px;
            font-weight: 700;
            color: var(--text-3);
            text-transform: uppercase;
            letter-spacing: 0.08em;
            margin-bottom: 8px;
            padding-left: 2px;
        }

        /* ─── Hero Section ─────────────────────────────────────────────────── */
        .hero-section {
            display: flex;
            align-items: center;
            gap: 16px;
            margin-bottom: 24px;
            transition: all 0.3s var(--easing-standard);
        }

        .hero-section.hidden {
            display: none !important;
        }

        .hero-text {
            flex: 1;
        }

        .hero-title {
            font-family: var(--font-display);
            font-size: 28px;
            font-weight: 800;
            color: #ffffff;
            line-height: 1.15;
            letter-spacing: -0.8px;
        }

        .hero-gradient {
            background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .hero-desc {
            font-size: 13px;
            color: var(--text-2);
            line-height: 1.5;
            margin-top: 8px;
        }

        .hero-image {
            width: 110px;
            height: 110px;
            object-fit: contain;
            flex-shrink: 0;
            animation: heroFloat 6s ease-in-out infinite;
            filter: drop-shadow(0 8px 20px rgba(37, 99, 235, 0.3));
        }

        @keyframes heroFloat {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-8px); }
        }

        /* ─── Input panels ─────────────────────────────────────────────────── */
        .input-card {
            background: var(--surface);
            border-radius: var(--radius-xl);
            padding: 20px;
            margin-bottom: 16px;
            box-shadow: var(--shadow-sm);
            border: 1px solid var(--border);
            transition: all 0.3s var(--easing-standard);
            position: relative;
        }

        .input-card:focus-within {
            border-color: var(--accent);
            box-shadow: var(--shadow-md), 0 0 0 3px rgba(37, 99, 235, 0.15);
        }

        .card-icon-header {
            display: flex;
            align-items: center;
            margin-bottom: 12px;
        }

        .card-icon-badge {
            width: 38px;
            height: 38px;
            border-radius: var(--radius-sm);
            background: rgba(37, 99, 235, 0.1);
            color: #3b82f6;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .url-input-wrapper {
            display: flex;
            align-items: center;
            background: var(--surface-3);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 12px 14px;
            transition: all 0.2s var(--easing-standard);
        }

        .url-input-wrapper:focus-within {
            border-color: var(--accent);
            background: rgba(37, 99, 235, 0.05);
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
        }

        .url-prefix {
            display: flex;
            align-items: center;
            gap: 4px;
            color: var(--accent);
            font-size: 13px;
            font-weight: 600;
            white-space: nowrap;
            padding-right: 10px;
            border-right: 1px solid var(--border);
            margin-right: 10px;
            flex-shrink: 0;
        }

        .url-prefix svg {
            flex-shrink: 0;
        }

        .url-input-wrapper input[type="url"] {
            flex: 1;
            padding: 0;
            font-size: 14px;
        }

        textarea {
            width: 100%;
            background: transparent;
            border: none;
            padding: 0;
            font-family: var(--font);
            font-size: 15px;
            color: var(--text);
            resize: none;
            min-height: 120px;
            max-height: 240px;
            line-height: 1.6;
            transition: none;
        }

        textarea::placeholder { color: var(--text-3); }
        textarea:focus {
            outline: none;
            border: none;
            box-shadow: none;
            background: transparent;
        }

        input[type="url"], input[type="text"] {
            width: 100%;
            background: transparent;
            border: none;
            padding: 0;
            font-family: var(--font);
            font-size: 15px;
            color: var(--text);
            line-height: 1.6;
            transition: none;
        }

        input::placeholder { color: var(--text-3); }
        input:focus {
            outline: none;
            border: none;
            box-shadow: none;
            background: transparent;
        }

        .card-footer-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px solid rgba(255, 255, 255, 0.04);
        }

        .char-count {
            font-size: 12px;
            color: var(--text-3);
            font-weight: 600;
        }

        /* ─── Buttons ────────────────────────────────────────────────────────── */
        .action-buttons-row {
            display: flex;
            gap: 12px;
            margin-bottom: 24px;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 12px 24px;
            border-radius: var(--radius-pill);
            font-family: var(--font);
            font-size: 14px;
            font-weight: 700;
            border: none;
            cursor: pointer;
            transition: all 0.2s var(--easing-standard);
            position: relative;
            overflow: hidden;
            white-space: nowrap;
        }

        /* Ripple effect */
        .btn::after {
            content: '';
            position: absolute;
            inset: 0;
            background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
            transform: scale(0);
            opacity: 0;
            transition: transform 0.4s, opacity 0.4s;
        }

        .btn:active::after {
            transform: scale(2.5);
            opacity: 1;
            transition: transform 0s, opacity 0s;
        }

        .btn-primary {
            background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
            color: white;
            box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
            flex: 6.5;
        }

        .btn-primary:hover {
            background: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
            box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
            transform: translateY(-1px);
        }

        .btn-primary:active {
            transform: scale(0.97);
            box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
        }

        .btn-primary:disabled {
            opacity: 0.3;
            background: #1e293b;
            color: var(--text-3);
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }

        .btn-ghost {
            background: transparent;
            color: #ffffff;
            border: 1.5px solid var(--border);
            flex: 3.5;
        }

        .btn-ghost:hover {
            background: rgba(255, 255, 255, 0.03);
            border-color: var(--border-strong);
        }

        .btn-ghost:active {
            transform: scale(0.97);
        }

        .btn svg { width: 15px; height: 15px; }

        /* ─── Features Bar ─────────────────────────────────────────────────── */
        .features-bar {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            padding: 8px 12px;
            margin-top: 12px;
            margin-bottom: 24px;
            overflow-x: auto;
            scrollbar-width: none;
            -ms-overflow-style: none;
        }

        .features-bar::-webkit-scrollbar {
            display: none;
        }

        .feature-pill {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 5px 10px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: 20px;
            white-space: nowrap;
            flex-shrink: 0;
        }

        .feature-pill svg {
            width: 12px;
            height: 12px;
            color: var(--accent);
            flex-shrink: 0;
        }

        .feature-pill-text {
            font-size: 11px;
            font-weight: 600;
            color: var(--text-2);
        }

        @media (max-width: 440px) {
            .features-bar {
                justify-content: flex-start;
                gap: 8px;
                padding: 6px 2px;
            }
        }

        /* ─── Progress bar ──────────────────────────────────────────────────── */
        .progress-wrap {
            width: 100%;
            margin-top: 12px;
            display: none;
        }
        .progress-wrap.visible { display: block; }


        .progress-label {
            font-size: 11px;
            color: var(--text-3);
            margin-bottom: 6px;
            display: flex;
            justify-content: space-between;
            font-weight: 500;
        }

        .progress-track {
            height: 5px;
            background: var(--surface-3);
            border-radius: 3px;
            overflow: hidden;
        }

        .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, var(--accent), #4f8ef7);
            border-radius: 3px;
            width: 0%;
            transition: width 0.4s var(--easing-standard);
        }
        .progress-fill.done { background: var(--green); }

        /* ─── Results ────────────────────────────────────────────────────────── */
        .results { display: none; }
        .results.visible { display: block; }

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

        .results.visible { animation: slideUp 0.35s var(--easing-spring); }

        /* ─── Score card ────────────────────────────────────────────────────── */
        .score-card {
            background: var(--surface);
            border-radius: var(--radius-xl);
            padding: 24px 20px 20px;
            margin-bottom: 14px;
            text-align: center;
            box-shadow: var(--shadow-md);
            border: 1px solid var(--border);
            position: relative;
            overflow: hidden;
        }

        .score-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
            background: var(--score-color, var(--accent));
            opacity: 0.8;
        }

        .score-ring-wrap {
            position: relative;
            width: 120px;
            height: 120px;
            margin: 0 auto 12px;
        }

        .score-ring {
            width: 120px;
            height: 120px;
            transform: rotate(-90deg);
        }

        .score-ring-bg {
            fill: none;
            stroke: var(--surface-3);
            stroke-width: 8;
        }

        .score-ring-fill {
            fill: none;
            stroke: var(--score-color, var(--accent));
            stroke-width: 8;
            stroke-linecap: round;
            stroke-dasharray: 314;
            stroke-dashoffset: 314;
            transition: stroke-dashoffset 1.2s var(--easing-spring);
        }

        .score-ring-inner {
            position: absolute;
            inset: 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .score-number {
            font-size: 42px;
            font-weight: 800;
            color: var(--score-color, var(--accent));
            line-height: 1;
            letter-spacing: -2px;
        }

        .score-denom {
            font-size: 11px;
            color: var(--text-3);
            font-weight: 500;
            margin-top: 1px;
        }

        .score-badge {
            display: inline-flex;
            align-items: center;
            padding: 5px 14px;
            border-radius: var(--radius-pill);
            font-size: 12px;
            font-weight: 700;
            letter-spacing: 0.04em;
            margin-top: 10px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        }

        .score-meta {
            display: flex;
            justify-content: center;
            gap: 0;
            margin-top: 16px;
            padding-top: 16px;
            border-top: 1px solid var(--border);
            background: var(--surface-2);
            margin: 16px -20px -20px;
            border-radius: 0 0 var(--radius-xl) var(--radius-xl);
            overflow: hidden;
        }

        .score-meta-item {
            flex: 1;
            padding: 12px 8px;
            text-align: center;
            border-right: 1px solid var(--border);
        }

        .score-meta-item:last-child { border-right: none; }

        .score-meta-item .label {
            font-size: 9px;
            color: var(--text-3);
            text-transform: uppercase;
            letter-spacing: 0.07em;
            font-weight: 600;
            display: block;
        }

        .score-meta-item .value {
            font-size: 14px;
            font-weight: 700;
            color: var(--text);
            margin-top: 2px;
            display: block;
        }

        /* ─── Info cards ────────────────────────────────────────────────────── */
        .info-card {
            background: var(--surface);
            border-radius: var(--radius-lg);
            padding: 18px;
            margin-bottom: 12px;
            box-shadow: var(--shadow-sm);
            border: 1px solid var(--border);
            transition: box-shadow 0.2s;
        }

        .info-card:hover {
            box-shadow: var(--shadow-md);
        }

        .info-card-header {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 14px;
            font-weight: 700;
            color: var(--text);
            margin-bottom: 14px;
            letter-spacing: -0.1px;
        }

        .icon-box {
            width: 30px;
            height: 30px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .icon-box svg { width: 15px; height: 15px; }

        .explanation-text {
            font-size: 13.5px;
            color: var(--text-2);
            line-height: 1.75;
        }

        /* ─── Manipulation bars ──────────────────────────────────────────────── */
        .manip-bar-wrap { margin-bottom: 10px; }
        .manip-bar-wrap:last-child { margin-bottom: 0; }

        .manip-bar-header {
            display: flex;
            justify-content: space-between;
            font-size: 12px;
            color: var(--text-2);
            margin-bottom: 5px;
            font-weight: 500;
        }

        .manip-bar-header span:last-child { font-weight: 700; }

        .manip-bar-track {
            height: 6px;
            background: var(--surface-3);
            border-radius: 4px;
            overflow: hidden;
        }

        .manip-bar-fill {
            height: 100%;
            border-radius: 4px;
            width: 0%;
            transition: width 0.8s var(--easing-spring);
        }

        /* ─── Red flags ──────────────────────────────────────────────────────── */
        .red-flag-item {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 10px 0;
            border-bottom: 1px solid var(--border);
        }
        .red-flag-item:last-child { border-bottom: none; padding-bottom: 0; }

        .red-flag-weight {
            min-width: 24px;
            height: 24px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 11px;
            font-weight: 800;
            color: white;
            flex-shrink: 0;
            margin-top: 1px;
            box-shadow: 0 1px 4px rgba(0,0,0,0.15);
        }

        .red-flag-indicator { font-size: 13px; font-weight: 600; color: var(--text); }
        .red-flag-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.5; }

        /* ─── Recommendations ────────────────────────────────────────────────── */
        .rec-item {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 8px 0;
            font-size: 13px;
            color: var(--text-2);
            line-height: 1.5;
        }
        .rec-item:first-child { padding-top: 0; }
        .rec-item svg { width: 16px; height: 16px; color: var(--green); flex-shrink: 0; margin-top: 1px; }

        /* ─── Verdict banner ─────────────────────────────────────────────────── */
        .verdict-banner {
            border-radius: var(--radius-lg);
            padding: 16px;
            display: flex;
            align-items: center;
            gap: 14px;
            margin-bottom: 14px;
            border: 1px solid;
            box-shadow: var(--shadow-sm);
        }

        .verdict-banner.safe    { background: var(--green-bg);  border-color: var(--green-light); }
        .verdict-banner.warning { background: var(--yellow-bg); border-color: var(--yellow-light); }
        .verdict-banner.danger  { background: var(--red-bg);    border-color: var(--red-light); }

        .verdict-icon {
            width: 44px;
            height: 44px;
            border-radius: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .verdict-banner.safe   .verdict-icon { background: var(--green-light); }
        .verdict-banner.warning .verdict-icon { background: var(--yellow-light); }
        .verdict-banner.danger  .verdict-icon { background: var(--red-light); }

        .verdict-icon svg { width: 22px; height: 22px; }

        .verdict-title { font-size: 15px; font-weight: 800; letter-spacing: -0.2px; }
        .verdict-banner.safe   .verdict-title { color: var(--green); }
        .verdict-banner.warning .verdict-title { color: var(--yellow); }
        .verdict-banner.danger  .verdict-title { color: var(--red); }

        .verdict-desc { font-size: 12px; color: var(--text-2); margin-top: 3px; line-height: 1.5; }

        /* ─── URL stats ─────────────────────────────────────────────────────── */
        .url-stat-row {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 8px;
            margin-bottom: 14px;
        }

        @media (max-width: 440px) {
            .url-stat-row { grid-template-columns: 1fr 1fr; }
        }

        .url-stat {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            padding: 14px 8px;
            text-align: center;
            box-shadow: var(--shadow-xs);
            transition: box-shadow 0.2s, transform 0.2s var(--easing-spring);
        }

        .url-stat:hover {
            box-shadow: var(--shadow-md);
            transform: translateY(-2px);
        }

        .url-stat .num { font-size: 24px; font-weight: 800; line-height: 1; }
        .url-stat .lbl { font-size: 9px; color: var(--text-3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

        /* ─── Threat items ───────────────────────────────────────────────────── */
        .threat-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 9px 0;
            border-bottom: 1px solid var(--border);
            font-size: 13px;
        }
        .threat-item:last-child { border-bottom: none; }

        .threat-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            flex-shrink: 0;
            box-shadow: 0 0 6px currentColor;
        }

        /* ─── History (inline list in main) ─────────────────────────────────── */
        .history-heading {
            font-size: 13px;
            font-weight: 700;
            color: var(--text-2);
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            letter-spacing: -0.1px;
        }

        .history-list { display: flex; flex-direction: column; gap: 8px; }

        .history-item {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            padding: 13px 14px;
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            transition: all 0.2s var(--easing-standard);
            box-shadow: var(--shadow-xs);
        }

        .history-item:hover {
            border-color: var(--border-strong);
            box-shadow: var(--shadow-md);
            transform: translateY(-1px);
        }

        .history-item:active {
            transform: scale(0.99);
        }

        .history-score {
            min-width: 38px;
            height: 38px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 800;
            flex-shrink: 0;
        }

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

        .history-text {
            font-size: 13px;
            color: var(--text);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-weight: 500;
        }

        .history-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; font-weight: 500; }

        .history-badge {
            font-size: 10px;
            padding: 4px 9px;
            border-radius: var(--radius-pill);
            font-weight: 700;
            text-transform: capitalize;
            flex-shrink: 0;
            letter-spacing: 0.02em;
        }

        /* ─── Empty state ────────────────────────────────────────────────────── */
        .empty-state {
            text-align: center;
            padding: 32px 16px;
            color: var(--text-3);
            font-size: 13px;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
        }

        /* ─── Image upload zone ─────────────────────────────────────────────── */
        .upload-zone {
            background: var(--surface-2);
            border: 2px dashed var(--border-strong);
            border-radius: var(--radius-lg);
            padding: 36px 20px;
            text-align: center;
            cursor: pointer;
            transition: all 0.25s var(--easing-standard);
            min-height: 180px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }

        .upload-zone:hover {
            border-color: var(--accent);
            background: var(--accent-light);
            transform: scale(1.01);
        }

        .upload-zone.dragover {
            border-color: var(--accent);
            background: var(--accent-light);
            box-shadow: 0 0 0 4px var(--accent-glow);
        }

        .upload-zone.has-image {
            border-style: solid;
            border-color: var(--border);
            padding: 14px;
            background: var(--surface-2);
        }

        .upload-zone svg { color: var(--text-3); transition: color 0.2s; }
        .upload-zone:hover svg { color: var(--accent); }

        .upload-label { font-size: 14px; font-weight: 600; color: var(--text-2); }
        .upload-sublabel { font-size: 12px; color: var(--text-3); }

        .upload-preview {
            max-width: 100%;
            max-height: 260px;
            border-radius: var(--radius-md);
            display: block;
        }

        .upload-clear {
            position: absolute;
            top: 10px;
            right: 10px;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background: rgba(15,17,23,0.6);
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 13px;
            transition: background 0.15s, transform 0.15s;
            backdrop-filter: blur(4px);
        }

        .upload-clear:hover { background: rgba(15,17,23,0.8); transform: scale(1.1); }

        .upload-preview-wrap {
            position: relative;
            display: inline-block;
        }

        .ocr-status {
            font-size: 12px;
            color: var(--text-3);
            margin-top: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            font-weight: 500;
        }

        .ocr-status .dot {
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background: var(--text-3);
        }

        .ocr-status.active .dot {
            background: var(--accent);
            animation: pulse 1s ease infinite;
        }

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

        .ocr-confidence {
            font-size: 11px;
            color: var(--text-3);
            margin-top: 5px;
            text-align: center;
            font-weight: 500;
        }

        /* ─── Bottom Navigation Bar ──────────────────────────────────────────── */
        /* ─── Bottom Navigation Bar ──────────────────────────────────────────── */
        .bottom-nav {
            position: fixed;
            bottom: 24px;
            left: 50%;
            transform: translateX(-50%);
            width: calc(100% - 32px);
            max-width: 360px;
            z-index: 50;
        }

        .bottom-nav-inner {
            background: rgba(13, 18, 31, 0.85);
            backdrop-filter: blur(20px) saturate(1.8);
            -webkit-backdrop-filter: blur(20px) saturate(1.8);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 999px;
            padding: 6px;
            display: flex;
            box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 0.5px rgba(255, 255, 255, 0.05);
        }

        .nav-item {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding: 10px 8px;
            border-radius: 999px;
            background: transparent;
            border: none;
            cursor: pointer;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            color: #64748b;
            font-family: var(--font);
            font-weight: 600;
            position: relative;
        }

        .nav-item::after {
            content: '';
            position: absolute;
            inset: 0;
            border-radius: 999px;
            background: currentColor;
            opacity: 0;
            transform: scale(0.8);
            transition: all 0.2s var(--easing-spring);
        }

        .nav-item:hover {
            color: #94a3b8;
        }

        .nav-item.active {
            color: #ffffff;
            background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
            box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
        }

        .nav-item.active::after {
            opacity: 0;
            transform: scale(0);
        }

        .nav-item:active {
            transform: scale(0.95);
        }

        .nav-icon {
            width: 20px;
            height: 20px;
            position: relative;
            z-index: 1;
        }

        .nav-label {
            font-size: 11px;
            font-weight: 700;
            position: relative;
            z-index: 1;
        }

        /* ─── History Page ──────────────────────────────────────────────────── */
        #history-page {
            position: fixed;
            inset: 0;
            background: var(--bg);
            z-index: 100;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            animation: slideUp 0.3s var(--easing-standard);
        }

        .history-page-topbar {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 16px;
            padding-top: max(12px, env(safe-area-inset-top));
            background: var(--surface);
            box-shadow: var(--shadow-sm);
            flex-shrink: 0;
        }

        .topbar-back-btn {
            width: 34px;
            height: 34px;
            border-radius: 10px;
            background: var(--surface-2);
            border: 1px solid var(--border);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-2);
            transition: all 0.2s var(--easing-standard);
            flex-shrink: 0;
        }

        .topbar-back-btn:hover {
            background: var(--surface-3);
            color: var(--text);
        }

        .topbar-back-btn:active {
            transform: scale(0.93);
        }

        .topbar-back-btn svg { width: 16px; height: 16px; }

        .history-page-content {
            flex: 1;
            overflow-y: auto;
            padding: 16px 14px;
            -webkit-overflow-scrolling: touch;
        }

        .history-page-content .history-item {
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            padding: 14px;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            transition: all 0.2s var(--easing-standard);
            box-shadow: var(--shadow-xs);
        }

        .history-page-content .history-item:hover {
            border-color: var(--border-strong);
            box-shadow: var(--shadow-md);
            transform: translateY(-1px);
        }

        .history-page-content .history-item:active {
            transform: scale(0.99);
        }

        .history-page-content .empty-state {
            border-radius: var(--radius-lg);
            margin-top: 8px;
        }

        /* ─── History Filter Bar ─────────────────────────────────────────── */
        .history-filter-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            padding: 10px 14px;
            background: var(--surface);
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
            flex-wrap: wrap;
        }

        .filter-chips {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
        }

        .chip {
            padding: 5px 12px;
            border-radius: var(--radius-pill);
            border: 1px solid var(--border);
            background: var(--surface-2);
            color: var(--text-2);
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.18s var(--easing-standard);
        }

        .chip:hover {
            border-color: var(--accent);
            color: var(--accent);
        }

        .chip.active {
            background: var(--accent);
            border-color: var(--accent);
            color: #fff;
            font-weight: 600;
        }

        .filter-right {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .sort-wrap {
            position: relative;
        }

        .sort-select {
            appearance: none;
            background: var(--surface-2);
            border: 1px solid var(--border);
            border-radius: var(--radius-sm);
            color: var(--text-2);
            font-size: 12px;
            font-weight: 500;
            padding: 5px 28px 5px 10px;
            cursor: pointer;
            transition: all 0.15s;
        }

        .sort-select:hover,
        .sort-select:focus {
            border-color: var(--border-strong);
            color: var(--text);
            outline: none;
        }

        .sort-wrap::after {
            content: '';
            position: absolute;
            right: 10px;
            top: 50%;
            transform: translateY(-50%);
            width: 0;
            height: 0;
            border-left: 4px solid transparent;
            border-right: 4px solid transparent;
            border-top: 5px solid var(--text-3);
            pointer-events: none;
        }

        .clear-all-btn {
            display: flex;
            align-items: center;
            gap: 5px;
            padding: 5px 10px;
            border-radius: var(--radius-sm);
            border: 1px solid var(--border);
            background: transparent;
            color: var(--text-3);
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.18s;
            white-space: nowrap;
        }

        .clear-all-btn:hover {
            border-color: #EF4444;
            color: #EF4444;
            background: rgba(239, 68, 68, 0.08);
        }

        .clear-all-btn:active {
            transform: scale(0.96);
        }

        .clear-all-btn svg {
            width: 13px;
            height: 13px;
        }

        /* ─── Confirmation Dialog ────────────────────────────────────────── */
        .confirm-dialog {
            position: fixed;
            inset: 0;
            z-index: 200;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0 24px;
        }

        .confirm-backdrop {
            position: absolute;
            inset: 0;
            background: rgba(0, 0, 0, 0.55);
            backdrop-filter: blur(4px);
            -webkit-backdrop-filter: blur(4px);
        }

        .confirm-box {
            position: relative;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-xl);
            padding: 28px 24px 24px;
            width: 100%;
            max-width: 320px;
            box-shadow: var(--shadow-xl);
            text-align: center;
            animation: slideUp 0.25s var(--easing-spring);
        }

        .confirm-icon {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            background: rgba(239, 68, 68, 0.12);
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 16px;
        }

        .confirm-icon svg {
            width: 26px;
            height: 26px;
        }

        .confirm-title {
            font-size: 17px;
            font-weight: 700;
            color: var(--text);
            margin-bottom: 8px;
        }

        .confirm-body {
            font-size: 13px;
            color: var(--text-2);
            line-height: 1.5;
            margin-bottom: 24px;
        }

        .confirm-actions {
            display: flex;
            gap: 10px;
        }

        .confirm-actions .btn {
            flex: 1;
            justify-content: center;
        }

        .btn-danger {
            background: #EF4444;
            color: #fff;
            border-color: #EF4444;
        }

        .btn-danger:hover {
            background: #DC2626;
            border-color: #DC2626;
        }

        /* ─── Toast ──────────────────────────────────────────────────────────── */
        .toast {
            position: fixed;
            bottom: 90px;
            left: 16px;
            right: 16px;
            background: rgba(15, 17, 23, 0.92);
            color: white;
            padding: 13px 18px;
            border-radius: var(--radius-md);
            font-size: 13px;
            font-weight: 500;
            z-index: 200;
            transform: translateY(120px);
            transition: transform 0.35s var(--easing-spring);
            text-align: center;
            backdrop-filter: blur(10px);
            box-shadow: 0 4px 20px rgba(0,0,0,0.2);
            max-width: calc(100% - 32px);
            margin: 0 auto;
        }
        .toast.visible { transform: translateY(0); }

        /* ─── Dark mode ─────────────────────────────────────────────────────── */
        @media (prefers-color-scheme: dark) {
            :root {
                --bg: #0f1117;
                --surface: #1a1d26;
                --surface-2: #22262f;
                --surface-3: #2a2f3a;
                --border: #2e3340;
                --border-strong: #3d4355;
                --text: #f0f2f5;
                --text-2: #a8adb8;
                --text-3: #6b7280;
                --nav-bg: rgba(26, 29, 38, 0.88);
                --nav-border: rgba(255,255,255,0.07);
                --accent-glow: rgba(79, 142, 247, 0.2);
            }
        }

        /* ─── Mobile refinements ────────────────────────────────────────────── */
        @media (max-width: 420px) {
            .score-number { font-size: 36px; }
            .score-ring-wrap { width: 100px; height: 100px; }
            .score-ring { width: 100px; height: 100px; }
            .score-ring-bg, .score-ring-fill { stroke-width: 7; }
            .score-ring-fill { stroke-dasharray: 263; stroke-dashoffset: 263; }
        }

        /* ─── Voice Recorder ────────────────────────────────────────────────── */
        .voice-input-card {
            padding: 18px;
        }

        .voice-recorder-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }

        .voice-recorder-title {
            font-size: 15px;
            font-weight: 700;
            color: var(--text);
            line-height: 1.2;
        }

        .voice-recorder-subtitle {
            font-size: 11px;
            color: var(--text-3);
            margin-top: 2px;
            font-weight: 500;
        }

        .waveform-container {
            background: var(--surface-2);
            border: 1px solid var(--border);
            border-radius: var(--radius-lg);
            padding: 12px 8px;
            margin-bottom: 12px;
            min-height: 80px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #waveform-canvas {
            width: 100%;
            max-width: 300px;
            height: 60px;
            border-radius: 8px;
        }

        .waveform-idle-text {
            position: absolute;
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 12px;
            color: var(--text-3);
            font-weight: 500;
        }

        .waveform-idle-text svg {
            color: var(--accent);
            flex-shrink: 0;
        }

        .voice-timer {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            font-size: 13px;
            font-weight: 600;
            color: var(--red);
            margin-bottom: 12px;
        }

        .voice-timer span:first-child {
            font-size: 20px;
            font-weight: 800;
            font-variant-numeric: tabular-nums;
        }

        .recording-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--red);
            animation: blink 1s ease-in-out infinite;
        }

        @keyframes blink {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.3; transform: scale(0.8); }
        }

        .voice-transcript-preview {
            background: var(--surface-2);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            padding: 12px;
            margin-bottom: 8px;
        }

        .voice-transcript-label {
            display: flex;
            align-items: center;
            gap: 5px;
            font-size: 10px;
            font-weight: 700;
            color: var(--accent);
            text-transform: uppercase;
            letter-spacing: 0.08em;
            margin-bottom: 6px;
        }

        .voice-transcript-text {
            font-size: 13px;
            color: var(--text-2);
            line-height: 1.6;
            max-height: 100px;
            overflow-y: auto;
        }

        .voice-buttons-row {
            display: flex;
            gap: 12px;
            margin-bottom: 24px;
        }

        .voice-buttons-row .btn-ghost {
            flex: 3.5;
        }

        .voice-buttons-row .btn-primary {
            flex: 6.5;
        }

        #voice-record-btn {
            background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
        }

        /* ─── Radar Chart ───────────────────────────────────────────────────── */
        .radar-chart-wrap {
            display: flex;
            align-items: center;
            gap: 16px;
            margin-bottom: 14px;
            flex-wrap: wrap;
        }

        .radar-svg {
            width: 160px;
            height: 160px;
            flex-shrink: 0;
        }

        .radar-legend {
            display: flex;
            flex-direction: column;
            gap: 7px;
        }

        .radar-legend-item {
            display: flex;
            align-items: center;
            gap: 7px;
            font-size: 12px;
            font-weight: 500;
            color: var(--text-2);
        }

        .radar-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            flex-shrink: 0;
        }

        /* ─── Compact manipulation bars (in radar card) ──────────────────────── */
        .manip-bars-compact .manip-bar-wrap {
            margin-bottom: 8px;
        }

        .manip-bars-compact .manip-bar-wrap:last-child {
            margin-bottom: 0;
        }

        .manip-bars-compact .manip-bar-track {
            height: 5px;
        }

        @media (max-width: 380px) {
            .radar-chart-wrap {
                flex-direction: column;
                align-items: flex-start;
            }
            .radar-svg {
                width: 140px;
                height: 140px;
            }
        }
