/* ===== リセット & 変数 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary:      #1B4332;
  --c-primary-mid:  #2D6A4F;
  --c-accent:       #40916C;
  --c-accent-light: #74C69D;
  --c-bg:           #F0F7F4;
  --c-surface:      #FFFFFF;
  --c-border:       #D8EDE3;
  --c-text:         #1A2E25;
  --c-text-sub:     #4A7C59;
  --c-danger:       #C0392B;
  --radius:         14px;
  --radius-sm:      8px;
  --shadow:         0 4px 24px rgba(27,67,50,.14);
  --shadow-sm:      0 2px 10px rgba(27,67,50,.10);
  --safe-bottom:    env(safe-area-inset-bottom, 0px);
  --safe-top:       env(safe-area-inset-top, 0px);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ===== 画面切り替え ===== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .22s ease, transform .22s ease;
  will-change: opacity, transform;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ===== ホーム画面 ===== */
.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(var(--safe-top) + 20px) 24px 20px;
  background: var(--c-primary);
  color: white;
}
.app-header svg { width: 44px; height: 44px; flex-shrink: 0; }
.app-title  { font-size: 26px; font-weight: 800; letter-spacing: .04em; }
.app-subtitle { font-size: 12px; opacity: .72; margin-top: 1px; }

.home-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 28px 20px calc(var(--safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-text-sub);
  margin-bottom: 14px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .18s ease;
  box-shadow: var(--shadow-sm);
  outline: none;
  -webkit-appearance: none;
}
.category-card:active { transform: scale(.97); }
.category-card.selected {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: white;
  box-shadow: var(--shadow);
}
.category-icon { font-size: 36px; line-height: 1; }
.category-name { font-size: 15px; font-weight: 700; text-align: center; }

/* ===== ボタン ===== */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--c-accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: all .18s ease;
  -webkit-appearance: none;
  box-shadow: var(--shadow);
}
.btn-primary svg { width: 22px; height: 22px; }
.btn-primary:disabled {
  background: #9BB8A8;
  box-shadow: none;
  cursor: default;
}
.btn-primary:not(:disabled):active { transform: scale(.97); background: var(--c-primary-mid); }

.btn-large { padding: 18px 28px; width: 100%; }

.btn-text {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--c-accent);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  outline: none;
  -webkit-appearance: none;
  min-width: 80px;
}
.btn-text svg { width: 17px; height: 17px; }
.btn-text:active { opacity: .7; }

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: none;
  cursor: pointer;
  color: white;
  outline: none;
  -webkit-appearance: none;
}
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:active { background: rgba(255,255,255,.32); }

/* ===== カメラ画面 ===== */
#screen-camera {
  background: #000;
}

.camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-overlay-top {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 14px) 16px 14px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
}

.category-badge {
  flex: 1;
  font-size: 14px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}

.gps-status {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.gps-status.loading { background: rgba(255,220,50,.22); color: #FFE066; }
.gps-status.ok      { background: rgba(74,198,120,.22); color: #7EEA9F; }
.gps-status.error   { background: rgba(220,80,80,.22);  color: #FF9090; }

.camera-overlay-bottom {
  position: relative;
  z-index: 10;
  margin-top: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px 0 calc(var(--safe-bottom) + 40px);
  background: linear-gradient(to top, rgba(0,0,0,.5), transparent);
}

.capture-ring {
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-capture {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: white;
  border: none;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, background .12s ease;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.btn-capture:active { transform: scale(.88); background: #eee; }
.capture-inner {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: white;
  border: 3px solid #D0D0D0;
}

/* ===== レビュー画面 ===== */
.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.review-title { font-size: 17px; font-weight: 700; }

.review-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.review-image-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #111;
  aspect-ratio: 4/3;
}
.review-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.review-image-info {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 10px 12px;
  background: linear-gradient(to top, rgba(0,0,0,.6), transparent);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}
.review-badge {
  font-size: 13px;
  font-weight: 700;
  color: white;
  background: rgba(255,255,255,.18);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 20px;
}
.review-time {
  font-size: 11px;
  color: rgba(255,255,255,.8);
}

.review-meta {
  background: var(--c-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  overflow: hidden;
}
.meta-row {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--c-text-sub);
  display: flex;
  align-items: center;
  gap: 8px;
}

.memo-section { display: flex; flex-direction: column; gap: 8px; }
.memo-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-sub);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.memo-label svg { width: 15px; height: 15px; }

.memo-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.5;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  resize: none;
  outline: none;
  -webkit-appearance: none;
  transition: border-color .15s;
}
.memo-textarea:focus { border-color: var(--c-accent); }
.memo-textarea::placeholder { color: #A0BAB0; }
.memo-count {
  text-align: right;
  font-size: 12px;
  color: var(--c-text-sub);
}

.review-footer {
  padding: 12px 16px calc(var(--safe-bottom) + 16px);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
}
.btn-save { padding: 17px 28px; width: 100%; background: var(--c-primary); }
.btn-save:not(:disabled):active { background: var(--c-primary-mid); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 90px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(27,67,50,.92);
  color: white;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  z-index: 9999;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
