/*
 * Chat auxiliary CSS
 *
 * Ownership: docs/architecture/css-ownership.md
 * Loaded after questionnaire.css and before Campaign Space/gameplay layers.
 * Scope: chat shell, toolbar/meta panels, party chat, auxiliary modals, world/profile lists and responsive overrides.
 */

.dm-body.chat-sidebar-open,
.dm-body.chat-history-open,
.dm-body.chat-gallery-open,
.dm-body.chat-comments-open,
.dm-body.chat-party-open,
.dm-body.community-comments-mobile-open {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

/* ------------------------------ CHAT ------------------------------ */

.chat-card-header {
    display: grid;
    gap: var(--spacing-xs);
}

.chat-card-header h3 {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.45rem;
    color: var(--color-text-primary);
}

.chat-card-subtitle {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.chat-profile-list {
    margin: var(--spacing-md) 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 12px;
}

.chat-profile-list li {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px;
    border-radius: var(--radius-md);
    background: rgba(12, 14, 29, 0.88);
    border: 1px solid rgba(120, 132, 220, 0.18);
}

.chat-profile-list .item-label {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.chat-profile-list .item-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.chat-limit-card {
    margin: var(--spacing-lg) auto;
    padding: 24px;
    border-radius: var(--radius-lg);
    background: rgba(12, 14, 29, 0.92);
    border: 1px solid rgba(120, 132, 220, 0.22);
    box-shadow: var(--shadow-card);
    display: grid;
    gap: var(--spacing-sm);
    text-align: center;
    max-width: 520px;
}

.chat-limit-card h4 {
    margin: 0;
    font-size: 1.25rem;
    font-family: 'Montserrat', sans-serif;
}

.chat-limit-card p {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.95rem;
}

.chat-limit-actions {
    margin-top: var(--spacing-md);
    display: flex;
    justify-content: center;
}

.chat-profile-list .item-empty {
    text-align: center;
    color: var(--color-text-secondary);
}

.chat-world-form {
    display: grid;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.chat-world-field {
    display: grid;
    gap: 8px;
}

.chat-world-field label {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.chat-world-actions {
    justify-content: flex-start;
}

.chat-select {
    cursor: pointer;
}

.chat-card-empty {
    margin: var(--spacing-md) 0 0;
    color: var(--color-text-secondary);
}

.chat-world-tree {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-world-region {
    border: 1px solid rgba(73, 107, 229, 0.18);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(22, 24, 45, 0.92), rgba(16, 18, 34, 0.92));
    padding: 14px 18px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.chat-world-region + .chat-world-region {
    margin-top: 4px;
}

.chat-world-region[open] {
    border-color: rgba(73, 107, 229, 0.55);
    box-shadow: 0 12px 28px rgba(12, 16, 38, 0.55);
}

.chat-world-region summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 12px;
    row-gap: 4px;
    align-items: center;
    color: var(--color-text-primary);
}

.chat-world-region summary strong {
    font-size: 1.05rem;
    grid-column: 1 / 2;
}

.chat-world-region summary small {
    color: rgba(199, 207, 255, 0.72);
    font-weight: 500;
    grid-column: 1 / 2;
}

.chat-world-region summary::-webkit-details-marker {
    display: none;
}

.chat-world-region summary::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    justify-self: end;
    font-size: 0.85rem;
    color: rgba(180, 190, 255, 0.72);
    transition: transform var(--transition-fast);
    grid-column: 2 / 3;
}

.chat-world-region[open] summary::after {
    transform: rotate(180deg);
}

.chat-world-location-list {
    list-style: none;
    padding-left: 0;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-world-location-list li {
    padding: 12px;
    border-radius: 14px;
    background: rgba(27, 30, 55, 0.85);
    border: 1px solid rgba(73, 107, 229, 0.22);
    display: grid;
    gap: 6px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.chat-world-location-list li.is-active {
    border-color: rgba(73, 107, 229, 0.55);
    box-shadow: 0 12px 24px rgba(12, 16, 32, 0.55);
    transform: translateY(-2px);
}

.location-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text-primary);
}

.location-summary {
    opacity: 0.85;
    line-height: 1.5;
}

.location-tags {
    font-size: 0.85rem;
    opacity: 0.78;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.location-tags span {
    font-weight: 600;
}

.chat-npc-list {
    list-style: none;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-npc-list li {
    padding: 10px;
    border-radius: 12px;
    background: rgba(27, 30, 55, 0.9);
    border: 1px solid rgba(73, 107, 229, 0.16);
}

.chat-npc-list li.is-active {
    border-color: rgba(255, 193, 7, 0.55);
    box-shadow: 0 0 0 1px rgba(255, 193, 7, 0.35);
}

.npc-name {
    font-weight: 600;
}

.npc-role,
.npc-traits,
.npc-location {
    font-size: 0.85rem;
    opacity: 0.8;
}

.dm-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1050;
}

.dm-modal.is-open {
    display: flex;
}

.dm-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(6, 7, 16, 0.78);
    backdrop-filter: blur(3px);
}

.dm-modal__dialog {
    position: relative;
    background: rgba(18, 20, 38, 0.95);
    border: 1px solid rgba(120, 132, 220, 0.22);
    border-radius: 18px;
    padding: 28px;
    width: min(420px, calc(100% - 32px));
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dm-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dm-modal__close {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.dm-modal__close:hover,
.dm-modal__close:focus-visible {
    color: var(--color-text-primary);
}

.dm-modal__body p {
    margin: 0;
    color: var(--color-text-secondary);
}

.dm-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.chat-shell {
    width: 100%;
    min-height: calc(100vh - 120px);
    padding: 0 20px 40px;
    display: flex;
    gap: var(--spacing-lg);
    align-items: flex-start;
    position: relative;
    max-width: 1280px;
    margin: 0 auto;
}

/* Safe area para dispositivos com notch */
@supports (padding: max(0px)) {
    .chat-shell {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-bottom: max(40px, env(safe-area-inset-bottom));
    }
}


.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.chat-toolbar {
    position: sticky;
    top: 92px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 24px;
    gap: 12px;
    flex-wrap: wrap;
    background: rgba(12, 14, 29, 0.88);
    border: 1px solid rgba(120, 132, 220, 0.24);
    border-radius: 20px;
    box-shadow: 0 14px 36px rgba(5, 9, 28, 0.35);
    backdrop-filter: blur(10px);
    z-index: 6;
}

.chat-share-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.chat-share-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(18, 20, 38, 0.6);
    border: 1px solid rgba(120, 132, 220, 0.25);
}

.chat-share-status.is-public {
    color: #9fffb4;
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.35);
}

.chat-share-status.is-private {
    color: var(--color-text-secondary);
}

.chat-share-form {
    display: inline-flex;
    align-items: center;
}

.chat-share-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(120, 132, 220, 0.26);
    color: var(--color-text-primary);
    text-decoration: none;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.chat-share-link:hover {
    border-color: rgba(73,107,229,0.55);
    background: rgba(32, 36, 66, 0.92);
}

.chat-toolbar__status {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.chat-toolbar__actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.chat-meta-panel {
    position: sticky;
    top: 84px;
    margin-top: 8px;
    margin-bottom: 10px;
    background: rgba(8, 10, 22, 0.52);
    border: 1px solid rgba(120, 132, 220, 0.16);
    border-radius: 12px;
    box-shadow: none;
    backdrop-filter: blur(10px);
    overflow: hidden;
    z-index: 6;
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.chat-meta-panel--compact {
    margin-top: 4px;
    margin-bottom: 6px;
    background: rgba(8, 10, 22, 0.3);
    border-color: rgba(120, 132, 220, 0.12);
}

.chat-meta-panel.is-open {
    box-shadow: 0 18px 42px rgba(5, 9, 28, 0.4);
    border-color: rgba(120, 132, 220, 0.35);
}

.chat-meta-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 14px;
    border-bottom: 1px solid rgba(120, 132, 220, 0.18);
}

.chat-meta-header__info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    flex: 1;
}

.chat-meta-header__badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(73, 107, 229, 0.18);
    border: 1px solid rgba(73, 107, 229, 0.32);
    border-radius: 999px;
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.chat-meta-panel--compact .chat-meta-header {
    padding: 7px 12px;
    border-bottom: none;
}

.chat-meta-panel--compact .chat-meta-header__info {
    gap: 8px;
}

.chat-meta-panel--compact .chat-meta-header__badge {
    background: rgba(73, 107, 229, 0.12);
    border-color: rgba(73, 107, 229, 0.2);
    font-size: 0.74rem;
}

.chat-share-status--compact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid;
}

.chat-share-status--compact.is-public {
    background: rgba(56, 224, 168, 0.16);
    border-color: rgba(56, 224, 168, 0.32);
    color: var(--color-success);
}

.chat-share-status--compact.is-private {
    background: rgba(73, 107, 229, 0.18);
    border-color: rgba(73, 107, 229, 0.32);
    color: var(--color-text-secondary);
}

.chat-meta-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid rgba(120, 132, 220, 0.24);
    border-radius: 8px;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.chat-meta-toggle:hover {
    background: rgba(73, 107, 229, 0.12);
    border-color: rgba(73, 107, 229, 0.35);
}

.chat-meta-toggle i {
    transition: transform var(--transition-fast);
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.chat-meta-toggle.is-open i {
    transform: rotate(-180deg);
}

.chat-meta-toggle__label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--color-text-primary);
}

.chat-meta-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: rgba(10, 12, 26, 0.92);
}

.chat-meta-content[hidden] {
    display: none;
}

.chat-meta-row {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.chat-meta-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chat-meta-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 14px;
    background: rgba(18, 20, 38, 0.88);
    border: 1px solid rgba(120, 132, 220, 0.22);
    color: var(--color-text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
    position: relative;
}

.chat-meta-button:hover,
.chat-meta-button:focus-visible {
    background: rgba(32, 36, 66, 0.92);
    border-color: rgba(73, 107, 229, 0.45);
    transform: translateY(-1px);
}

.chat-meta-button--accent {
    border-color: rgba(73, 107, 229, 0.45);
}

.chat-meta-roster {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 16px;
    background: rgba(16, 18, 34, 0.88);
    border: 1px solid rgba(120, 132, 220, 0.18);
}

.chat-meta-roster__title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.chat-meta-roster__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-meta-roster__status {
    min-height: 18px;
    margin: 0;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.chat-meta-roster__status.is-visible {
    opacity: 1;
}

.chat-meta-roster__status[data-state="success"] {
    color: #58d68d;
}

.chat-meta-roster__status[data-state="warning"] {
    color: #f4d03f;
}

.chat-meta-roster__status[data-state="error"] {
    color: #ff5162;
}

.chat-meta-roster__chip {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(18, 20, 38, 0.9);
    border: 1px solid rgba(120, 132, 220, 0.22);
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.chat-meta-roster__chip strong {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.3;
}

.chat-meta-roster__role {
    font-style: normal;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(73, 107, 229, 0.85);
    font-weight: 500;
    line-height: 1.2;
}

.chat-meta-roster__character {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-style: italic;
    line-height: 1.2;
}

.chat-meta-roster__chip.is-self {
    border-color: rgba(73, 107, 229, 0.55);
    color: var(--color-text-primary);
}

.info-label {
    display: block;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    color: var(--color-text-secondary);
    opacity: 0.85;
}

.info-value {
    font-size: 1.02rem;
    color: var(--color-text-primary);
    font-weight: 600;
}

.chat-meta-roster__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.chat-meta-roster__action {
    border: 1px solid rgba(120, 132, 220, 0.4);
    background: rgba(10, 12, 26, 0.72);
    color: var(--color-text-primary);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.chat-meta-roster__action:hover {
    border-color: rgba(73, 107, 229, 0.58);
    background: rgba(32, 36, 66, 0.9);
    transform: translateY(-1px);
}

.chat-meta-roster__action.is-danger {
    border-color: rgba(255, 81, 98, 0.5);
    color: #ff9aa6;
}

.chat-meta-roster__action.is-danger:hover {
    border-color: rgba(255, 81, 98, 0.8);
    background: rgba(127, 29, 29, 0.42);
}

.chat-meta-button.has-unread::after,
.chat-party-toggle.has-unread::after {
    content: "";
    position: absolute;
    top: 10px;
    right: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 0 2px rgba(10, 12, 26, 0.9);
}

.chat-party-toggle {
    position: relative;
}

.chat-meta-invite {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(120, 132, 220, 0.16);
}

.chat-meta-invite.is-sending {
    opacity: 0.75;
    pointer-events: none;
}

.chat-meta-invite__label {
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.chat-meta-invite__row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-meta-invite__row input[type="text"] {
    flex: 1;
    min-width: 0;
    background: rgba(10, 12, 26, 0.78);
    border: 1px solid rgba(120, 132, 220, 0.22);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--color-text-primary);
}

.chat-meta-invite__row input[type="text"]::placeholder {
    color: var(--color-text-muted);
}

.chat-meta-invite__row input[type="text"]:focus-visible {
    outline: none;
    border-color: rgba(73, 107, 229, 0.55);
    box-shadow: 0 0 0 2px rgba(73, 107, 229, 0.18);
}

.chat-status-banner {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    background: rgba(73, 107, 229, 0.12);
    border: 1px solid rgba(73, 107, 229, 0.3);
    border-radius: 20px;
    padding: 18px 22px;
    margin: 20px 24px 0;
    color: var(--color-text-primary);
    box-shadow: 0 18px 36px rgba(5, 9, 28, 0.25);
}

.chat-status-banner strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.chat-status-banner p {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.chat-status-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(73, 107, 229, 0.22);
    color: var(--color-accent);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.chat-status-banner[hidden] {
    display: none !important;
}

/* Legacy support - manter compatibilidade */
.chat-sidebar-toggle--floating,
.chat-comments-toggle--floating,
.chat-party-toggle--floating {
    display: none;
}

.chat-party-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: calc(100% - 16px);
}

.party-panel-section-title {
    margin: 2px 2px -2px;
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    font-weight: 700;
}

.party-round-objective {
    border: 1px solid rgba(73, 107, 229, 0.24);
    border-radius: 14px;
    background: rgba(12, 16, 34, 0.72);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.party-round-objective[hidden] {
    display: none !important;
}

.party-round-objective__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.party-round-objective__title {
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.party-round-objective__button {
    border: 1px solid rgba(73, 107, 229, 0.42);
    border-radius: 999px;
    background: rgba(73, 107, 229, 0.16);
    color: var(--color-text-primary);
    font-size: 0.72rem;
    padding: 4px 10px;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.party-round-objective__button:hover {
    border-color: rgba(73, 107, 229, 0.7);
    background: rgba(73, 107, 229, 0.28);
}

.party-round-objective__button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.party-round-objective__text {
    margin: 0;
    color: var(--color-text-primary);
    font-size: 0.8rem;
    line-height: 1.45;
}

.party-round-objective__meta {
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

.chat-card-header {
    margin-bottom: 10px;
}

.chat-goal-text {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--color-text-primary);
}

.chat-goal-meta {
    display: block;
    margin-top: 8px;
    font-size: 0.74rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.chat-context-rules {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 8px;
    color: var(--color-text-secondary);
    font-size: 0.82rem;
    line-height: 1.45;
}

.chat-context-lock {
    margin: 10px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(73, 107, 229, 0.25);
    background: rgba(16, 20, 42, 0.68);
    color: var(--color-text-secondary);
    font-size: 0.78rem;
    line-height: 1.4;
}

.chat-context-lock[data-state="locked"] {
    border-color: rgba(255, 159, 67, 0.45);
    background: rgba(84, 48, 18, 0.32);
    color: #ffd6a2;
}

.chat-context-lock[data-state="open"] {
    border-color: rgba(56, 224, 168, 0.35);
    background: rgba(14, 54, 42, 0.26);
    color: #9ff3ce;
}

.chat-memory-card {
    display: grid;
    gap: 12px;
}

.chat-memory-row {
    display: grid;
    gap: 8px;
}

.chat-memory-row h4 {
    margin: 0;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chat-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(73, 107, 229, 0.32);
    background: rgba(73, 107, 229, 0.12);
    color: var(--color-text-secondary);
    font-size: 0.74rem;
    line-height: 1;
}

.chat-chip.is-empty {
    border-style: dashed;
    background: rgba(18, 20, 38, 0.6);
    color: var(--color-text-muted);
}

.chat-memory-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-arc-state {
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid rgba(73, 107, 229, 0.3);
    background: rgba(16, 20, 42, 0.7);
    color: var(--color-text-secondary);
    font-size: 0.78rem;
    line-height: 1.45;
}

.chat-arc-state[data-state="empty"] {
    border-style: dashed;
    color: var(--color-text-muted);
    background: rgba(12, 14, 29, 0.62);
}

.chat-location-action {
    white-space: nowrap;
}

.chat-risk-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 6px;
}

.chat-risk-item {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    line-height: 1.45;
}

.chat-risk-item.is-empty {
    list-style: none;
    margin-left: -18px;
    color: var(--color-text-muted);
}

.chat-channel-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 10px;
}

.chat-channel-list li {
    display: grid;
    gap: 2px;
    border: 1px solid rgba(120, 132, 220, 0.2);
    border-radius: 10px;
    background: rgba(12, 14, 29, 0.72);
    padding: 10px 12px;
}

.chat-channel-list__name {
    font-size: 0.82rem;
    color: var(--color-text-primary);
    font-weight: 600;
}

.chat-channel-list__meta {
    font-size: 0.74rem;
    color: var(--color-text-muted);
}

.party-objective-threads {
    border: 1px solid rgba(73, 107, 229, 0.24);
    border-radius: 14px;
    background: rgba(12, 16, 34, 0.72);
    padding: 10px 12px;
    display: grid;
    gap: 10px;
}

.party-objective-threads[hidden] {
    display: none !important;
}

.party-objective-threads__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.party-objective-threads__title {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.party-objective-threads__clear {
    border: none;
    background: transparent;
    color: rgba(173, 186, 255, 0.95);
    font-size: 0.74rem;
    font-weight: 600;
    padding: 2px 6px;
}

.party-objective-threads__clear:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.party-objective-threads__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.party-objective-threads__chip {
    border: 1px solid rgba(73, 107, 229, 0.28);
    background: rgba(73, 107, 229, 0.12);
    color: var(--color-text-secondary);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.74rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.party-objective-threads__chip:hover {
    border-color: rgba(73, 107, 229, 0.52);
    background: rgba(73, 107, 229, 0.2);
}

.party-objective-threads__chip.is-active {
    border-color: rgba(56, 224, 168, 0.48);
    background: rgba(56, 224, 168, 0.2);
    color: #d5fff0;
}

.party-chat-item__thread {
    font-size: 0.72rem;
    color: rgba(173, 186, 255, 0.95);
    border: 1px solid rgba(73, 107, 229, 0.32);
    border-radius: 999px;
    padding: 2px 8px;
    background: rgba(73, 107, 229, 0.12);
    white-space: nowrap;
    margin-left: auto;
}

.dm-modal-open {
    overflow: hidden;
}

.dm-modal--text {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
}

.dm-modal--text.is-open {
    display: block;
}

.dm-modal--text .dm-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(7, 10, 20, 0.75);
    backdrop-filter: blur(3px);
}

.dm-modal--text .dm-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(620px, calc(100vw - 32px));
    margin: min(12vh, 80px) auto 0;
    border-radius: 16px;
    border: 1px solid rgba(120, 132, 220, 0.26);
    background: linear-gradient(180deg, rgba(13, 17, 36, 0.98), rgba(9, 12, 28, 0.98));
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.dm-modal--text .dm-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(120, 132, 220, 0.2);
}

.dm-modal--text .dm-modal__close {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(120, 132, 220, 0.3);
    border-radius: 10px;
    background: rgba(13, 17, 36, 0.9);
    color: var(--color-text-secondary);
}

.dm-modal--text .dm-modal__body {
    padding: 16px;
    display: grid;
    gap: 12px;
}

.dm-modal--text .dm-modal__title {
    margin: 0;
    font-size: 1.05rem;
    color: var(--color-text-primary);
}

.dm-modal--text .dm-modal__description {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    line-height: 1.45;
}

.dm-modal--text .dm-modal__textarea {
    min-height: 110px;
    resize: vertical;
    background: rgba(12, 14, 29, 0.96);
    border: 1px solid rgba(120, 132, 220, 0.3);
    color: var(--color-text-primary);
}

.dm-modal--text .dm-modal__counter {
    text-align: right;
    color: var(--color-text-muted);
    font-size: 0.74rem;
}

.dm-modal--text .dm-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.party-chat-body {
    flex: 1;
    overflow-y: auto;
    border-radius: 16px;
    border: 1px solid rgba(73, 107, 229, 0.18);
    background: rgba(12, 14, 29, 0.9);
    padding: 18px 16px;
    -webkit-overflow-scrolling: touch;
    min-height: 140px;
    max-height: 38vh;
}

.party-chat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 16px;
}

.party-chat-item {
    background: rgba(18, 20, 38, 0.92);
    border: 1px solid rgba(73, 107, 229, 0.2);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s ease, background 0.2s ease;
    position: relative;
}

.party-chat-item:hover {
    border-color: rgba(73, 107, 229, 0.35);
    background: rgba(18, 20, 38, 0.98);
}

.party-chat-item--objective {
    border-color: rgba(56, 224, 168, 0.38);
    background: rgba(56, 224, 168, 0.08);
}

.party-chat-item__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    min-height: 28px;
    flex-wrap: nowrap; /* Evita quebra de linha que causa sobreposição */
}

.party-chat-item__author-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0; /* Permite que o wrapper encolha se necessário */
    overflow: hidden; /* Previne overflow */
}

.party-chat-item__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    flex-shrink: 0;
}

.party-chat-item__author {
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    flex-shrink: 1;
}

.party-chat-item__meta time {
    color: var(--color-text-secondary);
    font-size: 0.72rem;
    opacity: 0.8;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 12px; /* Espaçamento maior para evitar sobreposição */
}

.party-chat-item__content {
    margin: 0;
    color: var(--color-text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding-top: 2px;
}

.party-chat-empty {
    text-align: center;
    padding: 14px 12px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    border: 1px dashed rgba(73, 107, 229, 0.35);
    border-radius: 12px;
    background: rgba(73, 107, 229, 0.06);
}

.party-chat-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 4px;
}

.party-chat-form__label {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

.party-chat-form__input {
    border-radius: 14px;
    border: 1px solid rgba(120, 132, 220, 0.24);
    background: rgba(12, 14, 29, 0.96);
    color: var(--color-text-primary);
    padding: 14px 16px;
    resize: vertical;
    min-height: 90px;
    font-size: 0.9rem;
    line-height: 1.5;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.party-chat-form__input:focus {
    outline: none;
    border-color: rgba(73, 107, 229, 0.5);
    box-shadow: 0 0 0 3px rgba(73, 107, 229, 0.15);
}

.party-chat-form__input.is-disabled {
    opacity: 0.5;
}

.party-chat-form__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.party-chat-form__counter {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.party-chat-form__counter.is-warning {
    color: #f1c40f;
}

.party-chat-form__counter.is-critical {
    color: #ff5162;
}

.party-chat-form__feedback {
    min-height: 18px;
    font-size: 0.78rem;
    color: var(--color-text-secondary);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.party-chat-form__feedback.is-visible {
    opacity: 1;
}

.party-chat-form__feedback[data-state="error"] {
    color: #ff5162;
}

.party-chat-form__feedback[data-state="success"] {
    color: #58d68d;
}

.chat-realtime-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    padding: 6px 12px;
    border-radius: 999px;
    margin: 0 0 10px 0;
    width: fit-content;
    border: 1px solid rgba(73, 107, 229, 0.28);
    background: rgba(12, 16, 34, 0.58);
    color: var(--color-text-secondary);
}

.chat-realtime-pill::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35);
    animation: chatRealtimePulse 1.8s infinite;
}

.chat-realtime-pill[data-state="online"]::before {
    background: var(--color-success);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.35);
}

.chat-realtime-pill[data-state="online"] {
    display: none;
}

.chat-realtime-pill[data-state="offline"]::before {
    background: var(--color-danger);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35);
}

@keyframes chatRealtimePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.35);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

.chat-system-banner {
    border-radius: 10px;
    padding: 10px 12px;
    margin: 8px 0;
    border: 1px solid var(--color-border);
    background: rgba(12, 16, 34, 0.65);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.chat-system-banner[data-tone="warning"] {
    border-color: rgba(255, 198, 88, 0.45);
    background: rgba(88, 62, 12, 0.35);
    color: var(--color-warning);
}

.chat-system-banner[data-tone="error"] {
    border-color: rgba(255, 81, 98, 0.45);
    background: rgba(74, 19, 34, 0.4);
    color: var(--color-danger);
}

.chat-system-banner__message {
    display: block;
    line-height: 1.5;
}

.chat-system-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chat-system-banner__action {
    min-height: 36px;
    border: 1px solid currentColor;
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-decoration: none;
}

.chat-system-banner__action:hover,
.chat-system-banner__action:focus-visible {
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 575.98px) {
    .chat-system-banner__actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .chat-system-banner__action {
        width: 100%;
    }
}


.party-chat-disabled {
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    background: rgba(18, 20, 38, 0.92);
    border: 1px dashed rgba(120, 132, 220, 0.32);
    border-radius: 12px;
    padding: 14px 16px;
    display: none;
}

.chat-party-panel[data-can-send="false"] .party-chat-form {
    opacity: 0.5;
    pointer-events: none;
}

.chat-party-panel[data-can-send="false"] .party-chat-form__counter {
    color: var(--color-text-muted);
}

.chat-party-panel[data-can-send="false"] .party-chat-disabled {
    display: block;
}


@media (max-width: 991px) {
    .chat-shell {
        flex-direction: column;
        padding-bottom: 80px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .chat-main {
        gap: var(--spacing-md);
        width: 100%;
    }


    .chat-meta-panel {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }


    .party-chat-body {
        padding: 14px 12px;
    }

    .party-chat-list {
        gap: 12px;
    }

    .party-chat-item {
        padding: 12px 14px;
        gap: 8px;
    }

    .party-chat-item__meta {
        gap: 8px;
        flex-wrap: wrap;
    }

    .party-chat-item__author-wrapper {
        gap: 8px;
        flex: 1 1 auto;
        min-width: 0;
    }

    .party-chat-item__avatar {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }

    .party-chat-item__author {
        font-size: 0.8rem;
        max-width: 150px;
    }

    .party-chat-item__meta time {
        font-size: 0.7rem;
        padding-left: 4px;
        margin-left: 0;
    }

    .party-chat-item__content {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .party-chat-form {
        gap: 12px;
    }

    .party-chat-form__input {
        padding: 12px 14px;
        min-height: 80px;
        font-size: 16px; /* Evita zoom no iOS */
    }

    .party-chat-form__footer {
        gap: 10px;
    }
}

/* ------------------------------ MEDIA QUERIES ------------------------------ */

@media (max-width: 991px) {
    .chat-container {
        border-radius: 20px;
    }
}

@media (max-width: 575px) {
    /* Chat Mobile Optimizations */
    .chat-shell {
        padding: 0 12px 20px;
    }


    .chat-meta-panel {
        margin-top: 6px;
        margin-bottom: 10px;
        border-radius: 14px;
    }

    .chat-meta-header {
        padding: 10px 12px;
    }

    .chat-meta-header__info {
        gap: 4px;
        flex-wrap: wrap;
    }

    .chat-meta-toggle__label {
        font-size: 0.85rem;
    }

    .chat-meta-header__badge,
    .chat-share-status--compact {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .chat-meta-panel--compact {
        margin-bottom: 4px;
    }


    .chat-meta-content {
        padding: 14px 12px;
        gap: 14px;
    }

    .chat-meta-roster {
        padding: 12px;
        border-radius: 12px;
    }

    .chat-meta-roster__chip {
        padding: 8px 10px;
        font-size: 0.8rem;
        gap: 3px;
    }

    .chat-meta-roster__chip strong {
        font-size: 0.85rem;
    }

    .chat-meta-roster__role {
        font-size: 0.65rem;
    }

    .party-round-objective {
        padding: 10px 12px;
        gap: 6px;
    }

    .party-round-objective__text {
        font-size: 0.8rem;
    }

    .party-objective-threads {
        padding: 9px 10px;
    }

    .party-objective-threads__chip {
        font-size: 0.72rem;
        padding: 5px 9px;
    }

    .chat-memory-actions {
        gap: 6px;
    }

    .chat-location-action {
        width: 100%;
        justify-content: center;
    }

    .dm-modal--text .dm-modal__dialog {
        width: calc(100vw - 20px);
        margin-top: 8vh;
    }

    .dm-modal--text .dm-modal__body {
        padding: 14px;
    }

    .chat-meta-roster__character {
        font-size: 0.7rem;
    }
}
