:root {
  --primary-color: white;
  --bg-color: #f4f7f6;
  --text-color: #333333;
  --radius: 16px;
  --tab-height: 80px;
  --guide-max-width: 920px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "M PLUS Rounded 1c", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- ヘッダー --- */
.app-header {
  background: #5d4037;
  height: 60px;
  padding: 6px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-header h1 {
  font-size: 2rem;
  color: var(--primary-color);

  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1;
}
.app-header img {
  height: 30px;
  display: block;
}

/* --- メインコンテンツエリア --- */
.content-area {
  background: #fff;
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--tab-height) + 20px);
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}
.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- ミニフッター（操作メニュー） --- */
.sub-btn {
  background: transparent;
  color: #999999;
  border: none;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.sub-btn:active {
  transform: scale(0.92);
  background: transparent;
}

#sub-camera.camera-actions {
  left: 0;
  right: 0;
  bottom: 0; /* ← 10px をやめて下端に密着 */
  padding: 10px 10px; /* ← 背景を端まで伸ばして、中身だけ余白 */
  background-color: rgba(255, 255, 255, 0.678);
}

.sub-btn img {
  width: 50px;
  height: auto;
  display: block;
}

.camera-actions .sub-btn {
  width: 140px;
}

.camera-actions .sub-btn > span:first-child {
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-actions .sub-btn > span:last-child {
  width: 100%;
  text-align: center;
  line-height: 1.2;
}

.tab-bar .tab-img {
  max-width: 50px;
  max-height: 30px;
  display: block;
}

/* --- タブバー（メインフッター） --- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--tab-height);
  background: #5d4037;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid #eee;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 100;
  height: var(--tab-height);
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s;
}
.tab-item.active {
  color: var(--primary-color);
}
.tab-icon {
  font-size: 1.6rem;
  margin-bottom: 2px;
}

/* --- 各画面要素 --- */
.camera-container {
  --cam-size: min(50vh, calc(100vw - 32px));

  width: var(--cam-size);
  height: var(--cam-size);
  margin: 10px auto 10px auto;

  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.camera-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: space-around;
  gap: 12px;
  padding: 0 10px;
  z-index: 10;
}

video,
canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hidden {
  display: none !important;
}
.info-area {
  width: min(92vw, 520px);
  margin: 0 auto 16px;
  background: #fff;
  border-radius: var(--radius);
  padding: 12px;
}

.camera-container img.preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.label-area {
  width: 100%;
  height: 10px;
}

/* メインラベル */
.main-label {
  width: 100%;
  margin: 4px 0 8px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 進捗バー */
.progress {
  display: flex;
  width: 100%;
  height: 12px;
  gap: 4px;
  align-items: center;
}

.seg {
  display: block;
  height: 100%;
  border-radius: 4px;
  flex: 0 0 auto;
}

.seg-1 {
  background-color: #a76956;
}
.seg-2 {
  background-color: #aaba78;
}
.seg-3 {
  background-color: #cba59a;
}
.seg-4 {
  background-color: #874577;
}
.seg-5 {
  background-color: #a89357;
}
.seg-6 {
  background-color: #a8576c;
}

/* 凡例 */
.legend {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(24px, auto);
  gap: 8px 16px;
  padding: 6px 0 0;
  margin: 0;
  font-size: 16px;
  color: #555;
  font-feature-settings: "tnum" 1;
  max-height: 120px;
  overflow-y: auto;
}

.legend li {
  display: flex;
  align-items: center;
  min-width: 0;
}

.legend li span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  margin-top: 1px;
}

.dot-1 {
  background-color: #a76956;
}
.dot-2 {
  background-color: #aaba78;
}
.dot-3 {
  background-color: #cba59a;
}
.dot-4 {
  background-color: #874577;
}
.dot-5 {
  background-color: #a89357;
}
.dot-6 {
  background-color: #a8576c;
}

.guide-wrap {
  padding: 19px;

  width: 100%;
  max-width: var(--guide-max-width);
  margin: 0 auto; /* 全体を中央寄せ */
  box-sizing: border-box;
}

.guide-title1 {
  color: #5d4037;
  font-size: 1.2rem;
  margin: 10px;
  text-align: center;
}

.guide-title2 {
  color: #5d4037;
  font-size: 1.2rem;
  margin-bottom: 10px;
}

.guide-empty {
  color: #777;
  font-size: 0.9rem;
  margin: 10px 0;
}

/* グループ（トグル＋パネル）も同じ幅に揃える */
.guide-group,
.guide-toggle,
.guide-panel,
.guide-table-scroll {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.guide-table-scroll {
  overflow: auto;
  border: 1px solid #eee;
  border-radius: 12px;
}

/* トグル */
.guide-toggle {
  text-align: left; /* 中央にしたいなら center */
  padding: 12px 14px;
  color: white;
  font-weight: 700;
  border: 1px solid #ddd;
  background: #614e48;
  border-radius: 8px;
  margin: 5px;
}

/* パネル（表のスクロールはここ） */
.guide-panel {
  padding: 8px 0 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* テーブル：panel幅に合わせる（必要なら min-width 分だけ横スクロール） */
.guide-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: #fff;
}

#guide-table-wrap {
  overflow: visible;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
  margin: 0;
}

.guide-table th,
.guide-table td {
  padding: 10px;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
  text-align: center;
  vertical-align: middle;
}

.guide-table th {
  position: sticky;
  top: 0;
  background: #fafafa;
  z-index: 1;
}

/* 画像も中央揃え */
.guide-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  margin: 0 auto;
}
