/* 網站版補充樣式：沿用核定原型的 panstone.css 與 panstone-fixes.css，只補互動所需元素 */
[hidden] { display: none !important; }
:root { --ink: #321007; --accent: #704125; --sand: #A97552; --meringue: #EFEBE8; --paper: #f7f7f6; }
.top, .right { background: var(--meringue); }
.brand { flex-direction: row; align-items: center; gap: 14px; }
.brand img { display: block; width: 142px; height: auto; }
.brand > div { display: grid; gap: 3px; padding-left: 14px; border-left: 1px solid var(--sand); }
.btn.pri, .btn.on, .seg button.on, .st.on i { background: var(--accent); color: white; border-color: var(--accent); }
.btn.pri:hover, .btn.acc:hover { background: var(--ink); }
.pc.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.scene.live { background-color: #e6e6e4; }
.bar-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.scene.live { aspect-ratio: auto; }
.scene.live .inner { position: relative; inset: auto; }
.view, .overlay { display: block; width: 100%; height: auto; }
.overlay { position: absolute; inset: 0; height: 100%; touch-action: none; }
.overlay.brushing { cursor: crosshair; }
.scene.live .drop { position: absolute; }
.scene.live.empty { aspect-ratio: 3 / 2; }
.scene.zoom .inner { transform: scale(1.8); transform-origin: var(--zx, 50%) var(--zy, 70%); }
.cmp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.cmp figure { margin: 0; aspect-ratio: auto; }
.cmp img { display: block; width: 100%; height: auto; }
.plist { display: flex; flex-direction: column; gap: 8px; }
.pc .swi { position: absolute; inset: 0; background-size: 400% auto; background-position: 40% 40%; }
.exp img { width: 100%; display: block; border-radius: 4px; }
.persp { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.persp summary { cursor: pointer; color: var(--ink2); }
.persp label { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px; align-items: center; margin: 8px 0; }
.persp input[type=range] { width: 100%; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; max-width: 80vw; z-index: 10; }
.box.err { border-color: var(--warn); }
.box.err b { color: var(--warn); }
label.btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.proc { z-index: 3; }
.drop { z-index: 2; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row-btns:not(:has(button:not([hidden]))) { display: none; }
/* 背景辨識時不擋住照片：處理提示縮到畫面底部 */
.scene.live .proc { inset: auto 16px 16px 16px; padding: 12px 16px; border-radius: 10px; background: rgba(246, 243, 237, .93); gap: 8px; }
#tryStatus { margin-bottom: 14px; }
/* 第 1 步：上傳區＋AI 示範空間縮圖（5.1）。沿用核定稿的卡片、徽章與字級 */
.scene.live.start { aspect-ratio: auto; }
.scene.live.start .drop { position: relative; inset: auto; margin: 18px; justify-content: flex-start; gap: 16px; padding: 22px 24px; }
.drop .upload { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; align-items: stretch; width: 100%; max-width: 860px; }
.own-photo { display: grid; align-content: center; justify-items: start; gap: 8px; text-align: left; }
.space-entry { display: grid; grid-template-rows: minmax(70px, 1fr) auto; position: relative; isolation: isolate; overflow: hidden; min-height: 132px; padding: 0; border: 1px solid var(--accent); border-radius: 10px; background: var(--accent); color: white; text-align: left; cursor: pointer; font: inherit; }
.space-entry img { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; object-fit: cover; }
.space-entry > span { grid-row: 2; display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; background: var(--accent); font-weight: 700; }
.space-entry:hover > span, .space-entry:focus-visible > span { background: var(--ink); }
.gallery { width: 100%; text-align: left; border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.ghead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ghead h3 { margin: 0; font-size: 15px; }
.ggrid, .gcats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.sc { border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 0; overflow: hidden; text-align: left; display: flex; flex-direction: column; font: inherit; color: inherit; }
.sc:hover { border-color: var(--ink2); }
.sc img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: var(--line2); }
.sc span { padding: 5px 8px 7px; font-size: 12px; line-height: 1.35; color: var(--ink2); }
.sc b { display: block; color: var(--ink); font-size: 13px; font-weight: 600; }
@media (max-width: 1366px) { .ggrid, .gcats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* 5.5 先選空間：類別卡片（代表圖＋名稱＋張數），選中的類別用深色框，與商品卡片的選中樣式一致 */
.space-groups { display: flex; gap: 8px; }
.space-groups button[aria-pressed="true"] { background: var(--ink); color: white; }
.gcats[hidden] { display: none; }
.cat { border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 0; overflow: hidden; text-align: left; display: flex; flex-direction: column; font: inherit; color: inherit; }
.cat:hover { border-color: var(--ink2); }
.cat.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.cat img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--line2); }
.cat b { display: block; color: var(--ink); font-size: 14px; font-weight: 600; }
/* 示範圖維持橫幅，較長的空間名稱與風格可換行 */
#sceneGrid .sc img { aspect-ratio: 16 / 9; }
.cat span, #sceneGrid .sc span { white-space: normal; overflow-wrap: anywhere; padding: 8px 10px; line-height: 1.5; font-size: 14px; }
#sceneGrid .sc b { display: inline; }
/* 6.1 分段按鈕（方向、檢視、修正工具、筆刷）：外框不再裁切，鍵盤焦點外框完整可見；圓角改由頭尾按鈕自己畫 */
.seg { overflow: visible; }
.seg button:first-child { border-radius: 7px 0 0 7px; }
.seg button:last-child { border-radius: 0 7px 7px 0; }
.seg button:focus-visible { position: relative; z-index: 1; }
#lineupNote { margin-top: 8px; } /* 原本在選款區塊內，獨立出來後保持相同間距 */
/* 6.1 照片依視窗高度縮放（寬度由 fitScene 設定）時置中 */
.scene.live { margin-inline: auto; max-width: 100%; }
/* 6.1 一般筆電與窄筆電（視窗高度 ≤ 860px）：右側面板緊湊排列，選款、方向、存方案、並排比較不必捲動；
   型號規格與透視微調移到方案下方。桌機高度維持核定版面。 */
@media (max-height: 860px) {
  .right { padding-top: 14px; gap: 10px; }
  #pTry { display: flex; flex-direction: column; gap: 10px; }
  #pTry > #lineupNote, #pTry > .kv, #pTry > .persp { order: 1; margin-top: 0; }
  #tryStatus { padding: 8px 12px; margin-bottom: 0; }
  .plist { gap: 6px; }
  .pc { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; padding: 6px 10px; }
  .pc .sw { width: 40px; height: 40px; }
  .pmeta { display: block; line-height: 1.35; }
  .pmeta small { display: block; font-size: 11px; }
  .pmeta b { font-size: 14px; margin-right: 8px; }
  .pmeta .mono { font-size: 12px; }
  #dirSec { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 12px; }
  #dirSec .note { flex-basis: 100%; }
  .slot { min-height: 0; padding: 4px 10px; }
}
/* 6.2 修正與比較的右欄：區塊之間留出與面板相同的間距（原本緊貼） */
#pFix, #pCompare, #pBox { display: flex; flex-direction: column; gap: 12px; }
/* 6.3 框選修正：在照片上拖出一個框 */
.overlay.boxing { cursor: crosshair; }
#boxActions .btn { flex: 1 1 auto; justify-content: center; }
/* 6.3 AI 標示：會用到 AI 的操作前面的小標；按鈕用 .ai 加在文字前 */
/* 頁首常駐的 AI 辨識餘額（三個步驟都看得到；只顯示伺服器回報的實際值） */
.aiq { flex: none; font-size: 13px; line-height: 1.4; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--blue); color: var(--blue); background: var(--card); font-weight: 500; white-space: nowrap; }
.aiq b { font-weight: 700; font-variant-numeric: tabular-nums; }
.aiq[data-tone="warn"] { border-color: var(--warn); color: var(--warn); }
.aiq[data-tone="muted"] { border-color: var(--line); color: var(--ink2); }
/* 已選款式：同一張照片可以留很多款（不設上限），小圖瀏覽；並排比較時挑任兩款 */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 .btn { justify-content: center; }
#savedCount, #cmpCount { font-weight: 400; color: var(--ink2); margin-left: 6px; font-size: 13px; }
.saved { display: flex; flex-direction: column; gap: 6px; max-height: min(44vh, 360px); overflow-y: auto; padding: 2px; }
.saved:empty { display: none; }
.sv { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 4px 6px 4px 4px; }
.sv.cur, .sv.inL, .sv.inR { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.svpick { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0; text-align: left; min-width: 0; font: inherit; color: inherit; }
button.svpick { cursor: pointer; }
.svpick img { width: 72px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 5px; background: var(--line2); flex: none; display: block; }
#cmpList .svpick img { width: 60px; }
.svn { flex: none; min-width: 20px; height: 20px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.svt { min-width: 0; font-size: 12px; line-height: 1.35; color: var(--ink2); }
.svt b { display: block; font-size: 13px; color: var(--ink); }
.sv .btn { font-size: 12px; padding: 4px 9px; }
.sv .seg button { font-size: 12px; padding: 4px 8px; white-space: nowrap; }
.aib { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; line-height: 1.5; padding: 0 6px; border-radius: 999px; background: var(--blue); color: #fff; margin-right: 6px; vertical-align: 1px; }
.btn.ai::before { content: 'AI'; font-size: 11px; font-weight: 700; letter-spacing: .04em; line-height: 1.5; padding: 0 6px; border-radius: 999px; background: #fff; color: var(--blue); margin-right: 2px; }
.btn.ai:not(.pri)::before { background: var(--blue); color: #fff; }
.toast { pointer-events: none; }

.swatch-row { position: relative; }
.swatch-row .pc { grid-template-columns: clamp(84px, 7vw, 112px) minmax(0, 1fr); gap: 14px; min-height: 100px; }
.swatch-row .sw { width: 100%; height: auto; aspect-ratio: 1.2; }
.swatch-row .swi { background-size: cover; background-position: center; }
.swatch-row .pmeta { padding-bottom: 27px; }
.swatch-zoom { position: absolute; left: calc(25px + clamp(84px, 7vw, 112px)); bottom: 9px; background: transparent; border: 0; padding: 2px 0; font: inherit; font-size: 13px; color: var(--ink); text-decoration: underline; cursor: zoom-in; }
#swatchDialog { width: min(820px, 84vw); max-height: 90vh; box-sizing: border-box; border: 0; border-radius: 12px; padding: 18px; color: var(--ink); }
#swatchDialog::backdrop { background: rgb(20 17 14 / 65%); }
.swatch-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.swatch-heading h2 { margin: 0; font-size: 20px; }
.swatch-heading button { padding: 6px 14px; cursor: pointer; }
#swatchPhoto { display: block; width: 100%; max-height: 72vh; object-fit: contain; }

.picker-heading, .product-pager { display: flex; align-items: center; gap: 10px; }
.picker-heading { justify-content: space-between; margin-bottom: 8px; }
.picker-heading h3 { margin: 0; }
.product-pager { font-size: 13px; font-variant-numeric: tabular-nums; }
.product-pager button { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; width: 36px; height: 32px; font-size: 18px; cursor: pointer; }
.product-pager button:disabled { opacity: .4; cursor: default; }
.product-pages { display: grid; grid-auto-flow: column; grid-auto-columns: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.product-page { scroll-snap-align: start; align-content: start; min-width: 0; padding: 3px; }

#backToSpaces { align-self: flex-start; }
