:root {
    --bg-color: #050507;
    --panel-bg: #0e0e10;
    --accent: #e6cba4;
    --accent-dim: rgba(230, 203, 164, 0.1);
    --cyber-green: #00ff9d;
    --cyber-green-glow: rgba(0, 255, 157, 0.2);
    --text-main: #e0e0e0;
    --receipt-paper: #f4f1ea;
    --receipt-ink: #2b2a29;
    --font-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    --font-receipt: "Courier New", "Courier", "PingFang SC", "Microsoft YaHei", monospace;
    --border: 1px solid #2a2a2c;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* 氛围层：CRT 扫描线与微弱闪烁 */
.screen-fx {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    /* 更加明显的扫描线 */
    background: linear-gradient(rgba(18, 16, 16, 0) 50%,
            rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg,
            rgba(255, 0, 0, 0.03),
            rgba(0, 255, 0, 0.01),
            rgba(0, 0, 255, 0.03));
    background-size: 100% 4px, 6px 100%;
    animation: flicker 0.15s infinite;
    opacity: 0.6;
}

/* 屏幕微弱闪烁动画 */
@keyframes flicker {
    0% {
        opacity: 0.55;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 0.55;
    }
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* --- 核心修复：截图模式强制样式 --- */
/* 当克隆体带有此 Class 时，强制移除所有动画并展开 */
.snapshot-mode {
    position: fixed !important;
    top: -9999px !important;
    left: 0 !important;
    width: 340px !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    transform: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    background: var(--receipt-paper) !important;
    border-radius: 0 !important;
}

.snapshot-mode * {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
}

/* 截图时移除锯齿边缘的阴影，避免渲染黑边 */
.snapshot-mode::after {
    box-shadow: none !important;
    z-index: 0 !important;
}

/* --- Modal 悬浮窗 --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 20px;
    max-width: 90%;
    /* 移除 max-height: 90vh; */
    height: auto;
    /* 确保高度自适应内容 */
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    color: var(--accent);
    font-weight: bold;
    letter-spacing: 1px;
    font-size: 1rem;
}

.modal-close {
    background: none;
    border: none;
    color: #666;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.img-container {
    /* 增加一个最大高度，让长图可以滚动 */
    max-height: 70vh;
    /* 限制图片容器高度，可根据需求调整 */
    overflow-y: auto;
    background: #050505;
    padding: 20px;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    /* 修复长图顶部被压缩的问题 */
    align-items: flex-start;
}

.img-container img {
    max-width: 100%;
    height: auto;
    /* 确保图片高度自适应 */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.modal-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #222;
    padding-top: 15px;
}

.modal-tip {
    color: #555;
    font-size: 0.7rem;
}

.cyber-btn.small {
    padding: 10px 20px;
    font-size: 0.8rem;
    width: 100%;
}

/* 左侧控制台 */
.control-panel {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    border-right: var(--border);
    max-width: 550px;
    min-width: 380px;
    background: var(--panel-bg);
    position: relative;
    z-index: 10;
    box-shadow: 10px 0 60px rgba(0, 0, 0, 0.4);
}

.cp-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

.brand-block h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #fff;
    margin-top: 5px;
    font-family: var(--font-ui);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--accent);
    letter-spacing: 1px;
    font-weight: bold;
}

.led {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
}

.lang-switch {
    display: flex;
    align-items: center;
    font-size: 0.8rem;
    color: #555;
    gap: 8px;
}

.lang-btn {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    font-weight: bold;
    padding: 4px;
    transition: color 0.2s;
}

.lang-btn.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.lang-btn:hover {
    color: #fff;
}

.main-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mode-tabs {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    border-bottom: 1px solid #333;
    padding-bottom: 0;
}

.tab-btn {
    background: transparent;
    border: none;
    color: #666;
    padding: 12px 0;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    position: relative;
    opacity: 0.7;
}

.tab-btn:hover {
    opacity: 1;
    color: #aaa;
}

.tab-btn.active {
    color: var(--accent);
    opacity: 1;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent-dim);
}

/* 面板切换动画：CRT 开启效果 */
.panel-section {
    display: none;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    height: 100%;
    opacity: 0;
    transform-origin: center top;
}

.panel-section.active {
    display: flex;
    animation: turnOn 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes turnOn {
    0% {
        opacity: 0;
        transform: scaleY(0) scaleX(0.8);
        filter: blur(10px);
    }

    60% {
        transform: scaleY(1.1) scaleX(1);
        /* 稍微拉伸一下 */
    }

    100% {
        opacity: 1;
        transform: scaleY(1) scaleX(1);
        filter: blur(0);
    }
}

.terminal-window {
    display: flex;
    flex-direction: column;
    background: #000;
    border: 1px solid #333;
    border-radius: 4px;
    overflow: hidden;
    flex: 1;
    min-height: 200px;
    transition: border-color 0.3s;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.terminal-window:focus-within {
    border-color: var(--cyber-green);
    box-shadow: 0 0 25px var(--cyber-green-glow), inset 0 0 10px rgba(0, 255, 157, 0.1);
}

.scan-mode {
    flex: 0;
    min-height: 140px;
    border-style: dashed;
}

.terminal-body {
    flex: 1;
    position: relative;
    padding: 0;
    display: flex;
}

textarea {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-receipt);
    padding: 20px;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    scrollbar-width: thin;
    scrollbar-color: #333 #000;
}

textarea::placeholder {
    color: #444;
    font-family: var(--font-ui);
    font-style: normal;
}

.terminal-footer {
    background: #080808;
    padding: 6px 15px;
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #444;
    font-family: var(--font-receipt);
    border-top: 1px solid #222;
}

.cyber-btn {
    position: relative;
    padding: 18px;
    background: var(--accent);
    border: none;
    color: #000;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 2px;
    letter-spacing: 1px;
    overflow: hidden;
    /* 必须加这个 */
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

/* 鼠标悬停时的强烈光晕 */
.cyber-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px var(--accent);
    text-shadow: 2px 0 var(--cyber-green), -2px 0 #ff00de;
}

/* 按钮文字的故障动画 */
.cyber-btn:hover .btn-text {
    animation: glitch-text 0.3s cubic-bezier(.25, .46, .45, .94) both infinite;
    display: inline-block;
}

@keyframes glitch-text {
    0% {
        transform: translate(0);
    }

    20% {
        transform: translate(-2px, 2px);
    }

    40% {
        transform: translate(-2px, -2px);
    }

    60% {
        transform: translate(2px, 2px);
    }

    80% {
        transform: translate(2px, -2px);
    }

    100% {
        transform: translate(0);
    }
}

.cyber-btn:active {
    transform: scale(0.99);
}

.cyber-btn.secondary {
    background: transparent;
    border: 1px solid #444;
    color: #888;
}

.cyber-btn.secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: none;
}

.output-console {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-top: 1px solid #222;
    padding-top: 20px;
    margin-top: 10px;
    overflow: hidden;
}

.console-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.75rem;
    color: #666;
    font-weight: bold;
}

.status-tag {
    background: #1a1a1a;
    padding: 2px 8px;
    border-radius: 2px;
    font-size: 0.6rem;
    color: #888;
}

/* --- 解密终端文字特效优化 --- */
.output-display {
    /* 增加内阴影，让屏幕看起来有深度 */
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
    background: #050505;
}

.cyber-text {
    font-family: 'Consolas', 'Monaco', monospace;
    /* 确保是终端字体 */
    font-size: 1.1rem;
    /* 增大字号 */
    line-height: 1.5;
    color: var(--cyber-green);
    word-break: break-all;
    white-space: pre-wrap;
    /* 增强辉光效果，制造过曝感 */
    text-shadow: 0 0 2px rgba(0, 255, 157, 0.8), 0 0 10px rgba(0, 255, 157, 0.4);
    font-weight: bold;
    min-height: 1.5em;
    /* 确保有内容前不塌陷 */
}

/* 模拟终端的光标块 */
.cursor-blink {
    display: inline-block;
    width: 10px;
    height: 1.2em;
    background-color: var(--cyber-green);
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: blink-animation 1s step-end infinite;
    box-shadow: 0 0 10px var(--cyber-green);
}

@keyframes blink-animation {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.footer-info {
    margin-top: auto;
    font-size: 0.65rem;
    color: #333;
    text-align: center;
    letter-spacing: 1px;
    padding-top: 20px;
}

.receipt-stage {
    flex: 1;
    background: #050505;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    perspective: 1500px;
}

.receipt-wrapper {
    transform: rotateX(5deg) rotateZ(-1deg);
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.7));
}

.receipt-stage:hover .receipt-wrapper {
    transform: rotateX(0deg) rotateZ(0deg) scale(1.02);
}

/* 优化小票主体样式 */
.receipt {
    background: var(--receipt-paper);
    color: var(--receipt-ink);
    width: 320px;
    padding: 50px 25px 25px 25px;
    /* 更改：更偏向老式点阵打印机的字体，提高行高 */
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Courier', monospace;
    font-size: 13px;
    /* 增加行高，模拟打印机间隔 */
    line-height: 1.4;
    font-weight: 600;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
    background-image: url("data:image/svg+xml,%3Csvg width='4' height='4' viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 3h1v1H1V3zm2-2h1v1H3V1z' fill='%23000000' fill-opacity='0.03' fill-rule='evenodd'/%3E%3C/svg%3E");
    /* 新增：轻微色差和柔化效果 */
    filter: brightness(0.98) contrast(1.05) blur(0.1px);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
    /* 增加内部阴影，模拟纸张厚度 */
    /* 新增：模拟打印不均的微弱纹理 (使用 ::before 或 ::after) */
    position: relative;
}

/* 新增：模拟噪点/打印颗粒感 */
.receipt::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* 使用纹理叠加 */
    background: repeating-linear-gradient(0deg,
            rgba(0, 0, 0, 0.01) 0px,
            rgba(0, 0, 0, 0.03) 1px,
            transparent 2px,
            transparent 4px);
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: multiply;
    /* 混合模式让噪点看起来更自然 */
}

.receipt::-webkit-scrollbar {
    width: 4px;
}

.receipt::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.receipt::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(45deg, transparent 33.3%, var(--receipt-paper) 33.3%, var(--receipt-paper) 66.6%, transparent 66.6%), linear-gradient(-45deg, transparent 33.3%, var(--receipt-paper) 33.3%, var(--receipt-paper) 66.6%, transparent 66.6%);
    background-size: 12px 24px;
    background-position: 0 -16px;
    z-index: 10;
}

.r-header {
    text-align: center;
    margin-bottom: 25px;
}

/* 修改 .r-logo 样式，实现视觉上的分散对齐 */
.r-logo {
    font-size: 1.8rem;
    font-weight: 900;
    /* 调整 letter-spacing 为正值，拉开文字间距 */
    letter-spacing: 12px;
    margin-bottom: 8px;
    color: #000;
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Courier', monospace;
    text-shadow: 0.5px 0.5px 0 rgba(0, 0, 0, 0.1);
    /* 新增：强制居中显示，但配合大的 letter-spacing 产生分散感 */
    text-align: center;
}

/* 修改 .r-sub 样式，进一步分散 */
.r-sub {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #555;
    margin-bottom: 20px;
    /* 将字母间距进一步拉大，达到分散对齐效果 */
    letter-spacing: 6px;
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Courier', monospace;
    font-weight: bold;
    /* 强制居中 */
    text-align: center;
}

.r-meta-grid {
    font-size: 0.75rem;
    font-weight: bold;
    color: #333;
    line-height: 1.6;
    border-bottom: 2px dashed #bbb;
    padding-bottom: 15px;
}

.meta-row {
    display: flex;
    justify-content: space-between;
}

.r-body {
    margin: 20px 0;
    min-height: 100px;
    padding-bottom: 10px;
}

@keyframes paperFeed {
    from {
        transform: scaleY(0);
        opacity: 0;
    }

    to {
        transform: scaleY(1);
        opacity: 1;
    }
}

.empty-state {
    text-align: center;
    color: #999;
    font-style: italic;
    padding-top: 40px;
    font-size: 0.8rem;
}

.r-item {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;

    /* 初始状态：不可见且略微向上 */
    opacity: 0;
    transform: translateY(-10px);

    /* 缩短动画时间，增加顿挫感 */
    animation: printLine 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes printLine {
    0% {
        opacity: 0;
        transform: translateY(-10px);
        filter: blur(2px);
        /* 加一点动态模糊 */
    }

    100% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

/* 新增：确保商品名称/价格的对齐 */
.r-main {
    display: flex;
    justify-content: space-between;
    font-weight: 800;
    font-size: 0.95rem;
    color: #000;
    /* 确保其也使用等宽字体 */
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Courier', monospace;
}

/* 优化商品描述行 */
.r-desc {
    /* 恢复到默认字体大小，避免过小 */
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
    font-weight: 500;
    /* 移除 scale 转换，避免影响对齐 */
    transform: none;
    /* 强制使用等宽字体，与主行保持一致 */
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Courier', monospace;
}

.receipt-fold {
    margin: 20px 0;
    text-align: center;
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.receipt-fold::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background-image: linear-gradient(to right, #bbb 50%, transparent 50%);
    background-size: 8px 1px;
}

.fold-icon {
    background: var(--receipt-paper);
    padding: 0 10px;
    color: #888;
    font-size: 14px;
    position: relative;
    z-index: 1;
}

.r-footer {
    margin-top: 10px;
    padding-top: 20px;
    text-align: center;
    border-top: 2px dashed #bbb;
}

.r-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.6rem;
    font-weight: 900;
    margin-bottom: 25px;
    color: #000;
    align-items: flex-end;
}

/* 确保底部校验信息使用等宽字体 */
.r-hash-block {
    text-align: left;
    font-size: 0.65rem;
    color: #555;
    margin-bottom: 25px;
    line-height: 1.5;
    /* 新增：强制使用等宽字体 */
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Courier', monospace;
}

.barcode-container {
    height: 55px;
    width: 95%;
    margin: 0 auto;
    opacity: 0.9;
    mix-blend-mode: multiply;
}

/* 修改 .thank-you 样式 */
.thank-you {
    font-size: 0.65rem;
    color: #999;
    margin-top: 15px;
    /* 增加字母间距 */
    letter-spacing: 3px;
    /* 调整 transform 为更小的缩放，或者移除 */
    transform: scale(0.95);
    /* 强制使用等宽字体 */
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Courier', monospace;
}

/* 悬浮按钮组 - 双按钮布局 */
.fab-copy {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-110%) translateY(80px);
    background: #111;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 0.85rem;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    display: flex;
    gap: 8px;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.fab-save {
    transform: translateX(10%) translateY(80px);
}

/* 激活态 */
.receipt-stage:hover .fab-copy {
    opacity: 1;
}

.receipt-stage:hover .fab-copy#btn-copy {
    transform: translateX(-110%) translateY(0);
}

.receipt-stage:hover .fab-copy#btn-save-img {
    transform: translateX(10%) translateY(0);
}

.fab-copy:hover {
    background: var(--accent);
    color: #000;
    box-shadow: 0 0 20px var(--accent-dim);
}

.toast {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: #000;
    padding: 12px 24px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
    z-index: 2000;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    top: 30px;
}

@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        overflow-y: auto;
        height: auto;
    }

    .control-panel {
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid #333;
        padding: 30px 20px;
        box-shadow: none;
    }

    .receipt-stage {
        padding: 50px 10px;
        min-height: 600px;
        overflow: visible;
    }

    .fab-copy#btn-copy {
        transform: translateX(-110%) translateY(0);
        opacity: 1;
        bottom: 20px;
    }

    .fab-copy#btn-save-img {
        transform: translateX(10%) translateY(0);
        opacity: 1;
        bottom: 20px;
    }
}

/* 新增：底部网址样式 */
.r-website {
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Courier', monospace;
    font-size: 0.75rem;
    color: #333;
    margin-top: 10px;
    margin-bottom: 10px;
    /* 增加与条形码的距离 */
    letter-spacing: 1px;
    text-align: center;
    font-weight: 800;
}