 /*
 * Grammar.css - 语法综合模块样式
 * 完全参考 QuickStart / Vocabulary 的二级导航设计语言
 */

/* ============================================================
   1. 基础容器
   ============================================================ */
.grammar-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    background-color: #fafafa;
    width: 100%;
    position: relative;
}

/* 固定头部 */
.grammar-wrapper .grammar-fixed-header {
    position: relative;
    top: 0;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    left: 0 !important;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   2. 二级导航（图标+文字，图标在上，文字在下）
   完全对齐 QuickStart / Vocabulary 的 sub-nav 样式
   ============================================================ */
.grammar-wrapper .grammar-sub-nav-container {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: none;
    height: 58px;
    background: #ffffff !important;
    padding: 0 0 0 24px !important;
    box-sizing: border-box;
    z-index: 6000;
}

/* 底线伪元素 */
.grammar-wrapper .grammar-sub-nav-container::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: rgba(0, 0, 0, 0.15);
    z-index: 25;
}

/* 右侧滚动条遮挡 */
.grammar-wrapper .grammar-sub-nav-container::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    width: 8px;
    height: 58px;
    background: #ffffff;
    z-index: 20;
}

.grammar-wrapper .grammar-sub-nav-bar {
    display: flex !important;
    justify-content: flex-start !important;
    gap: 20px !important;
    padding: 0 10px !important;
    height: 64px !important;
    overflow-x: auto;
    align-items: center;
    border-bottom: none;
    scroll-behavior: smooth;
}

/* 滚动条隐藏但保留滚动功能 */
.grammar-wrapper .grammar-sub-nav-bar::-webkit-scrollbar {
    display: none;
}

.grammar-wrapper .grammar-sub-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 2px !important;
    gap: 1px !important;
    min-width: 56px;
    flex-shrink: 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.grammar-wrapper .grammar-sub-icon {
    width: 28px !important;
    height: 28px !important;
    color: rgba(29, 29, 31, 0.88) !important;
    stroke: currentColor !important;
    fill: none;
}

.grammar-wrapper .grammar-sub-label {
    font-size: 13px !important;
    font-weight: 500;
    color: rgba(29, 29, 31, 0.55) !important;
    margin-top: -1px !important;
    white-space: nowrap;
}

/* 二级导航交互：hover 变蓝、active 加粗 */
.grammar-wrapper .grammar-sub-item:hover:not(.active) .grammar-sub-label {
    color: #0066cc !important;
}

.grammar-wrapper .grammar-sub-item.active .grammar-sub-label {
    color: rgba(29, 29, 31, 0.88) !important;
    text-shadow: 0.4px 0 0 currentColor; /* 防抖加粗 */
}

.grammar-wrapper .grammar-sub-item.active .grammar-sub-icon {
    color: rgba(29, 29, 31, 0.88) !important;
}

/* ============================================================
   3. 内容滚动区域
   ============================================================ */
.grammar-wrapper .grammar-content-scroll-area {
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    min-height: 0;
    padding: 24px 28px 40px;
}

.grammar-wrapper .grammar-content-scroll-area::-webkit-scrollbar {
    width: 8px;
}

.grammar-wrapper .grammar-content-scroll-area::-webkit-scrollbar-track {
    background: transparent;
}

.grammar-wrapper .grammar-content-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

/* ============================================================
   4. 内容详情区
   ============================================================ */
.grammar-wrapper .grammar-detail-container {
    max-width: 900px;
    margin: 0 auto;
}

.grammar-wrapper .grammar-detail-header {
    margin-bottom: 28px;
}

.grammar-wrapper .grammar-detail-title {
    font-size: 22px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0 0 8px;
}

.grammar-wrapper .grammar-detail-desc {
    font-size: 14px;
    color: #86868b;
    line-height: 1.6;
    margin: 0;
}

/* ============================================================
   5. 语法预览卡片网格
   ============================================================ */
.grammar-wrapper .grammar-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.grammar-wrapper .grammar-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 20px 16px;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    cursor: pointer;
}

.grammar-wrapper .grammar-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.grammar-wrapper .grammar-card-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.grammar-wrapper .grammar-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 6px;
}

.grammar-wrapper .grammar-card-desc {
    font-size: 13px;
    color: #86868b;
    line-height: 1.5;
}

/* ============================================================
   6. 动词活用 — 专用卡片样式
   ============================================================ */

/* --- 动词选择标签条 --- */
.grammar-wrapper .verb-select-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.grammar-wrapper .verb-select-tag {
    padding: 6px 18px;
    border: 1.5px solid rgba(0, 0, 0, 0.12);
    border-radius: 20px;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
}

.grammar-wrapper .verb-select-tag:hover {
    border-color: #c8507a;
    color: #c8507a;
}

.grammar-wrapper .verb-select-tag.active {
    background: #c8507a;
    border-color: #c8507a;
    color: #fff;
    font-weight: 600;
}

/* --- 动词详情卡片 --- */
.grammar-wrapper .verb-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
    padding: 32px 36px 28px;
    max-width: 680px;
    margin: 0 auto;
}

/* 卡片头部 */
.grammar-wrapper .verb-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
}

.grammar-wrapper .verb-card-title-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px;
}

.grammar-wrapper .verb-reading {
    font-size: 28px;
    font-weight: 800;
    color: #1d1d1f;
    letter-spacing: 0.5px;
}

.grammar-wrapper .verb-kanji-bracket {
    font-size: 22px;
    font-weight: 700;
    color: #333;
    margin-left: 2px;
}

.grammar-wrapper .verb-meanings {
    font-size: 14px;
    color: #86868b;
    margin-left: 10px;
    font-weight: 400;
}

.grammar-wrapper .verb-level-tag {
    flex-shrink: 0;
    padding: 4px 14px;
    background: #0066cc;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

/* 动词类型标签 */
.grammar-wrapper .verb-type-row {
    margin-bottom: 22px;
}

.grammar-wrapper .verb-type-tag {
    display: inline-block;
    padding: 3px 16px;
    background: linear-gradient(135deg, #c8507a, #d4668e);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border-radius: 14px;
    letter-spacing: 1px;
}

/* --- 活用形网格 --- */
.grammar-wrapper .verb-forms-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.grammar-wrapper .verb-form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: background 0.15s ease;
    border-radius: 8px;
}

.grammar-wrapper .verb-form-row:hover {
    background: rgba(200, 80, 122, 0.04);
}

.grammar-wrapper .verb-form-row:nth-child(odd) {
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    padding-right: 20px;
}

.grammar-wrapper .verb-form-row:nth-child(even) {
    padding-left: 20px;
}

.grammar-wrapper .verb-form-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.grammar-wrapper .verb-form-name {
    font-size: 13px;
    font-weight: 600;
    color: #c8507a;
}

.grammar-wrapper .verb-form-meaning {
    font-size: 12px;
    color: #86868b;
}

.grammar-wrapper .verb-form-value {
    font-size: 22px;
    font-weight: 700;
    color: #1d1d1f;
    letter-spacing: 0.5px;
}

/* --- 例句区域 --- */
.grammar-wrapper .verb-example-area {
    margin-top: 24px;
    padding: 18px 22px;
    background: #faf0f5;
    border-radius: 12px;
    border-left: 4px solid #c8507a;
}

.grammar-wrapper .verb-example-line {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}

.grammar-wrapper .verb-example-romaji {
    font-size: 12px;
    color: #b07090;
    font-style: italic;
    letter-spacing: 0.3px;
}

.grammar-wrapper .verb-example-jp {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.6;
}

.grammar-wrapper .verb-example-zh {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

/* ============================================================
   7. N1语法 — 真实数据双栏详情布局（移植自 grammar-12 设计稿）
   ============================================================ */

/* 双栏布局容器加宽（默认详情区 900px） */
.grammar-wrapper .grammar-detail-container.grammar-detail-wide {
    max-width: 1300px;
    height: 100%;
}

.grammar-wrapper .grammar-n1-layout {
    display: flex;
    gap: 0; /* 双栏不留间隔：左栏滚动条贴右沿与右栏列表紧挨，留白改由左栏右内边距承担 */
    align-items: flex-start;
    margin-top: -19px; /* 内容区顶 padding 24px - 19px = 左栏距二级导航下沿 5px */
}

/* N1 双栏：内容区去右内边距，列表栏贴窗口右沿；
   双列各自独立滚动，外层容器不再整体滚动 */
.grammar-wrapper .grammar-content-scroll-area.n1-flush-right {
    padding: 5px 0 12px 28px;
    overflow: hidden !important;
}

.grammar-wrapper .grammar-n1-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    /* 语法内容流独立滚动容器：显示细滚动条（样式同右栏列表） */
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    /* 不设 scrollbar-width：Chrome 下其非 auto 值会使 ::-webkit-scrollbar 自定义失效，
       回退原生滚动条并露出轨道背景边线；细滚动条由下方 webkit 伪元素实现 */
    /* 原双栏 gap 的留白移入容器内部：正文收尾位置不变，滚动条外移到右沿与右栏紧挨 */
    padding-right: 32px;
}

/* 滚动到底时为底部悬浮分页栏（高约30px）预留2倍其高度的占位，避免遮挡末尾内容；
   用伪元素占位项而非容器 padding-bottom：部分浏览器不将滚动容器自身尾部 padding 计入可滚动区域 */
.grammar-wrapper .grammar-n1-left::after {
    content: "";
    flex: 0 0 60px;
}

.grammar-wrapper .grammar-n1-left::-webkit-scrollbar {
    width: 4px;
}

/* 轨道全透明：不留背景色与边线，只保留滑块 */
.grammar-wrapper .grammar-n1-left::-webkit-scrollbar-track {
    background: transparent;
}

.grammar-wrapper .grammar-n1-left::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

/* 双栏撑满内容区：顶间距改由内容区 padding-top 承担 */
.grammar-wrapper .grammar-detail-wide .grammar-n1-layout {
    height: 100%;
    margin-top: 0;
}

/* 内容流语法块之间的分隔线 */
.grammar-wrapper .grammar-stream-block + .grammar-stream-block {
    margin-top: 28px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding-top: 16px; /* 分隔线到下一块主词条的留白高度减少 1/3（24px → 16px） */
}

/* --- 主词条与发音扬声器 --- */
.grammar-wrapper .grammar-main-heading {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 6px; /* 与语义看板间距再减半（13px → 6px） */
}

.grammar-wrapper .grammar-word {
    font-size: 36px; /* 主标题缩小 3px */
    font-weight: 800;
    color: #1e293b;
    margin: 0;
    letter-spacing: -0.5px;
}

.grammar-wrapper .audio-inline-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    opacity: 0.4;
    transition: opacity 0.2s, transform 0.1s;
    padding: 0;
    line-height: 1;
}

.grammar-wrapper .audio-inline-btn:hover {
    opacity: 1;
}

.grammar-wrapper .audio-inline-btn:active {
    transform: scale(0.9);
}

/* --- 多语义一体化轻量看板（单行并排） --- */
.grammar-wrapper .semantic-tips-panel {
    background-color: #f0f7ff;
    border: 1px solid #e1eeff;
    border-radius: 6px;
    padding: 10px 20px;
    margin-bottom: 12px; /* 与义项树间距减半（24px → 12px） */
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    column-gap: 0;
    row-gap: 8px;
}

.grammar-wrapper .semantic-inline-item {
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
}

.grammar-wrapper .si-badge {
    color: #1e5cb3;
    font-weight: 700;
    margin-right: 6px;
}

.grammar-wrapper .si-text {
    color: #334155;
}

/* 两两语义项之间自动生成间隔斜杠 //
   色/字重与 .si-text 保持一致：库内简述自带字面 // 时二者视觉统一 */
.grammar-wrapper .semantic-inline-item:not(:last-child)::after {
    content: "//";
    color: #334155;
    margin-left: 20px;
    margin-right: 20px;
    user-select: none;
}

/* --- 接续区 --- */
.grammar-wrapper .section-title-label {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px; /* 接续标题与首行接续的行距减少 4px */
    letter-spacing: 0.5px;
}

.grammar-wrapper .connection-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px; /* 行距 6px，同列条目间距 20px */
    margin-bottom: 16px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 14px 10px 5px;
}

.grammar-wrapper .connection-box {
    padding: 0;
    line-height: normal;
    font-size: 14px;
    font-weight: 700;
    color: #d32f2f;
    white-space: nowrap; /* 每条接续绝不内部折行 */
}

/* 接续序号（外圆圈样式） */
.grammar-wrapper .conn-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    box-sizing: border-box;
    border: 1px solid #334155;
    border-radius: 50%;
    font-family: monospace;
    font-size: 9px; /* 适配 12px 圆圈内空间 */
    font-weight: 700;
    color: #334155;
    margin-right: 6px;
    vertical-align: middle;
}

/* --- 核心逻辑树结构 --- */
.grammar-wrapper .senses-tree-container {
    display: flex;
    flex-direction: column;
    gap: 10px; /* 义项块间距减半（21px → 10px） */
}

.grammar-wrapper .sense-tree-block {
    display: flex;
    flex-direction: column;
    gap: 5px; /* 义项与例句间距减半（10px → 5px） */
    position: relative;
    padding-left: 20px;
}

.grammar-wrapper .sense-headline {
    display: flex;
    align-items: flex-start; /* 序号徽章与义项文本首行对齐，多行时不居中 */
    gap: 10px;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    color: #334155;
    margin-left: -20px; /* 圆圈序号徽章与主树线精准对齐 */
}
.sense-meaning-sub {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 400;
    color: #5f6470;
    line-height: 1.6;
}

.grammar-wrapper .sense-dot {
    background-color: #1e5cb3;
    color: #fff;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 3px;
}

/* --- 例句池分支 --- */
.grammar-wrapper .examples-tree-branch {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-left: 10px;
}

.grammar-wrapper .grammar-n1-left ruby {
    ruby-position: over;
    ruby-align: center;
}

.grammar-wrapper .grammar-n1-left rt {
    font-size: 10px;
    color: #64748b;
    padding-bottom: 3px;
    user-select: none;
}

/* 日文原句加粗，拉开中日文视距 */
.grammar-wrapper .ex-jp-text {
    font-size: 16px;
    line-height: 2;
    color: #0f172a;
    font-weight: 600;
}

/* 中文翻译变细变淡，消除沉重感 */
.grammar-wrapper .ex-tr-text {
    font-size: 14px;
    color: #64748b;
    margin-top: 2px;
    font-weight: 400;
}

.grammar-wrapper .ex-note-text {
    font-size: 13px;
    color: #94a3b8;
    margin-top: 2px;
}

.grammar-wrapper .ex-index {
    color: #94a3b8;
    font-weight: 700;
    margin-right: 8px;
}

/* --- 右栏：纵向可搜索语法点列表（独立滚动列，撑满内容区高度） ---
   只保留左侧竖线分隔，其余边框/圆角/阴影全部取消 */
.grammar-wrapper .grammar-n1-sidebar {
    width: 320px;
    flex-shrink: 0;
    background-color: #ffffff;
    border-radius: 0;
    padding: 20px;
    border: none;
    border-left: 1px solid #eaeded;
    position: static;
    height: 100%;
    display: flex;
    flex-direction: column;
    margin-top: -3px; /* 左栏 5px 基础上再上移：距二级导航下沿 2px（原 10px 的 1/5） */
    box-shadow: none;
    box-sizing: border-box;
}

.grammar-wrapper .sidebar-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.grammar-wrapper .sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}

.grammar-wrapper .count-badge {
    background-color: #f1f3f5;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

.grammar-wrapper .grammar-list-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* 滚动条贴列表卡片右沿（抵消侧栏右内边距），条目同步加宽；
       左侧负外边距使条目起始位置左移 */
    margin: 0 -20px 0 -12px;
    padding-right: 0;
}

.grammar-wrapper .grammar-list-scroll::-webkit-scrollbar {
    width: 4px;
}

.grammar-wrapper .grammar-list-scroll::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

.grammar-wrapper .list-item {
    display: flex;
    align-items: center;
    padding: 5px 12px 5px 4px; /* 行间距缩减 1/3（空白 18px → 12px）；左内边距再收窄 4px 使序号左移 */
    border-radius: 4px; /* 列表行圆角减小 */
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
}

.grammar-wrapper .list-item:hover {
    background-color: #f8fafc;
}

.grammar-wrapper .list-item.active-item {
    background-color: #fff1f1;
}

/* 右栏分类头行（模块 → 分类 → 词条 层级中间层）：粘性吸顶，滚动时持续提示当前分类 */
.grammar-wrapper .list-section-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 8px 12px 4px 4px;
    margin-top: 4px;
    border-top: 1px solid #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(#ffffff 85%, rgba(255, 255, 255, 0));
}

.grammar-wrapper .list-section-header .section-code {
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
    color: #d32f2f;
    flex-shrink: 0;
}

.grammar-wrapper .list-section-header .section-text {
    font-size: 14px;
    font-weight: 700;
    color: #334155;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grammar-wrapper .item-id {
    font-family: monospace;
    font-size: 15px; /* 列表文字增大 2px */
    color: #94a3b8;
    width: 30px; /* 收窄 6px，配合行左内边距使条目内容共左移 10px */
    font-weight: 500;
    flex-shrink: 0;
}

/* 语法文本超宽时单行显示，超出部分以省略号替代 */
.grammar-wrapper .item-text {
    font-size: 16px; /* 列表文字增大 2px */
    color: #475569;
    font-weight: 400;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grammar-wrapper .list-item.active-item .item-text {
    color: #d32f2f;
    font-weight: 700;
}

/* ============================================================
   8. 通用分页栏（语法内容流翻页）
   视觉规范与词汇页 .vocab-pagination 完全一致：
   居中自适应宽度、底边向上 6px、白色半透明 + 毛玻璃、圆角 8px、按钮间距 6px
   ============================================================ */
.grammar-wrapper .grammar-pagination {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    z-index: 100;
    width: auto;
}

.grammar-wrapper .grammar-pagination__item {
    min-width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 400;
    color: rgba(29, 29, 31, 0.45);
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.15s ease;
    user-select: none;
    padding: 0 2px;
}

.grammar-wrapper .grammar-pagination__item:hover {
    background: rgba(107, 92, 231, 0.12);
    color: #6B5CE7;
}

.grammar-wrapper .grammar-pagination__item--active {
    background: rgba(107, 92, 231, 0.85);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(107, 92, 231, 0.25);
    margin: 2px;
}

.grammar-wrapper .grammar-pagination__item--active:hover {
    background: rgba(90, 75, 210, 0.95);
    color: #ffffff;
}

/* 分页前后翻页箭头（页码超过 10 个时显示） */
.grammar-wrapper .grammar-pagination__arrow {
    min-width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: rgba(29, 29, 31, 0.6);
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.15s ease;
    user-select: none;
    padding: 0 2px;
}

.grammar-wrapper .grammar-pagination__arrow:hover {
    background: rgba(107, 92, 231, 0.12);
    color: #6B5CE7;
}

/* ============================================================
   9. NX语法三级分类导航（文字分隔样式，同单词分类字典三级导航）
   ============================================================ */
.grammar-wrapper .grammar-three-level-nav {
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 0 !important;
    width: 100% !important;
    height: 40px !important;
    padding: 0 0 0 24px !important;
    margin-top: 0px !important;
    flex-shrink: 0;
    background: #ffffff !important;
    z-index: 10;
    position: relative !important;
    box-sizing: border-box;
}

/* 三级导航底线 */
.grammar-wrapper .grammar-three-level-nav::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: #eee !important;
    z-index: 25;
}

/* 右侧滚动条遮挡 */
.grammar-wrapper .grammar-three-level-nav::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    width: 8px;
    height: 40px;
    background: #ffffff;
    z-index: 20;
}

.grammar-wrapper .grammar-nav-left {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    flex: 1 !important;
    gap: 0 !important;
}

/* 分类标签较长，宽度自适应（同字典三级导航变体） */
.grammar-wrapper .grammar-type-link {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    padding: 0 14px !important;
    font-size: 14px !important;
    font-weight: 600;
    color: rgba(29, 29, 31, 0.55) !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.grammar-wrapper .grammar-type-link:first-child {
    padding-left: 0 !important;
}

/* 中间分隔竖线 */
.grammar-wrapper .grammar-type-link:not(:last-child)::after {
    content: "" !important;
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    height: 16px !important;
    width: 1px !important;
    background: rgba(0, 0, 0, 0.15) !important;
}

.grammar-wrapper .grammar-type-link:hover:not(.active) {
    color: #0066cc !important;
}

.grammar-wrapper .grammar-type-link.active {
    color: rgba(29, 29, 31, 0.88) !important;
    text-shadow: 0.4px 0 0 currentColor;
}

/* ---------- 语法备注：标题行尾图标 + 半透明浮层 ---------- */
/* 标题行作为浮层定位基准 */
.grammar-wrapper .grammar-main-heading {
    position: relative;
}

/* 备注图标按钮：靠右对齐标题行 */
.grammar-wrapper .grammar-notes-btn {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: #f1f3f5;
    color: rgba(29, 29, 31, 0.6);
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.2s, background-color 0.2s;
}

.grammar-wrapper .grammar-notes-btn:hover,
.grammar-wrapper .grammar-notes-btn.active {
    color: #0066cc;
    background: #e8eef7;
}

.grammar-wrapper .grammar-notes-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
}

/* 浮层本体：左沿对齐语法块左边，右沿延伸到内容流右内边距区（不压滚动条）；
   半透明白底 + 毛玻璃（与分页栏同视觉语言） */
.grammar-wrapper .grammar-notes-popover {
    position: absolute;
    left: 0;
    right: -28px;
    z-index: 50;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

/* 默认紧贴标题下方；下方放不下时翻转到标题上方（偏移量与 JS NOTES_POP_GAP 一致） */
.grammar-wrapper .grammar-notes-popover.is-below {
    top: calc(100% + 4px);
}

.grammar-wrapper .grammar-notes-popover.is-above {
    bottom: calc(100% + 4px);
}

/* 指向标题的小三角 */
.grammar-wrapper .grammar-notes-popover::before {
    content: "";
    position: absolute;
    left: 64px;
    width: 14px;
    height: 14px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.15);
    transform: rotate(45deg);
}

.grammar-wrapper .grammar-notes-popover.is-below::before {
    top: -8px;
    border-right: none;
    border-bottom: none;
}

.grammar-wrapper .grammar-notes-popover.is-above::before {
    bottom: -8px;
    border-left: none;
    border-top: none;
}

.grammar-wrapper .grammar-notes-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: none;
    font-size: 22px;
    line-height: 1;
    color: rgba(29, 29, 31, 0.45);
    cursor: pointer;
    transition: color 0.2s;
}

.grammar-wrapper .grammar-notes-close:hover {
    color: #d32f2f;
}

/* 备注正文区：行高 = 1.7 行距再减 3px（约 20.8px）；最少撑起约 4 行并上下居中；
   最多显示 6 行文字 + 上下各 0.8 行的留白，超出部分在区内滚动 */
.grammar-wrapper .grammar-notes-body {
    --notes-lh: calc(1.7em - 3px);
    display: flex;
    flex-direction: column;
    font-size: 14px;
    line-height: var(--notes-lh);
    color: #475569;
    min-height: calc(4 * var(--notes-lh));
    max-height: calc((6 + 0.8 * 2) * var(--notes-lh));
    overflow-y: auto;
    padding: 0 44px 0 24px; /* 右侧为关闭按钮留位 */
    box-sizing: border-box;
}

.grammar-wrapper .grammar-notes-body::-webkit-scrollbar {
    width: 4px;
}

.grammar-wrapper .grammar-notes-body::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

/* 内容少于最小高度时上下居中；超出时不裁切顶部（margin:auto 而非 align-items）。
   文字上下留白 0.8 行距放在内容层，保证滚动到底时底部留白也计入可滚动区 */
.grammar-wrapper .grammar-notes-content,
.grammar-wrapper .grammar-notes-empty {
    margin: auto 0;
    padding: calc(0.8 * var(--notes-lh)) 0;
}

.grammar-wrapper .grammar-notes-item {
    white-space: pre-line; /* 表格类备注（如敬语变化表）按原样换行呈现 */
    background-color: #f0f7ff; /* 备注带背景框（用户裁定 2026-10-05） */
    border: 1px solid #e1eeff;
    border-radius: 6px;
    padding: 8px 12px;
}

.grammar-wrapper .grammar-notes-item + .grammar-notes-item {
    margin-top: 8px;
}

/* 无义项条目的备注内联直显：单个背景框 + 序号行（用户裁定 2026-10-05） */
.grammar-wrapper .grammar-notes-inline {
    margin: 0 0 14px 10px;
}

.grammar-wrapper .grammar-notes-inline-box {
    background-color: #f0f7ff;
    border: 1px solid #e1eeff;
    border-radius: 6px;
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* 字体样式与义项讲解面板 .title-l3-desc 同款（用户裁定 2026-10-05） */
    font-size: 13.5px;
    font-weight: 500;
    color: #3a3a3c;
}

.grammar-wrapper .grammar-notes-inline-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.grammar-wrapper .grammar-notes-inline-no {
    flex: none;
    font-weight: 700;
    color: #fa243c; /* 与例句序号同色 */
}

.grammar-wrapper .grammar-notes-inline-text {
    white-space: pre-line;
}

.grammar-wrapper .grammar-notes-empty {
    text-align: center;
    color: #86868b;
}

/* ==========================================================================
   NX 基础语法（N5SUM 条目树）：三级导轨布局，移植自 base_grammar-10.css
   1级 ★词类 → 2级 Ⅰ条目 → 3级 ❶用法；仅在 .grammar-wrapper .nx-tree-flow 内生效
   ========================================================================== */
.grammar-wrapper .nx-tree-flow {
    color: #1d1d1f;
    line-height: 1.5;
}

/* 1级：词类，左侧生成向下延伸的同级虚线导轨 */
.grammar-wrapper .level-1-block-with-dashline {
    position: relative;
    margin-bottom: 34px;
}

/* 折叠态：仅剩标题行，收紧上下间距，避免节间出现大空带 */
.grammar-wrapper .level-1-block-with-dashline.nx-collapsed {
    margin-bottom: 12px;
}

.grammar-wrapper .level-1-block-with-dashline.nx-collapsed .l1-node-header {
    margin-bottom: 0;
}

.grammar-wrapper .l1-node-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.grammar-wrapper .l1-symbol {
    font-size: 20px;
    color: #d4a373;
    margin-right: 12px;
    line-height: 1;
}

/* 左栏 1级 折叠/展开：标题行可点击，★ 换为 +/− 按钮 */
.grammar-wrapper .l1-node-header {
    cursor: pointer;
    user-select: none;
}

.grammar-wrapper .l1-toggle {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
    color: #d4a373;
    background-color: #fbf6ef;
    border: 1px solid #d4a373;
    border-radius: 5px;
    cursor: pointer;
    padding: 0;
    margin-right: 12px;
}

.grammar-wrapper .l1-toggle:hover {
    background-color: #f3e8d8;
}

.grammar-wrapper .title-l1 {
    font-size: 24px;
    font-weight: 800;
    color: #000000;
    margin: 0;
}

/* 2级：条目，虚线大导轨贯穿，Ⅰ 灰色徽章 */
.grammar-wrapper .level-2-block-with-solidline {
    position: relative;
    margin-left: 14px;
    padding-left: 26px;
    border-left: 1px dashed #c7c7cc;
    margin-top: 14px;
}

.grammar-wrapper .l2-node-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.grammar-wrapper .badge-l2 {
    font-size: 13px;
    font-weight: 700;
    color: #8e8e93;
    border: 1px solid #d2d2d7;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    background-color: #fafafa;
    flex-shrink: 0;
}

.grammar-wrapper .title-l2 {
    font-size: 17px;
    font-weight: 600;
    color: #8e8e93;
    margin: 0;
}

/* 3级：具体用法，2级实线导轨 + ❶ 红色圆徽 */
.grammar-wrapper .nx-sense-list {
    margin-top: 4px;
}

.grammar-wrapper .level-3-block {
    position: relative;
    margin-left: 10px;
    padding-left: 24px;
    border-left: 1px solid #d2d2d7;
    margin-top: 10px;
}

/* 序号与标题文字按基线对齐：标题折行时序号仍与第一行同高（原先 center 会跑到行块垂直中心） */
.grammar-wrapper .l3-node-header {
    display: flex;
    align-items: baseline;
    margin-bottom: 5px;
}

.grammar-wrapper .badge-l3 {
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    background-color: #fa243c;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}

/* 二层及以下义项序号：不用红底圆徽，纯文本编号 */
.grammar-wrapper .badge-l3-sub {
    background-color: transparent;
    color: #5a5a5e;
    font-size: 13px;
    width: auto;
    min-width: 18px;
    padding: 0 2px;
    margin-right: 4px;
}

.grammar-wrapper .title-l3 {
    font-size: 19px;
    font-weight: 700;
    color: #4a4a50; /* 纯黑过重的标题两级，字色稍微变浅（用户裁定 2026-10-05） */
    margin: 0;
}

/* 语法简述：与语义看板同款的浅底面板 + 加重字色，突出说明（用户裁定 2026-10-05） */
.grammar-wrapper .title-l3-desc {
    font-size: 13.5px;
    font-weight: 500;
    color: #3a3a3c;
    background-color: #f0f7ff;
    border: 1px solid #e1eeff;
    border-radius: 6px;
    margin: 0 0 12px 0;
    padding: 10px 20px;
}

/* 例：/如： 引导的讲解第二行：缩进对齐标题文字 */
.grammar-wrapper .title-l3-desc-ex {
    padding-left: 22px;
}

/* 例句精排：段间距、行间距深度压缩 */
.grammar-wrapper .compact-examples-section {
    margin-top: 10px;
    margin-bottom: 14px;
}

.grammar-wrapper .editorial-example-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 10px;
}

.grammar-wrapper .editorial-example-row:last-child {
    margin-bottom: 0;
}

.grammar-wrapper .example-index {
    font-size: 11.5px;
    font-weight: 700;
    color: #fa243c;
    width: 24px;
    margin-top: 2px;
    flex-shrink: 0;
}

.grammar-wrapper .example-sentences {
    display: flex;
    flex-direction: column;
}

.grammar-wrapper .sentence-jp {
    font-size: 15px;
    font-weight: 600;
    color: #000000;
    margin: 0;
    letter-spacing: 0.1px;
}

.grammar-wrapper .sentence-zh {
    font-size: 12.5px;
    color: #8e8e93;
    margin: 2px 0 0 0;
}

/* NX 基础语法三级树：例句翻译/注释行加大 2px（仅此模块），并加深字色提高可读性 */
.grammar-wrapper .nx-tree-flow .sentence-zh {
    font-size: 14.5px;
    color: #3a3a3c;
}

/* 右栏：名词 → 名词的简体 → 名词「だ形」三级树 */
.grammar-wrapper .nx-sidebar-tree {
    padding-top: 4px;
}

.grammar-wrapper .nx-side-l1 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 4px;
    font-size: 14px;
    font-weight: 800;
    color: #1d1d1f;
}

.grammar-wrapper .nx-side-l1 .l1-symbol {
    font-size: 14px;
    margin-right: 0;
}

.grammar-wrapper .list-item.nx-side-l2 {
    padding-left: 24px;
}

.grammar-wrapper .list-item.nx-side-l2.in-tree .item-text {
    font-weight: 600;
    color: #8e8e93;
}

.grammar-wrapper .nx-side-l3 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 44px;
    cursor: pointer;
    font-size: 14px;
    color: #3a3a3c;
    border-radius: 6px;
}

.grammar-wrapper .nx-side-l3:hover {
    background-color: #f2f2f7;
}

/* 3级 义项行选中态：配色同 2级 条目行 active-item */
.grammar-wrapper .nx-side-l3.active-sense {
    background-color: #fff1f1;
}

.grammar-wrapper .nx-side-l3.active-sense .nx-side-l3-text {
    color: #d32f2f;
    font-weight: 700;
}

/* 多层级义项树：depth-2/3 缩进与视觉区分 */
.grammar-wrapper .nx-side-depth-2 .nx-side-l3-text {
    font-size: 13px;
    color: #5a5a5e;
}

.grammar-wrapper .nx-side-depth-3 .nx-side-l3-text {
    font-size: 12px;
    color: #7a7a7e;
}

/* 左栏多层级义项：depth-2/3 标题字号递减 */
.grammar-wrapper .level-3-block[style*="margin-left: 18px"] .title-l3 {
    font-size: 15px;
}

.grammar-wrapper .level-3-block[style*="margin-left: 36px"] .title-l3 {
    font-size: 14px;
    color: #5a5a5e;
}
