/* 兩款 App 共用桌機尺度：清單與頁首對齊，照片工作區保留全視窗，工具依用途限寬。 */
.photo-zoom { position: absolute; right: 12px; top: 76px; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px; border-radius: 28px; background: rgba(14,14,15,.7); color: #fff; }
.photo-zoom .icon-btn { color: inherit; }
.photo-zoom .zoom-v { min-width: 44px; color: inherit; font-size: 12px; }
@media (pointer: coarse) { .photo-zoom { display: none; } }
@media (any-pointer: fine) { #editor .photo-zoom { display: flex; } }

@media (min-width: 900px) {
  :root { --desktop-width: 1200px; --desktop-gutter: 24px; --desktop-tools: 640px;
    --desktop-inset: max(var(--desktop-gutter), calc((100vw - var(--desktop-width)) / 2 + var(--desktop-gutter))); }

  /* 室內：首頁、牆面與選單共用同一組邊界。 */
  html[data-climbio-theme="indoor"] body { --tablet-width: var(--desktop-width); --tablet-gutter: var(--desktop-gutter); }
  html[data-climbio-theme="indoor"]:has(:is(#editor, #crop, #scan, #landing, #shareDialog):not([hidden])),
  html[data-climbio-theme="indoor"]:has(:is(#editor, #crop, #scan, #landing, #shareDialog):not([hidden])) body { overflow: hidden; }
  :is(#home, #wall) > .bar { min-height: 72px; }
  /* 返回圖示的線條對齊內容左緣（按鈕 48px、圖示 26px，兩側各有留白）。 */
  #wall > .bar #backBtn { margin-left: -11px; }
  #home .bar h1.brand { font-size: 28px; }
  #home .bar .wordmark { width: 177px; height: 38px; }
  #home .cont-card img { width: 64px; height: 64px; }
  #home .cont-text b { font-size: 18px; }
  #home .cont-text b.grade { font-size: 32px; }
  #home .cont-text :is(small, span) { font-size: 14px; }
  #homeMenu { right: var(--desktop-inset); top: 72px; }
  /* 兩款 Viewer 的同步提示是內容膠囊，不應撐滿桌面整列。 */
  #home > .sync-hint {
    flex: none;
    width: min(640px, calc(100% - 48px));
    margin: 4px auto 12px;
  }
  /* 安裝提示位於 #home 外，桌面固定置中並限寬，手機原位置不變。 */
  :is(.inst-bar, .rp-inst-bar) {
    left: 50%;
    right: auto;
    width: min(520px, calc(100vw - 48px));
    translate: -50% 0;
  }
  #home > .rfab, #wall > .rfab { right: var(--desktop-inset); bottom: 24px; }
  .crop-bar { padding: 16px var(--desktop-inset) 8px; }
  html[data-climbio-theme="indoor"] #find > .bar { padding-inline: var(--desktop-inset); min-height: 72px; }
  html[data-climbio-theme="indoor"] .find-gym { width: 100%; max-width: var(--desktop-width); margin-inline: auto; padding-inline: 24px; }
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet-backdrop > .sheet { width: min(480px, 100%); max-height: calc(100dvh - 48px); overflow-y: auto; margin: 0; }
  .sheet-backdrop > .sheet > :is(.sheet-group, .sheet-cancel) { flex-shrink: 0; }

  /* 定線與看線：上方工具同邊界，下方工具固定置中；縮放獨立放右側，兩種模式皆可用。 */
  #editor:not(.viewing) > .ed-top { left: var(--desktop-inset); right: var(--desktop-inset); padding: 16px 0 0; }
  #editor:not(.viewing) > .ed-bottom { align-items: center; padding: 0 24px 24px; }
  #editor:not(.viewing) .ed-panel { width: min(var(--desktop-tools), 100%); max-width: none; margin: 0 auto; align-items: stretch; }
  #editor .type-row { gap: 6px; padding: 6px; }
  #editor .type-row .type-btn { height: 42px; font-size: 14px; }
  #editor .type-row { --pw: calc((100% - 36px) / 5); --step: calc(var(--pw) + 6px); }
  #editor .type-pill { top: 6px; bottom: 6px; left: calc(6px + var(--i, 0) * var(--step)); }
  #editor > .vw { left: calc(var(--desktop-inset) - 12px); right: calc(var(--desktop-inset) - 12px); top: 4px; }
  #editor .vw-title b { font-size: 34px; }
  #editor .vw-title #routeTitle { font-size: 16px; }
  #editor .photo-zoom { right: var(--desktop-inset); top: 50%; transform: translateY(-50%); }
  #editor #vwFabWrap { right: var(--desktop-inset); bottom: 24px; }

  /* 戶外桌面：一般內容共享一組置中寬度；世界限寬、岩場全視窗捲動，Topo 才使用雙欄工作區。 */
  html[data-climbio-theme="outdoor"] .page:where(:not(.ak-photo-page):not(#pack):not(#ticks)) { max-width: var(--desktop-width); margin-inline: auto; }
  /* 桌面首頁以全視窗為捲動容器，內容仍與岩場、世界對齊。 */
  html[data-climbio-theme="outdoor"] #home { max-width: none; margin: 0; }
  html[data-climbio-theme="outdoor"] #home > .bar { width: 100%; max-width: var(--desktop-width); margin-inline: auto; }
  /* 地圖限寬至同一內容軸，不會從首頁跳成整個超寬螢幕。 */
  html[data-climbio-theme="outdoor"] #world { width: 100%; max-width: var(--desktop-width); margin-inline: auto; }
  html[data-climbio-theme="outdoor"] .page:not(.ak-photo-page) > .bar { padding-inline: 24px; min-height: 72px; }
  html[data-climbio-theme="outdoor"] #home .cards { max-width: var(--desktop-width); padding: 12px 24px 32px; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  /* FAB 在 #home 外面，是兄弟元素：原本的 #home .rfab 不會選到它。 */
  html[data-climbio-theme="outdoor"] #fab { right: var(--desktop-inset); bottom: 24px; }
  html[data-climbio-theme="outdoor"] #acct .ac-card { top: 16px; right: var(--desktop-inset); left: auto; width: 360px; max-height: calc(100dvh - 32px); overflow-y: auto; }
  html[data-climbio-theme="outdoor"] .region-list { padding: 8px 24px 32px; }
  html[data-climbio-theme="outdoor"] .page-summary { margin-inline: 24px; }
  /* 岩場頁外層占滿視窗，捲軸留在最右邊。四欄網格的外側兩欄是等寬留白，
     中間兩欄的內容寬度與首頁相同；右側內容再多也不會把頁面縮小。 */
  html[data-climbio-theme="outdoor"] body:not(.split) #pack {
    inset: 0; width: 100%; max-width: none; margin: 0; padding: 0; border: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 400px) minmax(0, calc(min(100%, var(--desktop-width)) - 472px)) minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 0 24px;
    align-content: start;
  }
  body:not(.split) #pack > .bar { grid-column: 2 / 4; padding-inline: 0; }
  body:not(.split) #packBanner { grid-column: 2; grid-row: 2; align-self: start; margin: 0; }
  body:not(.split) #packCards { grid-column: 3; grid-row: 2 / span 2; min-width: 0; align-self: start; padding: 0 0 96px; }
  body:not(.split) #packCards .cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); padding-inline: 0; }
  body:not(.split) #packMissing { grid-column: 2; grid-row: 3; align-self: start; margin-block: 16px; }
  body:not(.split) .pk-fab { left: auto; right: var(--desktop-inset); bottom: 24px; }
  html[data-climbio-theme="outdoor"] #ticks > * { width: 100%; max-width: 760px; }
  html[data-climbio-theme="outdoor"] #ticks > .bar { max-width: none; }
  html[data-climbio-theme="outdoor"] .rv-ask { align-items: center; padding: 24px; }
  html[data-climbio-theme="outdoor"] .rv-ask > .sheet { width: min(480px, 100%); max-height: calc(100dvh - 48px); overflow-y: auto; margin: 0 auto; }
  html[data-climbio-theme="outdoor"] .gd-here { margin-top: 8px; align-self: flex-start; }
  html[data-climbio-theme="outdoor"] #recv { justify-content: safe center; padding: 72px 24px 24px; }
  html[data-climbio-theme="outdoor"] #rvGo { margin-top: 8px; }
  html[data-climbio-theme="outdoor"] .way-card { align-self: center; width: min(760px, calc(100% - 48px)); margin: 16px 24px; padding: 24px; border-radius: 20px; }
}

/* 桌面滑鼠：以邊框回饋可點選範圍，不縮放卡片，避免照片飛入頁面時的位置跳動。 */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  :is(#wallList, #findList) .wall-card:hover:not(.acting),
  #routeList .route-card:hover:not(.acting),
  html[data-climbio-theme="outdoor"] :is(#cards, #packCards) .card:hover:not(.lifted):not(.dragging) {
    outline: 2px solid color-mix(in srgb, var(--accent) 42%, transparent);
    outline-offset: -2px;
  }
  :is(#wallList, #findList) .wall-card:focus-visible,
  #routeList .route-card:focus-visible,
  html[data-climbio-theme="outdoor"] :is(#cards, #packCards) .card:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
  }
  #topo .tp-nav:hover,
  #pack .bn-btn:hover,
  #editor .photo-zoom .icon-btn:hover { filter: brightness(1.18); }
}

/* 1600px 以上擴大內容工作區；但不把卡片拉到無限制寬，保留閱讀焦點。 */
@media (min-width: 1600px) {
  :root { --desktop-width: 1440px; }
}
@media (min-width: 2000px) {
  :root { --desktop-width: 1600px; }
}

@media (min-width: 1440px) and (min-height: 600px) and (orientation: landscape) {
  html[data-climbio-theme="outdoor"] body.split #topo .tp-pop {
    left: auto; right: 24px; bottom: 24px; margin: 0;
    width: min(400px, calc(100% - 48px));
  }
}

/* 內容區拉寬到 1440px 以上，路線縮圖從四欄增為五欄。 */
@media (min-width: 1600px) and (min-height: 600px) and (orientation: landscape) {
  html[data-climbio-theme="indoor"] #wall #routeList { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
