/* ==========================================================================
   layout.css — 照片排版页
   逻辑画布 920 × 1420（9.2cm × 14.2cm @ 100px/cm）
   ========================================================================== */

:root {
    --bg: #0d0d0d;
    --stripe: #161616;
    --panel: #1e1e1e;
    --line: #333;
    --brand: #0052FF;
    --brand-active: #0040CC;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background-color: var(--bg);
    background-image: repeating-linear-gradient(
        45deg,
        var(--bg) 0, var(--bg) 12px,
        var(--stripe) 12px, var(--stripe) 24px
    );
    color: #fff;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

/* ---------- 页面标题（字号与「上传」按钮一致：15px / 700） ---------- */
.page-title .star {
    color: #FFD54F;
    margin: 0 6px;
    font-size: 14px;
    letter-spacing: 0;
}

.page-title {
    flex: 0 0 auto;
    text-align: center;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 6px;

    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    text-indent: 2px;
    color: #fff;
}

/* ---------- 画布区 ---------- */
.stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.board {
    position: relative;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .45);

    /* JS 量好尺寸前先藏起来，避免画布以原始尺寸闪一下 */
    visibility: hidden;
}

.board.is-ready { visibility: visible; }

.board canvas { display: block; }

/* ---------- 底部按钮 ---------- */
.bottom-bar {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
    padding: 8px 20px calc(14px + var(--safe-bottom));
}

.btn {
    flex: 1 1 0;
    padding: 14px 10px;
    border: none;
    border-radius: 13px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 2px;
    text-indent: 2px;
    transition: background .15s, transform .12s;
}

.btn:active { transform: scale(.98); }

.btn--ghost {
    background: rgba(255, 255, 255, .07);
    color: #d8d8d8;
    border: 1px solid #3a3a3a;
}

.btn--ghost:active { background: rgba(255, 255, 255, .12); }

.btn--primary {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 8px 22px rgba(0, 82, 255, .35);
}

.btn--primary:active { background: var(--brand-active); }

/* ---------- 上传弹窗 ---------- */
.modal-mask {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    padding: 24px;
    background: rgba(0, 0, 0, .72);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-mask.show { display: flex; }

.modal-box {
    width: 100%;
    max-width: 320px;
    padding: 20px;
    background: #1a1a1a;
    border: 1px solid var(--line);
    border-radius: 16px;
    text-align: center;
}

.modal-box h3 {
    font-size: 17px;
    margin-bottom: 6px;
}

.modal-tip {
    font-size: 12px;
    color: #888;
    margin-bottom: 16px;
}

.modal-btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin-bottom: 10px;
    border: none;
    border-radius: 12px;
    background: #2a2a2a;
    color: #fff;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
}

.modal-btn:active { background: #343434; }

/* 提示弹窗：字体加大，画布中央 */
.alert-text {
    font-size: 19px;
    line-height: 1.65;
    padding: 12px 4px 24px;
    color: #f0f0f0;
}

.modal-btn--primary {
    background: var(--brand);
    color: #fff;
}

.modal-btn--primary:active { background: var(--brand-active); }

/* 确认弹窗：两张缩略图并排 */
.modal-box--wide { max-width: 400px; padding: 20px 18px 16px; }

.preview-row {
    display: flex;
    align-items: flex-start;   /* 各按自身高度，右边自然向下延伸 */
    gap: 14px;
    margin-bottom: 16px;
}

.preview-item { flex: 1 1 0; min-width: 0; }

/* 缩略图：不加任何框，两张严格同尺寸 */
.preview-item img {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: #111;
    border-radius: 0;
}

/* 图片下方只有文字有白底，高度固定，左右对齐 */
.preview-item .cap {
    display: block;
    box-sizing: border-box;
    height: 52px;
    margin-top: 6px;
    padding: 9px 8px 0;
    background: #fbfaf6;
    overflow: hidden;

    font-size: 12px;
    line-height: 1.25;
    text-align: left;
    letter-spacing: .3px;
    color: #3a3a3a;
}

.preview-item .cap b,
.preview-item .cap b.cap-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    color: #2f2f2f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-item .cap em {
    display: block;
    margin-top: 1px;
    font-style: normal;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.25;
    color: #6a6a6a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-tip {
    margin: -10px 0 16px;
    font-size: 12px;
    line-height: 1.5;
    color: #FFD54F;           /* 黄色提示 */
    letter-spacing: .3px;
}

.preview-meta {
    min-height: 20px;
    margin: 2px 0 16px;
    font-size: 15px;          /* 加大 */
    font-weight: 700;
    line-height: 1.5;
    color: #FF2D2D;           /* 亮红色 */
    letter-spacing: .5px;
}

.modal-cancel {
    width: 100%;
    padding: 12px;
    border: none;
    background: transparent;
    color: #888;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
}

/* ---------- 编辑工具栏 ---------- */
.edit-toolbar {
    display: none;
    position: fixed;
    left: 50%;
    bottom: calc(72px + var(--safe-bottom));
    transform: translateX(-50%);
    z-index: 60;
    align-items: center;
    gap: 3px;
    padding: 5px;
    max-width: calc(100vw - 10px);
    overflow-x: auto;                  /* 极窄屏兜底，可横向滑动 */
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    background: rgba(26, 26, 26, .96);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .55);
}

.edit-toolbar.show { display: flex; }

.tool-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #e8e8e8;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
}

.tool-btn svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tool-btn:active { background: rgba(255, 255, 255, .14); }

.edit-toolbar::-webkit-scrollbar { display: none; }

.tool-sep {
    width: 1px;
    height: 16px;
    background: #3a3a3a;
    margin: 0 3px;
}

.tool-btn--done {
    width: auto;
    padding: 0 12px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    white-space: nowrap;
}

.tool-btn--done:active { background: var(--brand-active); }

/* ---------- 轻提示 ---------- */
.toast {
    position: fixed;
    left: 50%;
    top: 12%;
    transform: translateX(-50%);
    z-index: 200;

    display: none;
    max-width: 80vw;
    padding: 10px 20px;

    background: rgba(0, 0, 0, .9);
    border: 1px solid var(--line);
    border-radius: 8px;

    color: #fff;
    font-size: 13px;
    text-align: center;
}

.toast.show { display: block; }

/* 屏幕中央的大提示（照片入袋等） */
.toast--center {
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 18px 26px;
    border-radius: 14px;
    font-size: 15.5px;
    font-weight: 600;
    line-height: 1.7;
    background: rgba(0, 0, 0, .88);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
    animation: toastPop .22s ease-out;
}
.toast--center .sub {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 400;
    opacity: .72;
}
@keyframes toastPop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(.92); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ---------- 调试面板（?debug=1） ---------- */
.debug {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    padding: 6px 8px;
    background: rgba(0, 0, 0, .88);
    color: #3f6;
    font-size: 10px;
    line-height: 1.5;
    font-family: Menlo, Consolas, monospace;
    white-space: pre-wrap;
    pointer-events: none;
}

.debug.show { display: block; }

/* ---------- 全屏查看器 ---------- */
.viewer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: #000;
    flex-direction: column;
}

.viewer.show { display: flex; }

.viewer-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
    background: #111;
    border-bottom: 1px solid #2a2a2a;
}

.viewer-info {
    flex: 1 1 auto;
    font-size: 12px;
    line-height: 1.45;
    color: #d0d0d0;
    font-family: Menlo, Consolas, monospace;
    letter-spacing: .2px;
}

.viewer-btn {
    flex: 0 0 auto;
    min-width: 38px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid #333;
    border-radius: 8px;
    background: #222;
    color: #eee;
    font-size: 16px;
    line-height: 1;
    font-family: inherit;
}

.viewer-btn:active { background: #333; }

.viewer-btn--close {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.viewer-stage {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    text-align: center;
    padding: 8px;
}

.viewer-stage img {
    display: block;
    margin: 0 auto;
    max-width: none;
    background: #fff;
}

.viewer-hint {
    flex: 0 0 auto;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    font-size: 11px;
    color: #777;
    text-align: center;
    background: #111;
}

/* 支付按钮里的价格 */
.btn-price {
    margin-left: 8px;
    font-size: 15px;
    font-weight: 800;
    color: #FFE082;
}

/* ---------- AI 生成中的遮罩 ---------- */
.loading-mask {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(0, 0, 0, .78);
    align-items: center;
    justify-content: center;
}

.loading-mask.show { display: flex; }

.loading-box {
    text-align: center;
    padding: 28px 32px;
    border-radius: 16px;
    background: #1a1a1a;
    border: 1px solid #333;
}

.loading-spinner {
    width: 38px;
    height: 38px;
    margin: 0 auto 16px;
    border: 3px solid rgba(255, 255, 255, .15);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 6px;
}

.loading-sub {
    font-size: 12px;
    color: #8a8a8a;
}
