/* ═══════════════════════════════════════════
   Coding AI — Premium chat workspace
   ═══════════════════════════════════════════ */

:root {
    --cai-bg: #06070d;
    --cai-surface: rgba(14, 17, 28, 0.88);
    --cai-surface-2: rgba(20, 24, 38, 0.92);
    --cai-border: rgba(148, 163, 184, 0.1);
    --cai-border-strong: rgba(148, 163, 184, 0.18);
    --cai-text: #eef2f7;
    --cai-muted: #94a3b8;
    --cai-accent: #818cf8;
    --cai-accent-2: #22d3ee;
    --cai-user: linear-gradient(135deg, #6366f1 0%, #a855f7 55%, #ec4899 100%);
    --cai-ai: linear-gradient(135deg, #10b981 0%, #06b6d4 50%, #6366f1 100%);
    --cai-glow: rgba(99, 102, 241, 0.35);
    --cai-radius: 18px;
    --cai-font: "Tajawal", "Cairo", system-ui, sans-serif;
    --cai-mono: "IBM Plex Mono", Consolas, Monaco, monospace;
}

.cai-shell {
    min-height: 100vh;
    color: var(--cai-text);
    font-family: var(--cai-font);
    background:
        radial-gradient(ellipse 100% 80% at 50% -30%, rgba(99, 102, 241, 0.22), transparent 55%),
        radial-gradient(ellipse 60% 50% at 100% 20%, rgba(236, 72, 153, 0.12), transparent 50%),
        radial-gradient(ellipse 55% 45% at 0% 80%, rgba(16, 185, 129, 0.1), transparent 50%),
        linear-gradient(180deg, #080a12 0%, var(--cai-bg) 100%);
    position: relative;
    overflow: hidden;
}

body.coding-ai-page #root > div:first-child {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
}

body.coding-ai-page .rcx-glass-home-back {
    display: inline-flex;
}

body.coding-ai-page .cai-shell {
    padding-top: calc(52px + env(safe-area-inset-top, 0px));
    min-height: 100vh;
}

body.coding-ai-page .cai-workspace {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0 6px 6px;
}

body.coding-ai-page .cai-app {
    min-height: calc(100vh - 52px - env(safe-area-inset-top, 0px) - 6px);
    max-height: calc(100vh - 52px - env(safe-area-inset-top, 0px) - 6px);
    border-radius: 16px;
    border: 1px solid rgba(129, 140, 248, 0.16);
    background: rgba(8, 10, 18, 0.55);
    backdrop-filter: blur(18px) saturate(150%);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 28px 80px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.cai-shell--ready {
    animation: caiShellFadeIn 0.45s ease-out both;
}

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

/* ── Boot / loading screen ── */
.cai-boot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cai-bg);
    color: var(--cai-text);
    overflow: hidden;
    font-family: var(--cai-font);
}

.cai-boot--fullscreen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(ellipse 80% 50% at 15% -10%, rgba(99, 102, 241, 0.28), transparent 55%),
        radial-gradient(ellipse 60% 40% at 90% 0%, rgba(236, 72, 153, 0.16), transparent 50%),
        radial-gradient(ellipse 55% 45% at 0% 100%, rgba(34, 211, 238, 0.12), transparent 50%),
        var(--cai-bg);
}

.cai-boot__glow {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.05) 1px, transparent 1px);
    background-size: 44px 44px;
    opacity: 0.65;
    pointer-events: none;
}

.cai-boot__inner {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 32px 24px;
    max-width: 340px;
}

.cai-boot__icon {
    width: 76px;
    height: 76px;
    margin: 0 auto 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(236, 72, 153, 0.22));
    border: 1px solid rgba(129, 140, 248, 0.4);
    font-size: 1.75rem;
    color: #c4b5fd;
    box-shadow: 0 16px 48px rgba(99, 102, 241, 0.28);
    animation: caiBootPulse 2s ease-in-out infinite;
}

.cai-boot__brand {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    background: linear-gradient(105deg, #fafafa 0%, #c4b5fd 45%, #22d3ee 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 10px;
}

.cai-boot__text {
    margin: 0 0 24px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--cai-muted);
}

.cai-boot__bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 99px;
    margin-bottom: 18px;
    overflow: hidden;
}

.cai-boot__bar-fill {
    display: block;
    height: 100%;
    width: 42%;
    border-radius: 99px;
    background: linear-gradient(90deg, #6366f1, #ec4899, #22d3ee);
    animation: caiBootBar 1.25s ease-in-out infinite;
}

.cai-boot__dots {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.cai-boot__dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #818cf8;
    opacity: 0.35;
    animation: caiBootDot 1.2s ease-in-out infinite;
}

.cai-boot__dots span:nth-child(2) { animation-delay: 0.15s; background: #a78bfa; }
.cai-boot__dots span:nth-child(3) { animation-delay: 0.3s; background: #22d3ee; }

@keyframes caiBootPulse {
    0%, 100% { transform: translateY(0); box-shadow: 0 16px 48px rgba(99, 102, 241, 0.28); }
    50% { transform: translateY(-5px); box-shadow: 0 22px 56px rgba(99, 102, 241, 0.4); }
}

@keyframes caiBootBar {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(320%); }
}

@keyframes caiBootDot {
    0%, 100% { opacity: 0.25; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .cai-boot__icon,
    .cai-boot__bar-fill,
    .cai-boot__dots span,
    .cai-shell--ready {
        animation: none;
    }
}

.cai-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, black, transparent);
    pointer-events: none;
}

.cai-shell--with-nav {
    margin-left: 0;
    width: 100%;
    min-height: 100vh;
}

@media (max-width: 768px) {
    .cai-shell--with-nav {
        margin-left: 0;
        width: 100%;
    }
}

/* ── Gate screens ── */
.cai-gate {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    z-index: 1;
}

.cai-gate__card {
    width: 100%;
    max-width: 480px;
    border: 1px solid var(--cai-border-strong);
    background: var(--cai-surface);
    backdrop-filter: blur(24px) saturate(160%);
    border-radius: 24px;
    padding: 28px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 40px 100px rgba(0, 0, 0, 0.55);
    animation: cai-rise 0.5s ease;
}

@keyframes cai-rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.cai-gate__head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.cai-gate__icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: #fff;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.cai-gate__icon--ai {
    background: var(--cai-ai);
    box-shadow: 0 12px 32px rgba(6, 182, 212, 0.25);
}

.cai-gate__icon--warn {
    background: linear-gradient(135deg, #f97316, #ef4444);
}

.cai-gate__title {
    font-weight: 800;
    font-size: 1.2rem;
    margin: 0 0 4px;
    letter-spacing: -0.02em;
}

.cai-gate__sub {
    color: var(--cai-muted);
    font-size: 0.88rem;
    margin: 0;
}

.cai-gate__body {
    border: 1px solid var(--cai-border);
    background: rgba(8, 10, 18, 0.6);
    border-radius: 14px;
    padding: 16px;
    color: #cbd5e1;
    line-height: 1.7;
    font-size: 0.9rem;
}

.cai-gate__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.cai-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.cai-btn:hover {
    transform: translateY(-2px);
}

.cai-btn--primary {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    box-shadow: 0 12px 32px rgba(79, 70, 229, 0.35);
}

.cai-btn--ghost {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--cai-border-strong);
    color: var(--cai-text);
}

.cai-btn--outline {
    background: transparent;
    border-color: var(--cai-border-strong);
    color: var(--cai-muted);
}

.cai-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22d3ee;
    box-shadow: 0 0 12px #22d3ee;
    animation: cai-pulse 1.4s ease-in-out infinite;
}

@keyframes cai-pulse {
    0%, 100% { opacity: 0.5; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.15); }
}

/* ── App layout ── */
.cai-app {
    display: flex;
    min-height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.cai-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 4, 12, 0.72);
    backdrop-filter: blur(4px);
    z-index: 40;
}

/* Sidebar */
.cai-chats {
    width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--cai-border);
    background: rgba(8, 10, 18, 0.82);
    backdrop-filter: blur(20px) saturate(150%);
    z-index: 50;
}

.cai-chats--mobile {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    box-shadow: 24px 0 80px rgba(0, 0, 0, 0.5);
    animation: cai-slide-in 0.25s ease;
}

@keyframes cai-slide-in {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@media (max-width: 900px) {
    .cai-chats:not(.cai-chats--open) {
        display: none;
    }
}

.cai-chats__head {
    padding: 18px 16px;
    border-bottom: 1px solid var(--cai-border);
}

.cai-chats__brand {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.cai-chats__logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cai-chats__logo-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--cai-ai);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 10px 28px rgba(6, 182, 212, 0.22);
    position: relative;
}

.cai-chats__logo-icon::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    pointer-events: none;
}

.cai-chats__logo-text {
    font-weight: 800;
    font-size: 0.98rem;
    letter-spacing: -0.01em;
}

.cai-chats__lang {
    font-size: 0.72rem;
    color: var(--cai-muted);
    margin-top: 2px;
}

.cai-badge {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    border-radius: 999px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    white-space: nowrap;
}

.cai-badge--free {
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
}

.cai-badge--premium {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.25);
}

.cai-new-chat {
    width: 100%;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid rgba(129, 140, 248, 0.35);
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.9), rgba(124, 58, 237, 0.85));
    color: #fff;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    box-shadow: 0 10px 32px rgba(79, 70, 229, 0.28);
    transition: transform 0.15s ease, opacity 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cai-new-chat:hover:not(:disabled) {
    transform: translateY(-1px);
}

.cai-new-chat:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: rgba(148, 163, 184, 0.1);
    box-shadow: none;
    border-color: var(--cai-border);
}

.cai-limits {
    margin-top: 10px;
    font-size: 0.72rem;
    color: var(--cai-muted);
    line-height: 1.5;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed var(--cai-border);
}

.cai-limits--warn { color: #fca5a5; border-color: rgba(248, 113, 113, 0.25); background: rgba(239, 68, 68, 0.08); }
.cai-limits--gold { color: #fde68a; border-color: rgba(251, 191, 36, 0.25); background: rgba(245, 158, 11, 0.08); }

.cai-chats__list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cai-chats__list::-webkit-scrollbar,
.cai-messages::-webkit-scrollbar {
    width: 6px;
}

.cai-chats__list::-webkit-scrollbar-thumb,
.cai-messages::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 999px;
}

.cai-chat-item {
    text-align: left;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.03);
    color: var(--cai-text);
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.cai-chat-item:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(129, 140, 248, 0.25);
}

.cai-chat-item--active {
    background: rgba(99, 102, 241, 0.16);
    border-color: rgba(129, 140, 248, 0.4);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.15);
}

.cai-chat-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cai-chat-item__title {
    font-size: 0.84rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cai-chat-item__meta {
    margin-top: 4px;
    font-size: 0.68rem;
    color: var(--cai-muted);
}

/* Main column */
.cai-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
}

.cai-topbar {
    height: 72px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--cai-border);
    background: rgba(8, 10, 18, 0.65);
    backdrop-filter: blur(16px) saturate(160%);
}

.cai-topbar__left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.cai-topbar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.cai-topbar__brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--cai-ai);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 0.95rem;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(6, 182, 212, 0.2);
}

.cai-topbar__brand-text {
    min-width: 0;
}

.cai-topbar__title {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.cai-topbar__subtitle {
    font-size: 0.72rem;
    color: var(--cai-muted);
    margin: 0;
}

.cai-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1px solid var(--cai-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--cai-muted);
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.cai-icon-btn:hover {
    background: rgba(99, 102, 241, 0.12);
    color: var(--cai-text);
    border-color: rgba(129, 140, 248, 0.3);
}

.cai-topbar__right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.cai-sub-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    font-weight: 800;
    border-radius: 999px;
    padding: 5px 12px;
    border: 1px solid var(--cai-border);
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
}

.cai-sub-pill img {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    object-fit: cover;
}

.cai-lang-tag {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--cai-muted);
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--cai-border);
    background: rgba(255, 255, 255, 0.03);
}

.cai-status-pill {
    font-size: 0.68rem;
    font-weight: 700;
    color: #86efac;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.25);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cai-status-pill__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

/* Disclaimer — compact strip */
.cai-disclaimer {
    flex-shrink: 0;
    padding: 10px 20px 0;
}

.cai-disclaimer__inner {
    max-width: min(1200px, 96%);
    margin: 0 auto;
    border: 1px solid rgba(167, 139, 250, 0.2);
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.08), rgba(15, 23, 42, 0.5));
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cai-disclaimer__icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: rgba(167, 139, 250, 0.15);
    display: grid;
    place-items: center;
    color: #c4b5fd;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.cai-disclaimer__label {
    display: none;
}

.cai-disclaimer__text {
    font-size: 0.76rem;
    color: #b8c5d9;
    line-height: 1.5;
    margin: 0;
}

.cai-disclaimer__inner--comfort .cai-disclaimer__icon {
    background: rgba(167, 139, 250, 0.18);
    color: #c4b5fd;
}

/* Welcome hero */
.cai-welcome {
    position: relative;
    margin-bottom: 12px;
    padding: 28px 24px 22px;
    border-radius: 24px;
    border: 1px solid rgba(129, 140, 248, 0.2);
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.15), transparent 70%),
        rgba(12, 15, 26, 0.85);
    text-align: center;
    overflow: hidden;
    animation: cai-rise 0.6s ease;
}

.cai-welcome__glow {
    position: absolute;
    inset: -50%;
    background: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.08), transparent 50%);
    pointer-events: none;
    animation: cai-glow-spin 20s linear infinite;
}

@keyframes cai-glow-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.cai-welcome__icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    font-size: 1.5rem;
    color: #fff;
    background: linear-gradient(135deg, #818cf8, #c084fc, #f472b6);
    box-shadow: 0 20px 50px rgba(129, 140, 248, 0.35);
    position: relative;
    z-index: 1;
}

.cai-welcome__title {
    margin: 0 0 8px;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 1;
}

.cai-welcome__sub {
    margin: 0 auto 20px;
    max-width: 480px;
    font-size: 0.9rem;
    color: var(--cai-muted);
    line-height: 1.65;
    position: relative;
    z-index: 1;
}

.cai-prompt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.cai-prompt-card {
    text-align: left;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid var(--cai-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--cai-text);
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.2s ease;
}

.cai-prompt-card:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: rgba(129, 140, 248, 0.35);
    background: rgba(99, 102, 241, 0.1);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.cai-prompt-card:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.cai-prompt-card__icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.cai-prompt-card__icon--bac { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.cai-prompt-card__icon--search { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
.cai-prompt-card__icon--psy { background: rgba(244, 114, 182, 0.2); color: #f9a8d4; }
.cai-prompt-card__icon--food { background: rgba(52, 211, 153, 0.2); color: #6ee7b7; }
.cai-prompt-card__icon--friend { background: rgba(251, 191, 36, 0.2); color: #fde68a; }

.cai-prompt-card__label {
    font-size: 0.82rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.cai-prompt-card__hint {
    font-size: 0.68rem;
    color: var(--cai-muted);
    line-height: 1.4;
}

.cai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.cai-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    border-radius: 999px;
    border: 1px solid var(--cai-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--cai-text);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.cai-chip:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(129, 140, 248, 0.4);
}

.cai-chip:disabled { opacity: 0.45; cursor: not-allowed; }

.cai-chip--mini {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: 12px;
}

.cai-syntax-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px dashed var(--cai-border-strong);
    background: transparent;
    color: var(--cai-muted);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.cai-syntax-toggle:hover {
    color: var(--cai-text);
    border-color: rgba(129, 140, 248, 0.4);
}

.cai-syntax-panel {
    margin-top: 14px;
    text-align: left;
    border: 1px solid var(--cai-border);
    border-radius: 14px;
    padding: 12px;
    background: rgba(8, 10, 18, 0.6);
    display: grid;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.cai-syntax-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--cai-muted);
    flex-wrap: wrap;
}

.cai-syntax-row code {
    font-family: var(--cai-mono);
    font-size: 0.74rem;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 6px;
    padding: 3px 8px;
    flex-shrink: 0;
}

.cai-composer__chips {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.cai-composer__hint code {
    font-family: var(--cai-mono);
    font-size: 0.68rem;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
}

/* Messages */
.cai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px 12px;
    scroll-behavior: smooth;
}

.cai-messages__inner {
    max-width: min(1200px, 96%);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.cai-msg {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: cai-msg-in 0.35s ease;
}

@keyframes cai-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.cai-msg__avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: #fff;
    position: relative;
}

.cai-msg__avatar--ai {
    background: var(--cai-ai);
    box-shadow: 0 8px 24px rgba(6, 182, 212, 0.2);
}

.cai-msg__avatar--ai::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 15px;
    background: conic-gradient(from 180deg, #6366f1, #22d3ee, #10b981, #6366f1);
    z-index: -1;
    opacity: 0.45;
    filter: blur(4px);
}

.cai-msg__avatar--user {
    background: var(--cai-user);
    box-shadow: 0 8px 24px rgba(168, 85, 247, 0.25);
}

.cai-msg__bubble {
    max-width: min(94%, 920px);
    border-radius: var(--cai-radius);
    padding: 16px 20px;
    border: 1px solid var(--cai-border);
    position: relative;
}

.cai-msg--assistant .cai-msg__bubble {
    background: var(--cai-surface-2);
    border-color: rgba(129, 140, 248, 0.15);
    border-top-left-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.cai-msg--user .cai-msg__bubble {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(168, 85, 247, 0.16));
    border-color: rgba(168, 85, 247, 0.25);
    border-top-right-radius: 6px;
}

.cai-msg__role {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--cai-muted);
    margin-bottom: 8px;
}

.cai-msg--assistant .cai-msg__role { color: #a5b4fc; }
.cai-msg--user .cai-msg__role { color: #e9d5ff; text-align: right; }

.cai-msg__text {
    font-size: 1.02rem;
    line-height: 1.8;
    direction: auto;
    unicode-bidi: plaintext;
    word-break: break-word;
    white-space: pre-wrap;
    color: #e8edf5;
}

.cai-msg__file {
    margin-top: 10px;
    font-size: 0.78rem;
    color: #93c5fd;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Structured sections */
.cai-section {
    margin: 12px 0;
    border-radius: 14px;
    border: 1px solid var(--cai-border);
    overflow: hidden;
}

.cai-section__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--cai-border);
}

.cai-section__body {
    padding: 12px 14px;
    font-size: 0.88rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.cai-section--explain .cai-section__head { background: rgba(59, 130, 246, 0.12); color: #93c5fd; }
.cai-section--algo .cai-section__head { background: rgba(139, 92, 246, 0.12); color: #c4b5fd; }
.cai-section--how .cai-section__head { background: rgba(34, 197, 94, 0.1); color: #86efac; }
.cai-section--output .cai-section__head { background: rgba(15, 23, 42, 0.9); color: #94a3b8; }
.cai-section--output .cai-section__body {
    font-family: var(--cai-mono);
    font-size: 0.82rem;
    background: #0a0f1a;
    color: #67e8f9;
}
.cai-section--psych .cai-section__head { background: rgba(244, 114, 182, 0.12); color: #f9a8d4; }
.cai-section--food .cai-section__head { background: rgba(52, 211, 153, 0.12); color: #6ee7b7; }

.cai-code {
    margin: 12px 0;
    border: 1px solid rgba(51, 65, 85, 0.8);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.cai-code__head {
    background: #0b1220;
    border-bottom: 1px solid rgba(51, 65, 85, 0.8);
    color: #9ca3af;
    font-size: 0.72rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
}

.cai-code__lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: #e2e8f0;
    text-transform: uppercase;
}

.cai-code__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cai-code__btn {
    border: 1px solid #334155;
    background: #111827;
    color: #cbd5e1;
    border-radius: 8px;
    padding: 5px 11px;
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background 0.15s ease;
}

.cai-code__btn:hover { background: #1e293b; }

.cai-code__btn--try {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.4), rgba(124, 58, 237, 0.35));
    border-color: rgba(129, 140, 248, 0.4);
    color: #e0e7ff;
}

.cai-code__copy {
    border: 1px solid #334155;
    background: #111827;
    color: #cbd5e1;
    border-radius: 8px;
    padding: 5px 11px;
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 600;
}

.cai-code pre {
    margin: 0;
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px;
    overflow-x: auto;
    font-family: var(--cai-mono);
    font-size: 0.82rem;
    line-height: 1.5;
}

.cai-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 12px 22px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.96);
    border: 1px solid rgba(129, 140, 248, 0.35);
    color: var(--cai-text);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    animation: cai-toast-in 0.3s ease;
}

@keyframes cai-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.cai-thinking {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--cai-muted);
    font-size: 0.88rem;
    padding: 8px 0;
    animation: cai-msg-in 0.3s ease;
}

.cai-thinking__bubble {
    padding: 12px 18px;
    border-radius: 16px;
    border: 1px solid var(--cai-border);
    background: var(--cai-surface);
    display: flex;
    align-items: center;
    gap: 10px;
}

.cai-thinking__dots span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cai-accent);
    margin-right: 3px;
    animation: cai-dot 1.2s ease-in-out infinite;
}

.cai-thinking__dots span:nth-child(2) { animation-delay: 0.15s; }
.cai-thinking__dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cai-dot {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-5px); }
}

/* Composer — floating pill */
.cai-composer {
    flex-shrink: 0;
    padding: 12px 16px 20px;
    background: linear-gradient(180deg, transparent, rgba(6, 7, 13, 0.85) 30%);
}

.cai-composer__inner {
    max-width: min(1200px, 96%);
    margin: 0 auto;
}

.cai-attachment {
    margin-bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--cai-border);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.78rem;
}

.cai-attachment button {
    border: 0;
    background: transparent;
    color: #fca5a5;
    cursor: pointer;
}

.cai-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    border: 1px solid rgba(129, 140, 248, 0.22);
    background: rgba(12, 15, 26, 0.95);
    border-radius: 20px;
    padding: 10px 10px 10px 12px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 20px 60px rgba(0, 0, 0, 0.35),
        0 0 40px rgba(99, 102, 241, 0.08);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cai-input-row:focus-within {
    border-color: rgba(129, 140, 248, 0.45);
    box-shadow:
        0 0 0 1px rgba(129, 140, 248, 0.15) inset,
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 48px rgba(99, 102, 241, 0.15);
}

.cai-input-row textarea,
.cai-input-row input[type="text"] {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--cai-text);
    outline: none;
    font-size: 1.05rem;
    font-family: var(--cai-font);
    direction: auto;
    unicode-bidi: plaintext;
    resize: none;
    min-height: 28px;
    max-height: 160px;
    line-height: 1.5;
    padding: 6px 4px;
}

.cai-send {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    font-size: 0.95rem;
    box-shadow: 0 10px 28px rgba(79, 70, 229, 0.35);
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.cai-send:hover:not(:disabled) {
    transform: scale(1.05);
}

.cai-send:disabled {
    background: rgba(148, 163, 184, 0.15);
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.6;
}

.cai-composer__hint {
    margin-top: 10px;
    font-size: 0.68rem;
    color: #64748b;
    text-align: center;
    line-height: 1.5;
}

@media (max-width: 640px) {
    .cai-prompt-grid {
        grid-template-columns: 1fr 1fr;
    }

    .cai-topbar__kicker {
        display: none;
    }

    body.coding-ai-page .cai-workspace {
        padding: 0;
    }

    body.coding-ai-page .cai-app {
        border-radius: 0;
        border-left: none;
        border-right: none;
        min-height: calc(100vh - 52px - env(safe-area-inset-top, 0px));
        max-height: calc(100vh - 52px - env(safe-area-inset-top, 0px));
    }

    .cai-disclaimer {
        display: none;
    }

    .cai-msg__bubble {
        max-width: 92%;
    }

    .cai-gate__features {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════
   Interface refresh — workspace UI
   ═══════════════════════════════════════════ */

.cai-chats__section {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 12px;
}

.cai-chats {
    border-right: 1px solid rgba(129, 140, 248, 0.12);
    background:
        linear-gradient(180deg, rgba(99, 102, 241, 0.06) 0%, transparent 120px),
        rgba(6, 8, 16, 0.92);
}

.cai-chat-item {
    position: relative;
    overflow: hidden;
}

.cai-chat-item--active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 99px;
    background: linear-gradient(180deg, #818cf8, #22d3ee);
}

.cai-topbar {
    height: 72px;
    border-bottom: 1px solid rgba(129, 140, 248, 0.12);
    background: rgba(6, 8, 16, 0.72);
}

.cai-topbar__kicker {
    margin: 0 0 2px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #64748b;
}

.cai-topbar__title {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(105deg, #f8fafc 0%, #c4b5fd 45%, #22d3ee 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.cai-topbar__brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.28);
}

.cai-icon-btn--menu {
    border-color: rgba(129, 140, 248, 0.22);
    background: rgba(99, 102, 241, 0.08);
    color: #c4b5fd;
}

.cai-messages {
    padding: 24px 28px 12px;
    mask-image: linear-gradient(180deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent 100%);
}

.cai-welcome__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(129, 140, 248, 0.28);
    background: rgba(99, 102, 241, 0.12);
    color: #c4b5fd;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 14px;
    position: relative;
    z-index: 1;
}

.cai-welcome {
    border: 1px solid rgba(129, 140, 248, 0.22);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.cai-prompt-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    max-width: 1000px;
    margin-left: auto;
    margin-right: auto;
}

.cai-prompt-card {
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    padding: 18px;
}

.cai-msg--assistant .cai-msg__bubble {
    background:
        linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(12, 18, 32, 0.88));
    border-color: rgba(129, 140, 248, 0.18);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.cai-msg--user .cai-msg__bubble {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.28), rgba(168, 85, 247, 0.2));
    border-color: rgba(168, 85, 247, 0.32);
    box-shadow: 0 12px 36px rgba(99, 102, 241, 0.15);
}

.cai-msg__avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
}

.cai-welcome {
    padding: 36px 32px 28px;
}

.cai-welcome__title {
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.cai-welcome__sub {
    font-size: 1rem;
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.cai-prompt-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.cai-prompt-card {
    padding: 18px;
}

.cai-prompt-card__label {
    font-size: 0.92rem;
}

.cai-input-row textarea,
.cai-input-row input[type="text"] {
    font-size: 1.05rem;
    min-height: 28px;
    max-height: 160px;
}

.cai-send {
    width: 50px;
    height: 50px;
    border-radius: 16px;
}

.cai-composer {
    padding: 0 28px 20px;
    background: transparent;
}

.cai-composer__dock {
    max-width: min(1200px, 96%);
    margin: 0 auto;
    padding: 18px 18px 12px;
    border-radius: 24px;
    border: 1px solid rgba(129, 140, 248, 0.18);
    background:
        linear-gradient(180deg, rgba(12, 15, 26, 0.96), rgba(8, 10, 18, 0.98));
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 -20px 60px rgba(0, 0, 0, 0.35),
        0 0 48px rgba(99, 102, 241, 0.1);
}

.cai-input-row {
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: rgba(4, 6, 14, 0.85);
    border-radius: 18px;
    padding: 12px 12px 12px 14px;
    box-shadow: none;
}

.cai-input-row:focus-within {
    border-color: rgba(129, 140, 248, 0.4);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.cai-send {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.35);
}

.cai-gate__card--login {
    max-width: 620px;
    padding: 0;
    overflow: hidden;
}

.cai-gate__hero {
    position: relative;
    text-align: center;
    padding: 36px 28px 24px;
    border-bottom: 1px solid rgba(129, 140, 248, 0.12);
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.2), transparent 70%),
        rgba(8, 10, 18, 0.6);
}

.cai-gate__orb {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.35), transparent 70%);
    filter: blur(24px);
    pointer-events: none;
}

.cai-gate__hero .cai-gate__icon {
    margin: 0 auto 16px;
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
}

.cai-gate__hero .cai-gate__title {
    font-size: 1.45rem;
    margin-bottom: 8px;
    background: linear-gradient(105deg, #f8fafc, #c4b5fd, #22d3ee);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.cai-gate__features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 18px 20px 0;
}

.cai-gate__feat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    border-radius: 14px;
    border: 1px solid rgba(129, 140, 248, 0.14);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.72rem;
    font-weight: 700;
    color: #cbd5e1;
    text-align: center;
    line-height: 1.35;
}

.cai-gate__feat i {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.14);
    color: #c4b5fd;
    font-size: 0.9rem;
}

.cai-gate__card--login .cai-gate__body {
    margin: 16px 20px 0;
    text-align: center;
    line-height: 1.65;
}

.cai-gate__card--login .cai-gate__actions {
    padding: 20px;
}

@media (min-width: 1400px) {
    .cai-messages__inner,
    .cai-composer__inner,
    .cai-composer__dock,
    .cai-disclaimer__inner {
        max-width: min(1400px, 96%);
    }

    .cai-msg__bubble {
        max-width: min(94%, 1000px);
    }
}
