/* =========================
   全局基础样式
   ========================= */

/* 去掉默认边距，防止页面出现白边和滚动条 */
body {
    margin: 0;
    overflow: hidden;
}

/* 让 <canvas> 作为块级元素，避免出现多余间隙 */
canvas {
    display: block;
}

/* 当 body 带有 .no-scroll 类时，禁止滚动（可通过 JS 动态启用） */
body.no-scroll {
    overflow: hidden;
}

/* =========================
   全局变量（方便统一管理颜色、动画时间等）
   ========================= */
:root {
    --animation-duration: 0.3s;
    /* 动画过渡时间 */
    --panel-bg-color: rgba(0, 0, 0, 0.4);
    /* 面板背景色（半透明黑） */
    --active-button-color: rgba(0, 0, 0, 0.4);
    /* 激活按钮颜色 */
    --inactive-button-color: rgba(0, 0, 0, 0.7);
    /* 非激活按钮颜色 */
    --general-color: rgba(76, 175, 80, 0);
    /* 备用颜色（绿色透明） */
    /* 控制台固定宽度（可修改为所需像素值） */
    --console-width: 400px;
}

/* =========================
   左上角标题面板
   ========================= */
.title-panel {
    position: absolute;
    /* 固定在页面中的某个位置 */
    top: 10px;
    /* 距离页面顶端 10px */
    left: 10px;
    /* 距离页面左侧 10px */
    background-color: var(--panel-bg-color);
    /* 使用统一定义的背景色 */
    color: white;
    padding: 10px;
    border-radius: 5px;
    /* 圆角边框 */
    font-family: Arial, sans-serif;
    z-index: 10;
    /* 层级高于画布 */
}

/* =========================
   右侧控制按钮容器
   ========================= */
.controls-toggle-container {
    position: fixed;
    /* 固定在窗口（滚动时也不会移动） */
    top: 20px;
    /* 距离顶端 20px */
    right: 0;
    /* 紧贴右边 */
    transition: right var(--animation-duration) ease;
    z-index: 25;
    /* 层级比标题还高 */
    display: flex;
    /* 使用 flex 布局 */
    flex-direction: column;
    /* 垂直排列 */
    align-items: flex-end;
    /* 对齐到右侧 */
}

/* 控制面板按钮样式（竖排文字） */
.controls-toggle {
    color: white;
    width: 40px;
    height: 120px;
    border-radius: 5px 0 0 5px;
    /* 只在左侧做圆角 */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* 鼠标悬停时显示手型 */
    transition: all var(--animation-duration) ease;
    writing-mode: vertical-rl;
    /* 竖排文字 */
    text-orientation: mixed;
    font-size: 16px;
    margin-bottom: 10px;
    position: relative;
    left: 0;
    transform-origin: right center;
}

.controls-toggle:hover {
    transform: scale(1.05);
    /* 悬停时放大 5% */
}

/* 说明面板按钮（和上面基本一样） */
.instructions-toggle {
    color: white;
    width: 40px;
    height: 120px;
    border-radius: 5px 0 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--animation-duration) ease;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 16px;
    position: relative;
    left: 0;
    transform-origin: right center;
}

.instructions-toggle:hover {
    transform: scale(1.05);
}

.qa-toggle {
    color: white;
    width: 40px;
    height: 120px;
    border-radius: 5px 0 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--animation-duration) ease;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 16px;
    position: relative;
    left: 0;
    transform-origin: right center;
}

.qa-toggle:hover {
    transform: scale(1.05);
}

.openmc-toggle {
    color: white;
    width: 40px;
    height: 120px;
    border-radius: 5px 0 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--animation-duration) ease;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 14px;
    position: relative;
    left: 0;
    transform-origin: right center;
    margin-top: 10px;
}

.openmc-toggle:hover {
    transform: scale(1.05);
}

.hes-toggle {
    color: white;
    width: 40px;
    height: 140px;
    border-radius: 5px 0 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--animation-duration) ease;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 14px;
    position: relative;
    left: 0;
    transform-origin: right center;
    margin-top: 10px;
}

.hes-toggle:hover {
    transform: scale(1.05);
}

/* =========================
   右侧滑出面板（控制面板 + 操作说明）
   ========================= */
.controls-wrapper,
.instructions-wrapper,
.qa-wrapper,
.openmc-wrapper,
.hes-wrapper {
    position: fixed;
    top: 0;
    right: -320px;
    /* 初始隐藏在屏幕外 */
    height: 90%;
    width: 300px;
    transition: right var(--animation-duration) ease;
}

.controls-wrapper {
    z-index: 20;
}

.instructions-wrapper {
    z-index: 19;
}

.qa-wrapper {
    z-index: 19;
}

.openmc-wrapper {
    z-index: 19;
}

.hes-wrapper {
    z-index: 19;
    right: -480px;
    width: min(460px, calc(100vw - 52px));
    height: 96%;
}

.hes-wrapper .hes-panel {
    width: 100%;
}

.hes-panel h5 {
    margin: 0;
    letter-spacing: 0;
}

.hes-tabs {
    position: sticky;
    top: 0;
    z-index: 3;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    margin-top: 14px;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: rgba(22, 24, 27, 0.96);
}

.hes-tab {
    min-height: 32px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: rgba(255, 255, 255, 0.68);
    font-size: 13px;
    cursor: pointer;
}

.hes-tab.active {
    background: rgba(25, 135, 84, 0.9);
    color: white;
}

.hes-tab-view[hidden] {
    display: none;
}

.hes-cycle-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.hes-section-title {
    margin-top: 2px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.92);
    font-size: 13px;
    font-weight: 600;
}

.hes-auto-flow {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.86);
    font-size: 12px;
    cursor: pointer;
}

.hes-auto-flow input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #198754;
}

.hes-form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 10px;
}

.hes-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 12px;
    line-height: 1.3;
}

.hes-field span {
    min-height: 16px;
    overflow-wrap: anywhere;
}

.hes-field .openmc-input[readonly] {
    border-color: rgba(25, 135, 84, 0.55);
    background-color: rgba(25, 135, 84, 0.12);
    color: rgba(255, 255, 255, 0.86);
}

.hes-advanced {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding: 8px 0;
}

.hes-advanced summary {
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    cursor: pointer;
}

.hes-advanced[open] summary {
    margin-bottom: 9px;
}

.hes-warning-list {
    display: grid;
    gap: 5px;
    margin-top: 8px;
}

.hes-warning {
    padding-left: 8px;
    border-left: 3px solid #ffc107;
    color: #ffe6a1;
    font-size: 12px;
    line-height: 1.4;
}

/* 面板内部样式 */
.controls,
.instructions,
.qa-panel,
.openmc-panel {
    color: white;
    padding: 20px;
    border-radius: 5px;
    height: 100%;
    width: 300px;
    box-sizing: border-box;
    background-color: var(--panel-bg-color);
    overflow-y: auto;
}

.qa-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.qa-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.qa-textarea {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.06);
    color: white;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
}

.qa-textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.qa-input {
    min-height: 110px;
}

.qa-output {
    min-height: 360px;
}

.qa-submit-button {
    width: 100%;
    margin-top: 4px;
}

.qa-submit-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    pointer-events: none;
}

.openmc-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.openmc-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

.openmc-input {
    width: 100%;
    min-height: 32px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.06);
    color: white;
    padding: 6px 8px;
    font-size: 13px;
    outline: none;
}

.openmc-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.openmc-action-button {
    width: 100%;
    margin-top: 4px;
}

.openmc-action-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    pointer-events: none;
}

.openmc-status {
    margin-top: 12px;
    padding: 8px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 13px;
    line-height: 1.35;
}

.openmc-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.openmc-metric {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.openmc-metric-label {
    color: rgba(255, 255, 255, 0.68);
    font-size: 12px;
}

.openmc-metric-value {
    color: white;
    font-size: 16px;
    margin-top: 4px;
    word-break: break-word;
}

.openmc-zone-list {
    margin-top: 10px;
}

.openmc-zone {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding: 8px 0;
    font-size: 13px;
}

.openmc-zone-name {
    color: white;
    font-weight: bold;
    margin-bottom: 4px;
}

.openmc-zone-values {
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.35;
}

.openmc-raw {
    max-height: 140px;
    margin-top: 10px;
    padding: 8px;
    overflow: auto;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
    color: rgba(255, 255, 255, 0.72);
    font-size: 11px;
    white-space: pre-wrap;
}

.openmc-image-section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.openmc-image-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.openmc-image-count {
    color: rgba(255, 255, 255, 0.58);
    font-size: 12px;
    font-weight: 400;
}

.openmc-image-empty {
    padding: 12px 8px;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    line-height: 1.45;
    text-align: center;
}

.openmc-image-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.openmc-image-card {
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}

.openmc-image-card:hover {
    border-color: rgba(25, 195, 125, 0.88);
    background: rgba(25, 195, 125, 0.1);
    transform: translateY(-1px);
}

.openmc-image-card img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    background: white;
}

.openmc-image-card-title {
    display: -webkit-box;
    min-height: 38px;
    padding: 6px 7px;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.88);
    font-size: 11px;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.openmc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 56px;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(7px);
}

.openmc-lightbox.active {
    display: flex;
}

.openmc-lightbox-content {
    display: flex;
    max-width: min(1180px, 94vw);
    max-height: 90vh;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.openmc-lightbox-content img {
    max-width: 100%;
    max-height: calc(90vh - 56px);
    object-fit: contain;
    border-radius: 8px;
    background: white;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}

.openmc-lightbox-title {
    color: white;
    font-size: 16px;
    text-align: center;
}

.openmc-lightbox-close {
    position: absolute;
    top: 18px;
    right: 24px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    color: white;
    font-size: 30px;
    line-height: 36px;
    cursor: pointer;
}

/* 隐藏滚动条但保留滚动功能 */
.instructions::-webkit-scrollbar {
    display: none;
}

.instructions {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* 添加 .active 类时滑出到屏幕内 */
.controls-wrapper.active,
.instructions-wrapper.active,
.qa-wrapper.active,
.openmc-wrapper.active,
.hes-wrapper.active {
    right: 0;
}

.hes-note {
    margin: 8px 0 0;
    color: #ffd166;
    font-size: 12px;
    line-height: 1.35;
}

.hes-source {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.56);
    font-size: 11px;
}

/* =========================
   小面板（诊断框、表格框）
   ========================= */
.diagbox {
    float: left;
    width: 260px;
    margin: 0 5px 5px 5px;
}

.tablebox {
    width: 600px;
    margin: 0 5px 5px 5px;
}

/* =========================
   左下角控制台（console）
   ========================= */
#console {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: var(--console-width);
    /* 固定宽度，可在 :root 中调整 --console-width */
    max-height: 200px;
    background-color: var(--panel-bg-color);
    color: white;
    padding: 10px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    font-size: 16px;
    overflow-y: auto;
    /* 内容过长时支持竖直滚动 */
    z-index: 9;
}

/* 隐藏滚动条但保留滚动功能 */
#console::-webkit-scrollbar {
    display: none;
}

#console {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* 控制台文字颜色区分 */
.error {
    color: red;
}

.info {
    color: white;
    font-family: Arial, sans-serif;
    font-size: 16px;
}

/* =========================
   操作说明内容
   ========================= */
.instructions-content {
    overflow-y: auto;
    display: flex;
}

.instructions-content::-webkit-scrollbar {
    display: none;
}

.instructions h3 {
    margin-top: 0;
}

/* =========================
   性能监控面板（左下角 FPS 图）
   ========================= */
#performance-panel {
    position: absolute;
    bottom: 160px;
    left: calc(2% + 120px);/*calc里面运算符号前后必须加空格*/
    width: 230px;
    height: 100px;
    background-color: transparent;
    color: white;
    padding: 10px;
    border-radius: 5px;
    z-index: 10;
    font-family: Arial, sans-serif;
    font-size: 12px;
}

#fps-chart {
    width: 100%;
    height: 100%;
}

/* =========================
   左下按钮面板
   ========================= */
#btn-panel {
    position: absolute;
    bottom: 150px;
    left: 10px;
    background-color: transparent;
    padding: 10px;
    width: 100px;
    flex-direction: column;
}

/* 横向排列左侧快捷按钮 */
#btn-panel.horizontal-btn-panel {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 8px;
    gap: 8px;
    /* 按钮间距，可调整 */
    position: fixed;
    /* 保持左侧固定（根据你以前定位策略调整） */
    left: 2%;
    bottom: 175px;
    /* 如果需要靠顶部 */
    z-index: 999;
    pointer-events: auto;
}

#btn-panel.horizontal-btn-panel .btn-group-inline {
    display: flex;
    align-items: center;
    gap: 6px;
}

#btn-panel.horizontal-btn-panel .btn,
#btn-panel.horizontal-btn-panel .btn-outline-success {
    margin: 0;
    padding-left: 10px;
    padding-right: 10px;
    height: auto;
}

/* 小屏幕适配：折行或改回竖排（可选） */
@media (max-width: 600px) {
    .hes-wrapper {
        width: calc(100vw - 44px);
    }

    .hes-panel {
        padding: 14px;
        background-color: rgb(20, 22, 25);
    }

    .hes-form-grid {
        grid-template-columns: 1fr;
    }

    #btn-panel.horizontal-btn-panel {
        flex-wrap: wrap;
        top: auto;
        bottom: 12px;
        /* 改为底部显示以免遮挡标题 */
        left: 12px;
    }
}

/* -------------------------
   版本与作者布局（meta-authors）
   目标：ver 与第一作者同一行，第二作者另起一行且与第一作者左对齐
   实现：使用 CSS Grid，两列两行布局，左列为版本/ by，右列为作者列表
   ------------------------- */
.meta-authors {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 8px;
    align-items: center;
    margin: 4px 0;
    color: #ffffff;
    font-size: 16px;
}

.meta-prefix {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    white-space: nowrap;
}

.meta-author-first {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

.meta-placeholder {
    /* 空单元格，保持第二行左列占位 */
    grid-column: 1 / 2;
    grid-row: 2 / 3;
}

.meta-author-second {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
}

.meta-author-first,
.meta-author-second {
    margin: 0;
    padding: 0;
    line-height: 1.1;
}
