/* =====================================================================
 * PhotoCraft 在线图像编辑器  /tools/photocraft
 * 布局目标：电脑端占满整个视口且保留左侧导航；平板 / 手机三端自适应。
 * 站点通用规则 body.tools-page 已解除 .app / .main-content 的 max-width，
 * 这里再把 .main-content 变成 flex 列容器，让 iframe 舞台吃掉全部剩余高度。
 * ===================================================================== */

.pc {
    --pc-bar-bg: var(--bg-elevated, #15202b);
    --pc-panel: var(--bg-secondary, #f7f9f9);
    --pc-border: var(--border-color, #2f3336);
    --pc-text: var(--text-primary, #e7e9ea);
    --pc-muted: var(--text-secondary, #8b98a5);
    --pc-accent: var(--accent, #1d9bf0);
    --pc-stage-bg: #262626;          /* 与官方 index.html 的加载底色一致，避免闪白 */
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

/* ---------- 满屏骨架 ---------- */
/* .app 固定为视口高度：桌面是横向 flex（左侧 sidebar 保留），
   手机端 style.css 已把它改成纵向 flex，mobile-header 约占 53px。 */
body.page-photocraft-full .app {
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
}
body.page-photocraft-full .main-content {
    flex: 1 1 auto;
    min-height: 0;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    border-right: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.page-photocraft-full .mobile-header { flex: 0 0 auto; }
/* 工具详情页统一的收藏按钮保留，但压缩高度，把空间让给画布 */
body.page-photocraft-full .tool-favbar { flex: 0 0 auto; padding: 4px 10px 0; }

/* ---------- 顶部工具条 ---------- */
.pc-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 9px 14px;
    background: var(--pc-bar-bg);
    border-bottom: 1px solid var(--pc-border);
    box-sizing: border-box;
}
.pc-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.pc-brand-ico {
    flex: 0 0 auto;
    width: 36px; height: 36px;
    display: grid; place-items: center;
    font-size: 21px; line-height: 1;
    border-radius: 10px;
    background: linear-gradient(145deg, #2c5f8a, #1b3b5c);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}
.pc-brand-txt { min-width: 0; }
.pc-title {
    margin: 0;
    font-size: 16px; font-weight: 700; line-height: 1.25;
    color: var(--pc-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-sub {
    margin: 2px 0 0;
    font-size: 12px; line-height: 1.35;
    color: var(--pc-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-chips { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.pc-chip {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px; line-height: 1.2;
    white-space: nowrap;
    border: 1px solid var(--pc-border);
    border-radius: 999px;
    color: var(--pc-muted);
    background: var(--pc-panel);
}
.pc-chip-engine { color: var(--pc-accent); border-color: var(--pc-accent); }
.pc-chip-safe { color: #2e9e6b; border-color: rgba(46, 158, 107, .45); }

.pc-ops { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.pc-render { display: inline-flex; align-items: center; gap: 6px; }
.pc-render-lb { font-size: 12px; color: var(--pc-muted); white-space: nowrap; }
.pc-sel {
    font-size: 12px;
    padding: 7px 8px;
    border: 1px solid var(--pc-border);
    border-radius: 8px;
    background: var(--pc-panel);
    color: var(--pc-text);
    max-width: 190px;
    cursor: pointer;
}
.pc-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 7px 11px;
    font-size: 12px; line-height: 1.2;
    white-space: nowrap;
    border: 1px solid var(--pc-border);
    border-radius: 8px;
    background: var(--pc-panel);
    color: var(--pc-text);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s, transform .15s;
    -webkit-tap-highlight-color: transparent;
}
.pc-btn:hover { border-color: var(--pc-accent); color: var(--pc-accent); }
.pc-btn:active { transform: translateY(1px); }
.pc-btn:focus-visible { outline: 2px solid var(--pc-accent); outline-offset: 2px; }
.pc-btn:disabled { opacity: .5; cursor: not-allowed; }
.pc-btn-main { background: var(--pc-accent); border-color: var(--pc-accent); color: #fff; }
.pc-btn-main:hover { color: #fff; filter: brightness(1.1); }

/* ---------- 使用说明 ---------- */
.pc-help {
    flex: 0 0 auto;
    padding: 14px 16px;
    background: var(--pc-panel);
    border-bottom: 1px solid var(--pc-border);
    max-height: 42vh;
    overflow: auto;
}
.pc-help[hidden] { display: none; }
.pc-help-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.pc-help-col { min-width: 0; }
.pc-help h2 { margin: 0 0 8px; font-size: 13px; color: var(--pc-text); }
.pc-help p, .pc-help li { margin: 0 0 6px; font-size: 12px; line-height: 1.6; color: var(--pc-muted); }
.pc-help ul { margin: 0; padding-left: 18px; }
.pc-help-lic { margin-top: 10px !important; font-size: 11px !important; opacity: .8; }

/* ---------- 轻提示 ---------- */
.pc-notice {
    flex: 0 0 auto;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 7px 14px;
    font-size: 12px;
    color: var(--pc-text);
    background: rgba(29, 155, 240, .1);
    border-bottom: 1px solid rgba(29, 155, 240, .28);
}
.pc-notice[hidden] { display: none; }
.pc-notice-x {
    border: 0; background: none; color: inherit;
    font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px;
}

/* ---------- 编辑器舞台 ---------- */
.pc-stage {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    background: var(--pc-stage-bg);
    overflow: hidden;
}
.pc-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: var(--pc-stage-bg);
}
/* 全屏：只把舞台放大到整个屏幕，工具条留在全屏元素之外 */
.pc-stage:fullscreen { width: 100vw; height: 100vh; background: var(--pc-stage-bg); }
.pc-stage:-webkit-full-screen { width: 100vw; height: 100vh; background: var(--pc-stage-bg); }
.pc-fs-exit {
    display: none;
    position: absolute;
    top: 10px; right: 10px;
    z-index: 5;
    padding: 7px 12px;
    font-size: 12px;
    color: #e7e9ea;
    background: rgba(20, 20, 20, .82);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 8px;
    cursor: pointer;
}
.pc-stage:fullscreen .pc-fs-exit { display: block; }
.pc-stage:-webkit-full-screen .pc-fs-exit { display: block; }
/* iOS Safari 等不支持元素全屏时的页面内降级：固定铺满视口 */
.pc-stage.is-pseudo-full {
    position: fixed;
    inset: 0;
    z-index: 9999;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
}
body.pc-pseudo-full { overflow: hidden; }
.pc-stage.is-pseudo-full .pc-fs-exit { display: block; }

/* ---------- 启动遮罩 / 错误面板 ---------- */
.pc-veil {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    padding: 20px;
    box-sizing: border-box;
    background: #262626;
    color: #d8d8d8;
    transition: opacity .35s ease, visibility .35s ease;
}
.pc-veil.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.pc-veil-box { width: min(520px, 100%); text-align: center; }
.pc-spinner {
    width: 38px; height: 38px;
    margin: 0 auto 18px;
    border: 3px solid rgba(255, 255, 255, .13);
    border-top-color: #4aa8ff;
    border-radius: 50%;
    animation: pc-spin .9s linear infinite;
}
@keyframes pc-spin { to { transform: rotate(360deg); } }
.pc-veil-t { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: #ececec; }
.pc-veil-s { margin: 0 0 18px; font-size: 12px; line-height: 1.65; color: #9c9c9c; }
.pc-track {
    width: min(320px, 100%);
    height: 4px;
    margin: 0 auto;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, .1);
}
.pc-track i {
    display: block;
    width: 38%; height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #2c79d3, #4aa8ff);
    animation: pc-slide 1.5s ease-in-out infinite;
}
@keyframes pc-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(263%); } }
.pc-veil.is-error .pc-spinner { display: none; }
.pc-veil.is-error .pc-track { display: none; }
.pc-veil.is-error::before {
    content: '!';
    display: grid; place-items: center;
    width: 40px; height: 40px;
    margin: 0 auto 16px;
    font-size: 22px; font-weight: 700;
    color: #fff;
    background: #c9514c;
    border-radius: 50%;
}
.pc-veil.is-error .pc-veil-t { color: #ffb4ae; }
.pc-veil-acts {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
    margin-top: 20px;
}
.pc-veil-acts[hidden] { display: none; }
.pc-veil .pc-btn { background: #333; border-color: #4a4a4a; color: #e7e9ea; }
.pc-veil .pc-btn:hover { border-color: #6fb6ff; color: #9fd0ff; }
.pc-veil .pc-btn-main { background: #2c79d3; border-color: #2c79d3; color: #fff; }
.pc-veil .pc-btn-main:hover { color: #fff; }
.pc-diag {
    margin: 16px 0 0;
    padding: 12px;
    max-height: 190px;
    overflow: auto;
    text-align: left;
    font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: #b9c6d3;
    background: #1b1b1b;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    white-space: pre-wrap;
    word-break: break-all;
}
.pc-diag[hidden] { display: none; }

/* ---------- 底部状态条 ---------- */
.pc-foot {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 14px;
    padding: 6px 14px;
    font-size: 11px;
    color: var(--pc-muted);
    background: var(--pc-bar-bg);
    border-top: 1px solid var(--pc-border);
}
.pc-status { flex: 0 0 auto; color: var(--pc-text); }
.pc-status.is-ok::before { content: '● '; color: #2e9e6b; }
.pc-status.is-bad::before { content: '● '; color: #c9514c; }
.pc-tips { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-foot-link { flex: 0 0 auto; color: var(--pc-accent); text-decoration: none; }
.pc-foot-link:hover { text-decoration: underline; }
.pc-noscript { padding: 12px 16px; font-size: 13px; color: #ffb4ae; }

/* =====================================================================
 * 三端适配
 * ===================================================================== */

/* 平板 / 小桌面：隐藏次要徽标与副标题，保证工具条不换行挤压画布 */
@media (max-width: 1100px) {
    .pc-bar { gap: 9px; padding: 8px 11px; }
    .pc-sub { display: none; }
    .pc-chip-safe { display: none; }
    .pc-render-lb { display: none; }
    .pc-help-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 手机：工具条折成两行，操作区可横向滚动；底部只留状态与来源链接 */
@media (max-width: 700px) {
    .pc-bar { flex-wrap: wrap; gap: 7px; padding: 8px 10px; }
    .pc-brand { flex: 1 1 100%; gap: 8px; }
    .pc-brand-ico { width: 30px; height: 30px; font-size: 18px; border-radius: 8px; }
    .pc-title { font-size: 14px; }
    .pc-chips { display: none; }
    .pc-ops {
        flex: 1 1 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 2px;
    }
    .pc-ops::-webkit-scrollbar { display: none; }
    .pc-btn { flex: 0 0 auto; padding: 6px 9px; font-size: 12px; }
    .pc-sel { font-size: 12px; padding: 6px 7px; max-width: 150px; }
    .pc-render { flex: 0 0 auto; }
    .pc-help { max-height: 55vh; padding: 12px; }
    .pc-help-grid { grid-template-columns: 1fr; gap: 12px; }
    .pc-help p, .pc-help li { font-size: 12px; }
    .pc-foot { gap: 8px; padding: 5px 10px; }
    .pc-tips { display: none; }
    .pc-foot .pc-status { flex: 1 1 auto; }
    .pc-veil { padding: 16px; }
    .pc-veil-box { width: 100%; }
    .pc-veil-acts { gap: 6px; }
    .pc-veil .pc-btn { font-size: 11px; padding: 6px 9px; }
}

/* 矮屏 / 手机横屏：进一步压缩，尽力给画布留高度 */
@media (max-height: 480px) {
    .pc-bar { padding: 5px 10px; }
    .pc-brand-ico { width: 26px; height: 26px; font-size: 16px; }
    .pc-title { font-size: 13px; }
    .pc-foot { padding: 4px 10px; }
    .pc-help { max-height: 70vh; }
}

@media (prefers-reduced-motion: reduce) {
    .pc-spinner { animation-duration: 2.4s; }
    .pc-track i { animation: none; width: 100%; opacity: .5; }
    .pc-veil { transition: none; }
    .pc-btn { transition: none; }
}
