/* タブレット・ペン操作 (js/touch.js): the view takes every pointer, the quick bar / navigation pad / modifier strip,
   and the tablet layout (body.tablet): 44 px targets, the outliner and the tray as drawers, no hover-only UI. */

/* everywhere: the 3D view handles pens and fingers itself (no page scroll / zoom / callout / text selection) */
#viewport { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@supports (height: 100dvh) { body { height: 100dvh; } } /* iPad Safari: 100vh is taller than the visible page */

/* long-press ring under the finger */
.lp-ring { position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; pointer-events: none; z-index: 30;
  border: 3px solid var(--accent); opacity: 0; transform: scale(.4); }
.lp-ring.go { animation: lpRing .55s ease-out forwards; animation-delay: .12s; }
@keyframes lpRing { from { opacity: .0; transform: scale(.4); } 30% { opacity: .7; } to { opacity: .9; transform: scale(1); } }

/* shared button look of the floating parts */
.tq { min-width: 44px; height: 44px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  padding: 2px 6px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer;
  font-size: 10px; line-height: 1.1; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tq svg { width: 22px; height: 22px; }
.tq b { font-size: 18px; font-weight: 600; line-height: 22px; }
.tq span { white-space: nowrap; }
.tq.on { background: var(--hover); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tq.down { background: var(--accent); color: var(--accent-ink); }
.tq[hidden] { display: none; }
body[data-mode="manga"] .tq svg { filter: invert(.85) hue-rotate(180deg); }

/* quick bar: bottom centre, above the status bar */
#quickBar { position: fixed; left: 50%; bottom: calc(40px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 2px; padding: 4px 6px; max-width: calc(100vw - 16px); overflow-x: auto;
  background: color-mix(in srgb, var(--panel2) 94%, transparent); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 22px rgba(0,0,0,.18); }
#quickBar i { width: 1px; align-self: stretch; margin: 6px 3px; background: var(--line); flex: none; }
#quickBar .tq { flex: none; }
#quickBar[hidden], #navPad[hidden], #modStrip[hidden] { display: none; }
body[data-mode="pages"] #quickBar .tq[data-k=delete] { display: none; }
/* the quick bar has 元に戻す / やり直す within reach of the thumb: the same pair at the top is not repeated */
body.tablet:has(#quickBar:not([hidden])) #toolbar [data-g=undo] { display: none; }

/* navigation pad: drag a button to move the camera (one hand: the pen in the other) */
#navPad { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); z-index: 25; display: flex; flex-direction: column; gap: 6px;
  padding: 6px; background: color-mix(in srgb, var(--panel2) 88%, transparent); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.14); }
#navPad.right { left: auto; right: 10px; }
#navPad .tq { width: 56px; height: 56px; touch-action: none; }
#navPad .tq b { font-size: 22px; }
body[data-mode="pages"] #navPad, body[data-mode="pages"] #modStrip { display: none; }

/* modifier strip: Shift / Ctrl / Alt latched */
#modStrip { position: absolute; right: 10px; top: 10px; z-index: 25; display: flex; flex-direction: column; gap: 6px; padding: 5px;
  background: color-mix(in srgb, var(--panel2) 88%, transparent); border: 1px solid var(--line); border-radius: 12px; }
#modStrip.left { right: auto; left: 10px; }
#modStrip .tq { width: 56px; }
#modStrip .tq b { font-size: 14px; }
#modStrip .tq.on { background: var(--accent); color: var(--accent-ink); }
/* fold tab: folded = only a small tab (the held keys show in it) */
#modStrip .mfold { min-height: 26px; height: 26px; padding: 0; display: flex; align-items: center; justify-content: center; gap: 3px; }
#modStrip .mfold b { font-size: 13px; transition: transform .15s; }
#modStrip .mfold i { font-style: normal; font-size: 10px; display: none; }
#modStrip.folded { padding: 3px; gap: 0; }
#modStrip.folded .tq[data-m] { display: none; }
#modStrip.folded .mfold { width: 40px; }
#modStrip.folded .mfold b { transform: rotate(180deg); }
#modStrip.folded.held .mfold { width: auto; padding: 0 6px; background: var(--accent); color: var(--accent-ink); }
#modStrip.folded.held .mfold i { display: inline; }

.touch-prefs .tp-row { display: grid; grid-template-columns: 1fr minmax(0, 220px); align-items: center; gap: 10px; min-height: 44px; border-bottom: 1px solid var(--line); }
.touch-prefs .tp-row select { min-height: 36px; }
.touch-prefs .tp-row input[type=checkbox] { width: 24px; height: 24px; justify-self: start; }
.touch-prefs .tp-help { margin: 10px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

/* ---------------- tablet layout ---------------- */
body.tablet { grid-template-rows: 44px 52px minmax(0, 1fr) 32px; -webkit-tap-highlight-color: transparent; }
body.tablet #menubar, body.tablet #toolbar, body.tablet #toolset, body.tablet #statusbar, body.tablet #sceneTabs, body.tablet #trayHead, body.tablet .dropdown { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.tablet .menu-top { min-height: 44px; padding: 0 12px; font-size: 14px; }
body.tablet #modeSwitch button { min-height: 36px; padding: 0 14px; }
body.tablet #verBadge, body.tablet #docTitle { display: none; }
body.tablet .tb, body.tablet #toolset .tb { width: 44px; height: 44px; }
body.tablet .tb svg { width: 24px; height: 24px; }
body.tablet #toolbar { gap: 3px; }
body.tablet #toolbar select, body.tablet #toolbar button:not(.tb) { min-height: 40px; }
body.tablet #toolset { grid-template-columns: 44px 44px; grid-auto-rows: 44px; gap: 3px; padding: 6px 3px; }
body.tablet .dropdown .item { min-height: 44px; align-items: center; padding: 6px 16px 6px 8px; font-size: 14px; }
body.tablet .dropdown { max-height: calc(100dvh - 60px); overflow-y: auto; }
body.tablet .stab { padding: 9px 16px; }
body.tablet #statusbar { font-size: 12px; }
body.tablet #navHint { display: none; }
body.tablet #statusbar { grid-template-columns: auto minmax(0, 1fr) auto 160px; }
body.tablet #olShow { display: none !important; }
body.tablet .ol-row { min-height: 44px; }
body.tablet .ol-row .ic { min-width: 32px; min-height: 32px; opacity: .75; }
body.tablet .panel > h3 { min-height: 44px; display: flex; align-items: center; }
body.tablet input, body.tablet select, body.tablet .btn { min-height: 36px; }
body.tablet input[type=range] { min-height: 32px; }
body.tablet .dialog { max-height: calc(100dvh - 40px); overflow-y: auto; }

/* the view takes the whole middle; the outliner and the tray slide over it as drawers */
body.tablet #main, body.tablet.ol-hidden #main, body.tablet.tray-hidden #main, body.tablet.tray-hidden.ol-hidden #main { grid-template-columns: 100px 0 minmax(0, 1fr) 0; }
/* the quick bar stays over the view, clear of an open tray drawer */
body.tablet:not(.tray-hidden) #quickBar { left: calc((100vw - min(360px, 88vw)) / 2); max-width: calc(100vw - min(360px, 88vw) - 16px); }
body.tablet #hier, body.tablet #tray { position: fixed; top: 96px; bottom: 32px; z-index: 60; display: flex !important; transition: transform .2s ease;
  box-shadow: 0 0 28px rgba(0,0,0,.22); }
body.tablet #hier { left: 0; width: min(330px, 86vw); }
body.tablet #tray { right: 0; width: min(360px, 88vw); }
body.tablet.ol-hidden #hier { transform: translateX(-105%); box-shadow: none; }
body.tablet.tray-hidden #tray { transform: translateX(105%); box-shadow: none; }
body.tablet.tray-hidden #trayBody, body.tablet.tray-hidden #trayHead span { display: revert; }
body.tablet[data-mode="pages"] #hier, body.tablet[data-mode="pages"] #tray { display: none !important; }
/* the toolset stays docked on the left (it is the tool palette); the pad sits right of it */
/* コマ割り: no toolset column, and the quick bar keeps only what works there (コマ割り has its own 元に戻す) */
body.tablet[data-mode="pages"]:is(*, .ol-hidden, .tray-hidden, .ol-hidden.tray-hidden) #main { grid-template-columns: 0 0 minmax(0, 1fr) 0; }
body[data-mode="pages"] #quickBar .tq:is([data-k=left], [data-k=right], [data-k=undo], [data-k=redo]), body[data-mode="pages"] #quickBar i { display: none; }

body.tablet #vcbInput { min-height: 0; height: 26px; } /* fits the 32 px status bar */

/* Android：画面切替はアイコンだけにせず、名前も表示する。 */
body.tablet #modeSwitch button:has(.mode-label){display:flex;flex-direction:column;justify-content:center;align-items:center;gap:1px;min-height:44px;min-width:48px;padding:0 6px}
#modeSwitch .mode-label{font-size:10px;line-height:12px;white-space:nowrap}
body.tablet #modeSwitch button:has(.mode-label) svg{width:20px;height:20px}
#menubar .dl-mb:disabled{opacity:.35;cursor:default}

#modeSwitch[data-icons] .mode-label{display:block!important}
