:root {
    --primary-color: #9E2A2B;
    --secondary-color: #F0DB4F;
    --accent-color: #3A5A40;
    --sidebar-width: 320px;
}
body {
    overflow-x: hidden;
}
*, *::before, *::after {
    box-sizing: border-box;
}
/* 核心布局 */
.layout-wrapper {
    display: flex;
    min-height: calc(100vh - 52px);
    margin-top: 52px;
}

.main-content {
    flex: 1;
    background: #f8f9fa;
    order: 2;
    max-width: 100vw; /* 新增 */
    overflow-x: hidden; /* 防止横向溢出 */
    padding: 2rem 1rem; /* 移动端减少两侧padding */    
}

.sidebar {
    _position: fixed;
    _left: 0;
    width: var(--sidebar-width);
    _height: calc(100vh - 52px);
    background: linear-gradient(180deg, var(--primary-color) 0%, rgba(158,42,43,0.95) 100%);
    color: white;
    padding: 1.5rem;
    overflow-y: auto;
    order: 1;
    height: auto; /* 自动高度 */
    min-height: 100vh; /* 桌面端保持全高 */
    position: -webkit-sticky; /* 新增粘性定位 */
    position: sticky;
    top: 52px;    
}

/* 侧边栏容器 */
.sidebar {
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}
/* 默认隐藏第11个及之后的列表项 */
.menu-list li:nth-child(n+16) {
  display: none;
}

/* 展开状态显示全部 */
.menu-list.is-expanded li {
  display: block !important;
}
.menu-list>.column {
    padding: 0 .75rem;
}
/* 展开按钮样式 */
.expand-button {
  margin-top: 1rem;
  width: 100%;
  text-align: center;
  cursor: pointer;
  color: #9E2A2B;
  transition: all 0.3s;
}
.expand-button:hover {
  background: #fff5f7;
}

/* 导航项交互设计 */
.menu-list a {
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.menu-list a:hover {
    color: #9E2A2B;
}

/* 激活状态指示 */
.menu-list a.is-active {
    background: linear-gradient(90deg, #e3f2fd 0%, #f8f9fa 100%);
    font-weight: 600;
}

/* 图标动态响应 */
.icon i {
    transition: transform 0.3s;
}
.menu-list a:hover .icon i {
    transform: rotate(15deg);
}


/* 文字信息模块 */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
    box-sizing: border-box; /* 防止padding导致溢出 */
    justify-content: center; 
}

dl {
  display: grid;
  grid-template-columns: auto 1fr; /* 两列布局 */
  gap: 8px 15px;
}

dt {
  grid-column: 1; /* 强制dt在第一列 */
  justify-self: end; /* 右对齐 */
}

dd {
  grid-column: 2; /* 强制dd在第二列 */
}

.stroke-animation {
    font-size: 2.5rem;
    margin: 0 0.3rem;
    animation: strokeFade 1.5s infinite;
}

@keyframes strokeFade {
    0%, 100% { opacity: 0.3; transform: translateY(5px); }
    50% { opacity: 1; transform: translateY(0); }
}

/* 相关汉字样式 */
.related-section {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.05);
}

.hanzi-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid rgba(158,42,43,0.1);
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
}

.hanzi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(158,42,43,0.15);
}

.hanzi {
    font-size: 2rem;
    font-family: "Noto Serif SC", serif;
    color: var(--primary-color);
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.py {
    font-size: 0.85em;
    color: #666;
    font-family: "Bopomofo Sans", sans-serif;
}

.meaning {
    font-size: 0.75em;
    color: #999;
    text-align: center;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* 笔顺动画容器调整 */
.stroke-animation-box {
    max-width: 150px;
    margin: 0 auto;
}

.stroke-gif {
    width: 150px;
    height: 150px;
    padding: 8px;
}

/* 异体字容器 */
.variant-box,.search-box {
    background: rgba(158,42,43,0.03);
    border: 1px solid rgba(158,42,43,0.1);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1rem;
}

/* 标题样式 */
.variant-header,.search-header {
    font-family: "Noto Serif SC", serif;
    font-size: 1.25rem;
    border-bottom: 2px dashed rgba(158,42,43,0.2);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}

/* 异体字列表 */
.variant-list,.search-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* 单个异体字项 */
.variant-item,.search-item {
    font-family: "Noto Serif SC", serif;
    font-size: 1.5rem;
    color: var(--primary-color);
    background: rgba(255,255,255,0.9);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: 1px solid rgba(158,42,43,0.15);
    transition: all 0.2s ease;
}

.search-item a{
    font-size:1rem;
    font-family: "Noto Serif SC", serif;;
}
/* 交互优化 */
.variant-item:hover,.search-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 12px rgba(158,42,43,0.1);
}

.semantic-box a{
    color: #fff;
    text-decoration: underline;
}
/* 近义词表格样式 */
.semantic-grid {
    background: linear-gradient(145deg, #f8f9fa 0%, #fff 100%);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 15px rgba(0,0,0,0.05);
}

.synonym-card {
    border: 1px solid rgba(158,42,43,0.1);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease;
}

.synonym-card:hover {
    transform: translateY(-3px);
}

.synonym-header {
    padding: 0.8rem 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 2px dashed rgba(158,42,43,0.15);
    font-family: "Noto Serif SC", serif;
}

.synonym-body {
    padding: 1rem;
    color: #444;
    line-height: 1.7;
    background: rgba(255,255,255,0.9);
}

/* 表格样式 */
.custom-table-section {
    background: linear-gradient(145deg, #f8f9fa 0%, #fff 100%);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.table-card {
    border: 1px solid rgba(158,42,43,0.1);
    border-radius: 8px;
    overflow: hidden;
    height: 100%;
}

.table-header {
    padding: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 2px dashed rgba(158,42,43,0.2);
}

.table-body {
    padding: 1.5rem;
    line-height: 1.8;
}

.table-body dt {
    color: var(--primary-color);
    font-weight: 500;
    margin-top: 0.8rem;
}

.table-body dd {
    color: #444;
    margin-left: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dotted #eee;
}

/* 新增字符详解样式 */
.character-explain .box {
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(158,42,43,0.1);
}

.info-item {
    padding: 1rem;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.info-item::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--primary-color);
    opacity: 0.3;
}

.info-tag {
    display: inline-block;
    min-width: 4em;
    color: var(--primary-color);
    font-weight: 600;
    margin-right: 1rem;
}

.hanzi {
    font-family: "Noto Serif SC", serif;
    font-size: 1.8rem;
}
#hanzi-canvas {
  /* 田字格背景图 */
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" fill="none" stroke="%23ddd"/><path d="M50 0v100M0 50h100" stroke="%23ccc" stroke-dasharray="2"/><rect x="25" y="25" width="50" height="50" fill="none" stroke="%23999"/></svg>');
  background-size: 100% 100%;
}
.py a {
    color: #4a4a4a;
    border-bottom: 1px dashed var(--primary-color);
}

.explain-detail {
    padding: 0 1.5rem 1rem;
    border-radius: 6px;
}

.explain-text {
    color: #444;
    line-height: 1.8;
    white-space: pre-line;
}

.more-link .button {
    transition: transform 0.2s;
}

.more-link .button:hover {
    transform: translateX(5px);
}
/* 词语模块样式 */
.word-section {
    background: linear-gradient(145deg, #f8f9fa 0%, #fff 100%);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.word-card {
    border: 1px solid rgba(158,42,43,0.1);
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.3s ease;
    background: rgba(255,255,255,0.95);
}

.word-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(158,42,43,0.1);
}

.word-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px dashed rgba(158,42,43,0.2);
}

.hanzi {
    font-family: "Noto Serif SC", serif;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.py {
    font-family: "Bopomofo Sans", sans-serif;
    color: #666;
    font-size: 0.9em;
}

.word-body {
    color: #444;
    line-height: 1.7;
    font-size: 0.95em;
}

/* 简繁转换容器 */
.simplified-traditional-box,.conversion-box {
    background: linear-gradient(145deg, #f8f9fa 0%, #fff 100%);
    border: 1px solid rgba(158,42,43,0.1);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: 0 2px 15px rgba(0,0,0,0.05);
}

/* 文本输入区 */
.conversion-textarea {
    width: 100%;
    height: 180px;
    font-family: "Noto Serif SC", serif;
    padding: 1rem;
    border: 2px solid rgba(158,42,43,0.2);
    border-radius: 8px;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.conversion-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(158,42,43,0.1);
}

/* 按钮容器 */
.conversion-controls {
    margin-top: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* 新增输出区间距规则 */
#pinyinOutput {
    margin-top: 1.5rem; /* 与按钮区相同间距 */
    background: rgba(158,42,43,0.03); /* 浅色背景区分 */
    border: 1px solid rgba(158,42,43,0.1); /* 与输入框统一边框 */
}

/* 按钮样式 */
.conversion-btn {
    flex: 1;
    max-width: 200px;
    border: 2px solid;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-simplified {
    border-color: var(--primary-color);
    background: rgba(158,42,43,0.1);
    color: var(--primary-color);
}

.btn-traditional {
    border-color: #4a4a4a;
    background: rgba(74,74,74,0.1);
    color: #4a4a4a;
}

.btn-clear {
    border-color: #999;
    background: rgba(153,153,153,0.1);
    color: #666;
}

   /* 静态汉字样式 */
.static-hanzi {
  font-size: 120px;
  font-family: '汉仪楷体', sans-serif; /* 可替换为其他已安装字体  */
  color: #666;
  text-align: center;
  line-height: 150px;
}

/* 禁用状态图标 */
.warning-icon {
  fill: #ff4757;
  vertical-align: middle;
  margin-right: 5px;
}

/* 按钮禁用样式 */
.hanzi-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
} 
@media (max-width: 1024px) {
    .layout-wrapper {
        flex-direction: column;
        /* 新增排列顺序控制 */
        display: flex;
        flex-wrap: nowrap;
    }
    
    .main-content {
        order: 1; /* 主内容置顶 */
        margin-top: 1rem; /* 增加顶部间隔 */
        margin-left:auto;
    }
    
    .sidebar {
        order: 2; /* 侧边栏置底 */
        position: static;
        width: 100%;
        margin-top: 2rem; /* 增加间隔 */
        background: linear-gradient(180deg, 
            rgba(158,42,43,0.95) 0%,
            var(--primary-color) 100%); /* 渐变方向反转 */
       min-height: auto; /* 移动端取消最小高度 */
        position: static; /* 取消粘性定位 */
        order: 2; /* 确保在移动端显示在下方 */        
    }
    .column.is-1 {
        width: 16.666%!important;
        flex: none;
    }    
}

/* 移动端适配 */
@media (max-width: 768px) {
   .layout-wrapper {
        flex-direction: column; /* 改为垂直布局 */
    }
    
    .main-content {
        order: 1; /* 主内容在下 */
        margin-left: 0;
        width: 100%;
    }
    .sidebar {
        order: 2; /* 侧边栏在上 */
        width: 100%;
        min-height: auto; /* 移动端取消固定高度 */
        position: static; /* 移动端禁用粘性定位 */
    }	
    .info-grid {
        grid-template-columns: minmax(280px, 1fr); /* 强制单列 */
        padding: 0 1rem; /* 两侧留白 */
    }    
    .info-grid > .notification {
        width: 100% !important;
        max-width: 100%;
        padding: 0.5rem 1rem;
        margin-bottom: 0.5rem;
    }
    .stroke-animation-box {
        max-width: 120px;
        margin-bottom: 1rem;
    }
    
    .stroke-gif {
        width: 120px;
        height: 120px;
    }
    
    .animation-controls {
        bottom: 5px;
        right: 5px;
    }
    
    .replay-btn {
        width: 28px;
        height: 28px;
    }

    .related-section {
        padding: 1.5rem;
    }
    
    .column.is-1 {
        width: 25%!important;
    }
    
    .hanzi {
        font-size: 1.5rem;
    }   
    .variant-box,.search-box {
        padding: 1rem;
        margin-top: 0.5rem;
    }
    
    .variant-item,.search-item {
        font-size: 1.2rem;
        padding: 0.4rem 0.8rem;
        margin: 0.3rem;
    }
    .variant-header,.search-header {
        font-size: 1.1rem;
    } 

    .semantic-grid {
        padding: 1rem;
    }
    
    .columns.is-variable.is-2 {
        --columnGap: 0.5rem;
    }
    
    .synonym-card {
        margin-bottom: 0.5rem;
    }
    
    .synonym-header {
        padding: 0.6rem 1rem;
    }
    
    .synonym-body {
        padding: 0.8rem;
        font-size: 0.9em;
    }

    .custom-table-section {
        padding: 1.5rem;
    }
    
    .table-body {
        padding: 1rem;
    }
    
    .table-body dd {
        margin-left: 1rem;
    }
    
    .column.is-6 {
        margin-bottom: 1.5rem;
    }    
    .info-item {
        margin-bottom: 1rem;
    }
    
    .info-tag {
        display: block;
        margin-bottom: 0.5rem;
    }
    
    .explain-text {
        font-size: 0.95em;
    }
    /* 优化列间距 */
    .columns.is-multiline .column.is-4 {
        margin-bottom: 0.5rem !important;  /* 从1.5rem缩小到0.5rem */
    }

    .column{
        padding: 0
    }

    /* 优化卡片间距 */
    .word-card {
        margin-bottom: 0.2rem;
        padding: 0.8rem;
    }

    /* 调整父容器间距 */
    .word-section {
        padding: 1rem;
    }
    .word-section {
        padding: 1.5rem;
    }
    
    .column.is-4 {
        width: 100%;
        margin-bottom: 1.5rem;
    }
    
    .hanzi {
        font-size: 1.3rem;
    }
    
    .word-body {
        font-size: 0.9em;
    }
    .conversion-textarea {
        height: 150px;
        font-size: 0.95em;
    }
    
    .conversion-btn {
        flex: 100%;
        max-width: none;
    }    
    #bihuaList.columns,#bushouList.columns,#wuxingList.columns {
        display: flex !important;
        flex-wrap: wrap;
  }
    #bihuaList .column.is-4,#bushouList .column.is-4,#wuxingList .column.is-4{
        width: 33.33%;
        flex: 0 0 auto;
        padding: 0.5rem; /* 缩小间距适应小屏幕 */
  }
    #bihuaList a,#bushouList a,#wuxingList a {
        font-size: 0.9em; /* 调小字体 */
        padding: 0.5rem 0.3rem;
  }    
}

@media (max-width: 480px) {
    .stroke-animation-box {
        max-width: 100px;
    }
    
    .stroke-gif {
        width: 100px;
        height: 100px;
    }
    .column.is-1 {
        width: 33.333%!important;
    }  
    .column.is-6 {
        width: 100% !important;
    }
    
    .synonym-card {
        border-radius: 6px;
    }      
}
