/* =============================================
   バスナビ PWA — 共通スタイル（ダークテーマ）
   ============================================= */
:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface2:    #21262d;
  --border:      #30363d;
  --primary:     #388bfd;
  --primary-dim: #1c3358;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --success:     #3fb950;
  --warning:     #d29922;
  --error:       #f85149;
  --walk-color:  #8b949e;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: calc(16px + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
}

/* ── ヘッダー ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── ボタン ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.1s, transform 0.1s;
  text-decoration: none;
  width: 100%;
}
.btn:active { opacity: 0.72; transform: scale(0.98); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(248,81,73,0.15); color: var(--error); border: 1px solid rgba(248,81,73,0.3); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  min-height: 44px;
  min-width: 44px;
  width: auto;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  transition: background 0.1s;
}
.btn-icon:active { background: var(--surface2); }

/* ── コンテンツ ── */
.content { padding: 16px; }

.section { margin-bottom: 20px; }
.section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

/* ── 目的地リスト ── */
.dest-list { display: flex; flex-direction: column; gap: 8px; }

.dest-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
  min-height: 72px;
  text-align: left;
  width: 100%;
  font: inherit;
  color: var(--text);
}
.dest-item:active { border-color: var(--primary); background: var(--surface2); }

.dest-icon {
  width: 44px;
  height: 44px;
  background: var(--primary-dim);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.dest-info { flex: 1; min-width: 0; }
.dest-name { font-size: 16px; font-weight: 600; }
.dest-address {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dest-arrow { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }

/* ── 削除ボタン（設定画面用） ── */
.delete-btn {
  background: none;
  border: none;
  color: var(--error);
  min-height: 44px;
  min-width: 44px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: background 0.1s;
}
.delete-btn:active { background: rgba(248,81,73,0.15); }

/* ── タブ ── */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  min-height: 48px;
  min-width: 80px;
  padding: 10px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── ルートサマリー ── */
.route-summary {
  background: var(--surface2);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.route-summary-left { display: flex; align-items: baseline; gap: 8px; }
.time-big { font-size: 32px; font-weight: 700; line-height: 1; }
.time-unit { font-size: 16px; color: var(--text-muted); }
.route-summary-right { text-align: right; }
.depart-arrive { font-size: 14px; font-weight: 500; }
.route-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── ルートステップ ── */
.steps-container { display: flex; flex-direction: column; }

.step {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  position: relative;
}

.step-timeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 36px;
  flex-shrink: 0;
  padding-top: 4px;
}
.step-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  z-index: 1;
}
.step-dot.bus   { background: var(--primary); }
.step-dot.walk  { background: var(--text-muted); }
.step-dot.start { background: var(--success); }
.step-dot.end   { background: var(--error); }

.step-line {
  width: 2px;
  flex: 1;
  min-height: 16px;
  background: var(--border);
  margin: 4px 0;
}
.step-line.bus { background: var(--primary); }

.step-body { flex: 1; padding-bottom: 8px; }

.step-time-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-weight: 500;
}
.step-main { font-size: 14px; font-weight: 600; line-height: 1.3; }
.step-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

.bus-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-dim);
  color: var(--primary);
  margin-top: 4px;
}
.walk-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── 入力フィールド ── */
.input-group { margin-bottom: 12px; }
.input-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; display: block; font-weight: 500; }
.input {
  width: 100%;
  padding: 13px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  min-height: 50px;
  appearance: none;
  -webkit-appearance: none;
}
.input:focus { border-color: var(--primary); }
.input::placeholder { color: var(--border); }

/* ── ローディング ── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── エラー ── */
.error-box {
  background: rgba(248,81,73,0.08);
  border: 1px solid rgba(248,81,73,0.35);
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  margin: 16px;
}
.error-box .error-icon { font-size: 36px; margin-bottom: 10px; }
.error-box .error-title { font-size: 15px; font-weight: 600; color: var(--error); margin-bottom: 6px; }
.error-box .error-msg { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ── 空状態 ── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 52px; margin-bottom: 14px; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 13px; line-height: 1.6; }

/* ── トースト ── */
#toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  z-index: 999;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ── API KEY 状態 ── */
.api-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 0;
}
.api-status.ok { color: var(--success); }
.api-status.ng { color: var(--error); }

/* ── 区切り線 ── */
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── 位置情報バー ── */
.loc-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.loc-bar.ok { border-color: var(--success); color: var(--success); }
.loc-bar.err { border-color: var(--error); color: var(--error); }
