/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    --bg:           #0a192f;
    --surface:      #0f2746;
    --surface-alt:  #112952;
    --cyan:         #00d4ff;
    --green:        #00ff9d;
    --text:         #e6f1ff;
    --text-muted:   #a3b1c6;
    --border:       rgba(0,212,255,0.25);
    --glow:         rgba(0,212,255,0.12);
    --radius:       10px;
    --transition:   0.25s ease;
}

/* Tool content container */
.tool-input-area {
    max-width: 1300px;
    margin: 0 auto 24px;
    padding: 0 20px;
}

.tool-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px 56px;
    font-size: 18px;
    line-height: 1.65;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    text-align: center;
    padding: 52px 0 36px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 40px;
}

.page-header .tool-badge {
    display: inline-block;
    background: rgba(0,212,255,0.1);
    border: 1px solid var(--cyan);
    color: var(--cyan);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 5px 14px;
    border-radius: 20px;
    margin-bottom: 16px;
}

.page-header h1 {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--cyan);
    margin-bottom: 14px;
    line-height: 1.2;
    border-bottom: none;
    display: block;
}

.page-header p {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 560px;
    margin: 0 auto 10px;
}

kbd {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: inherit;
    font-size: 0.85rem;
}

/* ============================================================
   CARD
   ============================================================ */
.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 30px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px var(--glow);
}

.tool-card h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--cyan);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* ============================================================
   INPUTS
   ============================================================ */
.input-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    align-items: start;
    margin-bottom: 20px;
}

.input-group { display: flex; flex-direction: column; }

.input-group label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
}

.input-group .hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.5;
}

#email-input,
#sender-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

#email-input {
    min-height: 220px;
    resize: vertical;
    line-height: 1.65;
}

#email-input::placeholder,
#sender-input::placeholder { color: var(--text-muted); opacity: 0.6; }

#email-input:focus,
#sender-input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0,212,255,0.15);
}

.button-row {
    display: flex;
    gap: 14px;
    margin-top: 18px;
    flex-wrap: wrap;
}

/* ============================================================
   TOOL BUTTONS
   ============================================================ */
.tool-btn {
    padding: 15px 34px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: filter var(--transition), transform 0.1s;
    display: inline-block;
}

.tool-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.tool-btn:active { transform: scale(0.97); }

.tool-btn-primary {
    background: linear-gradient(135deg, var(--cyan), var(--green));
    color: var(--bg);
    min-width: 180px;
}

.tool-btn-primary:hover { filter: brightness(1.1); text-decoration: none; }

.tool-btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.tool-btn-secondary:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    text-decoration: none;
}

/* ============================================================
   RESULTS
   ============================================================ */
#results { display: none; }

#risk-badge-wrap { margin-bottom: 24px; }

.risk-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 18px 28px;
    border-radius: var(--radius);
    font-size: 1.3rem;
    font-weight: 700;
    border-width: 1px;
    border-style: solid;
}

.badge-icon { font-size: 1.6rem; }

.risk-high   { background: rgba(255,80,60,0.12);  color: #ff6b5b;       border-color: #ff4a3a; }
.risk-medium { background: rgba(255,180,0,0.1);   color: #ffc845;       border-color: #e09000; }
.risk-low    { background: rgba(0,255,157,0.1);   color: var(--green);  border-color: var(--green); }

/* ============================================================
   SCORE BAR
   ============================================================ */
.score-label { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 10px; }
.score-label strong { color: var(--text); }

.score-bar-track {
    background: rgba(255,255,255,0.07);
    border-radius: 14px;
    height: 18px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.score-bar-fill {
    height: 100%;
    border-radius: 14px;
    transition: width 0.7s cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   FLAGS
   ============================================================ */
.flag-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(163,177,198,0.1);
}
.flag-item:last-child { border-bottom: none; }

.flag-dot {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.dot-urgency   { background: #e09000; box-shadow: 0 0 6px rgba(224,144,0,0.5); }
.dot-financial { background: #ff4a3a; box-shadow: 0 0 6px rgba(255,74,58,0.5); }
.dot-personal  { background: #b06aff; box-shadow: 0 0 6px rgba(176,106,255,0.5); }
.dot-url       { background: var(--cyan); box-shadow: 0 0 6px rgba(0,212,255,0.5); }
.dot-format    { background: var(--green); box-shadow: 0 0 6px rgba(0,255,157,0.4); }
.dot-address   { background: #ff4a3a; box-shadow: 0 0 6px rgba(255,74,58,0.6); }

.flag-category    { font-weight: 600; font-size: 1rem; color: var(--text); margin-bottom: 5px; }
.flag-explanation { color: var(--text-muted); font-size: 0.93rem; line-height: 1.6; }
.flag-matches     { margin-top: 9px; font-size: 0.88rem; color: var(--text-muted); }
.flag-matches-label { margin-right: 4px; }

.match-chip {
    display: inline-block;
    background: rgba(0,212,255,0.08);
    border: 1px solid rgba(0,212,255,0.25);
    border-radius: 4px;
    padding: 2px 9px;
    margin: 2px 2px 2px 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.86rem;
    color: var(--cyan);
}

/* ============================================================
   HIGHLIGHTED EMAIL
   ============================================================ */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0; }

#email-display {
    font-size: 0.93rem;
    line-height: 1.9;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Poppins', sans-serif;
    padding: 20px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    color: var(--text);
}

mark { border-radius: 3px; padding: 1px 3px; font-weight: 700; background: unset; }
mark.hl-urgency   { background: rgba(224,144,0,0.25);   color: #ffcc44; outline: 1px solid rgba(224,144,0,0.6); }
mark.hl-financial { background: rgba(255,74,58,0.2);    color: #ff8070; outline: 1px solid rgba(255,74,58,0.5); }
mark.hl-personal  { background: rgba(176,106,255,0.2);  color: #c89fff; outline: 1px solid rgba(176,106,255,0.5); }
mark.hl-url       { background: rgba(0,212,255,0.18);   color: #60e8ff; outline: 1px solid rgba(0,212,255,0.5); }
mark.hl-format    { background: rgba(0,255,157,0.15);   color: #50ffb8; outline: 1px solid rgba(0,255,157,0.4); }

/* ============================================================
   SENDER ADDRESS
   ============================================================ */
.addr-flag {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(163,177,198,0.1);
}
.addr-flag:last-child { border-bottom: none; }

.addr-parsed {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}
.addr-part { color: var(--text-muted); }
.addr-part strong { color: var(--text); }
.addr-part .addr-value { font-family: 'Courier New', monospace; color: var(--cyan); }

/* ============================================================
   ADVICE
   ============================================================ */
.advice-card {
    border-radius: var(--radius);
    padding: 28px 30px;
    margin-bottom: 24px;
    border-width: 1px;
    border-style: solid;
}
.advice-card h2   { font-size: 1.15rem; font-weight: 700; margin-bottom: 18px; border-bottom: none; }
.advice-card ul   { padding-left: 24px; }
.advice-card li   { margin-bottom: 11px; line-height: 1.65; font-size: 0.97rem; color: var(--text-muted); }
.advice-card li strong { color: var(--text); }

.advice-high   { background: rgba(255,74,58,0.07);   border-color: rgba(255,74,58,0.4); }
.advice-high h2   { color: #ff6b5b; }
.advice-medium { background: rgba(255,180,0,0.07);   border-color: rgba(224,144,0,0.4); }
.advice-medium h2 { color: #ffc845; }
.advice-low    { background: rgba(0,255,157,0.06);   border-color: rgba(0,255,157,0.35); }
.advice-low h2    { color: var(--green); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 680px) {
    .input-row { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
    .tool-wrap { font-size: 17px; }
    .page-header h1 { font-size: 1.75rem; }
    .risk-badge { font-size: 1.1rem; padding: 14px 18px; }
    .tool-btn { width: 100%; text-align: center; }
    .button-row { flex-direction: column; }
    .tool-card, .advice-card { padding: 20px 18px; }
}
