/* リセットと基本設定 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-deep: #0a1628;
  --bg-card: #0f2040;
  --bg-surface: #162a4e;
  --accent: #06b6d4;
  --accent-dim: #0891b2;
  --accent-glow: rgba(6, 182, 212, 0.3);
  --text-primary: #f0f9ff;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --danger: #f43f5e;
  --success: #10b981;
  --border: rgba(6, 182, 212, 0.2);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: -apple-system, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ヘッダー */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.app-header .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 16px;
  text-decoration: none;
  padding: 4px 0;
}

/* メインコンテンツ */
.main-content {
  padding: 16px;
  padding-bottom: calc(80px + var(--safe-bottom));
  min-height: 100vh;
}

/* 統計バー */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.stat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  display: block;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* 釣果カード */
.catch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.catch-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s, border-color 0.15s;
  -webkit-user-select: none;
}

.catch-card:active {
  transform: scale(0.97);
  border-color: var(--accent);
}

.catch-card .photo {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--bg-surface);
  display: block;
}

.catch-card .photo-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--text-muted);
}

.catch-card .card-body {
  padding: 10px 12px;
}

.catch-card .fish-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catch-card .fish-size {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.catch-card .fish-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 空状態 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 64px;
  margin-bottom: 16px;
  display: block;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.8;
}

/* FAB（追加ボタン） */
.fab {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a1628;
  font-size: 28px;
  font-weight: 300;
  border: none;
  box-shadow: 0 4px 20px var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 200;
}

.fab:active {
  transform: scale(0.93);
  box-shadow: 0 2px 10px var(--accent-glow);
}

/* フォーム */
.form-section {
  margin-bottom: 24px;
}

.form-section h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group textarea {
  resize: none;
  height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* 天気ピッカー */
.weather-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.weather-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.weather-btn svg {
  width: 28px;
  height: 28px;
}

.weather-btn span {
  font-size: 11px;
  font-family: inherit;
}

.weather-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(6, 182, 212, 0.08);
}

/* 写真エリア */
.photo-area {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: 16px;
  aspect-ratio: 4/3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  margin-bottom: 12px;
}

.photo-area img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
}

.photo-area .photo-hint {
  text-align: center;
  color: var(--text-muted);
  z-index: 1;
}

.photo-area .photo-hint svg {
  display: block;
  margin: 0 auto 8px;
}

.photo-area .photo-hint span {
  font-size: 14px;
}

.photo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

/* ボタン */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, opacity 0.1s;
  -webkit-user-select: none;
}

.btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.btn-primary {
  background: var(--accent);
  color: #0a1628;
  width: 100%;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  width: 100%;
  margin-top: 12px;
}

/* メジャー機能 */
.measure-container {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  touch-action: none;
}

.measure-canvas {
  width: 100%;
  display: block;
}

.measure-instructions {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.6;
}

.measure-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.measure-step:last-child {
  border-bottom: none;
}

.measure-step .step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a1628;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.measure-step.active .step-num {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.measure-step.done .step-num {
  background: var(--success);
}

.measure-result {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin-bottom: 12px;
}

.measure-result .length-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
}

.measure-result .length-unit {
  font-size: 18px;
  color: var(--text-secondary);
}

/* 詳細画面 */
.detail-photo {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: var(--bg-card);
  display: block;
}

.detail-photo-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  color: var(--text-muted);
}

.detail-body {
  padding: 16px;
}

.detail-fish-name {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.detail-fish-size {
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.detail-fish-size span {
  font-size: 24px;
  font-weight: 400;
  color: var(--text-secondary);
}

.detail-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-meta-item .label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.detail-meta-item .value {
  font-size: 15px;
  color: var(--text-primary);
  font-weight: 500;
}

.detail-memo {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

/* トースト通知 */
.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-primary);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* スクロールバー非表示 */
::-webkit-scrollbar {
  display: none;
}
