@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

:root {
  --bg:          #0c0c10;
  --surface:     rgba(255,255,255,0.042);
  --surface2:    rgba(255,255,255,0.075);
  --border:      rgba(255,255,255,0.068);
  --border2:     rgba(255,255,255,0.12);
  --text:        #f5f5f7;
  --text-sub:    rgba(245,245,247,0.55);
  --text-muted:  rgba(245,245,247,0.28);
  --blue:        #3b82f6;
  --blue-bright: #60a5fa;
  --blue-glow:   rgba(96,165,250,0.22);
  --blue-light:  #93c5fd;
  --red:         #f87171;
  --red-glow:    rgba(248,113,113,0.25);
  --amber:       #fbbf24;
  --amber-glow:  rgba(251,191,36,0.18);
  --green:       #34d399;
  --green-glow:  rgba(52,211,153,0.32);
  --r-xl:        22px;
  --r-lg:        16px;
  --r-md:        12px;
  --r-sm:        8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* 背景アンビエントグロー */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%,   rgba(59,130,246,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%,  rgba(139,92,246,0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ===== 画面 ===== */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 0 14px 100px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; animation: fadeUp .22s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== ヘッダー ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(20px, env(safe-area-inset-top)) 16px 10px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(12,12,16,0.78);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-bottom: 1px solid rgba(255,255,255,0.046);
  margin: 0 -14px 0;
}
.header-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.icon-btn:active { transform: scale(0.88); background: var(--surface2); }

/* ===== エラーバナー ===== */
.error-banner {
  display: none;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.18);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 13px;
  color: #fca5a5;
  margin: 10px 0 0;
  line-height: 1.5;
}
.error-banner.visible { display: block; }

/* ===== ヒーロー（カウントダウン） ===== */
.hero {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 36px 20px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  margin-bottom: 10px;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 110% 65% at 50% -15%, rgba(96,165,250,0.13) 0%, transparent 65%);
  pointer-events: none;
}

.hero-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
  position: relative;
}

/* カウントダウン本体 */
.countdown-timer {
  font-size: clamp(96px, 26vw, 124px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  position: relative;
  z-index: 1;
  transition: color .4s, font-size .3s;
}
.countdown-timer.warning { color: var(--amber); }
.countdown-timer.urgent  {
  color: var(--red);
  animation: urgentPulse 1s ease-in-out infinite;
}
@keyframes urgentPulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* 単位ラベル */
.countdown-unit {
  display: flex;
  justify-content: center;
  gap: 0;
  margin-top: 5px;
  position: relative;
}
.unit-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.unit-h { margin-left: 8px; margin-right: 46px; }
.unit-m { margin-right: 2px; }

/* 出発・到着チップ */
.time-chips {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 22px;
  position: relative;
}
.chip {
  background: rgba(255,255,255,0.052);
  border: 1px solid var(--border2);
  border-radius: 50px;
  padding: 7px 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 86px;
}
.chip-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.chip-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--blue-light);
  font-variant-numeric: tabular-nums;
}
.chip-arrow { color: var(--text-muted); font-size: 12px; }

.hero-updated {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 14px;
  position: relative;
}

/* ===== 現在地ピル ===== */
.location-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 9px 14px;
  margin-bottom: 10px;
  backdrop-filter: blur(12px);
}
.location-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow);
  flex-shrink: 0;
  animation: blink 2.4s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.18} }
.loc-text { flex:1; font-size:12px; color:var(--text-sub); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.loc-acc  { font-size:11px; color:var(--text-muted); flex-shrink:0; }

/* ===== タクシーカード ===== */
.taxi-card {
  display: none;
  background: var(--surface);
  border: 1px solid rgba(251,191,36,0.14);
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-bottom: 10px;
  backdrop-filter: blur(20px);
  position: relative;
}
.taxi-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 90% 70% at 50% 0%, rgba(251,191,36,0.065) 0%, transparent 70%);
  pointer-events: none;
}
.taxi-inner { padding: 18px; position: relative; }
.taxi-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.taxi-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.taxi-icon-sm { font-size: 15px; }
.taxi-fare {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--amber);
  line-height: 1;
  margin-bottom: 5px;
}
.taxi-fare.unnecessary { color: var(--green); }
.taxi-detail { font-size: 11px; color: var(--text-sub); margin-bottom: 6px; }
.taxi-note   { font-size: 10px; color: var(--text-muted); line-height: 1.5; }

/* ===== ステータスカード ===== */
.status-card {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 40px 20px 32px;
  text-align: center;
  margin-bottom: 10px;
  backdrop-filter: blur(20px);
}
.status-emoji { font-size: 44px; display: block; margin-bottom: 12px; }
.status-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.status-desc  { font-size: 13px; color: var(--text-sub); line-height: 1.7; white-space: pre-line; }

/* ===== 経路カード（折りたたみ） ===== */
.route-card {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-bottom: 10px;
  backdrop-filter: blur(20px);
}
.route-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.route-toggle-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.route-toggle-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.route-summary-text { font-size: 12px; color: var(--text-sub); }
.route-chevron {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform .22s ease;
}
.route-chevron.open { transform: rotate(180deg); }
.route-steps-wrap {
  overflow: hidden;
  max-height: 0;
  transition: max-height .32s ease;
}
.route-steps-wrap.open { max-height: 1200px; }
.route-steps { padding: 0 0 8px; border-top: 1px solid var(--border); }

.route-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  position: relative;
}
.route-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 27px; top: 36px; bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, var(--border2), transparent);
}

/* step-icon は renderRouteSteps が出力するクラス名 */
.step-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  position: relative; z-index: 1;
  margin-top: 1px;
}
.step-icon.transit { background: var(--blue); box-shadow: 0 0 10px var(--blue-glow); }
.step-icon.walk    { background: var(--surface2); border: 1px solid var(--border2); }

.step-body { flex: 1; min-width: 0; }
.step-name   { font-size: 13px; font-weight: 600; margin-bottom: 2px; display:flex; align-items:center; gap:5px; flex-wrap:wrap; }
.step-detail { font-size: 11px; color: var(--text-sub); line-height: 1.5; }
.step-time   { font-size: 11px; font-weight: 600; color: var(--blue-light); white-space: nowrap; text-align:right; line-height:1.7; flex-shrink:0; }
.line-badge  { display:inline-flex; align-items:center; padding:1px 7px; border-radius:20px; font-size:10px; font-weight:700; color:#fff; }

/* ===== ボタン ===== */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px;
  border-radius: var(--r-lg);
  font-size: 15px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all .12s;
  font-family: inherit;
  width: 100%;
}
.btn:active { transform: scale(0.96); }
.btn-primary  { background: var(--blue); color: #fff; box-shadow: 0 4px 20px rgba(59,130,246,0.26); margin-top: 16px; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary{ background: var(--surface2); color: var(--text); border: 1px solid var(--border); margin-top: 10px; }
.btn-danger   { background: rgba(248,113,113,0.07); color: #fca5a5; border: 1px solid rgba(248,113,113,0.18); margin-top: 10px; }
.btn:disabled { opacity: .38; cursor: not-allowed; }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 16px));
  right: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(59,130,246,0.30), 0 0 0 1px rgba(96,165,250,0.14);
  display: flex; align-items: center; justify-content: center;
  transition: transform .14s, box-shadow .14s;
  z-index: 200;
}
.fab:active { transform: scale(0.88); }
.fab.spinning { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 設定画面 ===== */
.settings-group { margin-bottom: 24px; }
.settings-group:first-of-type { margin-top: 16px; }
.settings-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 8px; padding: 0 4px;
}
.settings-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  backdrop-filter: blur(20px);
}
.settings-block-inner { padding: 16px; }
.settings-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
}
.settings-row + .settings-row { border-top: 1px solid var(--border); }
.settings-row-icon  { font-size: 17px; flex-shrink: 0; }
.settings-row-body  { flex: 1; min-width: 0; }
.settings-row-title { font-size: 14px; font-weight: 500; }
.settings-row-value { font-size: 12px; color: var(--text-sub); margin-top: 2px; word-break: break-all; }

.input-group { margin-bottom: 12px; }
.input-group:last-child { margin-bottom: 0; }
.input-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-sub); margin-bottom: 6px; letter-spacing: 0.04em; }
.text-input {
  width: 100%; padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text); font-size: 15px; font-family: inherit;
  outline: none; transition: border-color .15s;
  -webkit-appearance: none;
}
.text-input:focus { border-color: var(--blue); }
.text-input::placeholder { color: var(--text-muted); }
.save-status { margin-top: 10px; font-size: 12px; color: var(--text-sub); text-align: center; min-height: 18px; }

/* ===== 終電なし ===== */
.hero.no-train::before {
  background: radial-gradient(ellipse 110% 65% at 50% -15%, rgba(248,113,113,0.11) 0%, transparent 65%);
}
.hero.no-train .countdown-timer {
  font-size: clamp(40px, 12vw, 58px);
  letter-spacing: -0.02em;
}
