:root {
    --bg-main: #131314;
    --bg-sidebar: #1e1f20;
    --bg-input: #1e1f20;
    --text-main: #e3e3e3;
    --text-dim: #b4b4b4;
    --accent-blue: #8ab4f8;
    --accent-purple: #c58af9;
    --border-color: #333333;
    --hover-color: #2b2c2d;
    --sidebar-width: 280px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
}

h1, h2, h3, .logo span {
    font-family: 'Outfit', sans-serif;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar-header {
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
    padding-left: 5px;
}

.logo-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(45deg, #4285f4, #9b72cb, #d96570);
    border-radius: 50%;
    animation: pulse 4s infinite alternate;
}

.logo span {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 15px;
    border-radius: 25px;
    border: none;
    background-color: #2b2c2d;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background-color: #37393b;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.history-label {
    font-size: 12px;
    color: var(--text-dim);
    margin: 20px 0 10px 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.history-item {
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s;
}

.history-item:hover {
    background-color: var(--hover-color);
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 32px;
    height: 32px;
    background-color: #5c5e60;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.chat-header {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 18px;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
}

.sidebar-toggle:hover {
    background-color: var(--hover-color);
}

.current-model {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
}

.current-model:hover {
    background-color: var(--hover-color);
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 60px;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.welcome-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding-bottom: 100px;
}

.welcome-screen h1 {
    font-size: clamp(32px, 5vw, 56px);
    background: linear-gradient(135deg, #8ab4f8 0%, #c58af9 50%, #f98a96 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 15px;
    font-weight: 700;
    letter-spacing: -1px;
    filter: drop-shadow(0px 4px 12px rgba(197, 138, 249, 0.15));
}

.welcome-screen p {
    font-size: clamp(16px, 3vw, 24px);
    color: var(--text-dim);
    margin-bottom: 40px;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    width: 100%;
}

.card {
    background: linear-gradient(145deg, rgba(43,44,45,0.7), rgba(30,31,32,0.4));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 24px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 140px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.card:hover {
    background: linear-gradient(145deg, rgba(55,57,59,0.8), rgba(43,44,45,0.6));
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 25px rgba(138, 180, 248, 0.15);
    border-color: rgba(138, 180, 248, 0.3);
}

.card i {
    font-size: 24px;
    color: var(--accent-blue);
}

.card span {
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.4;
}

/* Chat Messages */
.message {
    margin-bottom: 30px;
    display: flex;
    gap: 20px;
    animation: fadeIn 0.4s ease;
}

.message-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-icon {
    background-color: #5c5e60;
}

.message.ai .message-icon {
    background: linear-gradient(45deg, #4285f4, #9b72cb);
}

.message-content {
    font-size: 16px;
    line-height: 1.6;
    padding-top: 6px;
}

.message-content pre {
    background-color: #2b2c2d;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
    overflow-x: auto;
}

.message-content code {
    font-family: 'Consolas', monospace;
    font-size: 14px;
}

.trace-link {
    margin-top: 10px;
    display: inline-block;
    color: var(--accent-blue);
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
}

.trace-link:hover {
    text-decoration: underline;
}

/* Input Area */
.input-container {
    padding: 20px 60px 40px;
    background-color: var(--bg-main);
}

.input-wrapper {
    background-color: var(--bg-input);
    border-radius: 32px;
    padding: 12px 24px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border: 1px solid transparent;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: #444;
}

#user-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 16px;
    padding: 8px 0;
    resize: none;
    outline: none;
    max-height: 200px;
    font-family: inherit;
}

.input-actions {
    display: flex;
    gap: 5px;
    padding-bottom: 5px;
}

.send-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.send-btn:not(:disabled) {
    color: var(--accent-blue);
}

.send-btn:not(:disabled):hover {
    background-color: #2b2c2d;
}

.disclaimer {
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    margin-top: 15px;
}

/* Trace Drawer */
.trace-drawer {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.trace-drawer.open {
    right: 0;
}

.trace-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.trace-header h3 {
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
}

.trace-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.trace-item {
    margin-bottom: 20px;
}

.trace-item label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 5px;
    font-weight: 600;
}

.trace-value {
    font-family: 'Consolas', monospace;
    font-size: 13px;
    background-color: #131314;
    padding: 10px;
    border-radius: 6px;
    word-break: break-all;
}

.decision-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}

.decision-badge.ALLOW { background-color: #0d3d1e; color: #81c995; }
.decision-badge.BLOCK { background-color: #3b1111; color: #f28b82; }
.decision-badge.REDACT { background-color: #3b2b11; color: #fdd663; }

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); filter: blur(0px); }
    100% { transform: scale(1.1); filter: blur(1px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 24px;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-dim);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .messages-container {
        padding: 20px;
    }
    .input-container {
        padding: 20px;
    }
    .welcome-screen h1 {
        font-size: 36px;
    }
    .trace-drawer {
        width: 100%;
        right: -100%;
    }
}

/* ── Health Status Bar ─────────────────────────────────────────────────── */
.health-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(30, 31, 32, 0.7);
    backdrop-filter: blur(8px);
    min-height: 44px;
}

.health-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.health-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.health-pill.ok {
    background: rgba(22, 101, 52, 0.3);
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.2);
}

.health-pill.ok i { color: #4ade80; font-size: 7px; }

.health-pill.err {
    background: rgba(127, 29, 29, 0.35);
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.2);
    animation: pulse-err 2s infinite;
}

.health-pill.err i { color: #f87171; font-size: 7px; }

.health-pill.checking {
    background: rgba(30, 31, 32, 0.5);
    color: var(--text-dim);
    border-color: var(--border-color);
}

.health-pill.checking i { color: var(--text-dim); font-size: 7px; animation: typing 1.4s infinite; }

@keyframes pulse-err {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

/* ── Sidebar Toggle Button ─────────────────────────────────────────────── */
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: var(--hover-color);
    color: var(--text-main);
}

/* ── ConversalX UI ──────────────────────────────────────────────────────── */

/* Active session highlight */
.history-item.active {
  background: #334155 !important;
  border-left: 3px solid #8ab4f8;
  padding-left: calc(12px - 3px);
}

.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease;
}

/* ── Error Card ────────────────────────────────────────────────────────── */
.error-card {
    background: linear-gradient(135deg, rgba(30,31,32,0.9), rgba(20,21,22,0.95));
    border: 1px solid var(--card-accent, #ef4444);
    border-left: 4px solid var(--card-accent, #ef4444);
    border-radius: 12px;
    padding: 16px 20px;
    max-width: 560px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    animation: fadeIn 0.3s ease;
}

.error-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 15px;
}

.error-card-desc {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 12px;
    line-height: 1.5;
}

.error-card-steps {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;
}

.error-card-steps li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    line-height: 1.5;
}

.step-num {
    background: rgba(255,255,255,0.08);
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.error-card-steps code {
    background: rgba(255,255,255,0.06);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    color: #93c5fd;
}

/* Role Selector */
.sidebar-section {
    margin-bottom: 20px;
}

.sidebar-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 8px;
    font-weight: 600;
}

.role-select {
    width: 100%;
    background-color: #2b2c2d;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.role-select:focus { border-color: #555; }

/* Suggestion cards */
.suggestions-group {
    margin-bottom: 28px;
}

.suggestions-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.suggestion-card {
    background: linear-gradient(145deg, rgba(43,44,45,0.6), rgba(30,31,32,0.3));
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px 20px;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.suggestion-card:hover {
    background: linear-gradient(145deg, rgba(55,57,59,0.8), rgba(43,44,45,0.5));
    border-color: rgba(138, 180, 248, 0.4);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(138, 180, 248, 0.15);
}

.suggestion-card i {
    color: var(--accent-blue);
    font-size: 16px;
}

.close-trace-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.close-trace-btn:hover { background: var(--hover-color); }

/* ── Download Report Action Button ───────────────────────────────────────── */
.download-report-btn {
    width: 100%;
    margin-top: 12px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(96, 165, 250, 0.05));
    border: 1px solid rgba(96, 165, 250, 0.25);
    color: #60a5fa;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.download-report-btn:hover {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.25), rgba(96, 165, 250, 0.1));
    border-color: #60a5fa;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.15);
}

.download-report-btn:active {
    transform: translateY(0);
}

/* ── Identity Panel ─────────────────────────────────────────────────────── */
.identity-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: border-color 0.3s;
}

.identity-card:has(.verified) {
    border-color: rgba(74, 222, 128, 0.25);
    background: rgba(74, 222, 128, 0.04);
}

.identity-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--text-dim);
    flex-shrink: 0;
    transition: all 0.4s;
}

.identity-info {
    flex: 1;
    min-width: 0;
}

.identity-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.identity-role {
    margin-top: 4px;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid;
    letter-spacing: 0.3px;
    transition: all 0.3s;
}

.role-badge.unverified {
    color: var(--text-dim);
    border-color: var(--border-color);
    background: rgba(255,255,255,0.03);
}

.role-badge.verified {
    /* color/border/bg set inline via JS */
}

/* ── Policy Note ─────────────────────────────────────────────────────────── */
.policy-note {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-dim);
    padding: 8px 0;
    opacity: 0.7;
}

.policy-note i {
    color: #8ab4f8;
    font-size: 13px;
}

/* ── Welcome subtitle ────────────────────────────────────────────────────── */
.welcome-sub {
    font-size: 15px !important;
    color: var(--text-dim);
    margin-top: -25px !important;
    margin-bottom: 32px !important;
    opacity: 0.8;
}

/* ── Decision badge extra states ─────────────────────────────────────────── */
.decision-badge.PROCEED { background-color: #0d3d1e; color: #81c995; }
.decision-badge.PROCEED_WITH_CONDITIONS { background-color: #1a3300; color: #b5e48c; }
.decision-badge.ALLOW  { background-color: #0d3d1e; color: #81c995; }
.decision-badge.BLOCK  { background-color: #3b1111; color: #f28b82; }
.decision-badge.DENY   { background-color: #3b1111; color: #f28b82; }
.decision-badge.REDACT { background-color: #3b2b11; color: #fdd663; }

/* ── Sidebar footer ──────────────────────────────────────────────────────── */
.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}
/ *   M a r k d o w n   T a b l e s   * /   . m e s s a g e - c o n t e n t   t a b l e   {   b o r d e r - c o l l a p s e :   c o l l a p s e ;   w i d t h :   1 0 0 % ;   m a r g i n :   1 0 p x   0 ;   f o n t - s i z e :   0 . 9 e m ;   b o r d e r - r a d i u s :   6 p x ;   o v e r f l o w :   h i d d e n ;   }   . m e s s a g e - c o n t e n t   t h ,   . m e s s a g e - c o n t e n t   t d   {   b o r d e r :   1 p x   s o l i d   r g b a ( 2 5 5 ,   2 5 5 ,   2 5 5 ,   0 . 1 ) ;   p a d d i n g :   8 p x   1 2 p x ;   t e x t - a l i g n :   l e f t ;   }   . m e s s a g e - c o n t e n t   t h   {   b a c k g r o u n d - c o l o r :   r g b a ( 2 5 5 ,   2 5 5 ,   2 5 5 ,   0 . 0 5 ) ;   f o n t - w e i g h t :   6 0 0 ;   c o l o r :   # f f f ;   }   . m e s s a g e - c o n t e n t   t r : n t h - c h i l d ( e v e n )   {   b a c k g r o u n d - c o l o r :   r g b a ( 2 5 5 ,   2 5 5 ,   2 5 5 ,   0 . 0 2 ) ;   }  
 