.npc-dialogues {
    width: 100%;
}

.npc-dialogues__surface {
    background: var(--mud-palette-surface);
}

.npc-dialogues__search {
    max-width: 20rem;
}

.npc-dialogues__layout {
    display: grid;
    grid-template-columns: minmax(20rem, 14rem) minmax(0, 1fr);
    gap: 1.25rem;
    min-height: 36rem;
    align-items: start;
}

.npc-dialogues__layout--with-detail {
    grid-template-columns: minmax(20rem, 14rem) minmax(0, 1fr) minmax(16rem, 22rem);
}

.npc-dialogues__npc-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 72vh;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.npc-dialogues__npc-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 0.65rem;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    font: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.npc-dialogues__npc-btn:hover {
    background: rgba(128, 128, 128, 0.1);
}

.npc-dialogues__npc-btn--active {
    background: rgba(var(--mud-palette-primary-rgb), 0.1);
    border-color: rgba(var(--mud-palette-primary-rgb), 0.35);
    box-shadow: 0 0 0 1px rgba(var(--mud-palette-primary-rgb), 0.15);
}

.npc-dialogues__npc-avatar {
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.npc-dialogues__npc-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.npc-dialogues__npc-meta {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    text-align: left;
}

.npc-dialogues__npc-name {
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.npc-dialogues__npc-id {
    font-size: 0.68rem;
    opacity: 0.75;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.npc-dialogues__npc-stats {
    font-size: 0.72rem;
    opacity: 0.65;
}

.npc-dialogues__sequences {
    min-width: 0;
    max-height: 72vh;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.npc-dialogues__empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 20rem;
    padding: 2rem;
    border: 1px dashed rgba(128, 128, 128, 0.35);
    border-radius: 0.75rem;
    background: rgba(128, 128, 128, 0.04);
}

.npc-dialogues__hero {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1rem 1.1rem;
    margin-bottom: 1.25rem;
    border-radius: 0.75rem;
    background: linear-gradient(
        135deg,
        rgba(var(--mud-palette-primary-rgb), 0.08) 0%,
        rgba(128, 128, 128, 0.06) 100%
    );
    border: 1px solid rgba(var(--mud-palette-primary-rgb), 0.15);
}

.npc-dialogues__hero-quest {
    flex-shrink: 0;
    margin-left: auto;
    display: flex;
    align-items: flex-start;
    align-self: flex-start;
}

.npc-dialogues__hero-quest .mud-chip {
    margin: 0;
    justify-content: flex-start;
}

.npc-dialogues__hero-avatar {
    flex-shrink: 0;
    width: 5.5rem;
    height: 5.5rem;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(var(--mud-palette-primary-rgb), 0.25);
}

.npc-dialogues__hero-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.npc-dialogues__hero-text {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    text-align: left;
}

.npc-dialogues__hero-id {
    font-size: 0.8rem;
    opacity: 0.8;
}

.npc-dialogues__hero-description {
    max-width: 40rem;
    opacity: 0.9;
}

.npc-dialogues__category-label {
    display: block;
    margin: 0.75rem 0 0.5rem;
    letter-spacing: 0.08em;
}

.npc-dialogues__sequence-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    align-items: stretch;
    gap: 0.65rem;
    margin-bottom: 0.5rem;
}

.npc-dialogues__sequence-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    align-self: stretch;
    height: 100%;
    min-height: 100%;
    gap: 0.35rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid rgba(128, 128, 128, 0.28);
    border-radius: 0.65rem;
    background: var(--mud-palette-surface);
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.npc-dialogues__sequence-card:hover {
    border-color: rgba(var(--mud-palette-primary-rgb), 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.npc-dialogues__sequence-card--active {
    border-color: var(--mud-palette-primary);
    box-shadow: 0 0 0 2px rgba(var(--mud-palette-primary-rgb), 0.2);
}

.npc-dialogues__sequence-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.35rem 0.5rem;
    width: 100%;
    text-align: left;
}

.npc-dialogues__sequence-card-head .mud-typography,
.npc-dialogues__sequence-card-head .mud-chip {
    margin: 0;
    justify-content: flex-start;
}

.npc-dialogues__sequence-key {
    display: block;
    width: 100%;
    margin: 0;
    font-size: 0.68rem;
    opacity: 0.7;
    text-align: left;
    word-break: break-all;
}

.npc-dialogues__sequence-preview {
    margin: 0;
    width: 100%;
    font-size: 0.85rem;
    line-height: 1.45;
    text-align: left;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.npc-dialogues__sequence-card .mud-typography {
    margin: 0;
}

.npc-dialogues__sequence-preview--empty {
    font-style: italic;
    opacity: 0.55;
}

.npc-dialogues__lines {
    position: sticky;
    top: 0;
    max-height: 72vh;
    overflow-y: auto;
    padding: 0.85rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(128, 128, 128, 0.28);
    background: var(--mud-palette-background);
}

.npc-dialogues__lines-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.npc-dialogues__lines-key-prefix {
    display: block;
    font-size: 0.72rem;
    opacity: 0.75;
    margin-top: 0.25rem;
    word-break: break-all;
}

.npc-dialogues__lines-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.npc-dialogues__line-card {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
}

.npc-dialogues__line-badge {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: rgba(var(--mud-palette-primary-rgb), 0.15);
    color: var(--mud-palette-primary);
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.npc-dialogues__line-body {
    min-width: 0;
    flex: 1;
}

.npc-dialogues__line-text {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.npc-dialogues__line-text--empty {
    font-style: italic;
    opacity: 0.55;
}

.npc-dialogues__line-key {
    font-size: 0.68rem;
    opacity: 0.65;
    word-break: break-all;
}

@media (max-width: 960px) {
    .npc-dialogues__layout,
    .npc-dialogues__layout--with-detail {
        grid-template-columns: 1fr;
    }

    .npc-dialogues__npc-list {
        max-height: none;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .npc-dialogues__npc-btn {
        width: auto;
        max-width: 14rem;
    }

    .npc-dialogues__lines {
        position: static;
        max-height: none;
    }
}
