.grammarViewCharts {
    display: grid;
    gap: 18px;
    width: 100%;
    margin-top: 18px;
    font-size: var(--main-font-size-1, inherit);
    line-height: 1.5;
}

.grammarViewChart {
    width: 100%;
    margin: 0;
}

.grammarViewChart figcaption {
    margin-bottom: 10px;
    font-weight: 700;
}

.grammarViewChartViewport {
    width: 100%;
    overflow: auto;
    padding: 12px;
    border: 1px solid #dce5f3;
    border-radius: 12px;
    background: #fbfdff;
}

/* 文法説明の枠内では、チャートの実寸でグリッドが広がらないようにする。 */
:is(.frame, .frameNonTitle) .grammarViewCharts {
    grid-template-columns: minmax(0, 1fr);
}

:is(.frame, .frameNonTitle) :is(.grammarViewCharts, .grammarViewChart, .grammarViewChartViewport) {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
}

.grammarViewChartMatrix {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 3px;
    font-size: inherit;
    line-height: inherit;
}

.grammarViewChartMatrix td {
    min-width: 135px;
    height: 55px;
    padding: 9px;
    box-sizing: border-box;
    border: 1px solid #dce5f3;
    border-radius: 7px;
    background: #fff;
    font-size: inherit;
    line-height: inherit;
    vertical-align: middle;
    white-space: pre-wrap;
}

.grammarViewChartMatrix tr:first-child td,
.grammarViewChartMatrix td:first-child {
    font-weight: 700;
    background: #eef4ff;
}

.grammarViewChartNodeArea {
    position: relative;
    min-width: 100%;
}

.grammarViewChartSvg {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 0;
}

.grammarViewChartNode {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 11px;
    border: 1px solid #526c9a;
    border-radius: 9px;
    box-sizing: border-box;
    background: #fff;
    box-shadow: 0 5px 15px rgba(35, 65, 120, .09);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    z-index: 2;
}

.grammarViewChartNodeText {
    display: block;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.grammarViewChartNode > .node-expansion-toggle {
    position: absolute;
    right: -12px;
    top: -12px;
    z-index: 6;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--main-color-3, #a78bfa);
    color: inherit;
    font: 700 13px/1 sans-serif;
    line-height: 1;
    cursor: pointer;
}
.grammarViewChartNode > .node-expansion-toggle[aria-expanded="true"] {
    background: var(--main-color-6, #c4b5fd);
}
.grammarViewChartNode > .node-expansion-list {
    position: absolute;
    left: 32px;
    bottom: calc(100% + 8px);
    display: grid;
    align-content: start;
    gap: 2px !important;
    width: max-content;
    min-width: max(100%, 180px);
    max-width: none;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid #526c9a;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 5px 15px rgba(35,65,120,.09);
    list-style: none;
}
.grammarViewChartNode > .nodeExpansionConnector {
    position:absolute;
    box-sizing:border-box;
    border-left:1px dashed #7c8eab;
    border-top:1px dashed #7c8eab;
    pointer-events:none;
}
.jwsChartSequence .grammarViewChartNode > .nodeExpansionConnector { visibility:hidden; }
.jwsChartSequence .grammarViewChartNode.animation-revealed > .nodeExpansionConnector { visibility:visible; }
.grammarViewChartNode > .node-expansion-list .expansionItem {
    display: list-item;
    min-height: 26px;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 26px;
    white-space: nowrap;
}
.grammarViewChartNode > .node-expansion-list .expansionItemGrammarTags {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
    width: 100%;
    max-width: 100%;
}
.grammarViewChartNode > .node-expansion-list .expansionItemGrammarTags .grammarViewChartNodeGrammarTag { max-width:100%;white-space:normal;overflow-wrap:anywhere;text-align:left; }
.grammarViewChartNodeGrammarTags {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    width: max-content;
    max-width: min(420px, 80vw);
    z-index: 4;
}
.grammarViewChartNodeGrammarTags.grammarViewChartNodeGrammarTagsRight { top:0;left:calc(100% + 6px);max-width:420px; }

.grammarViewChartNodeGrammarTag.grammarOutlineLabelButtonExplanation {
    width: auto;
    min-width: 0;
    min-height: 24px;
    margin: 0;
    padding: 3px 8px;
    border: 1px solid #7652aa;
    border-radius: 999px;
    background: #eee7fa;
    color: #38245a;
    font: inherit;
    font-size: .72em;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
}

.grammarViewChartNodeGrammarTag.grammarOutlineLabelButtonExplanation:hover,
.grammarViewChartNodeGrammarTag.grammarOutlineLabelButtonExplanation:focus-visible {
    background: #dfd2f4;
}

.grammarViewChartTreeNode {
    border-color: #7652aa;
}

.grammarViewChartLine {
    fill: none;
    stroke: #456fae;
    stroke-width: 2;
}

.grammarViewChartLine-dashed { stroke-dasharray: 8 6; }
.grammarViewChartLineDoubleOuter { stroke-width: 7; }
.grammarViewChartLine-double { stroke: #fbfdff; stroke-width: 3; }
.grammarViewChartArrow { fill: none; stroke: #456fae; stroke-width: 3; stroke-linejoin: round; }
.grammarViewChartDot { fill: #456fae; }

.grammarViewChartTreeLine {
    stroke: #456fae;
}

/* dashboard history also uses these read-only chart presentation classes. */
.historyChartSection.grammarViewChartViewport {
    box-sizing: border-box;
    background: #fbfdff;
    font-size: 20px;
    line-height: 1.4;
}

.historyChartNode.grammarViewChartNode {
    border-radius: 9px;
    border-color: #526c9a;
    box-shadow: 0 5px 15px rgba(35, 65, 120, .09);
}

.historyChartNode.grammarViewChartTreeNode {
    border-color: #7652aa;
}

.historyChartEdgeLabel.grammarViewChartEdgeLabel {
    transform: none;
}

.grammarViewChartEdgeLabel {
    position: absolute;
    min-width: 60px;
    max-width: 240px;
    padding: 5px 8px;
    border: 1px solid #afbed8;
    border-radius: 8px;
    box-sizing: border-box;
    background: #fff;
    text-align: center;
    white-space: pre-wrap;
    transform: translate(-50%, -50%);
    z-index: 3;
}

.grammarViewChartTypeconversation .grammarViewChartViewport {
    padding: 20px;
    background: #f7faf8;
}

.grammarViewConversationList {
    display: grid;
    gap: 28px;
    width: min(760px, 100%);
    margin: 0 auto;
}

.grammarViewConversationRow {
    position: relative;
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr) 76px;
    align-items: start;
    gap: 12px;
}

.grammarViewConversationRow:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    height: 28px;
    border-left: 2px solid #b8c5be;
}

.grammarViewConversationSpeaker {
    display: grid;
    justify-items: center;
    gap: 5px;
    grid-column: 1;
}

.grammarViewConversationRow-right .grammarViewConversationSpeaker {
    grid-column: 3;
}

.grammarViewConversationAvatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--conversation-person-color);
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    overflow: hidden;
}

.grammarViewConversationAvatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grammarViewConversationPersonName {
    max-width: 76px;
    font-size: .72em;
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
    overflow-wrap: anywhere;
}

.grammarViewConversationBubble {
    grid-column: 2;
    grid-row: 1;
    min-height: 62px;
    padding: 14px 16px;
    border: 1px solid var(--conversation-person-color);
    border-left: 5px solid var(--conversation-person-color);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(34, 60, 50, .08);
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.grammarViewConversationNarrationRow {
    display: block;
}

.grammarViewConversationNarration {
    position: relative;
    width: min(520px, 80%);
    margin: 0 auto;
    padding: 10px 42px;
    border: 1px solid #d5ddd8;
    border-radius: 999px;
    background: #eef2f0;
    color: #64716b;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.grammarViewConversationNarration::before,
.grammarViewConversationNarration::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 34px;
    border-top: 1px solid #b8c5be;
}

.grammarViewConversationNarration::before {
    right: 100%;
    margin-right: 10px;
}

.grammarViewConversationNarration::after {
    left: 100%;
    margin-left: 10px;
}

@media (max-width: 600px) {
    .grammarViewChartTypeconversation .grammarViewChartViewport {
        padding: 12px 8px;
    }

    .grammarViewConversationRow {
        grid-template-columns: 54px minmax(0, 1fr) 54px;
        gap: 7px;
    }

    .grammarViewConversationAvatar {
        width: 36px;
        height: 36px;
        font-size: 15px;
    }

    .grammarViewConversationPersonName {
        max-width: 54px;
        font-size: .62em;
    }

    .grammarViewConversationBubble {
        padding: 11px 12px;
    }
}
