/* ═══════════════════════════════════════════════════════════════════
   AI Writer — Native Port CSS
   Faithfully mirrors the original AI Workstation (Next.js + Tailwind)
   ═══════════════════════════════════════════════════════════════════ */

/* ── CSS Variables (from globals.css) ─────────────────────────────── */
#aiWriterNativeContainer {
    --brand-600: #0d9488;
    --brand-500: #14b8a6;
    --brand-400: #2dd4bf;
    --brand-100: #ccfbf1;
    --brand-50: #f0fdfa;
    --brand-800: #115e59;
    --brand-900: #134e4a;
    --bg: #f8fafc;
    --fg: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(0, 0, 0, 0.05);
}

/* ── Root Container ──────────────────────────────────────────────── */
#aiWriterNativeContainer {
    display: none;
    flex: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    background: var(--bg);
    flex-direction: row;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#aiWriterNativeContainer.flex {
    display: flex !important;
}

/* ── Scrollbar (matching original) ───────────────────────────────── */
#aiWriterNativeContainer ::-webkit-scrollbar { width: 4px; height: 4px; }
#aiWriterNativeContainer ::-webkit-scrollbar-track { background: transparent; }
#aiWriterNativeContainer ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 99px; }
#aiWriterNativeContainer ::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.3); }

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR — Mirrors Sidebar.tsx
   ══════════════════════════════════════════════════════════════════ */
.aiw-sidebar {
    width: 256px;  /* md:w-64 = 16rem = 256px */
    background: #fbfbfb;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    z-index: 20;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.02);
    flex-shrink: 0;
}

.aiw-sidebar-header {
    padding: 20px;  /* p-5 = 20px */
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Brand Title — "Articent Intelligence" */
.aiw-brand {
    display: flex;
    align-items: center;
    gap: 6px;  /* gap-1.5 */
    margin-left: -8px;
    margin-right: -16px;
}

.aiw-brand-title {
    font-family: Roboto, system-ui, sans-serif;
    font-weight: 600;
    font-size: 22px;
    color: var(--brand-600);
    letter-spacing: -0.025em;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s;
}
.aiw-brand-title:hover { opacity: 0.8; }

/* Search Row */
.aiw-search-row {
    display: flex;
    align-items: center;
    gap: 12px;  /* gap-3 */
}

.aiw-search-box {
    flex: 1;
    position: relative;
}

.aiw-search-icon {
    position: absolute;
    left: 14px;  /* pl-3.5 */
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: rgba(0, 0, 0, 0.4);
    transition: color 0.2s;
    display: flex;
}

.aiw-search-box:focus-within .aiw-search-icon {
    color: var(--brand-600);
}

.aiw-search-box input {
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid transparent;
    border-radius: 9999px;
    padding-left: 40px;
    padding-right: 16px;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    transition: all 0.3s;
    color: #0f172a;
    box-sizing: border-box;
}
.aiw-search-box input::placeholder { color: rgba(0, 0, 0, 0.4); }
.aiw-search-box input:hover { background: rgba(0, 0, 0, 0.08); }
.aiw-search-box input:focus {
    background: transparent;
    border-color: rgba(13, 148, 136, 0.4);
}

/* New Chat FAB */
.aiw-new-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;  /* rounded-[18px] */
    background: rgba(13, 148, 136, 0.15);
    color: var(--brand-600);
    border: none;
    cursor: pointer;
    transition: all 0.3s;
}
.aiw-new-btn:hover {
    background: rgba(13, 148, 136, 0.25);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.aiw-new-btn:active { transform: scale(0.95); }
.aiw-new-btn svg {
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.aiw-new-btn:hover svg {
    transform: rotate(180deg) scale(1.1);
}

/* Session History List */
.aiw-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Session item — now a flex ROW container (group hover pattern) */
.aiw-history-item {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    border-radius: 12px;
    transition: all 0.2s;
    color: #0f172a;
    opacity: 0.7;
    background: transparent;
    overflow: hidden;
}

.aiw-history-item:hover {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
}

.aiw-history-item.active {
    background: rgba(13, 148, 136, 0.1);
    font-weight: 600;
    color: var(--brand-600);
    opacity: 1;
}

/* The clickable text portion of the session item */
.aiw-history-link {
    flex: 1;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    background: transparent;
    color: inherit;
    font-family: inherit;
    text-align: left;
    transition: padding-right 0.2s;
    display: block;
}

.aiw-history-item:hover .aiw-history-link {
    padding-right: 68px; /* make room for action buttons */
}

/* Action buttons (Rename + Delete) — hidden by default, shown on hover */
.aiw-history-actions {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 20;
}

.aiw-history-item:hover .aiw-history-actions {
    opacity: 1;
}

.aiw-history-action-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: currentColor;
    transition: all 0.15s;
    flex-shrink: 0;
}

.aiw-history-action-btn:hover { background: rgba(255,255,255,0.2); }
.aiw-history-action-btn.delete:hover { background: rgba(239, 68, 68, 0.8); color: white; }
.aiw-history-action-btn svg { width: 12px; height: 12px; }

/* Sidebar Footer */
.aiw-sidebar-footer {
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.aiw-icon-btn {
    position: relative;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: transparent;
    border: none;
    color: rgba(0, 0, 0, 0.6);
    cursor: pointer;
    transition: all 0.2s;
}
.aiw-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #0f172a;
    transform: scale(1.05);
}
.aiw-icon-btn:active { transform: scale(0.95); }
.aiw-icon-btn svg { width: 20px; height: 20px; }

/* Admin button — teal accent */
.aiw-icon-btn.admin {
    color: var(--brand-600);
}
.aiw-icon-btn.admin:hover {
    background: rgba(13, 148, 136, 0.1);
    color: var(--brand-600);
}

/* Tooltip on hover for footer icon buttons */
.aiw-icon-btn .aiw-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    font-weight: 700;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 50;
}
.aiw-icon-btn .aiw-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
}
.aiw-icon-btn:hover .aiw-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}
/* Last button tooltip — align right to avoid overflow */
.aiw-icon-btn.tooltip-right .aiw-tooltip {
    left: auto;
    right: 0;
    transform: scale(0.95);
    transform-origin: bottom right;
}
.aiw-icon-btn.tooltip-right:hover .aiw-tooltip {
    transform: scale(1);
}
.aiw-icon-btn.tooltip-right .aiw-tooltip::after {
    left: auto;
    right: 16px;
    transform: none;
}

/* ══════════════════════════════════════════════════════════════════
   MAIN AREA — Mirrors ChatInterface.tsx
   ══════════════════════════════════════════════════════════════════ */
.aiw-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg);
    overflow: hidden;
}

/* Ambient Animated Background Glows */
.aiw-radial-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -10%;
    overflow: hidden;
    opacity: 0.8;
}

.aiw-radial-bg div:nth-child(1) {
    position: absolute; top: 15%; left: 5%; width: 500px; height: 500px;
    background: radial-gradient(circle at center, rgba(13,148,136,0.12) 0%, transparent 70%);
    animation: pulseGlowAmbient 4s ease-in-out infinite;
}
.aiw-radial-bg div:nth-child(2) {
    position: absolute; top: 5%; right: 5%; width: 450px; height: 450px;
    background: radial-gradient(circle at center, rgba(20,184,166,0.1) 0%, transparent 70%);
    animation: pulseGlowAmbient 6s ease-in-out 1s infinite;
}
.aiw-radial-bg div:nth-child(3) {
    position: absolute; bottom: 10%; left: 20%; width: 600px; height: 600px;
    background: radial-gradient(circle at center, rgba(15,118,110,0.08) 0%, transparent 65%);
    animation: pulseGlowAmbient 5s ease-in-out 2s infinite;
}

@keyframes pulseGlowAmbient {
    0%, 100% { transform: scale(1) translateY(0); opacity: 0.8; }
    50% { transform: scale(1.05) translateY(2%); opacity: 1; }
}

/* Dot pattern background (matching body::after from globals.css) */
.aiw-main::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: radial-gradient(#0f172a 1px, transparent 1px);
    background-size: 24px 24px;
    opacity: 0.025;
    mask-image: radial-gradient(circle at 50% 30%, black 20%, transparent 90%);
    -webkit-mask-image: radial-gradient(circle at 50% 30%, black 20%, transparent 90%);
}

/* Top-right user avatar */
.aiw-top-right {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 50;
}

.aiw-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f99052;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
}

/* ── Scrollable Content / Chat Area ──────────────────────────────── */
.aiw-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow-y: auto;
    padding: 32px 16px 150px 16px;  /* pt-8, pb-[150px] */
    scroll-behavior: smooth;
    position: relative;
}

/* ── Welcome / Empty State ───────────────────────────────────────── */
.aiw-welcome {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 672px;  /* max-w-2xl */
    margin: 0 auto;
    z-index: 10;
    padding: 0 16px;
    padding-bottom: 22vh;
    animation: fadeInUp 0.4s ease-out both;
}

.aiw-greeting {
    font-size: 24px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.4);
    margin-bottom: 12px;
    animation: fadeInUp 0.4s ease-out 100ms both;
}

.aiw-title {
    font-size: 44px;
    font-weight: 700;
    background: linear-gradient(to right, #0d9488, #0f766e);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.025em;
    line-height: 1.2;
    margin-bottom: 32px;
    animation: fadeInUp 0.4s ease-out 150ms both;
    width: 100%;
    padding: 0 8px;
}

.aiw-subtitle {
    max-width: 70%;
    margin: 0 auto;
    font-size: 16px;
    line-height: 1.8;
    color: rgba(0, 0, 0, 0.5);
    font-weight: 400;
    animation: fadeInUp 0.4s ease-out 200ms both;
}

.aiw-cursor {
    display: inline-block;
    width: 3px;
    height: 1.1em;
    background-color: rgba(13, 148, 136, 0.8);
    vertical-align: text-bottom;
    margin-left: 4px;
    border-radius: 1px;
    box-shadow: 0 0 8px rgba(13, 148, 136, 0.5);
    animation: blink 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ── Animations ──────────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Messages ────────────────────────────────────────────────────── */
.aiw-messages {
    max-width: 768px;  /* max-w-3xl */
    margin: 0 auto;
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 48px;  /* space-y-12 = 3rem */
}

.aiw-msg-row {
    display: flex;
    width: 100%;
    animation: fadeInUp 0.4s ease-out both;
}

.aiw-msg-row.user {
    justify-content: flex-end;
}
.aiw-msg-row.assistant {
    justify-content: flex-start;
}

/* User Bubble */
.aiw-msg-row.user .aiw-bubble {
    max-width: 82%;
    word-break: break-word;
    padding: 10px 20px;
    background: var(--brand-600);
    color: white;
    border-radius: 22px;
    border-top-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.2s;
}
.aiw-msg-row.user .aiw-bubble:hover {
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
    transform: translateY(-2px);
}
.aiw-msg-row.user .aiw-bubble:active {
    transform: scale(0.98);
}

/* AI / Assistant Bubble */
.aiw-msg-row.assistant .aiw-msg-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding-left: 8px;
}
.aiw-msg-row.assistant .aiw-msg-meta .aiw-meta-name {
    font-size: 13px;
    font-weight: 700;
    font-family: monospace, system-ui;
    color: rgba(0, 0, 0, 0.5);
    letter-spacing: -0.025em;
}
.aiw-msg-row.assistant .aiw-msg-meta .aiw-meta-time {
    font-size: 10px;
    font-family: monospace;
    letter-spacing: 0.05em;
    color: rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
}
.aiw-msg-row.assistant .aiw-msg-meta .aiw-meta-duration {
    font-size: 9px;
    font-family: monospace;
    font-weight: 700;
    color: rgba(13, 148, 136, 0.6);
    background: rgba(13, 148, 136, 0.1);
    padding: 2px 6px;
    border-radius: 6px;
}

.aiw-msg-row.assistant .aiw-bubble {
    max-width: 85%;
    word-break: break-word;
    overflow-x: hidden;
    padding: 10px 20px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: #4b5563;
    border-radius: 22px;
    border-top-left-radius: 4px;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    letter-spacing: 0.01em;
}

/* Message Timestamp (below user bubble) */
.aiw-msg-time {
    font-size: 11px;
    font-family: monospace;
    letter-spacing: 0.05em;
    color: rgba(0, 0, 0, 0.3);
    margin-top: 8px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: opacity 0.3s;
    opacity: 0;
    padding: 0 4px;
}
.aiw-msg-row.user .aiw-msg-time { justify-content: flex-end; }
.aiw-msg-row:hover .aiw-msg-time { opacity: 1; }

/* Message Action Buttons */
.aiw-msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    padding-left: 4px;
    opacity: 0;
    transition: opacity 0.3s;
}
.aiw-msg-row:hover .aiw-msg-actions { opacity: 1; }

.aiw-action-btn {
    background: transparent;
    border: none;
    color: rgba(0, 0, 0, 0.4);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}
.aiw-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.7);
}
.aiw-action-btn:active { transform: scale(0.95); }

/* ══════════════════════════════════════════════════════════════════
   INPUT CONTAINER — Glassmorphic Elevation Card 
   Mirrors the bottom input area in ChatInterface.tsx
   ══════════════════════════════════════════════════════════════════ */
.aiw-input-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 64px 16px 24px 16px;  /* pt-16 pb-6 px-4 */
    z-index: 30;
    pointer-events: none;
    background: linear-gradient(to top, var(--bg) 50%, rgba(248, 250, 252, 0.9) 80%, transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.aiw-input-box {
    width: 100%;
    max-width: 768px;  /* max-w-3xl */
    pointer-events: auto;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 24px;  /* rounded-3xl */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
    transition: all 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
    padding-top: 4px;
    transform-origin: bottom;
    animation: fadeInUp 0.4s ease-out both;
}

.aiw-input-box:hover {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.06);
    transform: scale(1.01);
}
.aiw-input-box:focus-within {
    box-shadow: 0 12px 64px rgba(13, 148, 136, 0.12);
    border-color: rgba(13, 148, 136, 0.3);
    transform: scale(1.015);
}

/* ── Input Toolbar (Preset / Provider / Model) ───────────────────── */
.aiw-input-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 16px 20px 4px 20px;  /* px-5 pt-4 pb-1 */
}

.aiw-toolbar-divider {
    width: 1px;
    height: 16px;
    background: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

/* Custom Selector (Preset / Provider / Model) */
.aiw-custom-selector {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    outline: none;
    padding: 0 4px;
    transition: color 0.2s;
}

/* Add border-left for Provider/Model to match original pl-5 border-l */
#aiProviderSelectorParent,
#aiModelSelectorParent {
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    padding-left: 20px;
    margin-left: 8px;
}

.aiw-selector-label {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.4;
    color: #0f172a;
    display: none;
}
@media (min-width: 768px) {
    .aiw-selector-label { display: inline; }
}

.aiw-selector-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--brand-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    letter-spacing: 0.025em;
}

.aiw-custom-selector:hover .aiw-selector-value {
    color: #0f766e;
}

.aiw-chevron {
    width: 14px;
    height: 14px;
    color: var(--brand-600);
    transition: transform 0.2s;
}

.aiw-custom-selector:focus-within .aiw-chevron {
    transform: rotate(180deg);
}

/* Dropdown Menus (Opens UPWARD) */
.aiw-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    padding: 4px;
    min-width: 180px;
    max-height: 380px;
    overflow-y: auto;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
    transform-origin: bottom left;
    transition: all 0.15s ease-out;
}

.aiw-custom-selector:focus-within .aiw-dropdown-menu {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.aiw-dropdown-item {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.15s;
    white-space: nowrap;
}
.aiw-dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
}
.aiw-dropdown-item:active { transform: scale(0.98); }

.aiw-dropdown-item.active {
    color: #0f766e;
    background: rgba(13, 148, 136, 0.1);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

/* ── Preset Grid Dropdown (App Drawer Style) ─────────────────────── */
.aiw-preset-dropdown {
    width: 340px !important;
    padding: 16px !important;
    border-radius: 24px !important;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.15) !important;
}

.aiw-preset-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
}
.aiw-preset-title {
    font-size: 13px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.6);
    letter-spacing: 0.025em;
}
.aiw-preset-count {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(0, 0, 0, 0.4);
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 99px;
}

.aiw-preset-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px 12px;
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.aiw-preset-grid::-webkit-scrollbar { display: none; }

.aiw-preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 0;
}

.aiw-preset-icon-box {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background: #ffffff;
    color: rgba(0, 0, 0, 0.6);
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    overflow: hidden;
}
.aiw-preset-btn:hover .aiw-preset-icon-box {
    background: rgba(0, 0, 0, 0.03);
    color: rgba(0, 0, 0, 0.9);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}
.aiw-preset-btn.active .aiw-preset-icon-box {
    background: var(--brand-600);
    border-color: transparent;
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(13, 148, 136, 0.35);
    transform: scale(1.05);
    z-index: 10;
}

.aiw-preset-label {
    font-size: 11px;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.3s;
}
.aiw-preset-btn:hover .aiw-preset-label { color: rgba(0, 0, 0, 0.8); }
.aiw-preset-btn.active .aiw-preset-label { color: var(--brand-600); font-weight: 700; }

/* Provider/Model selector text */
#aiProviderSelectorParent .aiw-selector-value,
#aiModelSelectorParent .aiw-selector-value {
    color: var(--brand-600);
}
#aiProviderSelectorParent:hover .aiw-selector-value,
#aiModelSelectorParent:hover .aiw-selector-value {
    color: #0f766e;
}

/* ── Textarea Input ──────────────────────────────────────────────── */
.aiw-textarea-wrapper {
    display: flex;
    align-items: flex-end;
    position: relative;
}

.aiw-textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 15px;
    line-height: 1.6;
    background: transparent;
    color: #0f172a;
    min-height: 90px;
    max-height: 40vh;
    font-family: inherit;
    padding: 20px 64px 20px 20px;  /* p-5 pr-16 */
}
.aiw-textarea::placeholder { opacity: 0.3; }

.aiw-send-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--brand-600);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.4;
}
.aiw-send-btn.active, .aiw-send-btn:not(:disabled) { opacity: 1; }

.aiw-send-btn i, .aiw-send-btn svg { width: 22px; height: 22px; }

/* Stop Button */
.aiw-stop-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #fee2e2;
    border: none;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.aiw-stop-btn:hover { background: #fecaca; }

/* Footer Text */
.aiw-footer-text {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.3);
    margin-top: 4px;
    text-align: center;
    pointer-events: auto;
}

/* ── Context Token Counter ───────────────────────────────────────── */
.aiw-ctx-counter {
    font-size: 11px;
    font-family: monospace;
    opacity: 0.3;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   MARKDOWN RENDERING — Matching ChatInterface.tsx prose styles
   ══════════════════════════════════════════════════════════════════ */

/* Code Blocks */
.aiw-code-block {
    background: #1e1e1e;
    border-radius: 16px;
    overflow: hidden;
    margin: 20px 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 100%;
    min-width: 0;
}
.aiw-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.4);
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    font-family: monospace;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    user-select: none;
}
.aiw-code-header button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 11px;
    font-family: monospace;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}
.aiw-code-header button:hover { color: white; }
.aiw-code-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
}
.aiw-code-block code {
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-family: 'SF Mono', Monaco, monospace;
    line-height: 1.6;
    letter-spacing: -0.01em;
}

/* Inline Code */
.aiw-inline-code {
    background: rgba(0, 0, 0, 0.05);
    color: var(--brand-600);
    padding: 1px 6px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    word-break: break-word;
}

/* Streaming cursor */
.aiw-stream-cursor {
    display: inline-block;
    width: 3px;
    height: 1.1em;
    background: var(--brand-600);
    margin-left: 4px;
    vertical-align: text-bottom;
    border-radius: 1px;
    animation: blink 1.2s infinite;
    box-shadow: 0 0 8px rgba(13, 148, 136, 0.5);
}

/* Typing Dots (Loading Indicator) */
.aiw-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    background: rgba(0, 0, 0, 0.05);
    padding: 12px 16px;
    border-radius: 16px;
    min-width: 60px;
}
.aiw-typing-dots span {
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    animation: aiw-bounce 1.4s infinite ease-in-out;
}
.aiw-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.aiw-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.aiw-typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes aiw-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Markdown Content Elements ───────────────────────────────────── */
.aiw-bubble p { margin-bottom: 1.25em; line-height: 1.75; }
.aiw-bubble p:first-child { margin-top: 0; }
.aiw-bubble p:last-child { margin-bottom: 0; }

.aiw-bubble h1, .aiw-bubble h2, .aiw-bubble h3 { letter-spacing: -0.025em; color: rgba(0,0,0,0.8); }
.aiw-bubble h1 { font-size: 1.15em; font-weight: bold; margin-top: 2em; margin-bottom: 1em; }
.aiw-bubble h2 { font-size: 1.05em; font-weight: 600; margin-top: 1.75em; margin-bottom: 1em; }
.aiw-bubble h3 { font-size: 1em; font-weight: 600; margin-top: 1.5em; margin-bottom: 1em; }

.aiw-bubble ul, .aiw-bubble ol { margin-bottom: 1.25em; padding-left: 20px; }
.aiw-bubble ul { list-style-type: disc; }
.aiw-bubble ol { list-style-type: decimal; }
.aiw-bubble li { margin-bottom: 4px; }
.aiw-bubble li::marker { color: rgba(13, 148, 136, 0.7); }

/* Blockquote (Branded Rounded Style) */
.aiw-bubble blockquote,
.aiw-blockquote {
    position: relative;
    margin: 28px 0;
    padding: 20px 24px;
    border-radius: 20px;
    background: linear-gradient(to bottom right, rgba(13,148,136,0.04), transparent);
    border: 1px solid rgba(13, 148, 136, 0.1);
    border-left: none;
    box-shadow: inset 0 1px 4px rgba(13,148,136,0.03);
    color: rgba(0, 0, 0, 0.8);
    font-style: normal;
    overflow: hidden;
}
.aiw-bubble blockquote::before {
    content: "\201C";
    position: absolute;
    top: -16px;
    left: -8px;
    font-size: 120px;
    line-height: 1;
    font-family: Georgia, serif;
    color: rgba(13, 148, 136, 0.1);
    pointer-events: none;
    user-select: none;
}

.aiw-hr { border: 0; border-top: 1px solid rgba(0,0,0,0.05); margin: 2em 0; }

/* Links */
.aiw-link {
    color: inherit;
    font-weight: 500;
    transition: opacity 0.2s;
    cursor: pointer;
    word-break: break-all;
}
.aiw-link:hover { opacity: 0.7; }

/* Images */
.aiw-img { max-width: 100%; border-radius: 16px; margin: 1em 0; border: 1px solid rgba(0,0,0,0.05); }

/* Tables (Matching original) */
.aiw-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 13px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0,0,0,0.02);
}
.aiw-bubble table thead {
    background: rgba(13, 148, 136, 0.05);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    color: rgba(0,0,0,0.8);
}
.aiw-bubble table th {
    padding: 12px 20px;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.025em;
    white-space: nowrap;
    text-align: left;
    min-width: 120px;
}
.aiw-bubble table td {
    padding: 12px 20px;
    font-size: 13px;
    vertical-align: top;
    color: rgba(0,0,0,0.7);
    line-height: 1.6;
    text-align: left;
    min-width: 120px;
}
.aiw-bubble table tbody { }
.aiw-bubble table tbody tr { transition: background 0.15s; }
.aiw-bubble table tbody tr:hover { background: rgba(0,0,0,0.05); }
.aiw-bubble table tbody tr:nth-child(even) { background: rgba(248,250,252,1); }

/* ── Think Block (Deep System Trace) ─────────────────────────────── */
.aiw-think-block {
    margin-bottom: 20px;
    min-width: 280px;
    border-radius: 18px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.01);
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    display: block;
    width: 100%;
    max-width: 100%;
}
.aiw-think-block[open] {
    box-shadow: 0 8px 30px rgba(0,0,0,0.04);
}
.aiw-think-block summary {
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    color: rgba(0,0,0,0.7);
    transition: all 0.2s;
}
.aiw-think-block summary:hover {
    background: rgba(0,0,0,0.04);
    color: rgba(0,0,0,1);
}
.aiw-think-content {
    padding: 4px 20px 20px 20px;
    font-size: 13.5px;
    color: rgba(0,0,0,0.7);
    letter-spacing: 0.025em;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}
.aiw-think-content::before {
    content: "";
    display: block;
    width: 100%;
    height: 1px;
    background: rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

/* Streaming Think Block (active) */
.aiw-think-block.streaming {
    border-color: rgba(13,148,136,0.2);
    background: rgba(13,148,136,0.02);
    box-shadow: 0 8px 30px rgba(13,148,136,0.08);
}
.aiw-think-block.streaming summary {
    color: var(--brand-600);
}

/* ══════════════════════════════════════════════════════════════════
   LOADING DOTS (Bounce animation matching original)
   ══════════════════════════════════════════════════════════════════ */
@keyframes bounceDot {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ══════════════════════════════════════════════════════════════════
   TOAST NOTIFICATION
   ══════════════════════════════════════════════════════════════════ */
.aiw-toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    z-index: 100;
    padding: 8px 20px;
    background: rgba(13, 148, 136, 0.95);
    border-radius: 9999px;
    box-shadow: 0 8px 30px rgba(13,148,136,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}
.aiw-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
