@import url('https://fonts.googleapis.com/css2?family=Bad+Script&display=swap');

.stack-widget {
    font-size: 12px;
}

/* 俄语手写体：使用近似手写风格的字体 */
.letter-cursive {
    font-family: 'Bad Script', cursive;
}
.letter-cursive .btn_letter {
    font-family: inherit;
}

/* 字母表：仅带 .letter-head-col 的容器内表格第一列加粗（默认不加粗） */
.letter-head-col table td:first-child {
    font-weight: bold;
}

/* 假名表：点击发音按钮 */
.btn_letter {
    cursor: pointer;
    display: inline-block;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    transition: background 0.15s ease;
}
.btn_letter:hover {
    background: rgba(128, 128, 128, 0.15);
}
.btn_letter:active {
    background: rgba(128, 128, 128, 0.25);
}

/* 深色模式：使用浅色半透明，在深色背景上可见 */
[data-theme="dark"] .btn_letter:hover {
    background: rgba(255, 255, 255, 0.12);
}
[data-theme="dark"] .btn_letter:active {
    background: rgba(255, 255, 255, 0.2);
}
@media (prefers-color-scheme: dark) {
    .btn_letter:hover {
        background: rgba(255, 255, 255, 0.12);
    }
    .btn_letter:active {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* 字母表页：语言选择入口与弹窗（JS 动态注入） */
.letter-lang-picker-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin: 0.4em 0 1em;
}
.letter-lang-picker-btn {
    display: inline-block;
    cursor: pointer;
    padding: 0.3em 0.9em;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 1px solid rgba(128, 128, 128, 0.3);
    border-radius: 16px;
    background: rgba(128, 128, 128, 0.06);
    color: inherit;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.letter-lang-picker-btn:hover {
    background: rgba(128, 128, 128, 0.12);
    border-color: rgba(128, 128, 128, 0.5);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.letter-lang-picker-btn:active {
    background: rgba(128, 128, 128, 0.18);
}
/* 深色模式 */
[data-theme="dark"] .letter-lang-picker-btn {
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .letter-lang-picker-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .letter-lang-picker-btn:active {
    background: rgba(255, 255, 255, 0.18);
}
@media (prefers-color-scheme: dark) {
    .letter-lang-picker-btn {
        border-color: rgba(255, 255, 255, 0.25);
        background: rgba(255, 255, 255, 0.06);
    }
    .letter-lang-picker-btn:hover {
        background: rgba(255, 255, 255, 0.12);
        border-color: rgba(255, 255, 255, 0.4);
    }
}

.letter-lang-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 1rem;
}
.letter-lang-modal-panel {
    position: relative;
    width: 560px;
    max-width: 90vw;
    max-height: 86vh;
    padding: 1.25rem 1.5rem;
    border-radius: 10px;
    background: var(--card-bg, #fff);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}
[data-theme="dark"] .letter-lang-modal-panel {
    background: var(--card-bg);
}
.letter-lang-modal-title {
    margin: 0 0 0.6rem;
    font-size: 1.1rem;
}
.letter-lang-tab-scroll {
    position: relative;
    z-index: 3;
    min-height: 2.8rem;
    overflow-x: hidden;
    overflow-y: visible;
    padding-top: 0.2rem;
    padding-bottom: 0.1rem;
    background: var(--card-bg, #fff);
}
.letter-lang-tab-bar {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    min-width: 0;
    gap: 0;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid rgba(128, 128, 128, 0.28);
}
.letter-lang-tab-btn {
    flex: 0 0 auto;
    position: relative;
    padding: 0.45em 1.2em 0.4em;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.5;
    cursor: pointer;
    border: none;
    margin-bottom: 0;
    background: transparent;
    color: rgba(128, 128, 128, 0.65);
    transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.letter-lang-tab-btn::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 2px;
    background: transparent;
    pointer-events: none;
    z-index: 3;
}
.letter-lang-tab-btn:hover {
    color: inherit;
}
.letter-lang-tab-btn.active {
    color: inherit;
    box-shadow: none;
}
.letter-lang-tab-btn.active::after {
    background: var(--theme-color, #4a9df5);
}
[data-theme="dark"] .letter-lang-tab-bar {
    border-bottom-color: rgba(255, 255, 255, 0.22);
}
[data-theme="dark"] .letter-lang-tab-btn {
    color: rgba(255, 255, 255, 0.4);
}
[data-theme="dark"] .letter-lang-tab-btn:hover,
[data-theme="dark"] .letter-lang-tab-btn.active {
    color: inherit;
}
.letter-lang-tab-pane {
    display: none;
}
.letter-lang-tab-pane.active {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.letter-lang-modal-body {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 0.2rem;
    padding-right: 0.2rem;
}

.letter-lang-modal-section {
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
}
[data-theme="dark"] .letter-lang-modal-section {
    border-color: rgba(255, 255, 255, 0.15);
}
.letter-lang-modal-region {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(128, 128, 128, 0.7);
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}
.letter-lang-modal-branch {
    font-size: 0.72rem;
    color: rgba(128, 128, 128, 0.62);
    margin-bottom: 0.35rem;
}
.letter-lang-modal-section .letter-lang-modal-list {
    margin-bottom: 0.45rem;
}
.letter-lang-modal-section .letter-lang-modal-list:last-child {
    margin-bottom: 0;
}
.letter-lang-modal-line {
    padding: 0.35rem 0.1rem;
    border-bottom: 1px dashed rgba(128, 128, 128, 0.2);
    line-height: 1.8;
}
.letter-lang-modal-line:last-child {
    border-bottom: none;
}
.letter-lang-inline-link {
    display: inline-block;
    color: inherit;
    text-decoration: none;
    margin-left: 0.15rem;
    font-size: 0.84rem;
    line-height: 1.6;
    white-space: nowrap;
}
.letter-lang-inline-link:hover {
    text-decoration: underline;
}
[data-theme="dark"] .letter-lang-modal-line {
    border-bottom-color: rgba(255, 255, 255, 0.15);
}
[data-theme="dark"] .letter-lang-modal-region {
    color: rgba(255, 255, 255, 0.45);
}
[data-theme="dark"] .letter-lang-modal-branch {
    color: rgba(255, 255, 255, 0.4);
}
.letter-lang-modal-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: flex-start;
}
.letter-lang-modal-link {
    display: inline-block;
    padding: 0.25em 0.55em;
    color: inherit;
    text-decoration: none;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 0.84rem;
}
.letter-lang-modal-link:hover {
    background: rgba(128, 128, 128, 0.15);
    text-decoration: underline;
}
[data-theme="dark"] .letter-lang-modal-link:hover {
    background: rgba(255, 255, 255, 0.1);
}
.letter-lang-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: inherit;
}
.letter-lang-modal-close:hover {
    background: rgba(128, 128, 128, 0.2);
}
[data-theme="dark"] .letter-lang-modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* 书写系统弹窗：提示文字 */
.letter-lang-modal-hint {
    font-size: 0.8rem;
    color: rgba(128, 128, 128, 0.7);
    margin-bottom: 0.5rem;
}
[data-theme="dark"] .letter-lang-modal-hint {
    color: rgba(255, 255, 255, 0.4);
}

/* 书写系统弹窗："其他"标签中的文字体系标注 */
.letter-lang-writing-badge {
    display: block;
    font-size: 0.7em;
    line-height: 1.3;
    color: rgba(128, 128, 128, 0.65);
    margin-top: 0.1em;
}
[data-theme="dark"] .letter-lang-writing-badge {
    color: rgba(255, 255, 255, 0.4);
}

/* 索引页"有发音"徽章 */
.lang-has-audio {
    display: inline-block;
    font-size: 0.7em;
    line-height: 1;
    padding: 0.2em 0.5em;
    margin-left: 0.3em;
    border-radius: 8px;
    background: #43a047;
    color: #fff;
    vertical-align: middle;
    white-space: nowrap;
}
[data-theme="dark"] .lang-has-audio {
    background: #2e7d32;
}

/* "其他"标签：badge 导致内容稍宽，仍保持 nowrap 但允许自然撑开 */
.letter-lang-modal-list.wide {
    display: flex;
    flex-wrap: wrap;
}