/* =====================================================================
 * 버스련 언제와 — 스타일
 * 모바일 웹앱 느낌 (iOS 스타일). 데스크톱에선 폰 프레임 안에 표시.
 * =================================================================== */

:root {
  --brand: #1f6feb;
  --brand-2: #4d9dff;
  --bg: #f2f4f8;
  --card: #ffffff;
  --ink: #1a2130;
  --ink-sub: #7b8494;
  --line: #e7eaf0;
  --danger: #ff4d5e;
  --ok: #16b364;

  /* 버스 유형 색 */
  --t-blue: #1f6feb;   /* 간선 */
  --t-green: #16b364;  /* 지선 */
  --t-red: #e5484d;    /* 광역 */
  --t-circle: #f59e0b; /* 순환 */
  --t-vill: #16b364;   /* 마을 */
  --t-air: #14b8c4;    /* 공항 */

  --radius: 16px;
  --shadow: 0 6px 24px rgba(20, 30, 55, 0.10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Pretendard", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 20% -10%, #2b4cff22, transparent),
    radial-gradient(1000px 500px at 90% 0%, #00c2ff22, transparent),
    #0e1524;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  overflow: hidden;
}

/* ---------- 폰 프레임 (데스크톱) ---------- */
.phone {
  width: 400px;
  height: 860px;
  max-height: 96dvh;
  background: #000;
  border-radius: 46px;
  padding: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 0 0 2px #1c1c22;
}
.app {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--bg);
  border-radius: 36px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 모바일: 프레임 없이 전체화면 */
@media (max-width: 480px) {
  body { display: block; overflow: auto; }
  .phone {
    width: 100%; height: 100dvh; max-height: none;
    border-radius: 0; padding: 0; box-shadow: none;
  }
  .app { border-radius: 0; }
}

/* ---------- 앱바 ---------- */
.appbar {
  flex: 0 0 auto;
  height: 56px;
  padding: 0 8px;
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 2px 12px rgba(31, 111, 235, 0.35);
  z-index: 5;
}
.appbar-back {
  border: 0; background: transparent; color: #fff;
  font-size: 30px; line-height: 1; width: 40px; height: 40px;
  cursor: pointer; visibility: hidden; border-radius: 12px;
}
.appbar-back:active { background: rgba(255,255,255,.18); }
.appbar-title {
  flex: 1; margin: 0; font-size: 18px; font-weight: 700;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.appbar-spacer { width: 40px; }

/* ---------- 화면 스크롤 영역 ---------- */
.screen {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 90px;
}
.screen::-webkit-scrollbar { width: 0; }

/* ---------- 탭바 ---------- */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--ink-sub); font-size: 11px; font-weight: 600;
  transition: color .15s, transform .1s;
}
.tab-ico { font-size: 21px; filter: grayscale(.4); opacity: .7; }
.tab.active { color: var(--brand); }
.tab.active .tab-ico { filter: none; opacity: 1; transform: translateY(-1px); }
.tab:active { transform: scale(.94); }

/* ---------- 홈 히어로 ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand), #6aa9ff);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.hero-hi { margin: 0 0 14px; font-size: 22px; font-weight: 800; }
.hero-loc {
  width: 100%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.22);
  color: #fff; font-size: 16px; font-weight: 700;
  padding: 14px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, transform .1s;
}
.hero-loc:active { background: rgba(255, 255, 255, 0.34); transform: scale(.98); }
.hero-loc .ico { font-size: 18px; }
.hero-sub { margin: 12px 0 0; font-size: 13px; opacity: .92; min-height: 16px; }

/* ---------- 블록 ---------- */
.block { margin-bottom: 22px; }
.block-title {
  font-size: 15px; font-weight: 800; color: var(--ink);
  margin: 0 4px 10px;
}
.hint { font-size: 13px; color: var(--ink-sub); margin: 0 4px 12px; line-height: 1.5; }

/* ---------- 리스트 로우 ---------- */
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 14px;
  padding: 14px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .1s, box-shadow .15s;
}
.row:active { transform: scale(.985); box-shadow: 0 2px 10px rgba(20,30,55,.08); }
.row-ico { font-size: 20px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 16px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--ink-sub); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-dist { font-size: 12px; font-weight: 700; color: var(--brand);
  background: #eef4ff; padding: 3px 8px; border-radius: 20px; }
.row-arrow { color: var(--ink-sub); font-size: 22px; font-weight: 300; }

/* ---------- 검색바 ---------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 14px; }
.searchbar input {
  flex: 1; border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 15px; font-size: 15px; background: var(--card);
  color: var(--ink); outline: none; box-shadow: var(--shadow);
}
.searchbar input:focus { border-color: var(--brand); }
.btn-search {
  border: 0; background: var(--brand); color: #fff; font-weight: 700;
  padding: 0 18px; border-radius: 14px; cursor: pointer; font-size: 15px;
}
.btn-search:active { background: #1a5fd0; }

/* ---------- 세그먼트 ---------- */
.seg {
  display: flex; background: #e6eaf2; border-radius: 12px; padding: 4px;
  margin-bottom: 16px;
}
.seg-btn {
  flex: 1; border: 0; background: transparent; padding: 9px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--ink-sub); border-radius: 9px;
  transition: all .15s;
}
.seg-btn.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* ---------- 버스 번호 뱃지 ---------- */
.rt-badge {
  display: inline-block; min-width: 44px; text-align: center;
  padding: 6px 10px; border-radius: 9px; color: #fff;
  font-weight: 800; font-size: 15px; background: var(--t-blue);
}
.rt-badge.t-blue { background: var(--t-blue); }
.rt-badge.t-green { background: var(--t-green); }
.rt-badge.t-red { background: var(--t-red); }
.rt-badge.t-circle { background: var(--t-circle); }
.rt-badge.t-vill { background: var(--t-vill); }
.rt-badge.t-air { background: var(--t-air); }

/* ---------- 정류장 상세 ---------- */
.st-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: 14px; padding: 18px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.st-name { font-size: 20px; font-weight: 800; }
.st-ars { font-size: 13px; color: var(--ink-sub); margin-top: 4px; }
.star { border: 0; background: transparent; font-size: 28px; cursor: pointer; }
.star:active { transform: scale(1.2); }

.st-refresh {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 12px; font-size: 12.5px; color: var(--ink-sub);
}
.btn-mini {
  border: 1px solid var(--line); background: var(--card); color: var(--brand);
  font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 20px; cursor: pointer;
}
.btn-mini.danger { color: var(--danger); }
.btn-mini:active { background: #f3f5f9; }

/* ---------- 도착 카드 ---------- */
.arr {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border-radius: 14px; padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 10px;
}
.arr-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.arr-next { font-size: 12px; color: var(--ink-sub); }
.arr-right { text-align: right; }
.arr-msg { font-size: 15px; font-weight: 800; color: var(--ink); }
.arr-msg.soon { color: var(--danger); }
.arr-msg2 { font-size: 12px; color: var(--ink-sub); margin-top: 2px; }
.btn-bell {
  margin-top: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--ink-sub); font-size: 12px; font-weight: 700;
  padding: 5px 10px; border-radius: 20px; cursor: pointer;
}
.btn-bell:active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- 노선 상세 (경유 정류소) ---------- */
.route-guide {
  background: #eef4ff; color: #26497f; border-radius: 12px;
  padding: 12px 14px; font-size: 13px; margin-bottom: 12px; line-height: 1.5;
}
.route-line { list-style: none; margin: 0; padding: 0 0 0 6px; position: relative; }
.route-line::before {
  content: ''; position: absolute; left: 12px; top: 8px; bottom: 8px;
  width: 3px; background: var(--line); border-radius: 3px;
}
.route-stop {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px 11px 8px; cursor: pointer; border-radius: 10px;
}
.route-stop:active { background: #f0f3f9; }
.route-stop .dot {
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 3px solid var(--brand-2); z-index: 1; flex: 0 0 auto;
}
.route-stop-nm { flex: 1; font-size: 15px; font-weight: 600; }
.route-stop-ars { font-size: 11.5px; color: var(--ink-sub); }
.route-stop.sel-start .dot { background: var(--ok); border-color: var(--ok); transform: scale(1.25); }
.route-stop.sel-end .dot { background: var(--danger); border-color: var(--danger); transform: scale(1.25); }
.route-stop.sel-start, .route-stop.sel-end { background: #eef4ff; }
.route-stop.in-range .dot { border-color: var(--brand); }
.route-stop.in-range { background: #f6f9ff; }

.route-time {
  background: linear-gradient(135deg, #16324f, #1f6feb);
  color: #fff; border-radius: 14px; padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.rt-head { font-size: 13px; opacity: .9; margin-bottom: 8px; }
.rt-body { font-size: 16px; line-height: 1.6; }
.rt-note { font-size: 11px; opacity: .75; margin-top: 8px; }

/* ---------- 알람 ---------- */
.alarm-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-radius: 14px; padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 10px;
}
.al-rt { font-size: 16px; font-weight: 800; }
.al-st { font-size: 12.5px; color: var(--ink-sub); margin-top: 3px; }
.btn-perm {
  width: 100%; border: 0; background: var(--card); color: var(--brand);
  font-weight: 700; padding: 14px; border-radius: 14px; cursor: pointer;
  box-shadow: var(--shadow); font-size: 14px; margin-top: 8px;
}

/* ---------- 설정 ---------- */
.settings { background: var(--card); border-radius: 14px; padding: 6px 16px;
  box-shadow: var(--shadow); }
.field {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0; border-bottom: 1px solid var(--line); font-weight: 600;
}
.field-v {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 0; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px;
}
.field-v input, .field input[type=text] {
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
  font-size: 14px; outline: none; font-weight: 500;
}
.field-v input:focus { border-color: var(--brand); }
.field input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--brand); }
.field-note { font-size: 12px; color: var(--ink-sub); line-height: 1.5; margin: 10px 2px; }
.btn-primary {
  width: 100%; border: 0; background: var(--brand); color: #fff;
  font-weight: 800; padding: 14px; border-radius: 12px; cursor: pointer;
  font-size: 15px; margin: 8px 0 16px;
}
.btn-primary:active { background: #1a5fd0; }
.about { text-align: center; color: var(--ink-sub); font-size: 12.5px; margin-top: 20px; line-height: 1.7; }

/* ---------- 상태 표시 ---------- */
.empty, .error, .loading {
  text-align: center; padding: 30px 16px; font-size: 14px;
  color: var(--ink-sub); line-height: 1.6;
}
.error { color: var(--danger); }
.loading::after {
  content: ''; display: inline-block; width: 18px; height: 18px;
  margin-left: 8px; border: 3px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 토스트 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px);
  background: rgba(20, 25, 40, 0.94); color: #fff; padding: 12px 18px;
  border-radius: 24px; font-size: 13.5px; font-weight: 600; max-width: 86%;
  text-align: center; opacity: 0; pointer-events: none; z-index: 100;
  transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 화면 전환 페이드 */
.screen > * { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
