/* ============================================================
 * 开局模块通用样式（2026-10-20 新增）
 *
 * 背景（bug 根因）：
 *   .opening-subtabs / .ost-tab / .settings-popup / .ctrl-btn
 *   / .op-source-btn 这一批公共规则，过去只写在
 *   modules/opening.php（打谱页）的内联 <style> 里。
 *   而 4 个子模块是通过 ?module=xxx 各自独立加载的：
 *     opening_practice / opening_stats / opening_personal / opening_personal_editor
 *   它们拿不到打谱页的 <style>，于是：
 *     · 子标签栏退化成浏览器默认 <a>（蓝色 + 下划线 + 16px，无间距）
 *     · 弹窗遮罩/内容框完全没有样式
 *     · 按钮变成浏览器默认灰色小方块
 *   练习页更严重：它 2026-10-19 上线时只写了
 *   .op-login-banner / .op-assign-tag 两条，46 个 class 里
 *   有 44 个在全站找不到任何规则 → 整页裸奔。
 *
 * 本文件把「所有子模块都要用」的公共部分抽出来，
 * 由各子模块用 <link> 引入。规则与 modules/opening.php
 * 的内联样式逐条对齐（视觉与打谱页保持一致）。
 * ============================================================ */

/* ---------- 主容器 ---------- */
.opening-module {
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
}

/* ---------- 子模块导航 ---------- */
.opening-subtabs {
    display: flex;
    gap: 6px;
    padding: 6px 12px 0;
    background: white;
    flex-shrink: 0;
    border-bottom: 1px solid #f0f0f0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.opening-subtabs::-webkit-scrollbar { display: none; }
.ost-tab {
    padding: 7px 14px;
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    text-decoration: none;
    color: #666;
    background: #f5f5f5;
    transition: all 0.2s;
    font-weight: 500;
    border: 1px solid transparent;
    border-bottom: none;
    position: relative;
    top: 1px;
    white-space: nowrap;
    flex-shrink: 0;
}
.ost-tab:hover { background: #e8e8e8; color: #333; }
.ost-tab.active {
    background: white;
    color: #667eea;
    border-color: #ddd;
    font-weight: 600;
}
.ost-tab.active:hover { background: white; }

/* ---------- 棋盘外框（练习页 / 编辑页共用） ---------- */
.op-practice-main > .board-section,
.op-editor-main > .board-section {
    flex: 0 0 520px;
    max-width: 48%;
    background: white;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}
.op-practice-main .board-header,
.op-editor-main .board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-shrink: 0;
    width: 100%;
}
.current-opening-name { font-size: 14px; font-weight: 600; color: #333; }
.current-opening-eco {
    font-size: 12px;
    background: #667eea;
    color: white;
    padding: 4px 10px;
    border-radius: 10px;
}
.canvas-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 6px;
    flex: 0 0 auto;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}
.canvas-wrapper canvas {
    border: none;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transform: translateZ(0);
    display: block;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    outline: none;
}

/* ---------- 控制按钮 ---------- */
.ctrl-btn {
    width: 36px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: #f0f0f0;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.ctrl-btn:hover { background: #e0e0e0; }
.ctrl-btn:active { transform: scale(0.95); }
.ctrl-btn.primary { background: #667eea; color: white; }
.ctrl-btn.primary:hover { background: #5a6fd6; }
.ctrl-btn.danger { background: #ffebee; color: #c62828; }
.ctrl-btn.danger:hover { background: #ffcdd2; }

/* ---------- 通用来源/操作按钮 ---------- */
.op-source-btn {
    padding: 7px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
    color: #333;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}
.op-source-btn:hover { background: #e8e8e8; }
.op-source-btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}
.op-source-btn.primary:hover { opacity: 0.9; background: linear-gradient(135deg, #667eea, #764ba2); }
.op-source-btn.danger { color: #c62828; border-color: #f0b6b6; background: #fff5f5; }
.op-source-btn.danger:hover { background: #ffe0e0; }

/* ---------- 弹窗 ---------- */
.settings-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.popup-mask {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}
.popup-content {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 320px;
    max-width: 90%;
    overflow: hidden;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
}
.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}
.popup-title { font-size: 16px; font-weight: 600; }
.popup-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #555;
}
.popup-close:hover { background: #e0e0e0; }
.popup-body { padding: 16px; overflow-y: auto; }

/* ---------- 小标题 + 走法列表（练习页 / 编辑页共用） ---------- */
.op-current-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    margin-bottom: 4px;
}
.op-sans-list {
    font-size: 12px;
    line-height: 1.7;
    color: #333;
    word-break: break-all;
    max-height: 160px;
    overflow-y: auto;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .opening-subtabs { padding: 6px 8px 0; gap: 4px; }
    .ost-tab { padding: 6px 10px; font-size: 12px; }
    .op-practice-main > .board-section,
    .op-editor-main > .board-section {
        flex: none;
        width: 100%;
        max-width: 100%;
    }
    .op-source-btn { padding: 6px 10px; font-size: 12px; }
    .ctrl-btn { width: 36px; height: 36px; font-size: 14px; }
}
