/* スマホ向けの上書き。vendor/annotate.css の後に読む。
   狙いは1つ、「指で押せる大きさにする」こと。色や配色は本家のまま使う。 */

body {
  /* 100vh は iOS でアドレスバーの分だけはみ出す。dvh が使えるならそちらを採る。 */
  height: 100dvh;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ---- 道具箱を指の大きさに ---- */

/* hidden を付けても、annotate.css の display: flex が勝ってしまうので打ち消す。
   これが無いと、画像を開く前から道具箱と操作欄が出てしまう。 */
.tools[hidden], .bar[hidden] { display: none !important; }

.tools {
  gap: 8px;
  padding: 6px 8px;
  padding-top: max(6px, env(safe-area-inset-top));
}

.tools button {
  min-height: 44px;
  min-width: 44px;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
}

/* 指では hover が起きない。押した瞬間の手応えだけ残す。 */
.tools button:hover { background: var(--bg-sunken); color: var(--fg-muted); }
.tools button:active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.tools button.is-active:not(.swatch) { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

.swatch, .tools button.swatch {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
}

/* まとまりの中も折り返させる。これが無いと道具7つが1行に並び、狭い画面で横にはみ出す。 */
.group {
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  min-width: 0;
}
.group-right { margin-left: auto; }

/* 道具だけは折り返さず、横に流して1段に収める。
   折り返すと道具箱が2段になり、そのぶん絵が小さくなって書き込みにくい。
   よく使う順(ペン→蛍光→矢印→四角→丸)に並んでいるので、あふれるのは後ろの2つ。 */
.group[aria-label="道具"] {
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  justify-content: flex-start;
  scrollbar-width: none;
}
.group[aria-label="道具"]::-webkit-scrollbar { display: none; }

/* ---- 絵 ---- */

.stage {
  position: relative;
  padding: 4px;
}

#canvas { box-shadow: 0 1px 6px rgba(0, 0, 0, .2); }

/* ---- 下の操作欄 ---- */

.bar {
  gap: 10px;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.bar .btn {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 15px;
}

.info { font-size: 13px; }

/* ---- 最初の画面 ---- */

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
  max-width: 420px;
  padding: 20px;
  text-align: center;
}
.welcome[hidden] { display: none; }

.welcome-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.big-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-sunken);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.big-btn:active { transform: scale(.98); }
.big-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.big-btn-icon { font-size: 20px; line-height: 1; }

.welcome-steps {
  margin: 0;
  padding-left: 22px;
  text-align: left;
  color: var(--fg-muted);
  line-height: 1.9;
}
.welcome-steps b { color: var(--fg); }

.welcome-note {
  margin: 0;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1.6;
}
.welcome-note[hidden] { display: none; }

/* ---- 知らせ ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .28);
}
.toast[hidden] { display: none; }

.hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* 横向きのときは道具箱が画面を食うので、少しだけ詰める */
@media (orientation: landscape) and (max-height: 480px) {
  .tools button { min-height: 38px; font-size: 13px; }
  .bar .btn { min-height: 38px; }
}
