body {
  font-family: sans-serif;
  margin: 0;
  background: #222;
  color: white;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.view-area {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  /* touch-action: none でブラウザのデフォルトタッチ操作（スクロール・戻る/進む）を無効化 */
  touch-action: none;
}

/* キャンバスコンテナ: キャンバスとボタンを包むラッパー */
.canvas-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* アップロードプロンプト: 画像未選択時に表示されるメッセージ */
.upload-prompt {
  text-align: center;
  color: #888;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-prompt p:first-child {
  font-size: 64px;
  margin-bottom: 10px;
}

.upload-prompt p:nth-child(2) {
  font-size: 18px;
  color: #aaa;
  margin-bottom: 24px;
}

/* アップロードボタン: 画像未選択時に中央に表示される大きなボタン */
.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 36px;
  background: #007bff;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  box-shadow: 0 4px 16px rgba(0, 123, 255, 0.4);
}

.upload-btn:hover {
  background: #0056b3;
  transform: scale(1.05);
}

.upload-btn:active {
  transform: scale(0.97);
}

/* フローティングボタン: キャンバス内の上部に配置 */
.floating-buttons {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 100;
}

/* アイコンボタン: 丸い形状の小さなボタン */
.btn-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.btn-icon:hover {
  transform: scale(1.1);
  background: #fff;
}

.btn-icon:active {
  transform: scale(0.95);
}

/* プライマリアイコンボタン（画像選択）: 青色 */
.btn-icon--primary {
  background: #007bff;
  color: white;
}

.btn-icon--primary:hover {
  background: #0056b3;
}

/* 保存アイコンボタン: 緑色 */
.btn-icon--save {
  background: #28a745;
  color: white;
}

.btn-icon--save:hover {
  background: #218838;
}

/* AI加工アイコンボタン: 紫色 */
.btn-icon--ai {
  background: #7c3aed;
  color: white;
}

.btn-icon--ai:hover {
  background: #6d28d9;
}

/* hiddenクラスとの組み合わせで確実に非表示 */
.btn-icon.hidden {
  display: none;
}

/* 入力フィールドグループ: 物件名・号室・日付・メモをまとめるコンテナ */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* 入力行: 物件名と号室を横並びにするコンテナ */
.input-row {
  display: flex;
  gap: 8px;
  min-width: 0;
}

/* 各入力フィールド: ラベルと入力欄をまとめるコンテナ */
.input-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

/* 小さい入力フィールド（号室用） */
.input-field--small {
  flex: 0 0 80px;
  min-width: 60px;
}

.input-field label {
  font-size: 10px;
  font-weight: bold;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-field input,
.input-field textarea {
  width: 100%;
  box-sizing: border-box;
}

input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  min-width: 0;
}

/* 物件名・号室・日付の入力フィールド: 小さいフォントサイズ */
#aptName,
#roomNo,
#dateInput {
  font-size: 12px;
}

/* 日付行: 日付入力とモード切り替えボタンを上下に配置 */
.date-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: none;
  min-width: 0;
}

.date-row input {
  flex: none;
  width: 100%;
}

.date-row .btn-toggle {
  width: 100%;
}

/* 日付モード切り替えボタン */
.btn-toggle {
  padding: 8px 10px;
  background: #6c757d;
  color: white;
  font-size: 14px;
  min-width: 40px;
}

textarea {
  flex: 1;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
  min-width: 0;
  resize: vertical;
}

.memo {
  flex: 2;
}

button {
  padding: 10px;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
}


/* カウンター: 現在の画像番号/全画像数を表示 */
.counter {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.6);
  padding: 5px 12px;
  border-radius: 15px;
  z-index: 20;
}

.hidden {
  display: none;
}


/* モーダル: 全画面オーバーレイ + 中央配置コンテンツ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* モーダル非表示時: hiddenクラスと組み合わせて詳細度を上げる */
.modal.hidden {
  display: none;
}

/* モーダル背景オーバーレイ: 半透明の黒 */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
}

/* モーダルコンテンツ: 白背景の中央カード */
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.25s ease-out;
}

/* モーダルスライドインアニメーション */
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* モーダルヘッダー: タイトルと閉じるボタン */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  color: #333;
}

/* 閉じるボタン: 右上の × */
.btn-close {
  background: none;
  border: none;
  font-size: 28px;
  color: #999;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.btn-close:hover {
  color: #333;
}

/* モーダル本体: 入力フォームを含むエリア */
.modal-body {
  padding: 20px;
}

.modal-body .input-group {
  gap: 12px;
}

.modal-body .input-field label {
  font-size: 12px;
}

.modal-body input,
.modal-body textarea {
  font-size: 14px;
  padding: 10px;
}

/* 黒板表示/非表示トグルボタン */
.btn-blackboard-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: #016563;
  color: white;
  font-size: 14px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-blackboard-toggle:hover {
  background: #014f4d;
}

.btn-blackboard-toggle--off {
  background: #6c757d;
}

.btn-blackboard-toggle--off:hover {
  background: #5a6268;
}

/* AI加工実行ボタン */
.btn-ai-submit {
  width: 100%;
  padding: 12px;
  background: #7c3aed;
  color: white;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-ai-submit:hover {
  background: #6d28d9;
}

.btn-ai-submit:disabled {
  background: #a78bfa;
  cursor: not-allowed;
}

/* AI加工ローディング表示 */
.ai-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  color: #555;
  font-size: 14px;
}

.ai-loading.hidden {
  display: none;
}

/* スピナーアニメーション */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e5e7eb;
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* AIエラーメッセージ */
.ai-error {
  padding: 10px 14px;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 13px;
  word-break: break-word;
}

.ai-error.hidden {
  display: none;
}

/* モバイル向けレイアウト: ボタンを小さく */
@media (max-width: 600px) {
  .floating-buttons {
    bottom: calc(15px + env(safe-area-inset-bottom));
    gap: 8px;
    padding: 8px 12px;
  }

  .btn-icon {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
}