/*
 * 토스 스타일 디자인 토큰·컴포넌트 (2026-09-17 사용자 요청 "토스 스타일").
 * 원칙: 회색 배경 위 흰 카드, 테두리·그림자·그라디언트 없음, 강조색 1개(파랑), 여백 넉넉히(취향: 레퍼런스 밀도의 절반 이하).
 * 색은 전부 토큰(OKLCH, 원 hex는 주석). 대비는 계산으로 확인 — 작은 파란 글씨·버튼은 #1B64DA(5.41:1), 다크 버튼 글씨는 어두운색(5.81:1).
 * 한국 금융 관례: 내려간 값(가격하락)은 파랑, 오류·실패는 빨강.
 */

@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

:root {
  --bg: oklch(96.6% 0.003 247.9); /* #F2F4F6 */
  --surface: oklch(100% 0 0); /* #FFFFFF */
  --fill: oklch(96.6% 0.003 247.9); /* #F2F4F6 입력칸·보조 버튼 */
  --fill-press: oklch(93% 0.005 247.9); /* #E5E8EB */
  --text: oklch(23.7% 0.02 258.4); /* #191F28 */
  --text-2: oklch(46% 0.028 256.2); /* #4E5968 */
  --text-3: oklch(56.2% 0.025 254.5); /* #6B7684 — 흰 카드 위에서만(4.62:1) */
  --accent: oklch(62% 0.191 258.2); /* #3182F6 — 글자가 아닌 강조(포커스·활성 탭) */
  --accent-text: oklch(53.2% 0.194 260.2); /* #1B64DA — 파란 글씨 */
  --accent-tint: oklch(95.9% 0.02 250.4); /* #E8F3FF */
  --btn-bg: oklch(53.2% 0.194 260.2); /* #1B64DA */
  --btn-bg-press: oklch(48% 0.19 260.5);
  --on-btn: oklch(100% 0 0);
  --danger-text: oklch(55.6% 0.209 23.9); /* #D22030 */
  --danger-tint: oklch(96.3% 0.018 17.5); /* #FFEEEE */
  --warn-text: oklch(51.1% 0.124 56.7); /* #9A5000 */
  --warn-tint: oklch(96.9% 0.028 79.5); /* #FFF3E0 */
  --ok-text: oklch(48.7% 0.109 160.3); /* #01724A */
  --ok-tint: oklch(96.1% 0.022 167.5); /* #E5F7EF */

  --radius-card: 20px;
  --radius-control: 14px;
  --radius-pill: 999px;
  --space-page: 20px;
  --content-max: 640px;
  --tabbar-h: 64px;
  --font: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: oklch(20.7% 0.01 285.5); /* #17171C */
  --surface: oklch(24.7% 0.013 285.4); /* #202027 */
  --fill: oklch(29.7% 0.016 285.4); /* #2C2C35 */
  --fill-press: oklch(33% 0.018 285.4);
  --text: oklch(98.5% 0.002 247.8); /* #F9FAFB */
  --text-2: oklch(81.8% 0.004 286.3); /* #C3C3C6 */
  --text-3: oklch(70.1% 0.009 286.2); /* #9E9EA4 */
  --accent: oklch(66.6% 0.174 256.8); /* #4593FC */
  --accent-text: oklch(72.7% 0.143 257.1); /* #6AA8FF */
  --accent-tint: oklch(28.9% 0.046 261.4); /* #1E2B42 */
  --btn-bg: oklch(66.6% 0.174 256.8); /* #4593FC */
  --btn-bg-press: oklch(61% 0.17 257);
  --on-btn: oklch(20.7% 0.01 285.5); /* #17171C */
  --danger-text: oklch(76.4% 0.142 16.1); /* #FF8A93 */
  --danger-tint: oklch(27.7% 0.043 5.9); /* #3A1F25 */
  --warn-text: oklch(81.7% 0.147 70.3); /* #FFB14A */
  --warn-tint: oklch(30.7% 0.036 76.2); /* #3A2D1A */
  --ok-text: oklch(77.9% 0.165 157.3); /* #3DD68C */
  --ok-tint: oklch(29.2% 0.037 172.9); /* #16322A */
  color-scheme: dark;
}

/* ── 기본 ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

.num {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 30;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-control);
}

.skip-link:focus {
  left: 12px;
}

/* ── 앱 바·탭 바 ──────────────────────────────────────── */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
}

.app-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 6px 12px 6px var(--space-page);
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-right: auto;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.top-nav {
  display: none;
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.app-actions form {
  margin: 0;
}

.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: var(--tabbar-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  box-shadow: 0 -1px 0 var(--fill-press);
}

.tab-bar a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tabbar-h);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
}

.tab-bar a[aria-current="page"] {
  color: var(--text);
}

.tab-bar a[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}

.tab-bar a {
  position: relative;
}

@media (min-width: 720px) {
  .tab-bar {
    display: none;
  }

  .top-nav {
    display: flex;
    gap: 2px;
    margin-right: 8px;
  }

  .top-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    border-radius: var(--radius-control);
    color: var(--text-2);
    font-weight: 600;
  }

  .top-nav a[aria-current="page"] {
    color: var(--text);
    background: var(--surface);
  }
}

/* ── 페이지 ───────────────────────────────────────────── */
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 8px var(--space-page) calc(var(--tabbar-h) + 40px);
}

@media (min-width: 720px) {
  .page {
    padding-bottom: 64px;
  }
}

.page-head {
  padding: 20px 0 24px;
}

.eyebrow {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

.title {
  margin-top: 4px;
  font-size: 26px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 6px;
  font-size: 15px;
  color: var(--text-2);
}

.section {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 22px 20px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.group-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 28px 4px 12px;
}

.list-meta {
  margin: 20px 4px 10px;
  font-size: 14px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.note {
  font-size: 15px;
  color: var(--text-2);
}

.footnote {
  margin: 24px 4px 0;
  font-size: 13px;
  color: var(--text-2);
}

/* ── 수치 ─────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 12px;
}

.stat-label {
  display: block;
  font-size: 14px;
  color: var(--text-3);
}

.stat-value {
  display: block;
  margin-top: 2px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ── 목록 행 ──────────────────────────────────────────── */
.rows {
  margin: -6px 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 0;
  color: var(--text);
}

a.row {
  margin: 0 -12px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  transition: background-color 0.15s ease;
}

a.row:active {
  background: var(--fill);
}

@media (hover: hover) {
  a.row:hover {
    background: var(--fill);
  }
}

a.row::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--text-3);
  border-right: 2px solid var(--text-3);
  transform: rotate(45deg);
  margin-left: 2px;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  display: block;
  font-size: 16px;
  font-weight: 600;
}

.row-sub {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  color: var(--text-3);
}

.clamp-1 {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row-value {
  flex: none;
  text-align: right;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.row-value .row-sub {
  font-weight: 400;
}

.row-main .pills {
  margin-top: 6px;
}

form > .btn-block {
  margin-top: 8px;
}

.is-down {
  color: var(--accent-text);
}

.is-danger {
  color: var(--danger-text);
}

/* ── 추천 카드 ────────────────────────────────────────── */
.picks {
  display: grid;
  gap: 12px;
}

.pick {
  display: block;
  padding: 22px 20px;
  background: var(--surface);
  border-radius: var(--radius-card);
  color: var(--text);
  transition: background-color 0.15s ease;
}

.pick:active {
  background: var(--fill);
}

.pick-meta {
  font-size: 14px;
  color: var(--text-3);
}

.pick-title {
  margin-top: 4px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.45;
}

.pick-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 14px;
}

.price {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.price-sub {
  font-size: 15px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.pick-note {
  margin-top: 14px;
  font-size: 15px;
  color: var(--text-2);
}

.pick-checks {
  margin-top: 10px;
  display: grid;
  gap: 4px;
}

.pick-checks li {
  position: relative;
  padding-left: 12px;
  font-size: 14px;
  color: var(--text-3);
}

.pick-checks li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-3);
}

/* ── 배지 ─────────────────────────────────────────────── */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--fill);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pill-blue {
  background: var(--accent-tint);
  color: var(--accent-text);
}

.pill-red {
  background: var(--danger-tint);
  color: var(--danger-text);
}

.pill-orange {
  background: var(--warn-tint);
  color: var(--warn-text);
}

.pill-green {
  background: var(--ok-tint);
  color: var(--ok-text);
}

.alert ul {
  display: grid;
  gap: 4px;
}

code {
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--fill-press);
}

.alert {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-control);
  background: var(--danger-tint);
  color: var(--danger-text);
  font-size: 14px;
  font-weight: 600;
}

/* ── 버튼 ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-control);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--btn-bg);
  color: var(--on-btn);
}

.btn-primary:active {
  background: var(--btn-bg-press);
}

.btn-secondary {
  background: var(--fill);
  color: var(--text-2);
}

.btn-secondary:active {
  background: var(--fill-press);
}

.btn-ghost {
  min-height: 44px;
  padding: 0 12px;
  background: transparent;
  color: var(--text-2);
  font-size: 15px;
}

.btn-ghost:active {
  background: var(--fill);
}

.btn-block {
  display: flex;
  width: 100%;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.pager > .btn-block {
  grid-column: 1 / -1;
}

/* ── 폼 ───────────────────────────────────────────────── */
.field {
  display: block;
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-3);
}

input,
select {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

input::placeholder {
  color: var(--text-3);
}

select {
  appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 10px;
}

.field-grid .field {
  margin-bottom: 0;
}

.field-grid .field-wide {
  grid-column: 1 / -1;
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-row input {
  flex: 1;
  min-width: 0;
}

.search-row .btn {
  flex: none;
}

details.filters {
  margin-top: 10px;
}

details.filters > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
}

details.filters > summary::-webkit-details-marker {
  display: none;
}

details.filters > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg);
  margin-right: 6px;
}

details.filters[open] > summary::after {
  transform: rotate(-135deg);
}

details.filters .field-grid {
  margin-top: 12px;
}

/* ── 항목·값 목록 ─────────────────────────────────────── */
.kv {
  margin: 0;
  display: grid;
  gap: 14px;
}

.kv-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
}

.kv dt {
  font-size: 15px;
  color: var(--text-3);
}

.kv dd {
  margin: 0;
  min-width: 0;
  font-size: 15px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.kv-row-stack {
  grid-template-columns: 1fr;
  gap: 4px;
}

.kv-row-stack dd {
  text-align: left;
  white-space: pre-line;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── 로그인·메시지 화면 ───────────────────────────────── */
.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto;
  padding: 40px var(--space-page);
}

.auth .title {
  font-size: 28px;
}

.auth form {
  margin-top: 32px;
}

/* 로그인 화면은 카드 없이 회색 배경 위에 입력칸이 놓이므로, 배경과 구분되게 흰 면을 쓴다. */
.auth input {
  background: var(--surface);
}

.auth .btn {
  margin-top: 12px;
}

.auth-actions {
  margin-top: 24px;
}

/* ── 움직임 줄이기 ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  .btn:active {
    transform: none;
  }
}
