@import url("https://cdn.staticfile.net/lxgw-wenkai-screen-webfont/1.7.0/lxgwwenkaiscreen.css");
/* 定义CSS变量 - 统一管理样式 */
    :root {
      --character-size: 36px;      /* 汉字大小 */
      --character-opacity: 0.3;     /* 汉字灰度 */
      --pinyin-size: 16px;          /* 拼音大小 */
      --pinyin-opacity: 0.4;        /* 拼音灰度 */
      --four-lines-opacity: 0.2;    /* 四线格灰度 */
    }

    /* 基础样式 */
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
      background: #f0f7ff;
      color: #1f2937;
      line-height: 1.5;
      padding-bottom: 20px;
    }
    header {
      background: linear-gradient(135deg, #003A66, #005599);
      color: white;
      padding: 25px 20px;
      text-align: center;
      box-shadow: 0 6px 18px rgba(0,0,0,0.15);
      border-bottom: 1px solid #e5e7eb;
      position: relative;
      overflow: hidden;
    }
    header::before {
      content: '';
      position: absolute;
      top: -10px;
      left: -10px;
      right: -10px;
      bottom: -10px;
      background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
      z-index: 0;
    }
    header h1 {
      font-weight: 700;
      font-size: 1.8rem;
      letter-spacing: -0.4px;
      margin-bottom: 8px;
      text-shadow: 0 2px 4px rgba(0,0,0,0.2);
      position: relative;
      z-index: 1;
    }
    header p {
      font-size: 1rem;
      opacity: 0.9;
      position: relative;
      z-index: 1;
    }

    /* 主容器布局 */
    .main-container {
      max-width: 1100px;
      margin: 0 auto;
      padding: 0 20px;
    }

    /* 输入区域 */
    .input-section {
      background: white;
      border-radius: 12px;
      padding: 25px;
      margin: 25px 0 20px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }

    textarea {
      width: 100%;
      height: 140px;
      padding: 18px;
      font-size: 16px;
      border: 1px solid #d1d5db;
      border-radius: 8px;
      resize: vertical;
      font-family: inherit;
      background: #fff;
      line-height: 1.6;
      transition: all 0.2s ease;
    }
    textarea:focus {
      outline: none;
      border-color: #003A66;
      box-shadow: 0 0 0 3px rgba(0, 58, 102, 0.15);
    }
    .input-hint {
      font-size: 13px;
      color: #6b7280;
      margin-top: 10px;
      text-align: center;
    }

    /* 示例按钮和教材按钮 */
    .input-buttons {
      display: flex;
      gap: 10px;
      margin-top: 15px;
      flex-wrap: wrap;
      justify-content: center;
    }
    
    .example-btn, .textbook-btn {
      padding: 8px 16px;
      font-size: 14px;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      background: #f9fafb;
      color: #374151;
      cursor: pointer;
      transition: all 0.15s ease;
      font-weight: 500;
    }
    
    .example-btn:hover, .textbook-btn:hover {
      background: #f3f4f6;
      border-color: #d1d5db;
    }
    
    .textbook-btn {
      background: #003A66;
      color: white;
      border-color: #003A66;
    }
    
    .textbook-btn:hover {
      background: #005599;
    }

    /* 生成练习按钮 - 增大字体 */
    .generate-btn-container {
      text-align: center;
      margin: 0 0 25px;
    }
    .generate-btn {
      background: linear-gradient(135deg, #003A66, #005599);
      color: white;
      border: none;
      border-radius: 8px;
      padding: 16px 40px;
      font-size: 18px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
      box-shadow: 0 4px 12px rgba(0, 58, 102, 0.25);
      display: inline-flex;
      align-items: center;
      gap: 10px;
    }
    .generate-btn:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 16px rgba(0, 58, 102, 0.35);
    }
    .generate-btn:active {
      transform: translateY(0);
    }

    /* 控制面板 - 重新布局 */
    .control-panel {
      background: white;
      border-radius: 12px;
      padding: 25px;
      margin: 0 0 25px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }
    
    /* 按钮区域 - 分为左右两部分 */
    .button-sections {
      display: flex;
      gap: 30px;
      margin-bottom: 25px;
    }
    
    .control-section {
      flex: 1;
    }
    
    .section-title {
      font-size: 16px;
      font-weight: 600;
      color: #374151;
      margin-bottom: 15px;
      padding-bottom: 8px;
      border-bottom: 2px solid #f0f7ff;
    }
    
    .button-group {
      display: flex;
      gap: 10px;
    }
    
    .control-btn {
      padding: 10px 16px;
      font-size: 14px;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      background: #f9fafb;
      color: #374151;
      cursor: pointer;
      transition: all 0.15s ease;
      font-weight: 500;
      flex: 1;
      text-align: center;
      white-space: nowrap;
    }
    
    .control-btn:hover {
      background: #f3f4f6;
      border-color: #d1d5db;
    }
    
    .control-btn.active {
      background: #003A66;
      color: white;
      border-color: #003A66;
    }

    /* 滑块区域 - 五个滑块并排 */
    .sliders-section {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      gap: 20px;
    }
    
    .slider-control {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    
    .slider-label {
      font-size: 14px;
      color: #4b5563;
      font-weight: 500;
      display: flex;
      justify-content: space-between;
    }
    
    .slider-label span:last-child {
      color: #003A66;
      font-weight: 600;
    }
    
    .slider-control input[type="range"] {
      width: 100%;
      height: 6px;
      -webkit-appearance: none;
      background: #e5e7eb;
      border-radius: 3px;
      outline: none;
    }
    
    .slider-control input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #003A66;
      cursor: pointer;
      box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }

    /* 打印和导出区域 */
    .export-section {
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      margin-bottom: 25px;
    }
    
    .export-btn {
      padding: 10px 16px;
      font-size: 14px;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      background: white;
      color: #374151;
      cursor: pointer;
      transition: all 0.15s ease;
      font-weight: 500;
      display: flex;
      align-items: center;
      gap: 6px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .export-btn:hover {
      background: #f9fafb;
      border-color: #d1d5db;
    }
    
    .export-btn.primary {
      background: #003A66;
      color: white;
      border-color: #003A66;
    }
    
    .export-btn.primary:hover {
      background: #005599;
    }

    /* 显示区域 - 固定宽度，居中显示，移动端可横向滑动 */
    .print-area {
      background: white;
      box-shadow: 0 4px 12px rgba(0,0,0,0.08);
      border-radius: 12px;
      padding: 25px;
      margin: 0 auto;
      max-width: 100%;
      overflow: auto;
      position: relative;
    }
    
    /* 工作表容器 - 固定宽度为12个60px格子的宽度 (720px) */
    .worksheet-container {
      width: 720px;
      margin: 0 auto;
      min-height: 200px;
      box-sizing: border-box; /* 新增：确保边框包含在宽度内 */
    }

    /* 印氪先生汉语拼音字体定义 */
    @font-face {
      font-family: 'Yinke Pinyin';
      src: url('../fonts/YinkePinyin.woff2') format('woff2'),
           url('../fonts/YinkePinyin.woff') format('woff'),
           url('../fonts/YinkePinyin.ttf') format('truetype');
      font-weight: normal;
      font-style: normal;
      font-display: swap; /* 确保文本在字体加载时可见 */
    }

    /* 拼音字体定义 */
    .pinyin-font {
      font-family: 'Yinke Pinyin', 'Noto Sans SC', 'Microsoft YaHei', 'PingFang SC', sans-serif;
      font-weight: 500;
    }

    /* 重新设计格子布局 */
    .worksheet-container {
      display: flex;
      flex-direction: column;
      margin-top: 12px;
    }

    /* 行容器 - 包含四线格行和格子行 */
    .line-container {
      display: flex;
      flex-direction: column;
      margin-bottom: 15px;
      position: relative;
      width: 100%;
    }

    /* 四线格行 - 包含四线格和拼音 */
    .four-lines-row {
      width: 100%;
      height: 40px;
      position: relative;
      margin-bottom: 10px;
    }

    .four-lines {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      pointer-events: none;
      box-sizing: border-box; /* 新增：确保边框计算正确 */
    }

    /* 四条线的精确定位 */
    .four-lines .line-1,
    .four-lines .line-2,
    .four-lines .line-3,
    .four-lines .line-4 {
      position: absolute;
      left: 0;
      width: 720px; /* 修改：固定宽度为720px */
      height: 0;
      border-top: 1px solid rgba(0,0,0,var(--four-lines-opacity));
      box-sizing: border-box; /* 新增 */
    }

    .four-lines .line-1 { top: 0; }
    .four-lines .line-2 { top: 33.33%; border-top-style: dashed; }
    .four-lines .line-3 { top: 66.67%; border-top-style: dashed; }
    .four-lines .line-4 { top: 100%; }

    /* 四线格竖线分割 - 与田字格对齐 */
    .four-lines .vertical-line {
      position: absolute;
      top: 0;
      width: 0;
      height: 100%;
      border-left: 1px solid rgba(0,0,0,var(--four-lines-opacity));
      box-sizing: border-box; /* 新增 */
    }

    /* 拼音行 - 位于四线格内部，第二格位置 */
    .pinyin-line {
      display: flex;
      width: 100%;
      height: 40px;
      position: absolute;
      top: 0;
      left: 0;
      z-index: 2;
      box-sizing: border-box; /* 新增 */
    }

    /* 格子行 - 关键修改：添加顶部和左边框，让每个格子共享边框 */
    .character-line {
      display: flex;
      width: 720px; /* 修改：固定宽度为720px */
      border-top: 1px solid #9ca3af;
      border-left: 1px solid #9ca3af;
      box-sizing: border-box; /* 新增：确保边框包含在宽度内 */
    }

    /* 固定格子大小 - 每行12个格子，每个60px正方形 */
    .pinyin-cell, .character-cell {
      width: 60px; /* 固定宽度 */
      height: 60px; /* 固定高度，形成正方形 */
      text-align: center;
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0; /* 防止格子被压缩 */
      box-sizing: border-box; /* 新增：确保边框包含在尺寸内 */
    }

    .pinyin-cell {
      height: 40px; /* 拼音行高度保持40px */
      cursor: pointer;
    }

    .pinyin-cell:hover {
      background-color: rgba(0, 58, 102, 0.05);
    }

    /* 关键修改：格子使用统一边框，避免叠加问题 */
    .character-cell {
      border: 1px solid #9ca3af; /* 统一边框 */
      border-top: none;
      border-left: none;
      cursor: pointer;
      background: white;
      position: relative; /* 为笔画按钮添加定位 */
    }

    /* 拼音显示样式 - 修复版本，确保所有声调正确对齐 */
    .pinyin-display {
      position: relative;
      z-index: 1;
      opacity: var(--pinyin-opacity);
      color: #374151;
      line-height: 1;
      padding: 0 2px;
      /* 使用印氪先生拼音字体作为首选字体 */
      font-family: 'Yinke Pinyin', -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
      font-weight: 500;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      /* 精确定位在四线格的第二和第三线之间 */
      top: 33.33%;
      transform: translateY(-38%); /* 微调垂直位置 */
      /* 确保字符基线对齐 */
      vertical-align: baseline;
      /* 强制使用相同的文本渲染方式 */
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      text-rendering: optimizeLegibility;
      font-size: var(--pinyin-size);
    }

    /* 格子区域 */
    .grid-box {
      position: relative;
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      box-sizing: border-box; /* 新增 */
    }

    /* 调整汉字大小到标准尺寸 - 使用楷体 */
    .character-trace {
      font-size: var(--character-size);
      font-weight: bold;
      color: #1f2937;
      opacity: var(--character-opacity);
      pointer-events: none;
      z-index: 1;
      font-family: "楷体", "KaiTi", "STKaiti", "Kaiti SC", "BiauKai", "楷体_GB2312", "AR PL UKai CN", "LXGW WenKai Screen", serif;
    }

    /* 田字格、米字格、空白格样式 */
    .tianzige .grid-box::before,
    .tianzige .grid-box::after {
      content: '';
      position: absolute;
      z-index: 0;
    }
    .tianzige .grid-box::before {
      width: 0;
      height: 100%;
      left: 50%;
      top: 0;
      border-left: 1px dashed rgba(0,0,0,0.25);
      transform: translateX(-50%);
    }
    .tianzige .grid-box::after {
      width: 100%;
      height: 0;
      top: 50%;
      left: 0;
      border-top: 1px dashed rgba(0,0,0,0.25);
      transform: translateY(-50%);
    }

    .mizige .grid-box::before,
    .mizige .grid-box::after,
    .mizige .diag1,
    .mizige .diag2 {
      content: '';
      position: absolute;
      z-index: 0;
      pointer-events: none;
    }
    .mizige .grid-box::before {
      width: 0;
      height: 100%;
      left: 50%;
      top: 0;
      border-left: 1px dashed rgba(0,0,0,0.25);
      transform: translateX(-50%);
    }
    .mizige .grid-box::after {
      width: 100%;
      height: 0;
      top: 50%;
      left: 0;
      border-top: 1px dashed rgba(0,0,0,0.25);
      transform: translateY(-50%);
    }
    .mizige .diag1,
    .mizige .diag2 {
      width: 141.42%;
      height: 0;
      top: 50%;
      left: 50%;
      border-top: 1px dashed rgba(0,0,0,0.25);
      transform-origin: center;
    }
    .mizige .diag1 {
      transform: translate(-50%, -50%) rotate(45deg);
    }
    .mizige .diag2 {
      transform: translate(-50%, -50%) rotate(-45deg);
    }

    .kongbaige .grid-box::before,
    .kongbaige .grid-box::after,
    .kongbaige .diag1,
    .kongbaige .diag2 {
      display: none;
    }

    /* 隐藏控制 - 使用visibility保持占位 */
    .hide-pinyin .pinyin-line { 
      visibility: hidden;
    }
    .hide-character .character-trace { 
      visibility: hidden !important; 
    }
    .hide-four-lines .four-lines-row { 
      visibility: hidden;
    }

    .popup {
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%);
      background: white;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
      padding: 6px;
      z-index: 100;
      display: none;
      white-space: nowrap;
    }
    .popup button {
      padding: 4px 10px;
      margin: 2px;
      font-size: 12px;
      background: #f9fafb;
      border: 1px solid #e5e7eb;
      border-radius: 4px;
      cursor: pointer;
      color: #374151;
    }
    .popup button:hover {
      background: #f3f4f6;
      border-color: #d1d5db;
    }

    .empty-row {
      width: 100%;
      height: 80px;
      margin: 10px 0;
      border: 1px dashed #d1d5db;
      border-radius: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #9ca3af;
      font-size: 14px;
      background: #f9fafb;
    }

    /* 加载提示 */
    .loading-indicator {
      display: none;
      text-align: center;
      padding: 20px;
      color: #6b7280;
    }

    /* 导出加载提示 */
    .export-loading {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: rgba(0, 0, 0, 0.8);
      color: white;
      padding: 20px 30px;
      border-radius: 8px;
      z-index: 10000;
      display: none;
      align-items: center;
      gap: 10px;
    }

    /* 新设计生字库弹窗样式 */
    .textbook-modal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.5);
      z-index: 2000;
      display: none;
      justify-content: center;
      align-items: center;
    }
    
    .textbook-modal-content {
      background: white;
      border-radius: 12px;
      width: 90%;
      max-width: 1200px;
      height: 80%;
      max-height: 700px;
      display: flex;
      flex-direction: column;
      box-shadow: 0 10px 25px rgba(0,0,0,0.2);
      overflow: hidden;
    }
    
    .textbook-modal-header {
      padding: 20px;
      border-bottom: 1px solid #e5e7eb;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    .textbook-modal-title {
      font-size: 1.5rem;
      font-weight: 600;
      color: #1f2937;
    }
    
    .textbook-modal-close {
      background: none;
      border: none;
      font-size: 1.5rem;
      cursor: pointer;
      color: #6b7280;
    }
    
    .textbook-modal-body {
      flex: 1;
      display: flex;
      overflow: hidden;
    }
    
    /* 树形导航样式 */
    .tree-nav {
      width: 300px;
      border-right: 1px solid #e5e7eb;
      background: #f9fafb;
      overflow-y: auto;
      padding: 15px 0;
    }
    
    .tree {
      list-style: none;
      padding-left: 0;
    }
    
    .tree-node {
      position: relative;
      padding-left: 20px;
    }
    
    .tree-node::before {
      content: '';
      position: absolute;
      top: 0;
      left: 10px;
      height: 100%;
      border-left: 1px solid #e5e7eb;
    }
    
    .tree-node:last-child::before {
      height: 12px;
    }
    
    .tree-node-content {
      display: flex;
      align-items: center;
      padding: 8px 15px;
      cursor: pointer;
      transition: all 0.2s;
      position: relative;
    }
    
    .tree-node-content::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 0;
      width: 10px;
      height: 0;
      border-top: 1px solid #e5e7eb;
    }
    
    .tree-node-content:hover {
      background: rgba(0, 58, 102, 0.05);
    }
    
    .tree-node-content.active {
      background: rgba(0, 58, 102, 0.1);
      color: #003A66;
      font-weight: 500;
    }
    
    .tree-toggle {
      width: 18px;
      height: 18px;
      margin-right: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 3px;
      background: white;
      border: 1px solid #e5e7eb;
      cursor: pointer;
      font-size: 12px;
      transition: all 0.2s;
    }
    
    .tree-toggle:hover {
      background: #f3f4f6;
    }
    
    .tree-toggle.expanded::after {
      content: '-';
    }
    
    .tree-toggle.collapsed::after {
      content: '+';
    }
    
    .tree-children {
      list-style: none;
      padding-left: 20px;
      display: none;
    }
    
    .tree-children.expanded {
      display: block;
    }
    
    .tree-node.leaf .tree-toggle {
      visibility: hidden;
    }
    
    /* 主内容区域 */
    .main-content {
      flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    
    .lessons-section {
      padding: 20px;
      border-bottom: 1px solid #e5e7eb;
      background: #f9fafb;
    }
    
    .section-title {
      font-size: 16px;
      font-weight: 600;
      color: #374151;
      margin-bottom: 15px;
    }
    
    .lessons-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
      gap: 10px;
    }
    
    .lesson-item {
      background: white;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      padding: 10px 12px;
      text-align: center;
      cursor: pointer;
      transition: all 0.2s;
      font-size: 18px;
    }
    
    .lesson-item:hover {
      border-color: #003A66;
    }
    
    .lesson-item.active {
      background: #003A66;
      color: white;
      border-color: #003A66;
    }
    
    .words-section {
      flex: 1;
      display: flex;
      flex-direction: column;
      padding: 20px;
      overflow: hidden;
    }
    
    .words-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 15px;
    }
    
    .words-count {
      color: #6b7280;
      font-size: 14px;
    }
    
    .words-actions {
      display: flex;
      gap: 10px;
    }
    
    .btn {
      padding: 8px 16px;
      border-radius: 6px;
      border: 1px solid #e5e7eb;
      background: white;
      color: #374151;
      cursor: pointer;
      transition: all 0.2s;
      font-weight: 500;
    }
    
    .btn:hover {
      background: #f3f4f6;
    }
    
    .btn.primary {
      background: #003A66;
      color: white;
      border-color: #003A66;
    }
    
    .btn.primary:hover {
      background: #005599;
    }
    
    .words-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
      gap: 12px;
      overflow-y: auto;
      padding: 5px;
      flex: 1;
    }
    
    .word-item {
      background: white;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      padding: 12px;
      text-align: center;
      cursor: pointer;
      transition: all 0.2s;
      font-size: 24px;
      position: relative;
    }
    
    .word-item:hover {
      border-color: #003A66;
      box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .word-item.selected {
      background: #003A66;
      color: white;
      border-color: #003A66;
    }
    
    .word-pinyin {
      font-size: 18px;
      color: #6b7280;
      margin-top: 4px;
    }
    
    .word-item.selected .word-pinyin {
      color: rgba(255,255,255,0.8);
    }
    
    .empty-state {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 100%;
      color: #6b7280;
      text-align: center;
      padding: 40px;
      grid-column: 1 / -1;
    }
    
    .empty-state-icon {
      font-size: 48px;
      margin-bottom: 16px;
      opacity: 0.5;
    }
    
    .textbook-modal-footer {
      padding: 15px 20px;
      border-top: 1px solid #e5e7eb;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    
    .selected-info {
      font-size: 14px;
      color: #6b7280;
    }
    
    /* 自定义拼音输入框样式 */
    .custom-pinyin-input {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: white;
      border: 2px solid #003A66;
      border-radius: 12px;
      padding: 25px;
      z-index: 2000;
      box-shadow: 0 10px 25px rgba(0,0,0,0.2);
      width: 90%;
      max-width: 400px;
      display: none;
    }

    .custom-pinyin-input h3 {
      color: #003A66;
      margin-bottom: 15px;
      text-align: center;
    }

    .custom-pinyin-input input {
      width: 100%;
      padding: 12px 15px;
      font-size: 18px;
      border: 1px solid #d1d5db;
      border-radius: 8px;
      margin-bottom: 20px;
      text-align: center;
      font-family: 'Yinke Pinyin', 'Noto Sans SC', sans-serif;
    }

    .custom-pinyin-input input:focus {
      outline: none;
      border-color: #003A66;
      box-shadow: 0 0 0 3px rgba(0, 58, 102, 0.15);
    }

    .pinyin-input-buttons {
      display: flex;
      gap: 10px;
      justify-content: center;
    }

    .pinyin-input-btn {
      padding: 10px 20px;
      font-size: 16px;
      border-radius: 6px;
      border: 1px solid #e5e7eb;
      background: white;
      color: #374151;
      cursor: pointer;
      transition: all 0.15s ease;
      font-weight: 500;
      flex: 1;
    }

    .pinyin-input-btn:hover {
      background: #f3f4f6;
      border-color: #d1d5db;
    }

    .pinyin-input-btn.primary {
      background: #003A66;
      color: white;
      border-color: #003A66;
    }

    .pinyin-input-btn.primary:hover {
      background: #005599;
    }

    /* ============ 重新设计汉字笔画功能样式 - 紧凑版 ============ */
    
    /* 笔画按钮 - 位于汉字格子右下角 */
    .stroke-button {
      position: absolute;
      bottom: 2px;
      right: 2px;
      width: 18px;
      height: 18px;
      background: rgba(0, 58, 102, 0.85);
      color: white;
      border-radius: 50%;
      font-size: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      opacity: 0;
      transition: all 0.2s ease;
      z-index: 10;
      box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    }
    
    .character-cell:hover .stroke-button {
      opacity: 1;
    }
    
    .stroke-button:hover {
      background: #005599;
      transform: scale(1.1);
    }
    
    /* 汉字笔画模态框 - 紧凑版 */
    .stroke-modal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.7);
      z-index: 3000;
      display: none;
      justify-content: center;
      align-items: center;
      padding: 20px;
      animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    
    /* 紧凑型模态框内容 */
    .stroke-modal-content {
      background: white;
      border-radius: 16px;
      width: 100%;
      max-width: 600px; /* 缩小最大宽度 */
      height: auto;
      max-height: 90vh;
      display: flex;
      flex-direction: column;
      box-shadow: 0 15px 30px rgba(0,0,0,0.25);
      overflow: hidden;
      animation: slideUp 0.4s ease;
    }
    
    @keyframes slideUp {
      from { transform: translateY(30px); opacity: 0; }
      to { transform: translateY(0); opacity: 1; }
    }
    
    /* 紧凑型头部 */
    .stroke-modal-header {
      padding: 18px 20px;
      background: linear-gradient(135deg, #003A66, #005599);
      color: white;
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: relative;
    }
    
    .stroke-modal-title {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    
    .stroke-modal-char-info {
      display: flex;
      align-items: center;
      gap: 12px;
    }
    
    .stroke-modal-character {
      font-size: 2.2rem;
      font-weight: bold;
      font-family: "楷体", "KaiTi", "STKaiti", "Kaiti SC", "BiauKai", "楷体_GB2312", "AR PL UKai CN", "LXGW WenKai Screen", serif;
      line-height: 1;
    }
    
    .stroke-modal-pinyin {
      font-size: 1.2rem;
      opacity: 0.9;
      font-family: 'Yinke Pinyin', sans-serif;
    }
    
    .stroke-modal-count {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 0.9rem;
      margin-top: 2px;
    }
    
    .stroke-count-badge {
      background: rgba(255,255,255,0.2);
      padding: 4px 10px;
      border-radius: 20px;
      font-size: 14px;
      font-weight: 500;
    }
    
    .stroke-modal-close {
      background: rgba(255,255,255,0.2);
      border: none;
      width: 36px;
      height: 36px;
      border-radius: 50%;
      cursor: pointer;
      font-size: 1.3rem;
      color: white;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: all 0.2s ease;
      flex-shrink: 0;
    }
    
    .stroke-modal-close:hover {
      background: rgba(255,255,255,0.3);
      transform: scale(1.05);
    }
    
    /* 修复：紧凑型主体布局 - 添加滚动支持 */
    .stroke-modal-body {
      display: flex;
      flex-direction: column;
      padding: 20px;
      gap: 20px;
      overflow-y: auto;
      max-height: calc(90vh - 120px);
      -webkit-overflow-scrolling: touch; /* 移动端平滑滚动 */
    }
    
    /* 笔画信息区 - 紧凑水平布局 */
    .stroke-info-container {
      display: flex;
      background: #f9fafb;
      border-radius: 10px;
      padding: 15px;
      gap: 15px;
      flex-wrap: wrap;
      justify-content: space-between;
    }
    
    .stroke-info-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      flex: 1;
      min-width: 100px;
    }
    
    .stroke-info-label {
      font-size: 11px;
      color: #6b7280;
      margin-bottom: 4px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }
    
    .stroke-info-value {
      font-size: 16px;
      font-weight: 600;
      color: #1f2937;
    }
    
    .stroke-demo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* 添加这行确保垂直居中 */
  background: #f9fafb;
  border-radius: 12px;
  border: 2px solid #e5e7eb;
  padding: 20px;
  gap: 15px;
  min-height: 240px; /* 增加最小高度，为动画留出空间 */
  height: 100%; /* 添加这行确保容器占满可用空间 */
}
    
    /* 修复：汉字笔画演示画布 - 关键修复：确保SVG动画居中 */
    #hanzi-canvas {
  width: 180px;
  height: 180px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
    
    /* 修复：确保Hanzi Writer生成的SVG居中 */
#hanzi-canvas > div {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative !important;
}

#hanzi-canvas svg {
  display: block;
  margin: auto;
  position: absolute;
  top: 50% !important; /* 关键修改：强制居中 */
  left: 50% !important; /* 关键修改：强制居中 */
  transform: translate(-50%, -50%) !important; /* 关键修改：强制居中 */
}

/* 静态汉字显示 - 修复垂直居中 */
.static-hanzi-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  text-align: center;
}

.static-hanzi-character {
  font-size: 70px;
  font-family: '楷体', 'KaiTi', 'STKaiti', 'Kaiti SC', 'BiauKai', '楷体_GB2312', 'AR PL UKai CN', 'LXGW WenKai Screen', serif;
  color: #003A66;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

/* 加载状态也需要垂直居中 */
.stroke-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* 确保垂直居中 */
  height: 180px;
  color: #6b7280;
  width: 100%;
}
    
    /* 修复：练习画布容器 - 确保居中 */
    #practice-canvas-container {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      min-height: 180px;
      position: relative;
      display: none;
    }
    
    /* 修复：练习画布样式 */
    #practice-canvas-container canvas {
      display: block;
      margin: 0 auto;
    }
    
    /* 修复：将笔画控制按钮移到画布外部 */
    .stroke-controls-container {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 15px;
      width: 100%;
      margin-top: 10px;
    }
    
    /* 紧凑型笔画控制按钮 */
    .stroke-controls {
      display: flex;
      gap: 8px;
      width: 100%;
      max-width: 400px;
      justify-content: center;
    }
    
    .stroke-control-btn {
      padding: 10px 16px !important;
      font-size: 13px !important;
      border-radius: 8px;
      border: 1px solid #e5e7eb;
      background: white;
      color: #374151;
      cursor: pointer;
      transition: all 0.2s;
      font-weight: 500;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      flex: 1;
      max-width: 140px;
      min-height: 44px;
    }
    
    .stroke-control-btn:hover {
      background: #f3f4f6;
      border-color: #d1d5db;
    }
    
    .stroke-control-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }
    
    .stroke-control-btn.primary {
      background: #003A66;
      color: white;
      border-color: #003A66;
    }
    
    .stroke-control-btn.primary:hover {
      background: #005599;
    }
    
    /* 进度指示器 */
    .stroke-progress {
      width: 100%;
      max-width: 400px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;
    }
    
    .progress-label {
      font-size: 13px;
      color: #6b7280;
    }
    
    .progress-bar {
      width: 100%;
      height: 6px;
      background: #e5e7eb;
      border-radius: 3px;
      overflow: hidden;
    }
    
    .progress-fill {
      height: 100%;
      background: #003A66;
      width: 0%;
      transition: width 0.3s ease;
    }
    
    /* 修复：紧凑型练习区 - 确保在移动端可滚动 */
    .practice-container {
      border-top: 1px solid #e5e7eb;
      padding-top: 15px;
      margin-top: 10px;
      width: 100%;
    }
    
    .practice-title {
      font-size: 1rem;
      font-weight: 600;
      color: #1f2937;
      margin-bottom: 12px;
      text-align: center;
    }
    
    .practice-buttons {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;
      width: 100%;
    }
    
    .practice-btn {
      padding: 10px 12px;
      font-size: 13px;
      border-radius: 6px;
      border: 1px solid #e5e7eb;
      background: white;
      color: #374151;
      cursor: pointer;
      transition: all 0.2s;
      font-weight: 500;
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    
    .practice-btn:hover {
      background: #f3f4f6;
    }
    
    .practice-btn.active {
      background: #003A66;
      color: white;
      border-color: #003A66;
    }
    
    .practice-btn.back-to-demo {
      background: #10b981;
      color: white;
      border-color: #10b981;
      grid-column: span 2;
    }
    
    .practice-btn.back-to-demo:hover {
      background: #059669;
    }
    
    /* 加载状态 */
    .stroke-loading {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 180px;
      color: #6b7280;
      width: 100%;
    }
    
    .stroke-loading-spinner {
      width: 36px;
      height: 36px;
      border: 3px solid #f0f7ff;
      border-top: 3px solid #003A66;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin-bottom: 12px;
    }
    
    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }

    /* 网络状态提示 */
    .network-status {
      position: fixed;
      top: 10px;
      right: 10px;
      background: rgba(0,0,0,0.7);
      color: white;
      padding: 8px 15px;
      border-radius: 20px;
      font-size: 12px;
      z-index: 10000;
      display: none;
      align-items: center;
      gap: 5px;
    }
    
    .network-status.online {
      background: #10b981;
    }
    
    .network-status.offline {
      background: #ef4444;
    }

 /* 打印样式 */
@media print {
  @page {
    margin: 1.5cm; /* 设置打印页边距为1.5厘米 */
    size: A4; /* 设置纸张大小为A4 */
  }
  
  /* 隐藏所有非打印元素 */
  header,
  .main-container > *:not(.print-area),
  .input-section,
  .control-panel,
  .generate-btn-container,
  .export-section,
  .toolbar,
  .control-section,
  .button-sections,
  .sliders-section,
  .example-buttons,
  .loading-indicator,
  .textbook-modal,
  .export-loading,
  .custom-pinyin-input,
  .stroke-modal,
  .stroke-button,
  .network-status { 
    display: none !important; 
  }
  footer {
    display: none !important;
  }
  body { 
    background: white !important; 
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    font-size: 12pt !important;
    color: black !important;
  }
  
  /* 只显示打印区域 */
  .print-area { 
    display: block !important;
    box-shadow: none !important; 
    padding: 0 !important; 
    margin: 0 !important;
    border-radius: 0 !important;
    width: 100% !important;
    max-width: none !important;
    background: white !important;
    position: static !important;
    page-break-inside: avoid;
    overflow: visible !important;
  }
  
  /* 确保打印区域内的内容正常显示 */
  .worksheet-container {
    display: block !important;
    margin-top: 0 !important;
    width: 720px !important; /* 新增：固定宽度 */
    margin: 0 auto !important; /* 新增：居中显示 */
    box-sizing: border-box !important; /* 新增 */
  }
  
  .line-container { 
    margin-bottom: 8px !important; 
    page-break-inside: avoid;
  }
  
  .four-lines-row { 
    height: 35px !important; 
    margin-bottom: 8px !important; 
    display: block !important;
    position: relative !important;
    width: 720px !important; /* 新增：固定宽度 */
  }
  
  .pinyin-line { 
    height: 35px !important; 
    display: flex !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 720px !important; /* 修改：固定宽度 */
    z-index: 2 !important;
  }
  
  /* 关键修改：打印时保持正确的边框设置 */
  .character-line {
    display: flex !important;
    width: 720px !important; /* 新增：固定宽度 */
    border-top: 1px solid #9ca3af !important;
    border-left: 1px solid #9ca3af !important;
    box-sizing: border-box !important; /* 新增 */
  }
  
  .character-cell { 
    height: 60px !important;
    width: 60px !important;
    display: flex !important;
    border-right: 1px solid #9ca3af !important;
    border-bottom: 1px solid #9ca3af !important;
    border-top: none !important;
    border-left: none !important;
    box-sizing: border-box !important; /* 新增 */
  }
  
  /* 关键修改：打印时继承CSS变量或内联样式，而不是固定值 */
  .character-trace { 
    font-size: unset !important; 
    opacity: unset !important;
    display: block !important;
  }
  
  .pinyin-cell {
    display: flex !important;
    height: 35px !important;
    width: 60px !important;
    position: relative !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important; /* 新增 */
  }
  
  /* 关键修改：拼音显示样式在打印时继承当前设置 */
  .pinyin-display {
    font-size: unset !important;
    opacity: unset !important;
  }
  
  .empty-row { 
    height: 60px !important; 
    color: transparent !important;
    background: transparent !important;
    border: 1px dashed #ccc !important;
    display: flex !important;
    width: 720px !important; /* 新增：固定宽度 */
  }
  
  /* 确保四线格在打印时继承页面中的灰度设置 */
  .four-lines {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 720px !important; /* 修改：固定宽度 */
    height: 100% !important;
    pointer-events: none !important;
    box-sizing: border-box !important; /* 新增 */
  }
  
  /* 关键修改：打印时四线格使用CSS变量 */
  .four-lines .line-1,
    .four-lines .line-2,
    .four-lines .line-3,
    .four-lines .line-4,
    .four-lines .vertical-line {
    border-color: rgba(0,0,0,var(--four-lines-opacity)) !important;
  }
  
  .four-lines .line-1 { 
    top: 0 !important; 
    width: 720px !important; /* 修改：固定为720px */
  }
  .four-lines .line-2 { 
    top: 33.33% !important; 
    width: 720px !important; /* 修改：固定为720px */
  }
  .four-lines .line-3 { 
    top: 66.67% !important; 
    width: 720px !important; /* 修改：固定为720px */
  }
  .four-lines .line-4 { 
    top: 100% !important; 
    width: 720px !important; /* 修改：固定为720px */
  }
  
  .four-lines .vertical-line {
    position: absolute !important;
    top: 0 !important;
    width: 0 !important;
    height: 100% !important;
    box-sizing: border-box !important; /* 新增 */
  }
  
  /* 关键修复：确保最后一条竖线在720px位置 */
  .four-lines .vertical-line:last-child {
    left: 720px !important; /* 最后一条竖线在720px位置 */
  }
  
  /* 隐藏所有弹出窗口 */
  .popup,
  #exportMenu,
  #charSizePopup {
    display: none !important;
  }
  
  /* 确保网格样式正确显示 */
  .grid-box::before,
  .grid-box::after,
  .diag1,
  .diag2 {
    border-color: rgba(0,0,0,0.25) !important;
  }
}

    /* 移动端基础适配 */
    @media (max-width: 900px) {
      .button-sections {
        flex-direction: column;
        gap: 20px;
      }
      
      .sliders-section {
        grid-template-columns: repeat(3, 1fr);
      }
      
      .textbook-modal-content {
        width: 95%;
        height: 90%;
      }
      
      .tree-nav {
        width: 250px;
      }
      
      .lessons-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
      }
      
      .words-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
      }
      
      /* 移动端打印区域优化 */
      .print-area {
        overflow-x: auto;
        padding: 15px;
        -webkit-overflow-scrolling: touch; /* 平滑滚动 */
      }
      
      /* 在移动端显示滚动提示 */
      .print-area::after {
        content: none;
        display: block;
        text-align: center;
        color: #6b7280;
        font-size: 12px;
        margin-top: 10px;
        padding: 5px;
      }
      
      /* 移动端汉字笔画模态框适配 - 紧凑型 */
      .stroke-modal-content {
        width: 98%;
        max-width: 500px;
        border-radius: 12px;
        margin: 10px;
        max-height: 95vh; /* 移动端使用更大的高度 */
      }
      
      .stroke-modal-body {
        max-height: calc(95vh - 100px); /* 调整内部滚动区域的高度 */
        padding: 15px;
        gap: 15px;
        overflow-y: auto; /* 确保可滚动 */
      }
      
      .stroke-modal-header {
        padding: 15px;
      }
      
      .stroke-modal-character {
        font-size: 1.8rem;
      }
      
      .stroke-modal-pinyin {
        font-size: 1rem;
      }
      
      .stroke-info-container {
        padding: 12px;
        gap: 10px;
      }
      
      .stroke-info-item {
        min-width: 80px;
      }
      
      .stroke-info-label {
        font-size: 10px;
      }
      
      .stroke-info-value {
        font-size: 14px;
      }
      
      /* 笔画演示区适配 */
      #hanzi-canvas {
        width: 160px;
        height: 160px;
      }
      
      /* 移动端笔画控制按钮适配 */
      .stroke-controls {
        flex-wrap: wrap;
      }
      
      .stroke-control-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
        min-height: 40px;
        flex: 1 0 calc(50% - 8px);
        max-width: none;
      }
      
      /* 练习按钮适配 */
      .practice-buttons {
        grid-template-columns: 1fr;
        gap: 6px;
      }
      
      .practice-btn.back-to-demo {
        grid-column: 1;
      }
    }

    @media (max-width: 768px) {
      .main-container {
        padding: 0 15px;
      }
      
      .sliders-section {
        grid-template-columns: repeat(2, 1fr);
      }
      
      .input-section, .control-panel, .print-area {
        padding: 20px;
      }
      
      .line-container { margin-bottom: 8px; }
      .four-lines-row { height: 35px; margin-bottom: 8px; }
      .pinyin-line { height: 35px; }
      .character-cell { height: 60px; width: 60px; } /* 保持正方形 */
      .character-trace { font-size: 28px; }
      header h1 { font-size: 1.5rem; }
      .export-section {
        justify-content: center;
        flex-wrap: wrap;
      }
      
      .generate-btn {
        padding: 14px 30px;
        font-size: 16px;
      }
      
      .input-buttons {
        flex-direction: column;
        align-items: stretch;
      }
      
      .example-btn, .textbook-btn {
        text-align: center;
        width: 100%;
      }
      
      .textbook-modal-body {
        flex-direction: column;
      }
      
      .tree-nav {
        width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
      }
      
      .lessons-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
      }
      
      /* 移动端滑块区域优化 */
      .slider-control {
        min-width: 140px;
      }
      
      /* 移动端笔画按钮大小调整 */
      .stroke-button {
        width: 16px;
        height: 16px;
        font-size: 9px;
      }
      
      /* 汉字笔画模态框移动端优化 */
      .stroke-modal-content {
        max-width: 95%;
        margin: 10px;
        max-height: 90vh;
      }
      
      .stroke-modal-body {
        padding: 15px;
        gap: 15px;
        max-height: calc(90vh - 90px);
      }
      
      .stroke-demo-container {
        padding: 15px;
      }
      
      #hanzi-canvas {
        width: 140px;
        height: 140px;
      }
      
      #practice-canvas-container {
        height: 140px;
      }
      
      /* 移动端笔画控制按钮优化 */
      .stroke-controls {
        flex-direction: column;
        align-items: stretch;
      }
      
      .stroke-control-btn {
        min-width: 100px;
        padding: 8px 10px !important;
        font-size: 11px !important;
        min-height: 38px;
        flex: 1;
      }
      
      .stroke-info-container {
        flex-direction: column;
        align-items: flex-start;
      }
      
      .stroke-info-item {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        min-width: auto;
      }
      
      .practice-container {
        padding-top: 12px;
        margin-top: 8px;
      }
    }

    @media (max-width: 480px) {
      .sliders-section {
        grid-template-columns: 1fr;
      }
      
      .control-panel {
        padding: 15px;
      }
      
      .button-group {
        flex-wrap: wrap;
      }
      
      .control-btn {
        flex: 1 0 45%;
        margin-bottom: 5px;
      }
      
      .export-btn {
        padding: 8px 12px;
        font-size: 13px;
      }
      
      .generate-btn {
        padding: 12px 20px;
        font-size: 15px;
      }
      
      header h1 {
        font-size: 1.3rem;
      }
      
      header p {
        font-size: 0.9rem;
      }
      
      .input-section {
        padding: 15px;
      }
      
      textarea {
        height: 120px;
        padding: 12px;
        font-size: 15px;
      }
      
      /* 移动端笔画模态框极致优化 */
      .stroke-modal-content {
        max-width: 100%;
        margin: 5px;
        border-radius: 10px;
        max-height: 95vh;
      }
      
      .stroke-modal-header {
        padding: 12px 15px;
      }
      
      .stroke-modal-character {
        font-size: 1.6rem;
      }
      
      .stroke-modal-pinyin {
        font-size: 0.9rem;
      }
      
      .stroke-count-badge {
        font-size: 12px;
        padding: 3px 8px;
      }
      
      .stroke-modal-close {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
      }
      
      #hanzi-canvas {
        width: 120px;
        height: 120px;
      }
      
      #practice-canvas-container {
        height: 120px;
      }
      
      .stroke-control-btn {
        min-width: 90px;
        padding: 6px 8px !important;
        font-size: 10px !important;
        min-height: 36px;
        flex: 0 0 calc(33.333% - 6px);
      }
      
      .stroke-demo-container {
        padding: 12px;
        gap: 12px;
      }
      
      .practice-buttons {
        grid-template-columns: 1fr;
        gap: 6px;
      }
      
      .practice-btn {
        padding: 8px 10px;
        font-size: 12px;
      }
    }
    
    /* 超小屏幕优化 */
    @media (max-width: 360px) {
      .stroke-control-btn {
        font-size: 9px !important;
        padding: 5px 6px !important;
        min-height: 34px;
      }
      
      .stroke-info-label {
        font-size: 9px;
      }
      
      .stroke-info-value {
        font-size: 13px;
      }
      
      .stroke-modal-character {
        font-size: 1.4rem;
      }
      
      #hanzi-canvas {
        width: 100px;
        height: 100px;
      }
      
      #practice-canvas-container {
        height: 100px;
      }
    }

/* 历史记录专属样式 */
.history-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
}
.history-item {
  transition: all 0.2s;
}
.history-item:hover {
  background-color: #f0f7ff !important;
  border-color: #b3d4ff !important;
}


/* 独立弹窗 (Modal) 通用样式 - 用于历史记录等 */
.modal {
  display: none; 
  position: fixed; 
  z-index: 3000; 
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5); /* 半透明黑色背景 */
  align-items: center; /* 垂直居中 */
  justify-content: center; /* 水平居中 */
}

/* 覆盖 display none，强制居中 */
.modal[style*="display: block"] {
  display: flex !important;
}

.modal-content {
  background-color: #ffffff;
  margin: auto;
  padding: 0;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 18px 25px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8fafc;
  border-radius: 12px 12px 0 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #1f2937;
  font-weight: 600;
}

.close-btn {
  color: #9ca3af;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover,
.close-btn:focus {
  color: #4b5563;
  text-decoration: none;
}

.modal-body {
  padding: 20px 25px;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-footer {
  padding: 15px 25px;
  border-top: 1px solid #e5e7eb;
  background-color: #f8fafc;
  border-radius: 0 0 12px 12px;
}
