/* ============================================================
   product-a-口语陪练/style-a.css
   产品 A 专属样式
   ============================================================ */

/* ================== 整体布局 ================== */
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-main);
}

/* ================== 顶部栏 ================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo { font-size: 20px; }

.title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-primary);
}

.subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name {
  font-size: 13px;
  color: var(--text-secondary);
}

.header-btn {
  padding: 5px 10px;
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
}

.header-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
}

/* ================== 主区（三段式） ================== */
.app-body {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  min-height: 0;
  overflow: hidden;
}

/* ================== 左栏 ================== */
.app-left {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 12px;
  overflow-y: auto;
  min-height: 0;

  width: 300px;       /* 或者 320px，你可以根据视觉感受调 */
  flex-shrink: 0;
}

.left-section-title {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 12px 0 6px;
  font-weight: 600;
}

.left-section-title:first-child {
  margin-top: 0;
}

.scene-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scene-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px 10px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
}

.scene-item:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.scene-item.active {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.scene-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
}

.scene-name-zh {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.scene-item.free-mode {
  border-style: dashed;
}

.scene-loading {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 8px;
}

/* ================== 中栏 ================== */
.app-center {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-main);
}

/* 黑板：产品 A 里默认收起 */
.app-center .core-blackboard {
  max-height: 45vh;
  border-bottom: 1px solid var(--border-color);
}

.app-center .core-board-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-height: 200px; /* 加这一行：给一个最低高度，防止被压扁 */
  max-height: 400px; /* 最高高度，防止太长 */
  overflow: auto;    /* 内容超出可以滚动 */
  background: #f8fafc;
}

.core-board-body img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain; /* 加这一行：保证图片保持比例缩放，不拉伸、不压扁 */
  display: block;
}

/* 对话区 */
.app-center .core-chat {
  flex: 1;
  min-height: 0;
}

/* 输入区 */
.app-input {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-main);
}

.app-input textarea {
  width: 100%;
  padding: 14px 18px; 
  border: 1px solid #e2e8f0; 
  border-radius: 16px; 
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  max-height: 140px;
  line-height: 1.6;
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03); 
  transition: all 0.2s ease;
  outline: none;
}

.app-input textarea:focus {
  outline: none;
  border-color: #4a6fa5;
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15), 0 2px 8px rgba(0,0,0,0.05);
}

.input-buttons {
  display: flex;
  gap: 10px; 
  flex-wrap: wrap;
  margin-top: 12px; 
}

.core-btn-mic {
  background: #10b981;
  color: #fff;
  user-select: none;
  touch-action: none;
}

.core-btn-mic.recording {
  background: #ef4444;
}

/* ================== 右栏 ================== */
.app-right {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  padding: 12px;
  overflow-y: auto;
  min-height: 0;
}

.right-section-title {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 12px 0 6px;
  font-weight: 600;
}

.right-section-title:first-child {
  margin-top: 0;
}

.tool-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
}

.tool-box input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  margin-bottom: 6px;
}

.tool-box input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.tool-box .core-btn {
  width: 100%;
  padding: 6px;
  font-size: 12px;
}

.tool-result {
  font-size: 12px;
  color: var(--text-main);
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-top: 6px;
  min-height: 32px;
  word-break: break-word;
  line-height: 1.5;
}

.status-line {
  font-size: 12px;
  color: var(--text-main);
  padding: 4px 0;
}

.status-line span {
  color: var(--color-primary);
  font-weight: 500;
}

/* ================== 底部状态栏 ================== */
.app-status {
  padding: 6px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ================== 弹窗 ================== */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-main);
  border-radius: var(--radius-xl);
  padding: 20px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h3 {
  font-size: 16px;
  color: var(--color-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 6px;
}

.modal-body {
  background: var(--bg-secondary);
  padding: 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  overflow-x: auto;
  max-height: 300px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.modal-footer .core-btn {
  flex: 1;
  padding: 8px;
  font-size: 13px;
}

/* ================== 欢迎弹窗 ================== */
.modal-content.welcome h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.modal-content.welcome p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.modal-content.welcome label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 12px 0 4px;
  font-weight: 500;
}

.modal-content.welcome input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
}

.modal-content.welcome input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.mode-options {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.mode-btn {
  flex: 1;
  padding: 12px 8px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.mode-btn:hover {
  border-color: var(--color-primary);
}

.mode-btn.active {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  font-weight: 600;
}

/* ================== 响应式（手机版预留） ================== */
@media (max-width: 768px) {
  .app-body {
    grid-template-columns: 1fr;
  }
  .app-left, .app-right {
    display: none;
  }
}

/* ============================================================
   用户类型自适应（成人 / 老人 / 孩子）
   ============================================================ */

/* 老人模式：放大字号、更松行高、更大按钮 */
body.mode-senior {
  font-size: 20px;
}

body.mode-senior .app-header .title { font-size: 20px; }
body.mode-senior .app-header .subtitle { font-size: 14px; }
body.mode-senior .user-name { font-size: 15px; }
body.mode-senior .header-btn { font-size: 14px; padding: 7px 12px; }

body.mode-senior .scene-name { font-size: 17px; }
body.mode-senior .scene-name-zh { font-size: 13px; }
body.mode-senior .scene-item { padding: 12px 14px; }

body.mode-senior .core-bubble { font-size: 20px; line-height: 1.8; }
body.mode-senior .core-meta { font-size: 13px; }

body.mode-senior .app-input textarea { font-size: 19px; min-height: 56px; }
body.mode-senior .core-btn { font-size: 16px; padding: 13px 20px; }
body.mode-senior .core-live { font-size: 15px; min-height: 40px; }
body.mode-senior .app-status { font-size: 13px; }

body.mode-senior .right-section-title,
body.mode-senior .left-section-title { font-size: 13px; }

body.mode-senior .tool-result { font-size: 15px; }
body.mode-senior .status-line { font-size: 15px; }

/* 孩子模式：略大、更活泼（加一点暖色点缀） */
body.mode-kid {
  font-size: 16px;
}

body.mode-kid .core-bubble { font-size: 15px; line-height: 1.6; }
body.mode-kid .core-btn { font-size: 14px; padding: 10px 16px; }
body.mode-kid .app-input textarea { font-size: 15px; }

/* 孩子模式：主色偏暖（黄橙），按钮和强调色换成暖色 */
body.mode-kid {
  --color-primary: #f59e0b;       /* 暖橙 */
  --color-primary-hover: #d97706;
  --color-primary-light: #fef3c7;
}
body.mode-kid .core-btn-primary { background: #f59e0b; }
body.mode-kid .core-btn-primary:hover { background: #d97706; }
body.mode-kid .core-msg.user .core-bubble { background: #f59e0b; }
body.mode-kid .core-board-tab.active { background: #f59e0b; }
body.mode-kid .header-btn:hover { background: #fef3c7; border-color: #f59e0b; }

/* ============================================================
   数独格子（渲染在黑板区）
   ============================================================ */
.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border: 3px solid #1a1a1a;
  background: #fff;
  width: min(100%, 360px);
  aspect-ratio: 1;
  margin: 0 auto;
}

.sudoku-cell {
  background: #fff;
  border: 1px solid #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
  user-select: none;
}

.sudoku-cell.given {
  color: #1a1a1a;
}

.sudoku-cell.empty {
  color: #4f46e5;
}

.sudoku-cell.border-right { border-right: 3px solid #1a1a1a; }
.sudoku-cell.border-bottom { border-bottom: 3px solid #1a1a1a; }

/* 中文对照（灰色小字） */
.zh-line {
  display: block;
  font-size: 12px;
  color: #8b8b8b;
  font-style: italic;
  margin-top: 4px;
  border-top: 1px dashed #e5e7eb;
  padding-top: 4px;
}
/* 用户填的数字（蓝色斜体，和「已知数字」区分） */
.sudoku-cell.user-filled {
  color: #8b0000;      /* 暗红 */
  font-style: normal;  /* 不斜体（可保留斜体，你定） */
}

/* 格子小键盘 */
.cell-numpad {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  gap: 4px;
  padding: 6px;
  background: #fff;
  border: 2px solid #4f46e5;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.cell-numpad button {
  width: 40px;
  height: 40px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.cell-numpad button:hover {
  background: #e0e7ff;
}

.cell-numpad button.clear {
  color: #dc2626;
  grid-column: span 3;
}

/* 填对 → 绿 */
.sudoku-cell.cell-correct {
  background: #dcfce7;
  color: #15803d;
}

/* 填错 → 红 */
.sudoku-cell.cell-wrong {
  background: #fee2e2;
  color: #b91c1c;
}

/* 数独进度 */
.sudoku-progress-row {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* 改成靠左对齐 */
  gap: 12px;                   /* 名字和数字之间留 12px 间隙 */
  padding: 6px 0;
  white-space: nowrap;         /* 防止文字换行 */
}

.sudoku-progress-row .level-name {
  cursor: pointer;
  color: #4f46e5;
  font-size: 16px;      /* ← 就加这一行 */
}

.sudoku-progress-row .level-name:hover {
  text-decoration: underline;
}

.sudoku-progress-row .level-stat {
  color: #15803d;
  font-weight: 600;
}

.sudoku-puzzle-list {
  display: none;
  padding-left: 12px;
  margin-top: 4px;
}

.sudoku-puzzle-list.show {
  display: block;
}

.sudoku-puzzle-list .puzzle-item {
  font-size: 11px;
  color: #6b7280;
  padding: 2px 0;
}

.sudoku-puzzle-list .puzzle-item.win {
  color: #15803d;
  font-weight: 600;
}
/* 数独「继续下一题」按钮 */
.sudoku-next-btn {
  display: block;
  margin: 14px auto 0;
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: #3b82f6;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.sudoku-next-btn:hover {
  background: #2563eb;
}

.sudoku-next-btn:active {
  transform: scale(0.97);
}

/* 侧边栏折叠样式 */
.sidebar-group {
  margin-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 8px;
}
.sidebar-title {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  padding: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 6px;
}
.sidebar-title:hover {
  background: #f1f5f9;
}
.toggle-icon {
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}
.sidebar-content {
  /* 默认展开，或者你想默认收起可以改成 display: none; */
  padding-top: 8px;
}
/* ==================== 手机端专用布局（抽屉模式） ==================== */
.mobile-menu-btn {
  display: none; /* PC端隐藏 */
}

@media (max-width: 768px) {
  /* 1. 顶部导航栏适配 */
  .app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    position: relative; /* 保证按钮层级正确 */
    z-index: 100;
  }
  .mobile-menu-btn {
    display: block;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #1e293b;
    padding: 0 10px;
  }
  .header-left .subtitle {
    display: none; /* 手机上隐藏副标题省空间 */
  }

  /* 2. 左右两栏变成抽屉 */
  .app-left, .app-right {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 1000;
    background: #ffffff;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
  }

     /* 强制覆盖外层布局，让抽屉固定在屏幕左侧 */
  .app-left {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 80vw !important; /* 占屏幕80% */
    z-index: 9999 !important;
    background: #ffffff !important;
    transform: translateX(-100%) !important; /* 默认隐藏到屏幕外 */
    transition: transform 0.3s ease !important;
    display: block !important;
    /* 万一它是在 flex 布局里被压扁了，这把直接把它拔出来 */
    margin: 0 !important; 
    padding: 20px !important;
  }

  .app-left.open {
    transform: translateX(0) !important; /* 滑出来！ */
  }

    .app-right {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    background: #ffffff !important;
    width: 75vw !important; /* 占屏幕 3/4 */
    transform: translateX(100%) !important; /* 默认藏在屏幕右边 */
    transition: transform 0.3s ease !important;
    display: block !important;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1) !important;
  }

  .app-right.open {
    transform: translateX(0) !important; /* 展开时滑出来 */
  }

  /* 打开抽屉时的类名 */
    .app-left.open, .app-right.open {
    transform: translateX(0) !important; /* 加上 !important */
  }

  /* 3. 遮罩层 */
  .mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
  }
  .mobile-overlay.show {
    display: block;
  }

  /* 4. 主中栏铺满屏幕 */
  .app-body {
    display: flex;
    flex-direction: row;
  }
  .app-center {
    width: 100vw;
    flex: 1;
  }
}

@media (max-width: 768px) {
  /* 手机端默认收起所有折叠内容 */
  .sidebar-content {
    display: none !important;
  }
  /* 如果用户点击了展开（假设 JS 会赋予 style="display: block"），让内联样式生效 */
  .sidebar-content[style*="display: block"] {
    display: block !important;
  }
}
/* 禁止手机端长按弹出系统菜单 */
body {
  -webkit-touch-callout: none; /* 禁止长按弹出菜单 */
  -webkit-user-select: none;   /* 禁止长按选中文字 */
  user-select: none;
}

/* 输入框允许正常选中和输入 */
textarea, input {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
  } 
  /* 1. 黑板默认高度（应对数学题卡） */
  .core-blackboard {
    max-height: 40vh !important;
  }
  
  .core-board-body {
    max-height: 32vh !important;
    padding: 4px !important;
  }

  /* 2. 重点：如果是数独，把黑板撑高，用 flex 居中 */
  .core-board-body:has(.sudoku-board) {
    max-height: 55vh !important; 
    padding: 10px !important;
    display: flex;
    justify-content: center; /* 水平居中 */
    align-items: center;     /* 垂直居中 */
  }
  
    /* 数独格子自适应，保证不溢出 */
  .sudoku-board {
    width: 100% !important;       /* 宽度占满可用空间 */
    max-width: 45vh !important;   /* 最大宽度不超过黑板高度的一半（维持正方形） */
    height: auto !important;      /* 高度自动，由宽度撑开 */
    max-height: 100% !important;  /* 保证绝对不超出黑板容器 */
    aspect-ratio: 1 / 1;          /* 强制长宽比为 1:1，完美的正方形 */
    margin: 0 auto;               /* 居中显示 */
    display: grid;                /* 确保内部 9x9 网格能完美铺满 */
  }