/* 朔方文境：畫作空間配置（/wall）
   沿用前台的展牆白、墨色、石灰色；直角、細線，跟作品頁同一套語言 */
.wt { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); margin-top: 40px; }
.wt-head { margin-bottom: 36px; max-width: 46em; }
.wt-head .page-title { margin-bottom: 12px; }
.wt-head p { margin: 0; color: var(--stone); font-size: 14px; }
.wt-head { max-width: none; }
@media (max-width: 720px) { .wt-head .br-desk { display: none; } }

.wt-app { display: grid; gap: 32px; grid-template-columns: 1fr; align-items: start; }
.wt-app > * { min-width: 0; }
@media (min-width: 960px) {
  .wt-app { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); }
  .wt-stagecol { position: sticky; top: 24px; }
}
@media (max-width: 959px) { .wt-stagecol { order: -1; } }

.wt-panel { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.wt-sec { border-top: 1px solid var(--rule); padding: 20px 0 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.wt-sec h2 { font-family: var(--serif); font-weight: 400; font-size: 17px; letter-spacing: .16em; margin: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.wt-sec h2 small { font-family: var(--sans); font-size: 12px; letter-spacing: .04em; color: var(--stone); }
.wt-hint { margin: 0; font-size: 12.5px; color: var(--stone); line-height: 1.6; }
.wt-label { font-size: 12px; color: var(--stone); letter-spacing: .06em; margin-bottom: 8px; }

.wt-btn { font: inherit; font-size: 13.5px; letter-spacing: .08em; padding: 8px 16px; border: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.wt-btn:hover { background: var(--panel); }
.wt-btn.primary { background: var(--ink); color: var(--wall); }
.wt-btn.primary:hover { background: #33353a; }
.wt-btn.small { font-size: 12px; padding: 5px 10px; letter-spacing: .04em; }
.wt-btn:disabled { opacity: .5; cursor: progress; }
.wt-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.wt-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.wt-seg button { font: inherit; font-size: 13px; letter-spacing: .06em; padding: 5px 12px; border: 1px solid var(--rule); background: transparent; color: var(--stone); cursor: pointer; }
.wt-seg button:hover { border-color: var(--ink); color: var(--ink); }
.wt-seg button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--wall); }
.wt-seg.small button { font-size: 12px; padding: 3px 9px; }

.wt-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.wt-row label, .wt-work .dims label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--stone); min-width: 0; }
.wt input[type="number"], .wt input[type="search"], .wt select {
  font: inherit; font-size: 14px; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--rule); padding: 6px 0; width: 100%; min-width: 0; border-radius: 0;
  font-variant-numeric: tabular-nums;
}
.wt input:focus, .wt select:focus { outline: none; border-bottom-color: var(--ink); }
.wt input[type="range"] { width: 100%; accent-color: var(--ink); }
.wt-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.wt-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.wt-toggle input { width: 15px; height: 15px; accent-color: var(--ink); }

/* 已選作品 */
.wt-works { display: flex; flex-direction: column; gap: 10px; }
.wt-work { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.wt-work .thumb { width: 56px; height: 56px; object-fit: contain; background: var(--panel); }
.wt-work .fields { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wt-work .t { margin: 0; font-family: var(--serif); font-size: 14px; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wt-work .meta { margin: 0; font-size: 12px; color: var(--stone); }
.wt-work .acts { display: flex; gap: 6px; }
.wt-work .acts a:hover { text-decoration: none; }
.wt-work .dims { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
.wt-empty { margin: 0; padding: 16px; background: var(--panel); font-size: 13px; color: var(--stone); }

/* 場景模板 */
.wt-tpls { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; max-height: 360px; overflow: auto; padding: 2px; }
.wt-tpls button { font: inherit; border: 1px solid transparent; background: transparent; color: var(--ink); padding: 0; cursor: pointer; display: flex; flex-direction: column; text-align: left; }
.wt-tpls img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--panel); }
.wt-tpls span { font-size: 12px; padding: 4px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--stone); }
.wt-tpls button[aria-pressed="true"] { border-color: var(--ink); }
.wt-tpls button[aria-pressed="true"] span { color: var(--ink); }
.wt-steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--stone); }

/* 預覽 */
.wt-stage { display: flex; flex-direction: column; gap: 12px; }
#stage { width: 100%; display: block; background: var(--panel); touch-action: none; cursor: grab; }
#stage.dragging { cursor: grabbing; }
.wt-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px 16px; }
.wt-stat { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12.5px; color: var(--stone); font-variant-numeric: tabular-nums; }
.wt-fit { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wt-fitbar { position: relative; width: 140px; height: 4px; background: var(--rule); overflow: hidden; }
.wt-fitbar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); }
.wt-fitbar b { position: absolute; left: 57%; width: 20%; top: 0; bottom: 0; border-left: 1px solid var(--stone); border-right: 1px solid var(--stone); }
.wt-fit.low i { background: var(--red); }
.wt-fit.low span { color: var(--ink); }
.wt-table { overflow-x: auto; }
.wt-table table { border-collapse: collapse; width: 100%; font-size: 12.5px; min-width: 520px; }
.wt-table th, .wt-table td { padding: 8px 10px 8px 0; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.wt-table th { font-weight: 400; color: var(--stone); font-size: 12px; }
.wt-table td.n { font-variant-numeric: tabular-nums; }
.wt-table tbody tr { cursor: pointer; }
.wt-table tr.sel td { background: var(--panel); }
.wt-stepper { display: inline-flex; align-items: center; gap: 4px; }
.wt-stepper .u { color: var(--stone); font-size: 12px; margin-left: 2px; }
.wt-table td .wt-stepper input[type="number"] { width: 3.6em; padding: 2px 0; font-size: 12.5px; text-align: center; -moz-appearance: textfield; appearance: textfield; }
.wt-stepper input::-webkit-inner-spin-button, .wt-stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.wt-step { width: 24px; height: 24px; padding: 0; border: 1px solid var(--rule); background: var(--wall); color: var(--ink); font: inherit; font-size: 14px; line-height: 1; cursor: pointer; }
.wt-step:hover { border-color: var(--ink); }

/* 挑選作品視窗 */
.wt-picker { width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0; border: 1px solid var(--rule); background: var(--wall); color: var(--ink); }
.wt-picker::backdrop { background: rgba(28, 29, 31, .45); }
.wt-picker .in { display: flex; flex-direction: column; max-height: calc(100vh - 66px); }
.wt-picker header { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; padding: 20px 24px 16px; border-bottom: 1px solid var(--rule); }
.wt-picker header h2 { font-family: var(--serif); font-weight: 400; font-size: 18px; letter-spacing: .16em; margin: 0; flex: 1 1 100%; }
.wt-picker header label { flex: 1 1 150px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--stone); }
.wt-pkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px 16px; padding: 20px 24px; overflow: auto; }
.wt-pkgrid button { font: inherit; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); display: flex; flex-direction: column; gap: 6px; position: relative; }
.wt-pkgrid img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--panel); outline: 1px solid transparent; outline-offset: 2px; }
.wt-pkgrid button[aria-pressed="true"] img { outline-color: var(--ink); }
.wt-pkgrid button.loading { opacity: .5; cursor: progress; }
.wt-pkgrid .cap { display: flex; flex-direction: column; min-width: 0; }
.wt-pkgrid .t { font-family: var(--serif); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wt-pkgrid .a { font-size: 12px; color: var(--stone); }
.wt-pkgrid .tick { position: absolute; top: 8px; right: 8px; font-size: 11px; letter-spacing: .06em; padding: 2px 8px; background: var(--wall); border: 1px solid var(--rule); }
.wt-pkgrid button[aria-pressed="true"] .tick { background: var(--ink); color: var(--wall); border-color: var(--ink); }
.wt-picker footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--stone); }
.wt-picker .none { padding: 0 24px 24px; color: var(--stone); }

.wt-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: var(--wall); padding: 8px 18px; font-size: 13px; letter-spacing: .06em; z-index: 60; }

/* 替換模式：已在牆上的作品不能選 */
.wt-picker.swapping .wt-pkgrid button.inuse { opacity: .4; cursor: default; }
.wt-picker.swapping .wt-pkgrid button:not(.inuse) .tick { background: var(--ink); color: var(--wall); border-color: var(--ink); }

/* 預覽下方工具列：全景／近景、尺寸標註與各按鈕同高 */
.wt-bar .wt-btns > .wt-btn, .wt-bar .wt-seg button { height: 32px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; padding-top: 0; padding-bottom: 0; }
.wt-bar .wt-seg button { font-size: 12px; padding-left: 12px; padding-right: 12px; }
.wt-tog { color: var(--stone); border-color: var(--rule); }
.wt-tog[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--wall); }
#styleSeg { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--rule); }
/* 近景：拖曳空白處移動、滾輪／雙指縮放 */
#stage.zoomable { touch-action: none; cursor: grab; }
#stage.zoomable.dragging { cursor: grabbing; }
/* 作品金額：個別價格與小計 */
.wt-prices { margin-top: 28px; }
.wt-prices h3 { font-size: 14px; font-weight: 500; letter-spacing: .12em; margin: 0 0 8px; }
.wt-prices ul { list-style: none; margin: 0; padding: 0; }
.wt-prices li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.wt-prices li .t { min-width: 0; }
.wt-prices li .p { white-space: nowrap; font-variant-numeric: tabular-nums; }
.wt-prices li.na .p { color: var(--stone); }
.wt-sum { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin: 0; padding: 12px 0 0; border-top: 1px solid var(--ink); margin-top: -1px; font-size: 13.5px; }
.wt-sum b { font-size: 17px; font-weight: 600; letter-spacing: .02em; }
.wt-sum-note { margin: 4px 0 0; font-size: 12px; color: var(--stone); text-align: right; }
.wt-prices-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.wt-prices-head h3 { margin: 0; }
.wt-prices li .p { text-align: right; }
.wt-prices li .p small { display: block; font-size: 11.5px; color: var(--stone); }
/* 作品清單：名稱、尺寸一行，按鈕另起一行，不再擠在右邊 */
.wt-work { grid-template-columns: 56px minmax(0, 1fr); align-items: start; }
.wt-work .acts { grid-column: 2; flex-wrap: wrap; margin-top: 2px; }
/* 隨機生成：綠色大按鈕，跟其他黑白按鈕分開，一眼就找得到 */
#rndBtn { background: #2F6B4F; border-color: #2F6B4F; color: #fff; font-size: 15px; letter-spacing: .14em; padding: 12px 20px; width: 100%; }
#rndBtn:hover { background: #255A41; border-color: #255A41; }
#rndBtn:disabled { opacity: .6; }
.wt-stagecol { display: flex; flex-direction: column; gap: 12px; }
/* 手機與平板：預覽 → 隨機搭配 → 作品清單 → 離地表格 → 空間場景 → 掛法 → 金額小計 */
@media (max-width: 959px) {
  .wt-app { display: flex; flex-direction: column; gap: 0; align-items: stretch; }
  .wt-stage, .wt-sec, .wt-table, .wt-stagehint, .wt-prices { width: 100%; box-sizing: border-box; }
  .wt-panel, .wt-stagecol { display: contents; }
  .wt-stage { order: 1; margin-bottom: 8px; }
  .wt-sec-rnd { order: 2; }
  .wt-sec-works { order: 3; }
  .wt-table { order: 4; margin-top: 8px; }
  .wt-stagehint { order: 5; }
  .wt-sec-room { order: 6; }
  .wt-sec-hang { order: 7; }
  .wt-panel > :not([class*="wt-sec-"]) { order: 7; }
  .wt-prices { order: 8; margin-bottom: 8px; }
}
/* 手機下載：預覽圖＋存到相簿 */
.wt-save { position: fixed; inset: 0; z-index: 200; background: rgba(20, 18, 16, .78); display: flex; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.wt-save-in { background: var(--wall, #faf9f6); width: 100%; max-width: 560px; max-height: 100%; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.wt-save-in img { width: 100%; height: auto; display: block; -webkit-touch-callout: default; }
.wt-save-in p { margin: 0; font-size: 15px; line-height: 1.7; }
.wt-save-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.wt-save-btns .wt-btn { flex: 1 1 auto; height: 48px; font-size: 16px; }
@media (max-width: 720px) { .wt { margin-top: 12px; } }
