:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-light: #dee2e6;
    --accent: #4a6fa5;
    --alert: #f8d7da;
    --alert-border: #dc3545;
    --hover-overlay: rgba(0, 0, 0, 0.03);
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    margin: 20px;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.4;
    font-size: 0.9rem;
}

h2 {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 6px;
    display: inline-block;
    font-size: 1.6rem;
}

/* 输入框基础样式（紧凑型） */
textarea {
    font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    resize: vertical;
    box-sizing: border-box;
    max-height: 40vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.2);
}

/* 主容器：单一模式布局 */
.multi-container {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

.multi-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 10px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
    padding: 16px;
}

.multi-box h3 {
    margin-top: 0;
    color: var(--accent);
    font-size: 1rem;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
}

/* 预览标题：包含不匹配计数 */
.multi-preview-title {
    display: flex;
    align-items: center;
    font-size: 1rem;
    color: var(--text-primary);
    margin: 20px 0 12px;
    padding-left: 4px;
    border-left: 3px solid var(--accent);
}

.multi-preview-title .mismatch-count {
    background: var(--alert);
    color: var(--alert-border);
    font-weight: bold;
    font-size: 0.9rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 8px;
    min-width: 24px;
    text-align: center;
    font-family: 'Segoe UI', sans-serif;
    white-space: nowrap;
}

/* 对齐预览容器 */
.multi-preview {
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    border-left: 3px solid var(--accent);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

/* 每一对音节行 */
.pair-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 6px;
    white-space: nowrap;
    border-radius: 6px;
    position: relative;
    margin-left: -20px;
    padding: 4px 8px 4px 20px;
}

/* 不匹配行：左侧添加警告图标 */
.pair-row.mismatch::before {
    content: "❗";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--alert-border);
    font-weight: bold;
    font-size: 1.1rem;
    text-shadow: 0 0 1px #fff;
    pointer-events: none;
}

.pair-row.mismatch {
    background: var(--alert);
    border-left: 3px solid var(--alert-border);
    margin-left: -20px;
    padding-left: 20px;
}

.pair {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 3px 6px;
    min-width: 25px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.pair:hover {
    background: var(--hover-overlay);
}

.top {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 1px;
}

.bottom {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.mismatch .top,
.mismatch .bottom {
    color: #721c24 !important;
}

/* 提示文本 */
p.small {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 12px 0;
    line-height: 1.7;
}

/* 指向 kana.html 的小引导条 */
.goto-kana {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(90deg, rgba(74, 111, 165, 0.06), transparent);
    border: 1px dashed var(--border-light);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.86rem;
    margin-bottom: 12px;
}

.goto-kana a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.goto-kana a:hover {
    text-decoration: underline;
}

/* 无障碍隐藏文本（屏幕阅读器可见，视觉上隐藏） */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* 滚动条优化 */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* 按钮基础样式，统一页面上的交互按钮外观 */
button {
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover {
    background: var(--hover-overlay);
}

/* 添加新词版本按钮 - 作为主操作，使用强调色 */
button.add-btn {
    background: var(--accent);
    color: #fff;
    border-color: rgba(74,111,165,0.9);
}

button.add-btn:hover {
    filter: brightness(0.95);
}

/* 删除按钮 - 使用细线并在悬停/聚焦时显示红色提示 */
button.delete-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}

button.delete-btn:hover {
    border-color: var(--alert-border);
    color: var(--alert-border);
    background: rgba(220,53,69,0.06);
}

/* 调整 multi-box 中控件按钮的布局与大小，使其与输入区视觉一致 */
.multi-box > div {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

/* 在小屏上让按钮行换行，避免溢出 */
@media (max-width: 480px) {
    .multi-box > div {
        flex-wrap: wrap;
        gap: 6px;
    }
}

/* 响应式微调 */
@media (max-width: 768px) {
    body {
        margin: 12px;
        font-size: 0.9rem;
    }

    .multi-container {
        flex-direction: column;
    }

    .multi-box {
        margin-bottom: 16px;
    }
}
