* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #2b2b2e; color: #eee;
  font: 14px/1.3 -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
body { display: flex; flex-direction: column; height: 100dvh; }

#bar {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top));
  background: #1c1c1e; border-bottom: 1px solid #000;
}
.grp { display: flex; align-items: center; gap: 4px; }
.grp.nav { margin-left: auto; }
button, select {
  font: inherit; color: #eee; background: #3a3a3e;
  border: 1px solid #4a4a50; border-radius: 6px;
  min-height: 36px; min-width: 36px; padding: 0 10px;
  touch-action: manipulation;
}
button.on { background: #0a66d8; border-color: #3d8cf0; }
button:disabled { opacity: .35; }
button.shp { padding: 0; width: 36px; font-size: 16px; }
button.col { padding: 0; width: 36px; position: relative; }
button.col::after {
  content: ""; position: absolute; inset: 7px; border-radius: 50%;
  background: var(--c); border: 1px solid #fff8;
}
button.col.on { background: #eee; border-color: #fff; }
button.col.light::after { border-color: #777; }             /* 白は背景に埋もれないよう濃い縁取りにする */
button.col.light.on::after { border: 2px solid #555; }
#sFillA, #sArrow { width: 7.5em; }                           /* 塗りと矢印は同じ場所で入れ替わる */
#menu {
  position: absolute; z-index: 5; display: flex; flex-direction: column; gap: 8px;
  padding: 10px; border-radius: 10px; background: #1c1c1e; border: 1px solid #555; box-shadow: 0 6px 20px #0009;
}
.mrow { display: flex; align-items: center; gap: 6px; }
.mrow span { width: 3.5em; font-size: 12px; color: #9a9aa0; }
.mrow button, .mrow select { min-height: 40px; }
#sDoc { width: 11em; text-overflow: ellipsis; }   /* 幅を固定し、PDFの名前でツールバーの並びが変わらないようにする */
#bPage { min-width: 92px; font-variant-numeric: tabular-nums; }
#bUpdate { background: #0a66d8; border-color: #3d8cf0; }

/* 状態の通知。ページ送りの左に置き、その行の空いた幅だけを使う（flex-basis 0 なので折り返しの原因にならない）。
   入りきらない分は … で切る。margin-left で、増えたぶんの隙間（#bar の gap）を打ち消す。
   show の間だけ出て押せる。warn = 橙、err = 赤 */
#msg {
  flex: 1 1 0; min-width: 0; margin-left: -12px; padding: 0 2px; text-align: right;
  font-size: 12px; color: #9a9aa0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; pointer-events: none; transition: opacity .25s; cursor: pointer;
}
#msg.show { opacity: 1; pointer-events: auto; }
#msg.warn { color: #ffa94d; font-weight: bold; }
#msg.err { color: #ff6b6b; font-weight: bold; }
/* 状態の一覧（通知かメニューの「保存とオフライン」で開く） */
#stPanel {
  position: absolute; top: 10px; right: 10px; z-index: 7; width: min(340px, calc(100% - 20px));
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 10px;
  background: #1c1c1e; border: 1px solid #555; box-shadow: 0 6px 20px #0009; font-size: 14px; color: #ddd;
}
#stPanel[hidden] { display: none; }
.strow { display: flex; gap: 10px; align-items: baseline; }
.strow span { width: 5em; flex: none; font-size: 12px; color: #9a9aa0; }
.strow .warn { color: #ffa94d; }
.strow .err { color: #ff6b6b; }
#stPanel p { margin: 0; font-size: 12px; color: #bbb; white-space: pre-wrap; }
#bStClose { align-self: flex-end; }
#stNote { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid #444; }
#stNote[hidden] { display: none; }
#stNote .warn { color: #ffa94d; }
#stNote ol { margin: 0; padding-left: 1.4em; font-size: 12px; color: #ddd; }
#stNote li + li { margin-top: 4px; }

#stage {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  touch-action: none;
}
#world {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  display: flex; align-items: center;
}
.sheet {
  position: relative; flex: none; overflow: hidden;
  background: #f1eee4;            /* 枠外領域の色 */
  box-shadow: 0 0 0 1px #0003;
}
.sheet canvas { position: absolute; left: 0; display: block; }
.sheet canvas.pdf { background: #fff; }
.sheet canvas.ann { top: 0; width: 100%; height: 100%; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

#selBar {
  position: absolute; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 10px;
  width: max-content; max-width: calc(100% - 24px); padding: 6px; border-radius: 10px;
  background: #1c1c1eee; border: 1px solid #000; box-shadow: 0 2px 10px #0006;
}
#selBar.top { bottom: auto; top: 12px; }                    /* 選択したものが画面の下にあるときは上に出す */
#selBar .sg { display: flex; gap: 4px; }
#selBar button, #selBar select { min-height: 40px; white-space: nowrap; }
#selInfo { font-size: 12px; color: #9a9aa0; padding: 0 2px; }

#empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; color: #bbb;
}
#empty[hidden] { display: none; }
#empty button { font-size: 18px; min-height: 52px; padding: 0 28px; background: #0a66d8; }

/* PDFの追加・切り替え中は操作を受け付けない。すぐ終わるときは文字を出さない */
#busy {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
}
#busy span {
  padding: 10px 18px; border-radius: 10px; background: #000c; color: #eee; font-size: 16px;
  opacity: 0; animation: busy-in 0s .35s forwards;
}
@keyframes busy-in { to { opacity: 1; } }

dialog {
  border: 1px solid #555; border-radius: 12px; background: #2b2b2e; color: #eee;
  padding: 20px; min-width: 300px;
}
dialog::backdrop { background: #0008; }
dialog p { margin: 0 0 14px; font-size: 16px; }
dialog button { display: block; width: 100%; min-height: 48px; margin-top: 8px; font-size: 16px; }
dialog button.sub { background: transparent; }
