/* 書類スキャン → Slack。スマホ縦持ち・画面いっぱい */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* hidden 属性で確実に隠す（display 指定に負けないように） */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #101418;
  color: #ffffff;
  font-size: 16px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* ルート: 画面いっぱいの縦flex。safe-area を避ける */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.titlebar {
  flex-shrink: 0;
  height: 52px;
  line-height: 52px;
  text-align: center;
  font-weight: bold;
  background: #1a2026;
}

/* 映像・キャンバスを置く領域 */
.stage,
.cam-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000000;
}

#cam-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 4隅の確認: 余白は canvas 側（JSのCROP_MARGIN=24px）に持たせるので、ステージの padding は 0 */
#crop-stage {
  padding: 0;
  box-sizing: border-box;
  touch-action: none;
}

#crop-canvas {
  display: block;
  touch-action: none;
}

.hint {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  text-align: center;
  line-height: 1.5;
}

/* 下部のボタン列 */
.bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 8px;
  padding: 8px;
  flex-wrap: wrap;
}

.btn {
  min-height: 48px;
  min-width: 0;
  flex: 1;
  padding: 0 12px;
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
}

.btn.main {
  background: #1976d2;
}

.btn.sub {
  background: #37474f;
}

.btn.ok {
  background: #2e7d32;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn.small {
  min-height: 44px;
  padding: 0 4px;
}

/* 撮影ボタン（大きな丸） */
.shutter {
  flex: none;
  width: 76px;
  height: 76px;
  min-height: 0;
  padding: 0;
  border: 5px solid #1976d2;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
}

.shutter:disabled {
  opacity: 0.45;
}

/* 文言（情報・エラー・警告・成功） */
.msg {
  margin: 8px;
  padding: 10px;
  border-radius: 8px;
  line-height: 1.5;
  font-size: 16px;
}

.msg.info {
  color: #cfd8dc;
  background: #263238;
}

.msg.err {
  color: #ff8a80;
  background: #3e1e1e;
}

.msg.alert {
  color: #ffffff;
  background: #d32f2f;
}

.msg.ok {
  color: #ffffff;
  background: #2e7d32;
}

/* 画面C: フィルタ */
.filters,
.formats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px;
  padding: 8px;
  border: 1px solid #455a64;
  border-radius: 10px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 8px;
  background: #1a2026;
  font-size: 16px;
}

.chip input {
  width: 20px;
  height: 20px;
  margin: 0;
}

/* 画面C: ページ一覧 */
.page-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px;
}

.page-card {
  padding: 8px;
  border-radius: 12px;
  background: #1a2026;
}

.page-head {
  margin-bottom: 6px;
  font-weight: bold;
}

.page-preview {
  display: block;
  width: 100%;
  height: auto;
  background: #ffffff;
}

.page-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}

/* 画面D: 送信フォーム */
.form {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #455a64;
  border-radius: 8px;
  background: #1a2026;
  color: #ffffff;
  font-size: 16px;
  font-family: inherit;
  -webkit-user-select: text;
  user-select: text;
}

.formats {
  margin: 0;
  flex-direction: column;
  align-items: stretch;
}

.formats legend {
  padding: 0 4px;
}

.summary {
  font-size: 18px;
  font-weight: bold;
}
