/* 熊猫影像手机 / iPad 版：深色修图界面；窄屏上下排（预览在上、工具在下），宽屏 / 横屏左右排（左预览、右工具） */
:root {
  --bg: #0f1216; --panel: #171b21; --panel2: #1f242c; --line: #2c333d; --text: #e9edf2; --dim: #9aa5b1;
  --accent: #2fb36f; --accent2: #23905a; --danger: #e5534b; --warn: #e3b341;
  --r: 12px; --tap: 44px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Thonburi", "Helvetica Neue", sans-serif; overscroll-behavior: none; }
body { display: flex; flex-direction: column; height: 100dvh; padding-left: var(--sal); padding-right: var(--sar); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* 顶栏 */
.top { display: flex; align-items: center; gap: 10px; padding: calc(var(--sat) + 6px) 12px 6px; background: #0b0e11; border-bottom: 1px solid var(--line); flex: none; }
.brand { display: flex; align-items: center; gap: 6px; white-space: nowrap; border: 0; background: none; padding: 4px; border-radius: 10px; color: var(--text); cursor: pointer; }
.brand:active { background: var(--panel2); }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.modes { display: flex; background: var(--panel2); border-radius: 999px; padding: 3px; margin-left: auto; }
.mode { border: 0; background: none; padding: 7px 18px; border-radius: 999px; min-height: 36px; color: var(--dim); }
.mode.on { background: var(--accent); color: #fff; font-weight: 600; }
.chips { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--panel2); color: var(--dim); white-space: nowrap; }
.chip.ok { color: #8ee0b2; } .chip.bad { color: #ffb4ad; }
.icon { border: 0; background: var(--panel2); width: var(--tap); height: 36px; border-radius: 10px; font-size: 18px; }
.icon.big { width: var(--tap); height: var(--tap); border-radius: 50%; background: var(--accent); color: #fff; flex: none; }

/* 两个模式 */
.view { display: none; flex: 1; min-height: 0; flex-direction: column; }
.view.on { display: flex; }
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #07090b; }
.canvasWrap { position: relative; flex: 1; min-height: 180px; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.canvasWrap canvas { max-width: 100%; max-height: 100%; display: block; }
.canvasWrap .overlay { position: absolute; pointer-events: none; }
.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 20px; background: #07090b; }
.empty img { width: 84px; height: 84px; border-radius: 20px; opacity: .9; }
.empty p { margin: 0; font-size: 17px; }
.empty small { color: var(--dim); max-width: 22em; }
.busy { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(0,0,0,.7); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.badge { position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.65); padding: 3px 9px; border-radius: 6px; font-size: 12px; }
.strip { display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; flex: none; background: #0b0e11; }
.strip button { flex: none; width: 54px; height: 54px; border-radius: 8px; border: 2px solid transparent; padding: 0; overflow: hidden; background: #222; }
.strip button.on { border-color: var(--accent); }
.strip img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 工具区 */
.tools { flex: none; max-height: 48dvh; display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: var(--sab); }
.bar { display: flex; align-items: center; gap: 6px; padding: 8px; overflow-x: auto; flex: none; }
.grow { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: var(--tap); padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); white-space: nowrap; cursor: pointer; user-select: none; -webkit-user-select: none; }
.btn:disabled { opacity: .4; }
.btn.primary, .big.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { color: #ffb4ad; }
.btn.wide { width: 100%; margin: 6px 0; }
.big { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 28px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel2); font-size: 17px; cursor: pointer; }
.tabs { display: flex; gap: 2px; padding: 0 6px; overflow-x: auto; border-bottom: 1px solid var(--line); flex: none; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 10px 12px; min-height: var(--tap); color: var(--dim); white-space: nowrap; border-bottom: 2px solid transparent; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.panels { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px 16px; flex: 1; min-height: 0; }
.panel { display: none; }
.panel.on { display: block; }
.panel h4 { margin: 14px 0 6px; font-size: 14px; color: var(--dim); font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; overflow-x: auto; }
.row.wrap { flex-wrap: wrap; overflow: visible; }
.row.center { justify-content: center; }
.lbl { color: var(--dim); font-size: 13px; }
.hint { color: var(--dim); font-size: 13px; margin: 6px 0; }
.warn { color: var(--warn); font-size: 14px; }
.mini { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 14px; }
.mini input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.chipBtn { min-height: 38px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); white-space: nowrap; }
.chipBtn.on { background: var(--accent2); border-color: var(--accent); color: #fff; }
textarea, select, input[type=text] { width: 100%; background: #0d1014; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
select { width: auto; min-height: 40px; }
input[type=color] { width: 40px; height: 32px; border: 0; background: none; padding: 0; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }

/* 滑杆 */
.slider { margin: 6px 0 10px; }
.slider label { display: flex; justify-content: space-between; font-size: 14px; color: var(--dim); user-select: none; -webkit-user-select: none; }
.slider label b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.slider.changed label { color: #8ee0b2; }
input[type=range] { width: 100%; height: 32px; accent-color: var(--accent); margin: 0; touch-action: pan-y; }

/* 预设格子 */
.presetGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.presetGrid.small { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.preset { border: 2px solid transparent; border-radius: 10px; background: var(--panel2); padding: 0 0 4px; overflow: hidden; text-align: center; font-size: 12px; min-height: var(--tap); }
.preset canvas, .preset .ph { width: 100%; aspect-ratio: 1; display: block; object-fit: cover; background: #222; }
.preset.on { border-color: var(--accent); }
.preset { position: relative; }
.preset i { position: absolute; left: 4px; top: 4px; font-style: normal; font-size: 10px; background: var(--accent); color: #fff; padding: 0 5px; border-radius: 6px; }
.preset span { display: block; padding-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 水印位置九宫格 */
.pos { display: grid; grid-template-columns: repeat(3, 44px); gap: 4px; margin: 6px 0; }
.pos button { height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); }
.pos button.on { background: var(--accent2); border-color: var(--accent); }

/* 裁剪框 */
.cropBox { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); touch-action: none; }
.cropBox::before, .cropBox::after { content: ""; position: absolute; inset: 33.3% 0; border-top: 1px solid rgba(255,255,255,.5); border-bottom: 1px solid rgba(255,255,255,.5); pointer-events: none; }
.cropBox::after { inset: 0 33.3%; border: 0; border-left: 1px solid rgba(255,255,255,.5); border-right: 1px solid rgba(255,255,255,.5); }
.cropBox i { position: absolute; width: 28px; height: 28px; border: 4px solid #fff; }
.cropBox i[data-h=nw] { left: -6px; top: -6px; border-right: 0; border-bottom: 0; }
.cropBox i[data-h=ne] { right: -6px; top: -6px; border-left: 0; border-bottom: 0; }
.cropBox i[data-h=sw] { left: -6px; bottom: -6px; border-right: 0; border-top: 0; }
.cropBox i[data-h=se] { right: -6px; bottom: -6px; border-left: 0; border-top: 0; }

/* AI 方案 */
.plan { background: #0d1014; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 8px; }
.plan ul { margin: 6px 0; padding-left: 18px; }
.plan .no { color: #ffb4ad; }

/* 视频 */
.canvasWrap.video canvas { background: #000; }
.transport { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: #0b0e11; flex: none; }
.transport input { flex: 1; }
.time { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline { display: flex; align-items: center; gap: 4px; padding: 8px; overflow-x: auto; background: #0b0e11; flex: none; min-height: 76px; }
.clipCard { flex: none; height: 58px; border-radius: 8px; border: 2px solid transparent; background: #222 center/cover; position: relative; min-width: 46px; overflow: hidden; }
.clipCard.on { border-color: var(--accent); }
.clipCard span { position: absolute; left: 3px; bottom: 2px; font-size: 11px; background: rgba(0,0,0,.6); padding: 0 4px; border-radius: 4px; }
.clipCard em { position: absolute; right: 3px; top: 2px; font-size: 11px; font-style: normal; background: rgba(0,0,0,.6); padding: 0 4px; border-radius: 4px; }
.transBtn { flex: none; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); font-size: 13px; padding: 0; }
.transBtn.on { border-color: var(--accent); }
.subList { margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.sub { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; align-items: start; background: #0d1014; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.sub .t { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; padding-top: 6px; }
.sub textarea { min-height: 0; padding: 5px 7px; font-size: 14px; }
.sub .bad { color: #ffb4ad; font-size: 12px; }
.progress { position: relative; height: 26px; background: var(--panel2); border-radius: 8px; overflow: hidden; margin: 10px 0; }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent2); }
.progress span { position: relative; display: block; text-align: center; line-height: 26px; font-size: 13px; }

/* 弹窗 */
dialog.sheet { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); width: min(560px, calc(100vw - 24px)); padding: 16px; }
dialog.sheet::backdrop { background: rgba(0,0,0,.55); }
dialog h3 { margin: 0 0 8px; }
.facts { padding-left: 18px; color: var(--dim); font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 24px); transform: translateX(-50%) translateY(20px); background: rgba(20,24,30,.95); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 10; text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%); }

/* 手机竖屏：按钮栏只留图标，导出始终看得见 */
@media (max-width: 480px) { .lw { display: none; } .bar .btn { min-width: var(--tap); } }
/* 很窄的手机：顶栏收紧 */
@media (max-width: 380px) {
  .brand b { display: none; }
  .mode { padding: 7px 14px; }
  .btn { padding: 0 10px; }
}
/* iPad / 横屏：左右分栏，工具区固定宽度、占满高度 */
@media (min-width: 820px), (orientation: landscape) and (min-width: 600px) {
  .view.on { flex-direction: row; }
  .tools { max-height: none; width: 380px; border-top: 0; border-left: 1px solid var(--line); }
  .bar { flex-wrap: wrap; }
  .bar .grow { display: none; }
  .panels { padding: 12px 14px 24px; }
  .presetGrid { grid-template-columns: repeat(3, 1fr); }
  .presetGrid.small { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1180px) {
  .tools { width: 430px; }
  .brand b { font-size: 17px; }
}
/* 横屏手机：高度很矮，预览尽量大 */
@media (orientation: landscape) and (max-height: 500px) {
  .top { padding-top: 4px; padding-bottom: 4px; }
  .timeline { min-height: 64px; }
  .clipCard { height: 46px; }
}

/* 语音输入 */
.askRow { display: flex; gap: 8px; align-items: stretch; margin: 6px 0; }
.askRow textarea { flex: 1; }
.btn.mic { min-width: 56px; font-size: 22px; padding: 0; }
.btn.mic.rec { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }

/* 美颜 */
.subbar { display: flex; gap: 6px; padding: 6px 10px; background: #0b0e11; flex: none; justify-content: center; }
.sub { border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; padding: 6px 18px; min-height: 36px; color: var(--dim); }
.sub.on { background: #c2477a; border-color: #c2477a; color: #fff; font-weight: 600; }
.fill { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#bCamUI video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#bCam, #bGuide { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; }
.tips { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.tip { align-self: flex-start; background: rgba(0,0,0,.6); border-left: 3px solid #f472b6; padding: 6px 10px; border-radius: 8px; font-size: 14px; max-width: 92%; }
.camBar { position: absolute; left: 0; right: 0; bottom: 14px; display: flex; align-items: center; justify-content: space-around; }
.shutter { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.25); }
.shutter:active { background: #fff; }
.camBtn { width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.45); border: 0; font-size: 24px; display: flex; align-items: center; justify-content: center; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .15s; }
.flash.on { opacity: .8; }
.poses { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.poseCard { background: #0d1014; border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: 13px; }
.poseCard span { font-size: 26px; }
.poseCard p { margin: 4px 0 0; color: var(--dim); }
.warnTxt { color: #fbbf24; }
#beauty .strip canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
#beauty .btn.primary#bAuto { background: #c2477a; border-color: #c2477a; }

.btn.stack { flex-direction: column; line-height: 1.1; gap: 1px; padding: 2px 12px; }
.btn.stack small { font-size: 10px; font-weight: 500; opacity: .9; }
.mode { white-space: nowrap; }
@media (max-width: 480px) {
  .mode { padding: 7px 12px; }
  #chipNet { display: none; }
  .top { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .brand b { display: none; }
}

.btn.wide { white-space: normal; text-align: center; padding: 8px 12px; }

.camSide { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; }
.camMini { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(0,0,0,.45); font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.camMini small { font-size: 9px; color: #fff; }
.camMini.on { background: rgba(194,71,122,.85); }
.tip.ai { border-left-color: #60a5fa; }
.poseOverlay { position: absolute; inset: 10px 66px 100px 10px; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.poseOverlay .poseCard { background: rgba(10,12,16,.82); }
/* 拍照时：取景框占满，工具面板收起（手机竖屏） */
@media (max-width: 819px) { #beauty.cam .tools { display: none; } }
#beauty.cam .strip { display: none; }

/* 语音助手 */
.vaBtn { position: absolute; right: 12px; bottom: 12px; z-index: 5; width: 58px; height: 58px; border-radius: 50%; border: 0; background: #c2477a; color: #fff; font-size: 26px; box-shadow: 0 4px 16px rgba(0,0,0,.45); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.vaBtn i { position: absolute; inset: -4px; border-radius: 50%; border: 3px solid rgba(244,114,182,.0); transition: transform .08s; pointer-events: none; }
.vaBtn.rec { background: #e11d48; } .vaBtn.rec i { border-color: rgba(244,114,182,.8); }
.vaBtn.busy { background: #7c3aed; }
.vaBtn.cont::after { content: "连续"; position: absolute; top: -8px; right: -6px; font-size: 10px; background: #fbbf24; color: #000; border-radius: 6px; padding: 0 4px; }
.vaBubble { position: absolute; left: 50%; bottom: 82px; transform: translateX(-50%); z-index: 5; max-width: calc(100% - 24px); background: rgba(12,14,18,.9); border: 1px solid var(--line); border-radius: 14px; padding: 8px 14px; font-size: 15px; text-align: center; }
#beauty.cam .vaBtn { bottom: 110px; }
.tapSave { position: fixed; left: 50%; bottom: calc(var(--sab) + 80px); transform: translateX(-50%); z-index: 20; min-height: 56px; padding: 0 22px; border-radius: 16px; border: 0; background: var(--accent); color: #fff; font-size: 17px; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

.stage { position: relative; }
