/* 자전거 점검 v3 - 시안 B (설계서 4절 시각 기준) */
:root {
  --bg: #FFFFFF;
  --surface: #F7F8FA;
  --line: #E5E7EB;
  --text: #111827;
  --muted: #6B7280;
  --accent: #1D4ED8;
  --accent-tint: rgba(29, 78, 216, .07);
  --g-u: #DC2626;
  --g-w: #D97706;
  --g-o: #6B7280;
  --accent-hover: #1E40AF;
  --on-accent: #FFFFFF;
  --press: #EEF0F3;
  --placeholder: #9CA3AF;
  --track: #D1D5DB;
  --inverse-bg: #111827;
  --inverse-text: #FFFFFF;
  --chart-grid: #EEF0F3;
  --chart-base: #D1D5DB;
  --dot: #9CA3AF;
  --shadow: 0 10px 30px rgba(17, 24, 39, .18);
  --backdrop: rgba(17, 24, 39, .4);
  --toast-act: #93C5FD;
  --r-card: 12px;
  --r-ctl: 8px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color-scheme: light;
}

/* ---------- 어두운 화면 (2026-11-17 추가) ----------
   기본은 기기 설정을 따름. 사용자가 고르면 <html data-theme="light|dark">로 덮어씀.
   순수 검정 대신 짙은 회색, 색은 어두운 배경에서 읽히도록 한 단계 밝게. */
:root[data-theme="dark"] {
  --bg: #0F1115; --surface: #181B21; --line: #2A2E36;
  --text: #E8EAED; --muted: #9AA0A6;
  --accent: #6EA8FE; --accent-hover: #8DBBFE; --accent-tint: rgba(110, 168, 254, .14); --on-accent: #0B1220;
  --g-u: #F87171; --g-w: #FBBF24; --g-o: #9AA0A6;
  --press: #22262E; --placeholder: #6B7280; --track: #3A3F48;
  --inverse-bg: #E8EAED; --inverse-text: #0F1115;
  --chart-grid: #1F232A; --chart-base: #3A3F48; --dot: #6B7280;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5); --backdrop: rgba(0, 0, 0, .6); --toast-act: #1D4ED8;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1115; --surface: #181B21; --line: #2A2E36;
    --text: #E8EAED; --muted: #9AA0A6;
    --accent: #6EA8FE; --accent-hover: #8DBBFE; --accent-tint: rgba(110, 168, 254, .14); --on-accent: #0B1220;
    --g-u: #F87171; --g-w: #FBBF24; --g-o: #9AA0A6;
    --press: #22262E; --placeholder: #6B7280; --track: #3A3F48;
    --inverse-bg: #E8EAED; --inverse-text: #0F1115;
    --chart-grid: #1F232A; --chart-base: #3A3F48; --dot: #6B7280;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5); --backdrop: rgba(0, 0, 0, .6); --toast-act: #1D4ED8;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.view:focus { outline: none; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* ---------- 머리글 · 탭 ---------- */
.hdr-in { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 60px; }
.brand { font-size: 17px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.hdr-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.date-wrap { position: relative; }
.date {
  appearance: none; -webkit-appearance: none;
  height: 44px; padding: 0 32px 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--bg); font-size: 15px; font-weight: 600; cursor: pointer;
}
.date:hover { background: var(--surface); }
.date-chev { position: absolute; right: 10px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--muted); pointer-events: none; }
.demo {
  font-size: 12px; line-height: 1; color: var(--muted); white-space: nowrap;
  padding: 5px 6px; border-radius: 4px; background: var(--surface);
}

.tabs { box-shadow: inset 0 -1px var(--line); }
.tabs-in { display: flex; gap: 24px; overflow-x: auto; scrollbar-width: none; }
.tabs-in::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: flex; align-items: center; height: 44px;
  color: var(--muted); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }

.view { padding-top: 20px; padding-bottom: 96px; min-height: 60vh; } /* 아래 96px: 알림이 마지막 버튼을 가리지 않게 */
.view.enter { animation: enter .16s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view.enter { animation: none; } }

/* ---------- 공통 ---------- */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.grade { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.g-u { color: var(--g-u); }
.g-w { color: var(--g-w); }
.g-o { color: var(--g-o); }
.muted { color: var(--muted); }
.sec-title { font-size: 15px; font-weight: 700; margin: 32px 0 12px; }
.empty { padding: 48px 0; text-align: center; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--bg); font-size: 15px; font-weight: 600; white-space: nowrap;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--surface); }
.btn:active { background: var(--press); }
.btn:disabled { color: var(--muted); background: var(--bg); cursor: default; opacity: .6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--g-u); }
.btn.block { width: 100%; }
.link-btn {
  min-height: 44px; padding: 0; border: 0; background: none;
  color: var(--accent); font-size: 15px; font-weight: 600;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.chip {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--bg); font-size: 15px; font-weight: 500; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.chip:hover { background: var(--surface); }
.chip .n { color: var(--muted); font-weight: 500; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); font-weight: 700; }
.chip[aria-pressed="true"] .n { color: var(--accent); }

.input {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--bg); font-size: 16px;
}
.input::placeholder { color: var(--placeholder); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border-radius: var(--r-card); padding: 14px 12px 12px; min-width: 0; }
.stat .v { font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; white-space: nowrap; }
.stat .v small { font-size: 15px; font-weight: 600; margin-left: 1px; letter-spacing: 0; }
.stat .k { margin-top: 4px; font-size: 13px; color: var(--muted); }

/* ---------- 오늘 점검 ---------- */
.prog-top { display: flex; align-items: baseline; gap: 8px; }
.prog-top .lbl { font-size: 15px; font-weight: 600; }
.prog-top b { font-size: 28px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.prog-top .of { color: var(--muted); }
.bar { height: 4px; margin: 10px 0 8px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s ease; }
.prog-sub { font-size: 13px; color: var(--muted); }

.chips {
  display: flex; gap: 6px; margin: 20px -16px 0; padding: 0 16px;
  overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips .chip { flex: 1 0 auto; }

.search-row { display: flex; gap: 8px; margin-top: 12px; }
.search { position: relative; flex: 1; min-width: 0; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 38px; }
.search .input::-webkit-search-cancel-button { -webkit-appearance: none; }
.switch {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 2px 0 4px; border: 0; background: none; font-size: 15px; font-weight: 500; white-space: nowrap;
}
.switch .track { position: relative; width: 36px; height: 22px; border-radius: 11px; background: var(--track); transition: background-color .15s; }
.switch .track::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s;
}
.switch[aria-checked="true"] .track { background: var(--accent); }
.switch[aria-checked="true"] .track::after { transform: translateX(14px); }

.list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.card {
  display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; column-gap: 8px; row-gap: 2px;
  padding: 14px 12px 14px 16px; border: 1px solid var(--line); border-radius: var(--r-card);
  background: var(--bg); transition: background-color .12s, border-color .12s;
}
.card:hover { background: var(--surface); }
.card:active { background: var(--press); }
.card .grade { grid-column: 1; grid-row: 1; align-self: center; }
.card .bike { grid-column: 2; grid-row: 1; font-weight: 700; }
.card .rank { grid-column: 3; grid-row: 1; justify-self: end; align-self: center; display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.card .chev { width: 16px; height: 16px; color: var(--placeholder); }
.card .loc { grid-column: 2; grid-row: 2; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .result { grid-column: 3; grid-row: 2; justify-self: end; align-self: center; font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
.card .why { grid-column: 2 / 4; grid-row: 3; font-size: 13px; color: var(--muted); }
.card.done > :not(.result) { opacity: .55; }
.more { margin-top: 12px; }

/* ---------- 상세 ---------- */
.topbar { display: flex; align-items: center; height: 48px; margin-top: -12px; }
.back {
  display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px 0 0;
  border: 0; background: none; color: var(--accent); font-size: 15px; font-weight: 600;
}
.back svg { width: 18px; height: 18px; }
.d-meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.d-bike { font-size: 28px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; margin-top: 6px; }
.d-loc { margin-top: 2px; color: var(--muted); }

.tl { position: relative; user-select: none; -webkit-user-select: none; }
.tl svg, .lc svg { display: block; width: 100%; overflow: visible; }
.tl .hit { cursor: pointer; }
.tip {
  position: absolute; z-index: 5; transform: translate(-50%, -100%);
  padding: 6px 8px; border-radius: 6px; background: var(--inverse-bg); color: var(--inverse-text);
  font-size: 13px; line-height: 1.4; white-space: nowrap; pointer-events: none;
}
.tip[hidden] { display: none; }

.reports li { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.reports li:first-child { border-top: 1px solid var(--line); }
.reports .ts { flex: none; min-width: 104px; color: var(--muted); }

.result-sec { margin-top: 32px; padding-top: 4px; border-top: 1px solid var(--line); }
.flabel { display: block; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.field + .field { margin-top: 16px; }
.parts { display: flex; flex-wrap: wrap; gap: 8px; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
.actions .btn { min-height: 48px; padding: 0 8px; }
.saved {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 6px 4px 6px 16px; border-radius: var(--r-card); background: var(--surface);
}
.saved .txt { font-weight: 600; }
.saved .memo { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.saved .link-btn { flex: none; padding: 0 12px; }
.saved-acts { flex: none; display: flex; }
.muted-link { color: var(--muted); }
.next-btn { margin-top: 12px; }
.next-btn svg { width: 18px; height: 18px; }

/* ---------- 기록 ---------- */
.log-actions { display: flex; gap: 8px; margin-top: 16px; }
.log-actions .btn { flex: 1; }
.log { margin-top: 24px; }
.lrow {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; column-gap: 8px; row-gap: 2px;
  grid-template-areas: "time bike grade" "time det det";
  padding: 12px 8px; margin: 0 -8px; border-bottom: 1px solid var(--line); border-radius: 0;
}
a.lrow:hover { background: var(--surface); }
.lrow .time { grid-area: time; color: var(--muted); }
.lrow .bike { grid-area: bike; font-weight: 700; }
.lrow .grade { grid-area: grade; justify-self: end; }
.lrow .det { grid-area: det; font-size: 13px; color: var(--muted); }
.lrow .det .res { color: var(--text); font-weight: 600; }
.lrow .det .part:not(:empty)::before, .lrow .det .memo:not(:empty)::before { content: " \00B7  "; color: var(--muted); }
.lhead { display: none; }

/* ---------- 성과 ---------- */
.def { margin-top: 12px; font-size: 13px; color: var(--muted); }
.lc { position: relative; }
.gbars { display: flex; flex-direction: column; gap: 12px; }
.gbar { display: grid; grid-template-columns: 56px minmax(0, 1fr) 52px; align-items: center; gap: 12px; }
.gbar .track { height: 12px; border-radius: 4px; background: var(--surface); overflow: hidden; }
.gbar .fill { height: 100%; border-radius: 4px; background: var(--accent); }
.gbar .val { text-align: right; font-weight: 700; }
.sub-date { margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.foot { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- 서비스 소개 ---------- */
.prose h1 { font-size: 20px; font-weight: 700; }
.prose h2 { font-size: 15px; font-weight: 700; margin: 32px 0 8px; }
.prose p + p { margin-top: 8px; }
.prose .steps { counter-reset: s; display: flex; flex-direction: column; gap: 8px; }
.prose .steps li { counter-increment: s; display: flex; gap: 12px; align-items: baseline; }
.prose .steps li::before {
  content: counter(s); flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); font-size: 13px; font-weight: 700; text-align: center; line-height: 22px;
}
.gtable { width: 100%; border-collapse: collapse; }
.gtable th, .gtable td { padding: 10px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.gtable th { font-size: 13px; font-weight: 500; color: var(--muted); }
.gtable td:first-child { width: 88px; }
.terms { display: grid; grid-template-columns: 88px minmax(0, 1fr); }
.terms dt, .terms dd { padding: 10px 0; border-bottom: 1px solid var(--line); }
.terms dt { font-weight: 700; }
.prose ul.dash li { position: relative; padding-left: 14px; }
.prose ul.dash li + li { margin-top: 6px; }
.prose ul.dash li::before { content: ""; position: absolute; left: 0; top: .72em; width: 6px; height: 1px; background: var(--muted); }

/* ---------- 알림 · 대화상자 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  padding: 12px 18px; border-radius: var(--r-ctl); background: var(--inverse-bg); color: var(--inverse-text);
  font-size: 15px; font-weight: 600; white-space: nowrap;
  transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
/* 되돌리기 버튼이 있는 알림 (2026-11-17 추가) */
.toast.has-act { display: flex; align-items: center; gap: 16px; padding: 4px 6px 4px 18px; }
.toast.has-act.show { pointer-events: auto; }
.toast-act {
  min-height: 40px; padding: 0 12px; border: 0; border-radius: 6px; background: none;
  color: var(--toast-act); font-size: 15px; font-weight: 700;
}
.toast-act:hover { text-decoration: underline; text-underline-offset: 3px; }
.dlg {
  width: min(320px, calc(100% - 32px)); padding: 24px 20px 20px;
  border: 0; border-radius: var(--r-card); color: var(--text); background: var(--bg);
  box-shadow: var(--shadow);
}
.dlg::backdrop { background: var(--backdrop); }
.dlg-title { font-size: 17px; font-weight: 700; }
.dlg-body { margin-top: 6px; color: var(--muted); }
.dlg-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }

/* ---------- 휴대폰: 상세는 전체 화면 ---------- */
@media (max-width: 767px) {
  body.detail .hdr, body.detail .tabs { display: none; }
  body.detail .topbar {
    position: sticky; top: 0; z-index: 10; margin: 0 -16px; padding: 0 16px; height: 52px;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  body.detail .view { padding-top: 0; }
  body.detail .d-head { padding-top: 16px; }
}

/* 좁은 휴대폰: 등급 필터 4개를 한 줄에 */
@media (max-width: 399px) {
  .chips { gap: 6px; }
  .chips .chip { flex: 1 1 auto; padding: 0 6px; gap: 4px; }
}
/* 숫자 상자 라벨: 좁은 폭에서는 기간을 둘째 줄로 */
@media (max-width: 479px) {
  .stat .per { display: block; }
  .stat .sep { display: none; }
}

/* ---------- 넓은 화면 ---------- */
@media (min-width: 640px) {
  .chips .chip { flex: 0 0 auto; padding: 0 16px; }
  .lhead {
    display: grid; grid-template-columns: 64px 112px 64px 80px 80px minmax(0, 1fr); column-gap: 12px;
    padding: 0 8px 8px; margin: 0 -8px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted);
  }
  .lrow { grid-template-columns: 64px 112px 64px 80px 80px minmax(0, 1fr); grid-template-areas: none; column-gap: 12px; align-items: center; }
  .lrow .time, .lrow .bike, .lrow .grade { grid-area: auto; justify-self: start; }
  .lrow .det { display: contents; font-size: 15px; }
  .lrow .det .part, .lrow .det .memo { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lrow .det .part:not(:empty)::before, .lrow .det .memo:not(:empty)::before { content: none; }
}

/* ---------- 화면 모드 전환 (2026-11-17 추가) ---------- */
.theme-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--r-ctl);
  background: none; color: var(--muted);
}
.theme-btn:hover { background: var(--surface); color: var(--text); }
.theme-btn svg { width: 20px; height: 20px; }
@media (max-width: 399px) { .theme-btn { display: none; } } /* 좁은 휴대폰은 서비스 소개 탭에서 바꿈 */
.theme-row { display: flex; gap: 6px; flex-wrap: wrap; }
