/* 사랑공장 디자인 시스템 v1 토큰 (인라인). 계산기라 다크 배경을 쓰되 토큰 색만 조합한다 */
:root {
  --brand: #E63A58;
  --brand-hover: #D22F4C;
  --brand-soft: #FDEEF1;
  --gray-900: #191C20;
  --gray-700: #3A3F47;
  --gray-500: #6B7280;
  --gray-400: #9CA3AF;
  --gray-200: #E4E7EB;
  --gray-100: #F0F2F5;
  --gray-50: #F7F7F9;
  --white: #FFFFFF;
  --error: #DC2626;
  --r-8: 8px;
  --r-16: 16px;
  --font: Pretendard, -apple-system, "Malgun Gothic", sans-serif;
  --ease: 0.15s ease;
  --gap: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--gray-900);
  color: var(--white);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  word-break: keep-all;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
ul { list-style: none; margin: 0; padding: 0; }
p, h2 { margin: 0; }

/* 틀: 폰은 꽉 차게, 데스크톱은 가운데 */
.app {
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 48px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status {
  flex: 1;
  font-size: 12px;
  color: var(--gray-500);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status.is-error { color: var(--brand); }
.refresh, .icon-btn {
  width: 44px;
  height: 44px;
  margin-right: -12px;
  border: 0;
  border-radius: var(--r-8);
  background: transparent;
  color: var(--gray-400);
  display: inline-grid;
  place-items: center;
  transition: background var(--ease), color var(--ease);
}
.refresh:hover, .icon-btn:hover { background: var(--gray-700); color: var(--white); }
.refresh[disabled] { color: var(--gray-700); cursor: default; }
.refresh:focus-visible, .icon-btn:focus-visible, .code:focus-visible, .swap:focus-visible, .key:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

/* 표시부 */
.display {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding-bottom: 16px;
}
.line {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 48px;
}
.line-mid { justify-content: space-between; min-height: 32px; }
.amount {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-weight: 400;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  overflow: hidden;
  white-space: nowrap;
}
.amount-out { font-size: 40px; color: var(--gray-400); }
.amount-in { font-size: 56px; color: var(--white); }
.amount.is-long { font-size: 32px; }
.amount-in.is-long { font-size: 40px; }
.amount.is-error { color: var(--brand); }

.code {
  flex: none;
  height: 32px;
  padding: 0 8px 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--gray-700);
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background var(--ease);
}
.code:hover { background: var(--gray-500); }
.code .chev { color: var(--gray-400); }

.swap {
  width: 44px;
  height: 44px;
  margin-left: -12px;
  border: 0;
  border-radius: var(--r-8);
  background: transparent;
  color: var(--gray-400);
  display: inline-grid;
  place-items: center;
  transition: background var(--ease), color var(--ease);
}
.swap:hover { background: var(--gray-700); color: var(--white); }
.rate-line {
  font-size: 12px;
  color: var(--gray-500);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* 키패드 */
.keys {
  flex: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
}
.key {
  height: clamp(44px, 9dvh, 76px);
  border: 0;
  border-radius: 999px;
  background: var(--gray-700);
  color: var(--white);
  font-size: 28px;
  font-weight: 400;
  display: grid;
  place-items: center;
  transition: background var(--ease), color var(--ease);
}
.key:active { background: var(--gray-500); }
.key.fn { background: var(--gray-400); color: var(--gray-900); font-size: 20px; font-weight: 600; }
.key.fn:active { background: var(--gray-200); }
.key.op { color: var(--brand); font-size: 32px; }
.key.op:active { background: var(--gray-500); }
.key.op.is-active { background: var(--white); color: var(--brand); }
.key.eq { background: var(--brand); color: var(--white); font-size: 32px; }
.key.eq:active { background: var(--brand-hover); }

/* 하단: 배너 한 줄 + 앱 다운로드 한 줄 */
.foot { flex: none; padding-top: 16px; display: flex; flex-direction: column; gap: 4px; }
.banner {
  height: 48px;
  padding: 0 12px 0 16px;
  border-radius: var(--r-8);
  background: var(--gray-700);
  color: var(--white);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--ease);
}
.banner:hover { background: var(--gray-500); }
.banner:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.banner-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner svg { color: var(--gray-400); flex: none; }
.app-row {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  color: var(--gray-500);
}
.app-row[hidden] { display: none; }
.app-row > span:first-child { margin-right: 4px; }
.app-link {
  padding: 8px 4px;
  color: var(--gray-400);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--r-8);
  transition: color var(--ease);
}
.app-link:hover { color: var(--white); }
.app-link:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: 448px;
  margin: 0 auto;
  padding: 12px 16px;
  border-radius: var(--r-8);
  background: var(--gray-200);
  color: var(--gray-900);
  font-size: 14px;
  z-index: 20;
}
.toast[hidden] { display: none; }

/* 통화 선택 시트 */
.picker {
  position: fixed;
  inset: 0;
  z-index: 10;
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--gray-900);
  overflow-y: auto;
}
.picker[hidden] { display: none; }
.picker-bar { position: sticky; top: 0; background: var(--gray-900); z-index: 1; }
.icon-btn { margin: 0 0 0 -12px; }
.picker-title { font-size: 20px; font-weight: 700; line-height: 1.25; }
.search-wrap { padding: 8px 0 12px; }
.search {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--gray-700);
  border-radius: var(--r-8);
  background: var(--gray-700);
  color: var(--white);
  font-size: 16px; /* iOS: 16px 미만이면 포커스 시 화면이 확대된다 */
  outline: none;
  -webkit-appearance: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.search::placeholder { color: var(--gray-400); }
.search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(230, 58, 88, 0.25); }

.picker-list .item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--r-8);
  background: transparent;
  text-align: left;
  transition: background var(--ease);
}
.picker-list .item:hover { background: var(--gray-700); }
.picker-list .item.is-current { background: var(--gray-700); }
.picker-list li[hidden] { display: none; }
.flag { font-size: 24px; line-height: 1; width: 32px; text-align: center; flex: none; }
.item .meta { flex: 1; min-width: 0; }
.item .cc { font-size: 16px; font-weight: 700; line-height: 1.25; }
.item .name { font-size: 14px; color: var(--gray-400); }
.item .tick { color: var(--brand); flex: none; }
.no-result { padding: 48px 16px; text-align: center; font-size: 14px; color: var(--gray-500); }

/* 설정 시트: 즐겨찾기 체크 */
.sheet-desc { font-size: 14px; color: var(--gray-400); padding: 8px 0 0; }
.sub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  font-size: 14px;
  color: var(--gray-400);
  font-variant-numeric: tabular-nums;
}
.sub-actions { display: inline-flex; gap: 4px; margin-right: -12px; }
.text-btn {
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--r-8);
  background: transparent;
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--ease), color var(--ease);
}
.text-btn:hover { background: var(--gray-700); }
.text-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.text-btn[disabled] { color: var(--gray-500); background: transparent; cursor: default; }
.text-btn.wide { width: 100%; background: var(--gray-700); }
.text-btn.wide:hover { background: var(--gray-500); }
.sheet-foot {
  position: sticky;
  bottom: 0;
  padding: 12px 0 0;
  background: var(--gray-900);
}
.item .box {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: var(--r-8);
  border: 2px solid var(--gray-500);
  display: grid;
  place-items: center;
  color: transparent;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.item .box svg { width: 16px; height: 16px; }
.item.is-checked .box { background: var(--brand); border-color: var(--brand); color: var(--white); }
.item.is-checked .cc { color: var(--white); }
.item[role="checkbox"]:not(.is-checked) .cc { color: var(--gray-400); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
