/* ===== Main-area section views (Chats / Workspaces lists) ===== */
/* width: 100% matters: these are flex items of the centered .messages-container,
   which would otherwise shrink-wrap them to their content width.
   Top/side padding adds to .messages-container's padding so section headings
   land at the exact same offset as .main-view-panel (Settings, Models, Profile). */
.section-view {
    width: 100%;
    max-width: calc(var(--section-max-width) + 8px);
    margin: 0 auto;
    padding: 8px 4px 40px;
    display: flex;
    flex-direction: column;
}

.section-head {
    width: 100%;
    max-width: var(--section-max-width);
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 auto 16px;
    gap: 12px;
}

.section-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.section-title {
    font-size: var(--text-xl);
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    margin: 0;
}

.section-new-btn {
    flex: 0 0 auto;
    padding: 7px 14px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    background: var(--accent);
    color: var(--on-accent);
    font-size: var(--text-sm);
    cursor: pointer;
    box-shadow: var(--shadow-btn);
    transition: background-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.section-new-btn:hover {
    background: var(--accent-hover);
}

.section-new-btn:active:not(:disabled) {
    transform: translateY(0.5px);
    box-shadow: none;
}

.section-new-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.section-new-quill-icon {
    width: 17px;
    height: 17px;
    display: block;
    flex: 0 0 auto;
}

.section-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Chats "Next chat starts with" defaults strip (UIP-04 / UIP-08) */
.chats-next-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-xs);
}

.chats-next-label {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-muted);
}

.chats-next-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.chats-next-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 11px;
    max-width: 220px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.chats-next-pill:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.chats-next-pill.home {
    background: var(--surface-tint);
}

.chats-next-pill.model {
    background: var(--accent-subtle);
    border-color: transparent;
    color: var(--accent);
}

.chats-next-pill.model:hover {
    border-color: var(--accent);
}

.chats-next-ava {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    flex: 0 0 18px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.chats-next-ava img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chats-next-ava .avatar-emoji {
    font-size: 12px;
    line-height: 1;
}

.chats-next-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chats-next-pill .chevron {
    width: 13px;
    height: 13px;
    opacity: 0.7;
    flex: 0 0 auto;
}

/* Chats search + persona filter toolbar (UIP-08) */
.chats-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.chats-toolbar[hidden] {
    display: none;
}

.chats-search-wrap {
    position: relative;
    flex: 1 1 200px;
    min-width: 160px;
}

.chats-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

input.chats-search {
    width: 100%;
    height: 34px;
    padding: 0 30px 0 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: var(--text-sm);
}

input.chats-search:focus {
    outline: none;
    border-color: var(--accent);
}

.chats-search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.chats-search-clear[hidden] {
    display: none;
}

.chats-search-clear:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.chats-persona-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    max-width: 100%;
}

.chats-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    max-width: 180px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.chats-filter-pill:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.chats-filter-pill.active {
    background: var(--accent-subtle);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.chats-filter-pill-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Quieter sibling of .section-new-btn for secondary actions (Import). */
.section-secondary-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    cursor: pointer;
    box-shadow: var(--shadow-btn-secondary);
    transition: border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.section-secondary-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.section-secondary-btn:active:not(:disabled) {
    transform: translateY(0.5px);
    box-shadow: none;
}

.section-list {
    display: flex;
    flex-direction: column;
}

/* ===== Personas section — character-select tile grid =====
   Personas are characters, not config rows: the portrait is the primary
   element, with name / role chip / tagline as a caption beneath it. The
   persona editor's Avatar tab reuses .persona-tile-portrait and the caption
   classes so its preview is literally the tile you get here. */
.persona-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.persona-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    box-shadow: var(--shadow-xs);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.persona-tile:hover {
    border-color: var(--accent-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.persona-tile.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}

.persona-tile-open {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
}

.persona-tile-open:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: var(--radius-md);
}

.persona-tile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.persona-tile-btn {
    flex: 1 1 0;
    min-width: 0;
}

/* 1:1 rounded portrait — chosen over a 3:4 crop so existing square avatar
   uploads are never re-cropped. */
.persona-tile-portrait {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--accent-subtle) 100%);
    font-size: 56px;
}

.persona-tile-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Corner marker rather than an inline pill — it belongs to the portrait. */
.persona-tile-active {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--on-accent);
    background: var(--accent);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.persona-tile-caption {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.persona-tile-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.persona-tile-role {
    align-self: flex-start;
    max-width: 100%;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 1px 7px;
    border-radius: var(--radius-full);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The tagline is voice, not metadata — italic, and allowed two lines before
   it clamps, so a real sentence fits. */
.persona-tile-tagline {
    font-size: var(--text-xs);
    font-style: italic;
    line-height: 1.4;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.persona-tile-tagline.empty {
    font-style: normal;
    color: var(--text-muted);
    opacity: 0.7;
}

.persona-tile-menu {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity 0.15s;
}

.persona-tile:hover .persona-tile-menu,
.persona-tile:focus-within .persona-tile-menu,
.persona-tile-menu:focus-visible {
    opacity: 1;
}

/* Hover-reveal hides the menu entirely on touch, where there is no hover to
   reveal it. Narrow viewports are covered too — pointer detection alone is
   unreliable (hybrid laptops, emulated viewports). */
@media (hover: none), (max-width: 640px) {
    .persona-tile-menu {
        opacity: 1;
    }
}

.persona-card-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    background: var(--accent-subtle);
    padding: 1px 6px;
    border-radius: var(--radius-full);
}

/* Model role markers: Main and Aux (AX-01).
   ONE component, so the two read as a pair. They previously differed in more
   than colour — the aux one carried a border the main one did not, which made
   it a pixel taller and visibly a different kind of thing. Now identical in
   every metric; only the hue says which role it is. Sized off the same box as
   .persona-card-badge above, which it sits beside on model cards. */
.role-badge {
    display: inline-block;
    flex: 0 0 auto;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.5;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    /* Both carry the explanation on hover, so both say so. */
    cursor: help;
}

.role-badge.main {
    color: var(--accent);
    background: var(--accent-subtle);
}

/* Quieter than main: a model can hold both at once, and which one answers you
   in chat is the more important of the two to read at a glance. */
.role-badge.aux {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

/* ===== Chat & Project list rows ===== */
.conversation-item,
.project-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 4px;
    background-color: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background-color 0.2s;
}

.conversation-item:hover,
.project-item:hover {
    background-color: var(--bg-tertiary);
}

.conversation-item.active,
.project-item.active {
    background-color: var(--accent-subtle);
}

.conversation-info,
.project-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}

.conversation-title,
.project-name {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-time,
.project-meta {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

/* Row/card "⋯" menus: always visible (hover-reveal was invisible on touch
   devices and easy to miss); hovering the button itself still tints it. */
.conversation-menu-btn,
.project-menu-btn {
    padding: 4px 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    transition: background-color 0.2s, color 0.2s;
}

/* Shared chevron rotation (used by Chats home/project groups and collapsible container sections) */
.group-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    flex: 0 0 auto;
    transition: transform 0.15s;
}

.group-chevron.collapsed {
    transform: rotate(-90deg);
}

/* ===== Home-grouped chat list (Chats view, UIP-08) ===== */
.chats-home-group {
    margin-bottom: 14px;
}

.chats-home-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.chats-home-toggle {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    margin-left: -6px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s;
}

.chats-home-toggle:hover {
    background-color: var(--bg-tertiary);
}

.chats-home-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    flex: 0 0 auto;
}

.chats-home-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chats-group-count {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-muted);
    flex: 0 0 auto;
}

.chats-group-new-btn {
    flex: 0 0 auto;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--accent);
    font-family: var(--font-main);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-btn-secondary);
    transition: border-color 0.15s, background-color 0.15s, transform 0.1s;
}

.chats-group-new-btn:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.chats-group-new-btn:active {
    transform: translateY(0.5px);
    box-shadow: none;
}

.chats-home-body[hidden],
.chats-project-body[hidden] {
    display: none;
}

.chats-project-sub {
    margin-top: 6px;
}

.chats-project-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 4px 3px 14px;
}

.chats-project-toggle {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: none;
    padding: 3px 6px;
    margin-left: -6px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s, color 0.15s;
}

.chats-project-toggle:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.chats-project-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chats-sub-new-btn {
    flex: 0 0 auto;
    border: none;
    background: none;
    color: var(--accent);
    font-family: var(--font-main);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s;
}

.chats-sub-new-btn:hover {
    background: var(--accent-subtle);
}

.conversation-item.indented {
    margin-left: 14px;
}

.chats-step-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 2px 0 4px 10px;
}

.chats-step-actions.indented {
    margin-left: 24px;
}

.chats-step-btn {
    border: none;
    background: none;
    color: var(--accent);
    font-family: var(--font-main);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.chats-step-btn:hover {
    background: var(--accent-subtle);
}

.chats-step-btn.quiet {
    color: var(--text-muted);
}

.chats-step-btn.quiet:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chats-filter-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 4px;
}

/* Small persona avatar on group headers and workspace chat rows */
.conversation-persona-avatar {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
}

.conversation-persona-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.conversation-persona-avatar .avatar-emoji {
    font-size: 13px;
    line-height: 1;
}

.conversation-item .conversation-persona-avatar {
    margin-right: 8px;
}

.conversation-menu-btn:hover,
.project-menu-btn:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

/* ===== Top-bar breadcrumb (workspace / project indicator) ===== */
/* Lives inside .chat-top-meta alongside persona name; segments navigate. */
.workspace-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
    padding: 4px;
    margin: -4px;
    font-family: var(--font-main);
    font-size: inherit;
    color: var(--text-secondary);
    overflow: hidden;
}

.breadcrumb-seg {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 165px;
    min-width: 0;
    padding: 1px 5px;
    border: none;
    border-radius: 5px;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s;
}

.breadcrumb-seg.breadcrumb-unfiled {
    color: var(--text-muted);
}

.breadcrumb-seg span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breadcrumb-seg:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Inside a workspace: the breadcrumb segments take the accent color. */
.workspace-breadcrumb.active .breadcrumb-seg {
    color: var(--accent);
}

.breadcrumb-icon {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
}

.breadcrumb-sep {
    color: var(--text-muted);
    flex: 0 0 auto;
}

@media (max-width: 767px) {
    .breadcrumb-seg {
        max-width: 96px;
    }

    .chats-next-pill {
        max-width: 170px;
    }

    .chats-next-pill.home {
        max-width: 220px;
    }

    .chats-search-wrap {
        flex: 1 1 100%;
        min-width: 0;
    }

    .chats-home-toggle,
    .chats-project-toggle,
    .chats-filter-pill,
    .chats-step-btn {
        min-height: 36px;
    }

    .chats-group-new-btn,
    .chats-sub-new-btn {
        min-height: 34px;
    }
}

.drill-list {
    display: flex;
    flex-direction: column;
}

.empty-state.small {
    padding: 6px 8px;
    background: none;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* ===== Project files (modal) ===== */
.project-files-section {
    margin-top: 8px;
}

/* Quiet, inline empty state here — the global .empty-state grey box looks
   oversized for this small list area. */
.project-files-section .empty-state {
    padding: 8px 0;
    background: none;
    border-radius: 0;
}

.project-file-list {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.project-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-color);
}

.project-file-item:last-child {
    border-bottom: none;
}

/* Row-friendly version of the attachment type chip (.att-badge is absolute). */
.project-file-badge {
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.project-file-name {
    flex: 1;
    min-width: 0;
    font-size: var(--text-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-file-size {
    flex-shrink: 0;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Context toggle (CT-03): whether this file is loaded into chats. Sits at the
   row's left edge, before the type badge. Size, color and cursor come from the
   base checkbox rule (one 16px box app wide) — only the in-flight state below
   is specific to these rows. */
.project-file-toggle:disabled {
    cursor: progress;
}

/* An unloaded file stays fully legible (it is still a real file you may want to
   open, download, or delete) but reads as inactive at a glance. */
.project-file-item.is-context-off .project-file-name,
.project-file-item.is-context-off .project-file-badge {
    opacity: 0.55;
}

.project-file-item.is-context-off .project-file-name {
    font-style: italic;
}

.project-file-download,
.project-file-delete {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--text-base);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.project-file-download:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.project-file-delete:hover {
    background: var(--border-color);
    color: var(--error);
}

/* ===== Context Menu ===== */
.context-menu {
    position: absolute;
    min-width: 120px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    overflow: hidden;
}

.context-menu-item {
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: var(--text-sm);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background-color: var(--bg-tertiary);
}

.context-menu-check-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.context-menu .context-menu-check-item.active::after {
    float: none;
    margin-left: 0;
    flex-shrink: 0;
}

.context-menu-check-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.context-menu-item.context-menu-indent {
    padding-left: 26px;
}

.context-menu-item.danger {
    color: var(--error);
}

.context-menu-item.danger:hover {
    background-color: color-mix(in srgb, var(--error) 10%, transparent);
}

/* Wider variant used by the top-bar persona/model popovers */
.context-menu-wide {
    min-width: 200px;
    max-width: 280px;
}

.context-menu-separator {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
}

.context-menu-label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 16px 4px;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.context-menu-empty {
    padding: 10px 16px;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* Avatar options popover (WR-10): a context menu holding mini preset rows */
.avatar-menu {
    min-width: 230px;
}

.avatar-menu .avatar-menu-row {
    display: flex;
    gap: 6px;
    margin: 2px 12px 10px;
}

.avatar-menu .size-preset-btn,
.avatar-menu .position-preset-btn {
    padding: 6px 8px;
    font-size: var(--text-xs);
}

.avatar-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* The ✓ stays in the layout when unchecked (visibility, not textContent) so
   the glyph's taller line box can't nudge the row height on toggle. */
.avatar-menu-check {
    color: var(--accent);
    min-width: 14px;
    text-align: right;
}

.avatar-menu-check.off {
    visibility: hidden;
}

/* ===== Profile section (UP-02) — the user as a character =====
   Sibling of the Personas grid in the rail, and deliberately shaped like the
   persona editor rather than the Settings form: a persona describes who the
   model plays, this describes who it plays to. */

.profile-intro {
    margin-bottom: 18px;
}

/* A section is a card so the list reads as discrete blocks rather than one
   long form. The disabled state stays legible — it is kept content, not
   deleted content, and greying it out to unreadable would misreport that. */
.profile-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 12px;
    background: var(--bg-tertiary);
    transition: border-color 0.15s, opacity 0.15s;
}

.profile-section.disabled {
    opacity: 0.6;
    border-style: dashed;
}

.profile-section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* The title is an input, but should read as a heading until you touch it —
   a boxed field here made every section look like an unfilled form. */
.profile-section-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    border-color: transparent;
    background: transparent;
    font-size: var(--text-base);
    font-weight: 600;
}

.profile-section-title:hover {
    border-color: var(--border-color);
}

.profile-section-title:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.profile-section-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.profile-section-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 4px 0 0;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    cursor: pointer;
}

.profile-section-toggle input {
    margin: 0;
}

.profile-section-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.profile-section-btn:hover {
    border-color: var(--border-color);
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.profile-section-btn.danger:hover {
    border-color: var(--error);
    color: var(--error);
}

/* Body textareas carry the app-wide field appearance; only the reset of the
   resizable wrapper's margin belongs to this view. */
.profile-section .textarea-resizable {
    margin-bottom: 0;
}

.profile-section-body {
    width: 100%;
    margin-bottom: 0;
}

.profile-empty {
    margin: 0 0 12px;
    padding: 16px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    text-align: center;
}

/* The running cost line. Quiet by default; it is reassurance, not a warning. */
.profile-status {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--text-xs);
}

.profile-status.pending {
    color: var(--accent);
}
