﻿.pinyin-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
}

.pinyin-line {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    margin: 10px 0;
    flex-wrap: wrap;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.pinyin-text,
.chinese-text {
    letter-spacing: 0;
}

.pinyin-text {
    color: #000000;
    font-size: 0.9em;
    line-height: 1.2;
    margin-bottom: 0.3em;
    text-align: center;
    white-space: nowrap;
    font-family: system-ui, Arial, sans-serif;
}

.chinese-text {
    color: #000000;
    font-size: 1.1em;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    font-family: system-ui, Arial, sans-serif;
}

/* 单行模式 */
.pinyin-wrapper.single-line {
    text-align: left;
    align-items: flex-start;
}

    .pinyin-wrapper.single-line .pinyin-line {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        margin: 1em 0;
        width: 100%;
    }

    .pinyin-wrapper.single-line .pinyin-text {
        margin-bottom: 0;
        margin-right: 0.5em;
        white-space: normal;
        letter-spacing: 2px;
    }

    .pinyin-wrapper.single-line .chinese-text {
        white-space: normal;
        letter-spacing: 2px;
    }

/* 单行模式：字符单元固定宽度，保证换行后的行内对齐 */
.pinyin-wrapper.single-line .pinyin-char-group {
    align-items: center;
    width: 2.2em;
    min-width: 2.2em;
    max-width: 2.2em;
}

/* 与 PoemFormatter 集成 */
.poem-uniform .pinyin-line,
.poem-irregular .pinyin-line {
    margin: 0.5em 0;
}

.poem-uniform .pinyin-text,
.poem-irregular .pinyin-text {
    letter-spacing: 8px;
}

/* 不等长：整块左对齐 */
.poem-irregular {
    text-align: left;
    align-items: flex-start;
}

/* 不等长：取消字符分组的固定宽度与居中对齐 */
.poem-irregular .pinyin-char-group {
    align-items: flex-start;
    width: auto;
    min-width: auto;
    max-width: none;
}

.poem-irregular .pinyin-line {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
}

/* 响应式设计 */
@media screen and (max-width: 768px) {


    .pinyin-char-group {
        width: 1.3em;
        min-width: 1.3em;
        max-width: 1.3em;
    }

    /* 单行模式：移动端同样固定字符宽度，保证整齐 */
    .pinyin-wrapper.single-line .pinyin-char-group {
        width: 1.3em;
        min-width: 1.3em;
        max-width: 1.3em;
    }

        .pinyin-char-group .pinyin {
            font-size: 9px;
            margin-bottom: 1px;
            white-space: nowrap;
        }

        .pinyin-char-group .hanzi {
            font-size: 13px;
        }

    /* 不等长：移动端同样取消固定宽度 */
    .poem-irregular .pinyin-char-group {
        width: auto;
        min-width: auto;
        max-width: none;
    }

    .header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        padding: 8px 0 !important;
    }

        .header-row .title {
            font-size: 1.1em !important;
            word-break: break-all;
        }

        .header-row .author,
        .header-row .pinyin-label,
        .header-row .voice-btn {
            font-size: 0.95em !important;
        }

    .header-btns {
        flex-direction: row !important;
        gap: 6px !important;
        margin-top: 6px !important;
    }

    .pinyin-switch .pinyin-label {
        font-size: 0.95em !important;
    }

    .voice-btn {
        width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
    }

        .voice-btn svg {
            width: 20px !important;
            height: 20px !important;
            display: block;
            margin: 0 auto;
        }
}

.pinyin-char-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 2.2em;
    min-width: 2.2em;
    max-width: 2.2em;
}

    .pinyin-char-group .pinyin {
        color: #7d97ad;
        font-size: 13px;
        line-height: 1.2;
        border-bottom: 1px dotted #bdbdbd;
        width: 100%;
        text-align: center;
        font-family: Arial, sans-serif;
        margin-bottom: 2px;
        white-space: nowrap;
    }

    .pinyin-char-group .hanzi {
        color: #222;
        font-size: 20px;
        line-height: 1.5;
        font-family: 'Microsoft YaHei', Arial, sans-serif;
        text-align: center;
        width: 100%;
    }

    .pinyin-char-group.punct .pinyin {
        border-bottom: none;
        color: transparent;
    }

    .pinyin-char-group.punct .hanzi {
        color: #222;
    }

.poem-line-single,
.pinyin-line.single {
    letter-spacing: 0.5em;
}

/* 单行模式：自适应换行，左对齐，不滚动 */
.pinyin-line.single {
    white-space: normal;
    overflow: visible;
    flex-wrap: wrap;
  
    letter-spacing: 0; /* 取消额外字距 */
    align-items: flex-start; /* 同一行顶部对齐，避免有高有低 */
}

.pinyin-line.single .pinyin-char-group,
.pinyin-line.single .pinyin,
.pinyin-line.single .hanzi {
    white-space: normal;
}

/* 单行模式：拼音与汉字的细节优化 */
.pinyin-line.single .pinyin-char-group .pinyin {
    color: #a8b4c4; /* 更柔和的拼音颜色 */
    border-bottom-color: #cfd6dd; /* 虚线更浅 */
    line-height: 1.2; /* 上行固定行高 */
    height: 1.2em;   /* 上行固定高度，保证整齐 */
}

.pinyin-line.single .pinyin-char-group .hanzi {
    line-height: 1.6; /* 下行固定行高 */
    height: 1.6em;   /* 下行固定高度，保证整齐 */
}

/* 单行模式：标点更紧凑 */
.pinyin-line.single .pinyin-char-group.punct {
    margin-right: 4px;
}

.pinyin-char-group.mizige {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 2.2em;
    margin: 0 0.1em;
    position: relative;
}

    .pinyin-char-group.mizige .pinyin-outside {
        display: block;
        color: #7d97ad;
        font-size: 15px;
        line-height: 1.2;
        font-family: Arial, sans-serif;
        margin-bottom: 5px;
        white-space: nowrap;
        min-height: 1.1em;
    }

    .pinyin-char-group.mizige .hanzi-wrap {
        position: relative;
        width: 2.2em;
        height: 2.2em;
        display: block;
    }

    .pinyin-char-group.mizige .mizige-bg {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 0;
        pointer-events: none;
        background: url('data:image/svg+xml;utf8,<svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="100%" height="100%" fill="none" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/><line x1="0" y1="0" x2="100%" y2="100%" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/><line x1="100%" y1="0" x2="0" y2="100%" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/><line x1="50%" y1="0" x2="50%" y2="100%" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/><line x1="0" y1="50%" x2="100%" y2="50%" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/></svg>') center/cover no-repeat;
    }

    .pinyin-char-group.mizige .hanzi {
        position: absolute;
        left: 0;
        top: 45%;
        width: 100%;
        text-align: center;
        color: #222;
        font-size: 22px;
        line-height: 1.5;
        font-family: 'Microsoft YaHei', Arial, sans-serif;
        z-index: 1;
        transform: translateY(-50%);
        pointer-events: none;
    }

    .pinyin-char-group.mizige.punct .pinyin-outside {
        color: transparent;
    }

    .pinyin-char-group.mizige.punct .hanzi {
        color: #222;
    }

@media screen and (max-width: 768px) {
    .pinyin-char-group.mizige {
        width: 1.6em;
    }

        .pinyin-char-group.mizige .pinyin-outside {
            font-size: 12px;
            min-height: 0.8em;
            margin-bottom: 3px;
        }

        .pinyin-char-group.mizige .hanzi-wrap {
            width: 1.6em;
            height: 1.6em;
        }

        .pinyin-char-group.mizige .hanzi {
            top: 47%;
            font-size: 16px;
        }
}

/* 拼音米字格展示样式 */
.pinyin-line, .hanzi-line {
    display: flex;
    justify-content: center;
    margin-bottom: 1px;
}

.hanzi-cell {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-family: 'Kaiti', '楷体', serif;
    background: url('data:image/svg+xml;utf8,<svg width="38" height="38" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="38" height="38" fill="none" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/><line x1="0" y1="0" x2="38" y2="38" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/><line x1="38" y1="0" x2="0" y2="38" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/><line x1="19" y1="0" x2="19" y2="38" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/><line x1="0" y1="19" x2="38" y2="19" stroke="%23e06666" stroke-width="0.4" stroke-dasharray="2,2"/></svg>') center/cover no-repeat;
    margin: 0 2px;
}

.pinyin-cell {
    width: 38px;
    text-align: center;
    font-size: 14px;
    color: #444;
    font-family: 'Arial', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    margin: 0 2px;
}

/* 拼音开关样式 */
.pinyin-toggle-row {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0;
    margin-top: 0;
}

.pinyin-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

    .pinyin-switch input[type="checkbox"] {
        display: none;
    }

    .pinyin-switch .slider {
        width: 36px;
        height: 20px;
        background: #e6d8b6;
        border-radius: 12px;
        position: relative;
        margin-right: 8px;
        transition: background 0.2s;
    }

        .pinyin-switch .slider:before {
            content: "";
            position: absolute;
            left: 3px;
            top: 3px;
            width: 14px;
            height: 14px;
            background: #fff;
            border-radius: 50%;
            transition: transform 0.2s;
        }

    .pinyin-switch input:checked + .slider {
        background: #b89b5b;
    }

        .pinyin-switch input:checked + .slider:before {
            transform: translateX(16px);
        }

.pinyin-label {
    font-size: 14px;
    color: #a88a4e;
    font-weight: 500;
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
    .hanzi-cell {
        width: 32px;
        height: 32px;
        font-size: 22px;
    }

    .pinyin-cell {
        width: 32px;
        font-size: 12px;
    }

    .pinyin-switch .slider {
        width: 32px;
        height: 18px;
    }

        .pinyin-switch .slider:before {
            width: 12px;
            height: 12px;
        }

    .pinyin-switch input:checked + .slider:before {
        transform: translateX(14px);
    }

    .pinyin-label {
        font-size: 12px;
    }
}

/* 拼音显示样式 */
.pinyin-content {
    margin-top: 15px;
    line-height: 1.8;
    padding: 10px;
    background-color: #f9f5ea;
    border-radius: 4px;
}

.pinyin-line {
    margin-bottom: 5px;
    clear: both;
    overflow: hidden;
}

.pinyin-char {
    display: inline-block;
    text-align: center;
    margin-right: 5px;
    vertical-align: top;
}

.pinyin-char .py {
    display: block;
    font-size: 12px;
    color: #b89b5b;
    height: 20px;
    line-height: 20px;
}

.pinyin-char .hz {
    display: block;
    font-size: 18px;
    font-weight: 500;
    color: #333;
}

.non-pinyin {
    display: inline-block;
    margin-right: 5px;
    font-size: 18px;
    line-height: 40px;
}

/* 语音播放器样式 */
.audio-player {
    margin: 15px 0;
    padding: 10px;
    background: #f9f5ea;
    border-radius: 4px;
}

.audio-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #b89b5b;
}

.audio-player audio {
    width: 100%;
}

/* 错误信息样式 */
.error {
    color: #e74c3c;
    padding: 10px;
    background: #fef2f0;
    border-radius: 4px;
    margin: 10px 0;
}

/* 加载中样式 */
.loading {
    text-align: center;
    padding: 20px;
    color: #888;
}

/* 仅移动端：逗号后换行占位 */
.br-after-comma {
    display: inline;
}

@media screen and (max-width: 768px) {
    .br-after-comma {
        display: block;
        width: 100%;
        height: 0;
        line-height: 0;
        margin: 0;
        padding: 0;
        clear: both;
    }
}