:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --text-main: #0f172a;
    --text-muted: #475569;
    --border-color: #cbd5e1;
    --border-focus: #3b82f6;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: #fef2f2;

    --email-bg: #f0fdf4;  --email-txt: #166534;  --email-brd: #bbf7d0;
    --phone-bg: #f0f9ff;  --phone-txt: #075985;  --phone-brd: #bae6fd;
    --ip-bg: #fff5f5;     --ip-txt: #991b1b;     --ip-brd: #fee2e2;
    --custom-bg: #fffbeb; --custom-txt: #92400e; --custom-brd: #fde68a;

    --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: Inter, system-ui, -apple-system, sans-serif;
}

/* ==========================================================================
   1. MOBILE OPTIMIZED VIEW (DEFAULT)
   ========================================================================== */
body {
    background-color: var(--bg-page);
    color: var(--text-main);
    padding: 0.5rem;
    line-height: 1.4;
    display: flex;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    width: 100%;
    max-width: 100%;
    background-color: var(--bg-card);
    padding: 0.85rem; 
    border-radius: 8px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.step-flow-container {
    display: flex;
    flex-direction: column;
}

.step-block {
    margin-bottom: 1.25rem; 
}

.step-body {
    width: 100%;
}

/* সেকশন হেডার যেখানে ২টি আলাদা চাইল্ড এলিমেন্ট আছে (Title + Button/Badge) */
.step-title-row, 
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem; 
    gap: 0.5rem;
}

/* সব হেডিংয়ের জন্য স্ট্যান্ডার্ড লেফট-আলাইনড বেস স্টাইল (ফিক্সড টাইটেল স্প্লিট বাগ) */
h2 {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 0.9rem; /* মোবাইলের জন্য ক্লিয়ার ও রিডেবল সাইজ */
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.01em;
    margin-bottom: 0.65rem; /* বক্স ও টাইটেলের সমান দূরত্ব নিশ্চিত করে */
}

/* যেখানে টাইটেল ছাড়া অন্য এলিমেন্ট নেই, সেখানে ওভাররাইড মার্জিন হ্যান্ডলিং */
.step-title-row h2,
.report-header h2 {
    margin-bottom: 0; 
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background-color: var(--primary-light);
    color: var(--primary);
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 0.45rem;
    flex-shrink: 0;
}

.import-btn {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.45rem;
    border-radius: 5px;
    transition: var(--transition-smooth);
    white-space: nowrap;
    flex-shrink: 0;
}

.import-btn:hover {
    background-color: var(--bg-page);
}

.import-btn svg {
    width: 11px;
    height: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

textarea {
    width: 100%;
    height: 145px; 
    padding: 0.65rem; 
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem; /* মোবাইল ফ্রেন্ডলি ইনপুট সাইজ */
    outline: none;
    resize: vertical;
    color: var(--text-main);
    transition: var(--transition-smooth);
}

textarea::placeholder {
    color: #94a3b8;
    font-size: 0.82rem;
}

textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

textarea::-webkit-scrollbar, .detected-display-box::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
textarea::-webkit-scrollbar-thumb, .detected-display-box::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 2px;
}

.textarea-counter {
    text-align: right;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.keyword-input-row {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.45rem;
}

.keyword-input-row input {
    flex: 1;
    padding: 0.5rem 0.65rem; 
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

.keyword-input-row input::placeholder {
    color: #94a3b8;
    font-size: 0.82rem;
}

.keyword-input-row input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.btn-inline-add {
    padding: 0 0.85rem;
    background-color: #f1f5f9;
    color: #334155;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-inline-add:hover {
    background-color: #e2e8f0;
    color: var(--text-main);
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.tag {
    background: #f1f5f9;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    border: 1px solid #e2e8f0;
}

.tag button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
}

.badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.05rem 0.35rem;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    border: 1px solid #dbeafe;
}

.detected-display-box {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-height: 65px; 
    max-height: 120px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem; 
    background-color: #f8fafc;
    margin-bottom: 0.55rem;
    align-content: flex-start;
    overflow-y: auto;
}

.empty-placeholder {
    width: 100%;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    text-align: center;
}

.empty-placeholder svg {
    width: 14px;
    height: 14px;
    stroke: #94a3b8;
}

.pii-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding-left: 0.45rem;
    padding-right: 0.1rem;
    height: 24px;
    border-radius: 4px;
    background: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

.type-tag {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.01rem 0.12rem;
    border-radius: 2px;
}

.pii-pill:has(.type-email) { border: 1px solid var(--email-brd); background: var(--email-bg); }
.pii-pill:has(.type-phone) { border: 1px solid var(--phone-brd); background: var(--phone-bg); }
.pii-pill:has(.type-ip) { border: 1px solid var(--ip-brd); background: var(--ip-bg); }
.pii-pill:has(.type-custom) { border: 1px solid var(--custom-brd); background: var(--custom-bg); }

.type-email { color: var(--email-txt); background: rgba(22, 101, 52, 0.05); }
.type-phone { color: var(--phone-txt); background: rgba(7, 89, 133, 0.05); }
.type-ip { color: var(--ip-txt); background: rgba(153, 27, 27, 0.05); }
.type-custom { color: var(--custom-txt); background: rgba(146, 64, 14, 0.05); }

.pill-value {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pill-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--danger);
    font-size: 1.1rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
    min-width: 20px;
    height: 100%;
    border-radius: 0 2px 2px 0;
    transition: var(--transition-smooth);
}

.pill-close:hover {
    color: var(--danger-hover);
    background-color: rgba(220, 38, 38, 0.05);
}

.btn {
    padding: 0.55rem 0.45rem; 
    border: 1px solid transparent;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.78rem; 
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    transition: var(--transition-smooth);
    white-space: nowrap; 
}

.btn-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.btn-primary { background-color: var(--primary); color: white; font-size: 0.85rem; padding: 0.6rem 0.85rem; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background: #ffffff; color: var(--text-main); border-color: var(--border-color); width: 100%; }
.btn-secondary:hover { background-color: var(--bg-page); }
.btn-danger { background: var(--danger-light); color: var(--danger); border-color: #fecaca; width: 100%; font-size: 0.85rem; }
.btn-danger:hover { background-color: var(--danger); color: white; }

.btn-full {
    width: 100%;
}

.actions-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

#reset-btn {
    grid-column: span 2;
    padding: 0.6rem 0.85rem;
}


/* ==========================================================================
   2. DESKTOP VIEW
   ========================================================================== */
@media (min-width: 768px) {
    body {
        padding: 2.5rem 1.5rem;
    }

    .app-container {
        max-width: 820px;
        padding: 2.5rem;
        border: 1px solid #e2e8f0;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    }

    .step-block {
        margin-bottom: 1.75rem;
    }

    .step-title-row, 
    .report-header {
        margin-bottom: 0.75rem;
    }

    h2 {
        font-size: 1.15rem;
        margin-bottom: 0.75rem;
    }
    
    .step-title-row h2,
    .report-header h2 {
        margin-bottom: 0; 
    }

    .step-num {
        width: 22px;
        height: 22px;
        font-size: 0.8rem;
        margin-right: 0.55rem;
        border-radius: 5px;
    }

    .import-btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.65rem;
    }

    textarea {
        height: 160px;
        font-size: 0.95rem;
        padding: 0.85rem;
    }
    
    textarea::placeholder {
        font-size: 0.92rem;
    }

    .keyword-input-row input {
        font-size: 0.95rem;
        padding: 0.6rem 0.85rem;
    }
    
    .keyword-input-row input::placeholder {
        font-size: 0.92rem;
    }

    .btn-inline-add {
        font-size: 0.9rem;
        padding: 0 1.25rem;
    }

    .detected-display-box {
        min-height: 100px;
        max-height: 200px;
        padding: 0.85rem;
        margin-bottom: 0.75rem;
    }

    .empty-placeholder {
        font-size: 0.85rem;
    }

    .pill-value {
        font-size: 0.85rem;
        max-width: 170px;
    }

    .btn {
        font-size: 0.9rem;
        padding: 0.65rem 1.25rem;
    }

    .actions-row {
        display: flex;
        flex-direction: row;
        gap: 0.5rem;
    }

    .actions-row .btn {
        width: auto;
    }
    
    #reset-btn {
        grid-column: auto;
        margin-left: auto;
    }
}