/* 歯列図の上の手書きメモ。canvasは zoom のかからない stage に重ねる。 */
.tooth-memo-stage { position: relative; width: fit-content; margin: 0 auto 12px; }
.tooth-memo-stage > .tooth-diagram { margin: 0; }
.tooth-memo-canvas { position: absolute; inset: 0; z-index: 3; width: 100%; height: 100%; border-radius: 14px; pointer-events: none; }
.tooth-memo-canvas.is-drawing { box-shadow: inset 0 0 0 2px rgba(197, 156, 88, .7); cursor: crosshair; pointer-events: auto; touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

.tooth-memo-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.tooth-memo-tools__pens { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tooth-memo-tools__pens[hidden] { display: none; }
.tooth-memo-tools button { min-width: 40px; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--green-dark); font: inherit; font-size: 13px; cursor: pointer; touch-action: manipulation; }
.tooth-memo-tools button:disabled { opacity: .4; cursor: default; }
.tooth-memo-tools button[aria-pressed="true"] { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.tooth-memo-tools button:focus-visible { outline: 3px solid rgba(197, 156, 88, .45); outline-offset: 1px; }
.tooth-memo-tools .tooth-memo-color { width: 40px; padding: 0; background-clip: content-box; border-radius: 999px; padding: 8px; }
.tooth-memo-tools .tooth-memo-color[aria-pressed="true"] { background-clip: content-box; }
.tooth-memo-tools .tooth-memo-color--black, .tooth-memo-tools .tooth-memo-color--black[aria-pressed="true"] { background-color: #1c2624; }
.tooth-memo-tools .tooth-memo-color--red, .tooth-memo-tools .tooth-memo-color--red[aria-pressed="true"] { background-color: #d32f2f; }
.tooth-memo-tools .tooth-memo-color--blue, .tooth-memo-tools .tooth-memo-color--blue[aria-pressed="true"] { background-color: #1a5fc4; }
.tooth-memo-tools__status { min-width: 0; margin: 0; color: var(--muted); font-size: 12px; }
.tooth-memo-tools__status.is-error { color: var(--danger); font-weight: 700; }
.tooth-memo-viewer .tooth-memo-tools__status:empty { display: none; }

/* 書いている間はパネルをスクロールできないので、歯の選択の案内を隠して歯列図に場所を譲る。 */
.is-tooth-memo-drawing > .tooth-chart-dialog__help,
.is-tooth-memo-drawing .tooth-chart__clear,
.is-tooth-memo-drawing [data-tooth-selection] { display: none; }
.tooth-chart-dialog.is-tooth-memo-drawing .tooth-chart__panel { max-height: none; }
.tooth-chart-dialog.is-tooth-memo-drawing .tooth-chart__footer { position: static; display: block; width: auto; min-width: 0; }
.tooth-chart-dialog.is-tooth-memo-drawing .tooth-chart__footer .tooth-chart__done { display: block; width: 100%; }
@media (max-height: 520px) {
  .tooth-chart-dialog.is-tooth-memo-drawing { width: calc(100% - 8px); max-width: none; max-height: calc(100dvh - 8px); }
  .is-tooth-memo-drawing > header { display: none; }
  .tooth-chart-dialog.is-tooth-memo-drawing .tooth-chart__panel { display: grid; grid-template-areas: "stage tools" "stage footer"; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 0 12px; align-items: start; }
  .is-tooth-memo-drawing .tooth-memo-stage { grid-area: stage; margin: 0; }
  .is-tooth-memo-drawing .tooth-memo-tools { grid-area: tools; }
  .is-tooth-memo-drawing .tooth-chart__footer { grid-area: footer; }
}

/* 処置行の「メモあり」印。編集できない行でも押せるようリンクにしている。 */
.tooth-memo-chip { position: relative; display: inline-grid; width: 24px; height: 24px; place-items: center; border: 1px solid #dcb777; border-radius: 999px; background: #fff3d6; color: #7a5200; font-size: 13px; line-height: 1; text-decoration: none; vertical-align: middle; }
.tooth-memo-chip[hidden] { display: none; }
.tooth-memo-chip::after { position: absolute; inset: -9px; content: ""; }
.tooth-memo-chip:focus-visible { outline: 3px solid rgba(197, 156, 88, .45); outline-offset: 1px; }
.tooth-picker { position: relative; }
.tooth-picker > .tooth-memo-chip { position: absolute; top: -7px; right: -7px; z-index: 1; width: 22px; height: 22px; font-size: 12px; }

/* 2026-11-05: 小さい画面でも「選択をすべて解除」「決定」をスクロールせずに押せるようにする。
   小窓を縦の flex にして歯列図の欄を残りの高さに収め（歯列図の縮小は admin-detail-layout.js）、
   欄が高さに収まらない場合も下部のボタンは欄の下端に固定する。 */
.tooth-chart-dialog[open] { display: flex; flex-direction: column; }
.tooth-chart-dialog[open] > header, .tooth-chart-dialog[open] > .tooth-chart-dialog__help { flex: 0 0 auto; }
.tooth-chart-dialog[open] .tooth-chart__panel { flex: 1 1 auto; min-height: 0; max-height: none; padding-bottom: 0; }
.tooth-chart-dialog .tooth-chart__footer { position: sticky; bottom: 0; left: 0; z-index: 5; padding-bottom: 14px; background: #fbfcfb; }
/* 固定した帯は欄の左右の余白まで広げ、後ろの歯列図が透けないようにする（歯列図は横幅に収めるので横のスクロールは出ない）。 */
.tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) .tooth-chart__footer { width: auto; margin-inline: -14px; padding-inline: 14px; }
/* 横長で高さが足りない画面（横向きのスマホ・iPadの横向き・ノートPC）: 手書き中の横向きと同じく、歯列図を左、
   手書き・ボタンを右に並べて歯列図を高さに収める（歯をなるべく小さくしない）。縦長の画面は上の縦並びのまま。 */
@media (min-aspect-ratio: 1/1) and (max-height: 930px) {
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) { width: min(900px, calc(100% - 16px)); max-width: none; }
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) .tooth-chart__panel { display: grid; grid-template-areas: "stage tools" "stage footer"; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 0 16px; align-items: start; padding-bottom: 14px; }
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) .tooth-memo-stage,
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) .tooth-chart__panel > .tooth-diagram { grid-area: stage; margin: 0; }
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) .tooth-memo-tools { grid-area: tools; }
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) .tooth-chart__footer { grid-area: footer; position: static; display: grid; align-self: end; width: auto; min-width: 0; grid-template-columns: 1fr; gap: 8px; margin-inline: 0; padding: 10px 0 0; }
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) .tooth-chart__clear, .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) .tooth-chart__done { width: 100%; min-width: 0; }
}
/* さらに高さの低い画面（横向きのスマホ）: 見出しを詰め、案内文を隠して歯列図に場所を譲る。 */
@media (max-height: 520px) {
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) { width: calc(100% - 8px); max-height: calc(100dvh - 8px); }
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) > header { padding: 8px 14px 6px; }
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) > header h3 { font-size: 16px; }
  .tooth-chart-dialog[open]:not(.is-tooth-memo-drawing) > .tooth-chart-dialog__help { display: none; }
}
/* 2026-11-12: 「選択をすべて解除」の文字を大きく（10px → 16px）。押せる範囲も少し広げる。手書き中は従来どおり隠す。 */
.tooth-chart-dialog .tooth-chart__clear { min-height: 40px; padding: 8px 12px; font-size: 16px; line-height: 1.2; }
