/* Global Styles */
:root {
    --primary-color: #030213; /* figma primary */
    --secondary-color: #717182; /* figma muted-foreground */
    --background-color: #ffffff; /* figma background */
    --text-color: #0a0a0a; /* figma foreground approx */
    --border-color: rgba(0,0,0,0.1); /* figma border */
    --hover-color: #ececf0; /* figma muted */
    --accent-color: #9810fa; /* brand purple retained */
    --panel-bg: #f8f8fa; /* align left panel with figma */
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    --nav-height: 56px;
}

/* Right panel details styles */
.details-header { text-align: center; padding: 0.75rem 0.75rem 0.5rem; }
.details-header .placeholder-title { font-size: 0.95rem; font-weight: 400; margin-bottom: 0.25rem; color: #374151; display: none; }
.persona-avatar.circle { width: 112px; height: 112px; border-radius: 50%; overflow: hidden; margin: 0.25rem auto 0.6rem; border: 2px solid var(--border-color); background: #fff; }
.details-header .persona-name { font-weight: 400; margin: 0.5rem 0 0.2rem; font-size: 0.95rem; color: #111; white-space: normal; overflow: visible; text-overflow: unset; word-break: break-word; }
.persona-meta { display: grid; gap: 1px; color: #6b7280; font-size: 0.8rem; line-height: 1.25; text-align: center; }

.persona-section { padding: 0 0.25rem; border: none; }
.persona-section h4 { font-size: 0.85rem; font-weight: 400; margin: 0.6rem 0 0.35rem; color: #111; }
.persona-section p { font-size: 0.82rem; line-height: 1.4; color: #4b5563; margin: 0 0 0.5rem; text-align: left; }

/* Kill any accidental underlines/borders inside right panel headings */
.right-panel .persona-section h4,
.right-panel h4 { border: 0 !important; box-shadow: none !important; }

.persona-actions { padding: 0.5rem 0.5rem 0.5rem; display: grid; gap: 0.5rem; }
.persona-actions .btn { width: 100%; height: 38px; line-height: 38px; border-radius: 12px; border: 1px solid transparent; cursor: pointer; transition: filter 0.2s ease; font-size: 0.9rem; }

/* Tighter spacing above About and Personality sections */
.right-panel .details-content .persona-section:first-of-type h4 { margin-top: 0.25rem !important; }
.right-panel .details-content .persona-section:nth-of-type(2) h4 { margin-top: 0.25rem !important; }

/* Reduce spacing between paragraphs in right panel */
.right-panel .persona-section p { line-height: 1.32; margin: 0 0 0.25rem; }
.right-panel .persona-section p:last-child { margin-bottom: 0.15rem; }

/* Ensure stacking and width even if earlier rules exist */
.right-panel .persona-actions { display: grid !important; grid-template-columns: 1fr; }
.right-panel .persona-actions .btn { width: 100% !important; }
.persona-actions .btn-primary { background: var(--accent-color); color: #fff; box-shadow: 0 0 0 2px rgba(152,16,250,0.2) inset; }
.persona-actions .btn-primary:disabled { background: #c7cdd6; cursor: not-allowed; box-shadow: none; }
.persona-actions .btn-secondary { background: #fff; color: #000; border-color: var(--border-color); }
.persona-actions .btn:hover { filter: brightness(0.98); }

/* Extra-tight vertical rhythm in right panel */
.right-panel .details-header { padding-bottom: 0.35rem !important; }
/* Moderately compact spacing for readability */
.right-panel .details-content .persona-section h4 { margin: 0.3rem 0 0.25rem !important; }
.right-panel .details-content .persona-section p { line-height: 1.32 !important; margin: 0 0 0.25rem !important; }
.right-panel .details-content .persona-section p:first-child { margin-top: 0 !important; }
.right-panel .details-content .persona-section p:last-child { margin-bottom: 0.15rem !important; }
.right-panel .details-content .persona-section + .persona-section h4 { margin-top: 0.28rem !important; }

/* Unify right panel text color to a lighter gray */
.right-panel .details-content { color: #4b5563; }
.right-panel .details-content .details-header .persona-name { color: #111 !important; font-size: 0.92rem; }
/* Keep section titles black and slightly smaller */
.right-panel .details-content .persona-section h4 { color: #111 !important; font-size: 0.82rem; }
.right-panel .details-content .persona-meta { color: #4b5563 !important; }

/* Footer label under input */
.ai-powered, .ai-powered-label, .footer-label, .chat-footer-label { display: none !important; }
.chat-footer, .chat-bottom-spacer { display: none !important; }

/* align chat input lower to match right panel buttons */
.chat-input { margin-bottom: 0; }
.chat-footer-label {
    text-align: center;
    color: var(--secondary-color);
    font-size: 0.8rem;
    padding: 0.25rem 0 0.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

/* App Layout */
.app-container {
    display: flex;
    height: calc(100vh - var(--nav-height));
    width: 100%;
    overflow: hidden;
}

/* Top Navigation */
.top-nav {
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background: #f9f9f9;
    border-bottom: 1px solid var(--border-color);
}

.top-nav .brand a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

.top-nav .nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.top-nav .nav-links a {
    color: var(--text-color) !important;
    text-decoration: none;
    font-weight: 600;
}

.top-nav .nav-links a[aria-current="page"] {
    color: var(--text-color) !important;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.top-nav .nav-links a:hover {
    text-decoration: underline;
}

/* Match WP-like responsive paddings and spacing */
@media (max-width: 1024px) {
    .top-nav { padding: 0 20px; }
    .top-nav .nav-links { gap: 1.25rem; }
}

@media (max-width: 767px) {
    .top-nav { padding: 0 10px; }
    .top-nav .nav-links { gap: 1rem; }
}

/* Left Panel */
.left-panel {
    width: 240px;
    flex: 0 0 240px;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* show only when needed */
    overflow-x: hidden; /* prevent horizontal scroll */
    transition: var(--transition);
    scrollbar-gutter: auto; /* no reserved gutter; scrollbar hugs border */
    padding-right: 0; /* ensure scrollbar touches border */
}

/* Collapsed state for left panel (desktop) */
.left-panel.collapsed {
    width: 0;
    flex-basis: 0;
    border-right: none;
    padding: 0;
    overflow: hidden;
}

/* Thinner, light gray scrollbar for left panel */
.left-panel { scrollbar-width: thin; scrollbar-color: #edeff2 transparent; }
.left-panel::-webkit-scrollbar { width: 1px; }
.left-panel::-webkit-scrollbar-track { background: transparent; }
.left-panel::-webkit-scrollbar-thumb { background-color: #edeff2; border-radius: 0; }
.left-panel::-webkit-scrollbar-button { width: 1px; height: 6px; background: transparent; }
.left-panel::-webkit-scrollbar:horizontal { height: 0 !important; }

.logo {
    font-size: 1.5rem;
    font-weight: 600;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-color);
}

.persona-categories {
    padding: 0.5rem 0 0.5rem 0;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden; /* prevent horizontal scroll in inner scroller */
    scrollbar-gutter: stable; /* always reserve space so content doesn't shift */
}
/* Ensure inner scroller uses the same ultra-thin scrollbar */
.persona-categories { scrollbar-width: thin; scrollbar-color: #edeff2 transparent; }
.persona-categories::-webkit-scrollbar { width: 1px; }
.persona-categories::-webkit-scrollbar-track { background: transparent; }
.persona-categories::-webkit-scrollbar-thumb { background-color: #edeff2; border-radius: 0; }
.persona-categories::-webkit-scrollbar-button { width: 1px; height: 6px; background: transparent; }

.category {
    margin-bottom: 0.5rem;
}

.category-header {
    padding: 0.4rem 1.75rem 0.4rem 0.75rem; /* reserve a bit more space for chevron */
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
    position: relative; /* for absolute chevron */
}

/* Reserve a few pixels so hover/click background doesn't collide with scrollbar */
.left-panel .category-header,
.left-panel .persona-item { margin-right: 0; }
.left-panel .persona-list { padding-right: 0; }

.category-header:hover {
    background-color: var(--hover-color);
}
/* Lighter hover for persona rows */
.persona-item:hover { background-color: var(--hover-color); }

.toggle-icon {
    font-size: 1.2rem;
    transition: transform 0.2s ease;
    display: inline-block;
    position: absolute;
    right: 14px; /* place chevron left so it doesn't collide or shift */
}

.category.active .toggle-icon { transform: rotate(90deg); }

.persona-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    margin: 0 0 0 0.5rem; /* remove right margin so scrollbar sits flush */
}

.category.active .persona-list {
    max-height: 1000px; /* Adjust based on content */
}

.persona-item {
    height: 44px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 22px;
}

.persona-item:hover { background-color: #eef0f4; }

.persona-item.active {
    background-color: #e7eaf0;
}

.persona-item .persona-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 6px; /* tighter spacing to name */
    flex-shrink: 0;
}

.persona-item .persona-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.persona-name {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Chat Area */
.chat-container {
    flex: 1 1 0%;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    width: auto;
    height: 100%;
    min-height: 0; /* allow flex children to shrink and scroll */
    min-width: 0; /* allow flex child to shrink horizontally and not force layout growth */
    border-right: 1px solid var(--border-color);
}

.chat-header {
    display: flex; /* row layout */
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1.5rem; /* slightly tighter top bar */
    background: #f8f8fa; /* light gray bar */
    border-bottom: none; /* remove bottom line */
    text-align: left;
    visibility: hidden; /* hidden until active */
    min-height: 48px; /* slimmer bar */
}
.chat-header.active {
    visibility: visible;
    border-bottom: none; /* keep line removed when active */
}

/* Header left: avatar + title */
.chat-header-left { display: flex; align-items: center; gap: 10px; }
.chat-header-avatar { width: 48px; height: 48px; border-radius: 50%; overflow: visible; background: #f3f4f6; border: 1px solid #e5e7eb; flex: 0 0 48px; position: relative; }
.chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center center; display: block; border-radius: 50%; }
.chat-close { background: transparent; border: none; color: #9aa3b2; font-size: 22px; cursor: pointer; margin-left: auto; padding: 0; border-radius: 9999px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.chat-close:hover { background: #f3f4f6; color: #111; border-radius: 9999px; }

.chat-header-label {
    font-size: 0.75rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.25rem;
}

.chat-header h2 {
    font-size: 1rem; /* ~16px */
    margin: 0;
    color: #101828;
    font-weight: 600;
}

.chat-header p {
    color: #000;
    font-size: 0.9rem;
}


.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    scrollbar-gutter: stable both-edges;
    width: 100%;
}
/* Hide chat scrollbars while preserving scroll functionality */
.chat-messages { scrollbar-width: none; -ms-overflow-style: none; }
.chat-messages::-webkit-scrollbar { display: none; }

/* Onboarding state fills and centers the chat */
.chat-messages.onboard { justify-content: flex-start; align-items: center; text-align: center; padding-top: 2.5rem; }

/* Chat hero intro */
.chat-hero { margin: 24px auto 8px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.chat-hero-avatar { width: 120px; height: 120px; border-radius: 50%; overflow: visible; border: 2px solid #e5e7eb; background: #f3f4f6; }
.chat-hero-avatar { position: relative; }
.chat-hero-emoji { position: absolute; top: -6px; right: -6px; font-size: 2rem; line-height: 1; }
.chat-hero-avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center center; display: block; border-radius: 50%; }
.chat-hero-name { margin-top: 6px; margin-bottom: 0; font-weight: 400; color: #111; font-size: 0.95rem; }
.chat-hero-tagline { color: #6b7280; font-size: 0.88rem; margin-top: 2px; }
.chat-hero-note { margin-top: 2px; color: #6b7280; font-size: 0.82rem; }

.onboard .welcome-title {
    font-size: 2rem; /* ~32px */
    color: var(--accent-color);
    font-weight: 700;
    margin-bottom: 0.75rem;
}
.onboard .welcome-text {
    color: #6a7282; /* muted body */
    max-width: 560px;
    line-height: 1.6;
}
.onboard .welcome-cta {
    margin-top: 0.75rem;
    font-weight: 700;
    color: #000;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease-out;
    word-break: break-word;
    overflow-wrap: anywhere;
    margin: 0.25rem 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
    background-color: var(--accent-color);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant {
    align-self: flex-start;
    background-color: #f1f3f5;
    border-bottom-left-radius: 0.25rem;
}

.chat-input { 
    padding: 0.9rem 0.5rem 0.6rem; /* match bottom inset with persona-actions for alignment */
    border-top: none;
    display: flex;
    align-items: flex-end;
    justify-content: center; /* center inner wrapper */
    gap: 0.75rem;
    position: relative;
    margin-top: 2px; /* only a slight push from content above */
}

/* Centered inner wrapper to control margins/max width */
.chat-input-inner {
    position: relative;
    width: 100%;
    max-width: none; /* use full content width minus header inset */
    width: calc(100% - 3rem); /* align edges with 1.5rem header padding on both sides */
    margin: 0 auto; /* keep centered in remaining space */
}

/* New wrapper around textarea and send button */
.input-wrap {
    position: relative; /* anchor send button */
    width: 100%;
}

.chat-input textarea {
    flex-grow: 1;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 24px !important;
    /* Slightly slimmer field for better visual alignment */
    padding: 8px 2.6rem 8px 1rem; /* 42px field height */
    font-family: inherit;
    font-size: 1rem;
    line-height: 22px; /* 10 + 22 + 10 = 42px total height */
    resize: none;
    max-height: 200px; /* cap growth */
    transition: none; /* remove focus animation, keep contour only */
    height: auto; /* allow JS to control height for auto-grow */
    min-height: 38px; /* keep base thickness */
    background: #f3f4f6;
    overflow: hidden; /* no scrollbar inside input */
    box-shadow: 0 6px 16px rgba(16,24,40,0.08); /* stronger elevation like mock */
}

/* Chat messages container */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
}

/* Typing indicator within message */
.message.assistant .typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.message.assistant .typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #6c757d;
    animation: bounce 1.4s infinite ease-in-out both;
}

.message.assistant .typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.message.assistant .typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
/* Thin scrollbar for chat thread */
#chat-messages { scrollbar-width: thin; scrollbar-color: #e5e7eb transparent; }
#chat-messages::-webkit-scrollbar { width: 6px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background-color: #e5e7eb; border-radius: 3px; }

.chat-input textarea:disabled {
    background: rgba(229,231,235,0.4);
    color: #9ca3af;
    cursor: not-allowed;
}
.chat-input textarea::placeholder { color: #9ca3af; font-size: 0.85rem; }

.chat-input textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1.5px var(--accent-color); /* just purple contour */
    background: #f3f4f6;
}

#send-button {
    background-color: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 9999px; /* circular */
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0; /* ensure inner svg has no baseline shift */
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    position: absolute; /* inside the input-wrap */
    right: 8px;
    top: 50%;
    transform: translateY(-62%); /* recenter for 42px textarea */
    z-index: 2;
    border: none; /* remove white circular contour */
    box-shadow: 0 4px 10px rgba(16,24,40,0.12);
}
/* ensure SVG is perfectly centered visually */
#send-button svg { display: block; margin: 0; width: 16px; height: 16px; }

#send-button:hover {
    filter: brightness(0.95);
}

#send-button:disabled {
    background-color: #c7cdd6;
    cursor: not-allowed;
}

/* Right Panel */
.right-panel {
    width: 240px; /* slightly smaller */
    flex: 0 0 240px;
    background-color: #f7f8fb; /* light gray like mock */
    border-left: 1px solid #e5e7eb; /* subtle divider */
    overflow: hidden; /* panel itself doesn't scroll; content area will */
    transition: width 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column; /* allow footer actions to sit at bottom */
}
.right-panel.collapsed { width: 0; flex-basis: 0; }

/* Right panel onboarding placeholder vs details */
.right-panel .details-content { display: none; }
.right-panel.active .placeholder { display: none; }
.right-panel.active .details-content { display: block; }

/* Placeholder styling */
.right-panel .placeholder { padding: 2.5rem 1.25rem; color: var(--secondary-color); text-align: center; }
.right-panel .placeholder-inner { margin-top: 0.75rem; }
.right-panel .placeholder-title { color: #0f172a; font-weight: 400; font-size: 1.1rem; margin-top: 0.75rem; margin-bottom: 0.6rem; }
.right-panel .placeholder-icon {
    position: relative;
    width: 120px; height: 120px; border-radius: 50%; border: 2px dashed #d5dae1;
    display: inline-flex; align-items: center; justify-content: center; margin: 1.25rem 0 1.1rem; color: #b7c0ca;
    font-weight: 400; font-size: 0.95rem; background: transparent; z-index: 1;
}
.right-panel .placeholder-icon::after {
    display: none; /* remove inner circle; keep only dashed outer ring */
}
/* Ensure inline SVG icon sits above the inner white circle */
.right-panel .placeholder-icon svg {
  position: relative;
  z-index: 1;
  display: block;
}
.right-panel .placeholder-subtitle { color: #0f172a; font-weight: 400; margin-bottom: 0.3rem; }
.right-panel .placeholder-text { font-size: 0.88rem; color: #6b7280; max-width: 260px; margin: 0 auto; line-height: 1.45; }

/* Details content spacing */
.right-panel .details-content { padding: 1.25rem 0.5rem 80px; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }

/* Hide-content state: keep panel width but hide inner content */
.right-panel.hide-content .placeholder,
.right-panel.hide-content .details-content { display: none; }

.close-panel {
    position: absolute;
    top: 14px; /* fine-tuned alignment with chat close X */
    left: 0.5rem;
    font-size: 1.25rem;
    cursor: pointer;
    color: #9aa3b2; /* muted like mock */
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close-panel:hover {
    background-color: var(--hover-color);
    color: var(--text-color);
}

.persona-details-content {
    padding: 2rem 1.5rem;
}

.persona-avatar.small {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 1.5rem;
    border: 3px solid var(--primary-color);
}

.persona-avatar.small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.persona-details-content h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: #000;
}

.persona-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
    background-color: var(--hover-color);
    padding: 1rem;
    border-radius: 8px;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-weight: 600;
}

.persona-bio, .persona-background {
    margin-bottom: 1.5rem;
}

.persona-bio h4, .persona-background h4 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: #000;
}

.persona-bio p, .persona-background p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-color);
}

/* Persona search and CTA */
.persona-search { padding: 0 0.5rem 0.5rem 0.5rem; }

.section-title {
    font-size: 0.8rem;
    color: var(--secondary-color);
    padding: 0 1rem 0.35rem 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.persona-search input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 0.6rem 2.2rem 0.6rem 0.9rem; /* more rounded and room for icon */
    font-size: 0.9rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat right 10px center;
}
.persona-search input:hover { background-color: #f3f4f6; }
.persona-search input:focus { background-color: #e5e7eb; outline: none; }

.browse-personas-cta {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 1.5rem 1rem; /* match chat-input vertical padding for alignment */
    border-top: 1px solid var(--accent-color);
}

.browse-personas {
    display: inline-block;
    width: 100%;
    text-align: center;
    background-color: var(--accent-color);
    color: #fff;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.browse-personas:hover {
    filter: brightness(0.95);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background-color: var(--accent-color); color: #fff; }
.btn-primary:hover { filter: brightness(0.95); }

.btn-secondary { background-color: #fff; color: #111; border: 1px solid var(--border-color); }

/* Persona Profile button visual per mock */
.persona-actions .btn.btn-secondary {
  border: 2px solid var(--accent-color);
  border-radius: 9999px;
  font-weight: 700;
  line-height: 34px; /* 38px height minus 4px border for perfect centering */
}
.btn-secondary:hover { filter: brightness(0.95); }

.persona-actions { display: grid !important; grid-template-columns: 1fr; gap: 0.6rem; position: absolute; left: 0; right: 0; bottom: 0; background: #f7f8fb; padding: 0.9rem 1rem 1rem; border-top: none; }
.persona-actions .btn { width: 100%; font-size: 0.95rem; height: 38px; line-height: 38px; border-radius: 9999px; font-weight: 500; }
/* Ensure stacked layout takes precedence */
.right-panel .persona-actions { display: grid !important; grid-template-columns: 1fr !important; }

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; padding: 0 1rem; }
.typing-indicator span {
    width: 6px; height: 6px; background: #bbb; border-radius: 50%; display: inline-block;
    animation: blink 1.4s infinite both;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

/* Modal overlay for persona profile */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: none;
  pointer-events: none; /* don't block UI when hidden */
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
}
.modal-overlay.open { display: flex; pointer-events: auto; }
.modal-dialog {
  background: transparent; /* show only the image */
  width: auto; /* shrink to image width */
  max-width: 92vw; /* cap width */
  max-height: 90vh;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: visible; /* allow close button to sit slightly outside */
  display: inline-block; /* size to content so close sits at image corner */
}
.modal-close {
  position: absolute;
  top: -12px; /* sit right on the outer edge */
  right: -12px; /* sit right on the outer edge */
  background: rgba(255,255,255,0.95);
  border: none;
  font-size: 1.1rem;
  color: #111;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  border: 1px solid rgba(209,213,219,0.9); /* subtle border to separate on light areas */
  z-index: 2;
}
.modal-content { padding: 0; background: transparent; }

/* Profile sheet look */
.profile-sheet { background: transparent; border: none; }
.profile-sheet .sheet-header { display: flex; gap: 1rem; align-items: center; padding: 1rem; border-bottom: 1px solid #e5e7eb; }
.profile-sheet .sheet-avatar { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; border: 1px solid #e5e7eb; }
.profile-sheet .sheet-title .hello { font-style: italic; color: #374151; margin-bottom: 0.25rem; }
.profile-sheet .sheet-title h3 { margin: 0; font-size: 1.25rem; font-weight: 600; }
.profile-sheet .sheet-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; padding: 1rem; border-bottom: 1px solid #e5e7eb; font-size: 0.95rem; }
.profile-sheet .sheet-block { padding: 1rem; border-bottom: 1px solid #e5e7eb; }
.profile-sheet .sheet-block h4 { margin: 0 0 0.5rem; font-size: 1rem; font-weight: 600; }
.profile-sheet .sheet-block p { margin: 0; line-height: 1.6; color: #374151; }
/* Ensure full-sheet PNG scales to fit viewport height and width without scroll */
.profile-sheet-image {
  display: block;
  max-width: 92vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  margin: 0 auto;
}

/* Persona list avatar adjustments */
.persona-item .persona-avatar {
  width: 36px;
  height: 36px;
  border-radius: 9999px;
  overflow: hidden;
  flex: 0 0 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  background: #f3f4f6;
}
.persona-item .persona-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.persona-item .persona-name { margin-left: 6px; }

/* Right panel avatar adjustments */
#detail-avatar {
  width: 88px;
  height: 88px;
  border-radius: 9999px;
  overflow: hidden;
  border: 2px solid #e5e7eb;
  background: #f3f4f6;
  display: none;
}
#detail-avatar img,
#detail-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Chat header title smaller on persona chat */
#chat-title.small { font-size: 1rem; color: #101828; font-weight: 600; }

/* Left panel spacing */
.left-panel .section-title:first-of-type { margin-top: 1.5rem; }
.persona-search { margin-top: 1rem; }

/* Responsive Design */
@media (max-width: 1024px) {
    .right-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 400px;
        z-index: 1000;
        box-shadow: -4px 0 10px rgba(0, 0, 0, 0.1);
    }
}

@media (max-width: 768px) {
    .left-panel {
        position: fixed;
        top: 0;
        left: -280px;
        bottom: 0;
        z-index: 1000;
        box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .left-panel.active {
        left: 0;
    }
    
    .chat-container {
        margin-left: 0;
    }
    
    .right-panel {
        max-width: 100%;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Persona Overview vertical side tag */
.side-tag {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    background: var(--accent-color);
    color: #fff;
    padding: 12px 8px; /* slightly bigger */
    border-radius: 10px 0 0 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-weight: 700;
    font-size: 13px; /* bigger */
    letter-spacing: 0.08em;
    cursor: pointer;
    z-index: 1100;
    user-select: none;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.side-tag:hover { filter: brightness(0.95); }

/* On small screens the mobile slide-in CSS already handles the panel; keep tag visible */

/* === Desktop-only overrides (temporarily disable mobile layout) === */
@media (max-width: 1024px) {
  .right-panel {
    position: relative !important;
    top: auto !important; right: auto !important; bottom: auto !important;
    width: 240px !important;
    max-width: 240px !important;
    box-shadow: none !important;
  }
}

@media (max-width: 768px) {
  .left-panel {
    position: static !important;
    left: 0 !important;
    bottom: auto !important;
    z-index: auto !important;
    box-shadow: none !important;
  }
  .left-panel.active { left: 0 !important; }
  .chat-container { margin-left: 0 !important; }
  .right-panel { max-width: 240px !important; }
}

/* === Figma desktop alignment overrides === */
.chat-header h2 { font-weight: 600; }

.side-tag {
  padding: 10px 6px !important;
  border-radius: 10px 0 0 10px !important;
  letter-spacing: 0.06em !important;
  font-size: 12px !important;
}
