:root {
  color-scheme: light;
  font-family: "Pretendard Variable", "Pretendard", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--ui-navy, #172033);
  background: var(--ui-bg, #eef3fa);
  --navy: var(--ui-navy);
  --blue: var(--ui-blue);
  --muted: var(--ui-muted);
  --line: var(--ui-line);
  --cream: var(--ui-cream);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
input[type="checkbox"] { width: auto; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: wait; }
:focus-visible { outline: 3px solid #5482b1; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 6vw, 2.15rem); line-height: 1.2; letter-spacing: -.035em; }
h2 { font-size: 1.12rem; }
h3 { font-size: .95rem; }
p, small { line-height: 1.6; }
small, .note { color: var(--muted); }
small { display: block; }
svg { display: block; width: 100%; height: auto; }

.app {
  font-size: var(--ui-body-size);
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 480px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 50px #10233b14;
}
/* 넓은 화면: 왼쪽 은행 화면(480px) + 오른쪽 AI 상담 (app.mjs의 desktop, ADR 0031) */
.app.desk {
  display: grid;
  grid-template-columns: 480px minmax(0, 1fr);
  align-items: start;
  gap: 20px;
  width: min(100%, 1240px);
  padding: 20px;
  background: transparent;
  box-shadow: none;
}
.desk-main { display: flex; flex-direction: column; min-height: calc(100dvh - 40px); border-radius: var(--ui-radius); background: #fff; overflow: clip; }
.app.desk[data-page="home"] .desk-main, .app.desk[data-page="accounts"] .desk-main { background: transparent; }
.desk-main .ui-tabs { grid-template-columns: repeat(4, minmax(0, 1fr)); border-radius: var(--ui-radius) var(--ui-radius) 0 0; }
.desk-main .ui-tab[data-action="chat"] { display: none; } /* 상담은 오른쪽에 늘 열려 있다 */
.desk-chat { position: sticky; top: 20px; display: flex; flex-direction: column; height: calc(100dvh - 40px); border-radius: var(--ui-radius); background: #fff; overflow: hidden; }
.desk-chat .chat-screen { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.desk-chat .ui-header { border-bottom: 1px solid var(--ui-line); }
.desk-chat .ui-header [data-action="menu"] { display: none; }
.desk-chat main.chat { flex: 1; min-height: 0; }
.desk-chat .chat-feed { overflow-y: auto; scrollbar-width: thin; }
.desk-chat .composer { bottom: 0; }
.desk-chat .chat-feed:has(> .chat-examples) { justify-content: center; } /* 대화 전 빈 상담 칸은 안내를 가운데에 (ADR 0032) */
/* "새 기능" 말풍선 (ADR 0032): 휴대폰은 하단 탭의 AI 상담을, 넓은 화면은 오른쪽 상담 칸 제목을 가리킨다.
   화살표 위치 = 탭 바 안쪽 여백 16px + 탭 한 칸의 절반 - 말풍선 오른쪽 여백 8px - 화살표 반 폭 7px */
.ai-tip { position: fixed; z-index: 3; right: calc((100% - min(100%, 480px)) / 2 + 8px); bottom: calc(var(--ui-tabs-height) + 12px); display: flex; align-items: flex-start; gap: 10px; width: min(300px, calc(100% - 16px)); padding: 14px 8px 14px 14px; border-radius: var(--ui-radius-sm); background: var(--ui-navy); color: #fff; box-shadow: 0 8px 24px #17203333; animation: ai-tip-in .3s ease-out; }
.ai-tip::after { content: ""; position: absolute; right: calc((min(100vw, 480px) - 32px) / 10 + 1px); bottom: -6px; width: 14px; height: 14px; border-radius: 2px; background: inherit; transform: rotate(45deg); }
.ai-tip-badge { flex: none; margin-top: 2px; padding: 2px 7px; border-radius: 999px; background: var(--ui-blue); font-size: 11px; font-weight: 800; }
.ai-tip p { flex: 1; color: #d5deee; font-size: 13px; line-height: 1.5; word-break: keep-all; }
.ai-tip strong { display: block; margin-bottom: 2px; color: #fff; font-size: 15px; }
.ai-tip .ai-tip-close { flex: none; width: 32px; min-height: 32px; height: 32px; margin-top: -6px; padding: 6px; color: #fff; }
.desk-chat .ai-tip { position: absolute; top: 72px; right: auto; bottom: auto; left: var(--ui-page-gutter); }
.desk-chat .ai-tip::after { top: -6px; right: auto; bottom: auto; left: 28px; }
.app.ai-tip-on .ui-tab[data-action="chat"] { position: relative; color: var(--ui-blue); }
.app.ai-tip-on .ui-tab[data-action="chat"]::after { content: ""; position: absolute; top: 6px; left: calc(50% + 10px); width: 8px; height: 8px; border-radius: 50%; background: var(--ui-error); }
@keyframes ai-tip-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .ai-tip { animation: none; } }
.desk-chat .bubble { max-width: 76%; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 64px;
  padding: 8px 20px;
  border-bottom: 1px solid #eef1f3;
  font-weight: 800;
  font-size: 1.12rem;
}
.topbar > div, .brand { display: inline-flex; align-items: center; gap: 8px; }
.brand svg { width: 25px; }
.back, .quiet { border: 0; background: transparent; min-height: 44px; }
.back { min-width: 36px; padding: 0 6px; font-size: 1.45rem; }
.quiet { padding: 0 7px; font-size: .84rem; color: var(--blue); font-weight: 700; }
main { flex: 1; padding: 22px var(--ui-page-gutter) 28px; }
main > * + * { margin-top: 20px; }
.benefit-panel { margin-top: 16px; }
.benefit-panel > * + *, .benefit-panel article > * + * { margin-top: 10px; }
.benefit-panel fieldset { margin: 10px 0; border: 1px solid var(--line); }
.benefit-panel article { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.right { text-align: right; }
.right strong, .card strong { display: block; }
.hero, .card { padding: var(--ui-space-md); border-radius: var(--ui-radius); background: var(--cream); }
.hero p, .card p { color: var(--muted); margin-top: 4px; }
.balance { background: #f1f4f7; }
.balance p { color: var(--navy); font-weight: 750; }
.balance h1, .balance-line strong { font-variant-numeric: tabular-nums; }
.balance-line { border-top: 1px solid #dfd9cc; margin-top: 15px; padding-top: 14px; }
.balance-line strong { font-size: 1.4rem; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rows strong { font-size: .91rem; }
.rows small { margin-top: 2px; font-size: .77rem; }
.account-link { text-align: left; border: 0; background: transparent; padding: 4px 0; }
.credit { color: var(--blue); }
.outline {
  border: 1px solid #a5bcd4;
  padding: 7px 11px;
  min-height: var(--ui-touch);
  border-radius: 9px;
  background: #fff;
  color: var(--blue);
  font-size: .85rem;
  font-weight: 700;
}
.right .outline { margin-top: 5px; }
.segments { display: flex; gap: 6px; margin-top: 12px; }
.segments button { padding: 8px 16px; min-height: var(--ui-touch); border: 1px solid var(--line); background: #fff; border-radius: 999px; }
.segments [aria-pressed="true"] { background: var(--blue); color: white; border-color: var(--blue); }
.empty { padding: 20px 0; color: var(--muted); }
.app > .cards-screen, .app > .products-app { flex: 1; }
/* 내용이 짧은 화면(전체 메뉴 등)에서도 하단 탭이 바닥에 붙게 한다 */
.app > #ext-screen { flex: 1; display: flex; flex-direction: column; }
.primary {
  width: 100%;
  min-height: 49px;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}
.dock { position: sticky; bottom: 0; padding: 10px 0 max(8px, env(safe-area-inset-bottom)); background: #fff; }
.dock > * + * { margin-top: 10px; }
.transfer { display: flex; flex-direction: column; }
.transfer > .dock { margin-top: auto; }
.transfer > form { flex: 1; display: flex; flex-direction: column; }
.transfer form .dock { margin-top: auto; }
.note { font-size: .84rem; }
.progress { color: var(--muted); font-size: .84rem; }
.progress strong { color: var(--navy); }
.bank .brand { font-weight: 800; }
.bank .brand svg { width: 18px; }
label { display: grid; gap: 8px; font-weight: 700; }
label + label { margin-top: 12px; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid #cbd5df;
  border-radius: 11px;
  padding: 10px 12px;
  color: var(--navy);
  background: #f7f9fb;
}
label + button { margin-top: 12px; }
form .note { margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 20px; }
.error { color: #a22938; font-size: .87rem; margin-top: 6px; }
.error:empty { display: none; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: start; margin: 0; }
h1 + dl { margin-top: 15px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-weight: 750; }
.success-mark { border-radius: 100%; display: grid; place-items: center; width: 58px; height: 58px; background: #eaf3e9; color: #24633a; font-size: 1.65rem; }

/* AI 상담: 노비즈 뱅크 채팅 모양 (ADR 0031). 흰 바탕, AI 말풍선은 옅은 회청색, 내 말은 파랑, 예시는 칩 */
.chat-screen { display: contents; }
main.chat { display: flex; flex-direction: column; padding: 0; background: var(--ui-white); }
main.chat > * + * { margin-top: 0; }
.chat-progress { position: sticky; top: 0; z-index: 1; padding: 10px var(--ui-page-gutter) 8px; border-bottom: 1px solid var(--ui-line); background: var(--ui-white); }
.chat-steps { display: flex; gap: 6px; }
.chat-step { flex: 1; padding: 6px 2px; border-radius: 10px; background: var(--ui-surface); color: var(--ui-muted); font-size: 12px; font-weight: 600; text-align: center; white-space: nowrap; transition: background .3s, color .3s; }
.chat-step.past { background: var(--ui-blue-soft); color: var(--ui-blue-text); }
.chat-step.on { background: var(--ui-blue); color: var(--ui-white); }
.chat-step.wait { background: var(--ui-amber); color: var(--ui-white); }
.chat-flow { margin-top: 6px; color: var(--ui-muted); font-size: 12px; line-height: 1.5; }
.chat-feed { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: var(--ui-space-md) var(--ui-page-gutter) var(--ui-space-lg); }
.chat-feed > * { scroll-margin-bottom: 90px; }
.chat-row { display: flex; align-items: flex-start; gap: var(--ui-space-sm); }
.chat-avatar { flex: 0 0 32px; display: grid; place-items: center; height: 32px; border-radius: 11px; background: var(--ui-blue-soft); }
.chat-avatar svg { width: 20px; }
.bubble { max-width: 84%; margin: 0; padding: 12px 15px; border-radius: 18px; overflow-wrap: anywhere; line-height: 1.55; font-size: 15px; }
.bubble p { white-space: pre-wrap; }
.bubble.assistant { border-top-left-radius: 6px; background: var(--ui-surface); }
.bubble.user { align-self: flex-end; border-bottom-right-radius: 6px; background: var(--ui-blue); color: var(--ui-white); }
.chat-hint { margin-top: var(--ui-space-xs); color: var(--ui-muted); font-size: var(--ui-small-size); }
.chat-examples { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-example { min-height: 32px; padding: 5px 12px; border: 1px solid var(--ui-line); line-height: 1.35; border-radius: 999px; background: var(--ui-white); color: var(--ui-navy); font-size: 14px; font-weight: 500; text-align: left; }
.chat-example:hover { border-color: var(--ui-blue); background: var(--ui-blue-soft); color: var(--ui-blue-text); }
.bubble.status { color: var(--ui-muted); font-size: var(--ui-small-size); }
.chat-dots { display: inline-flex; gap: 3px; margin-left: 6px; }
.chat-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: chat-dot 1.2s infinite ease-in-out; }
.chat-dots i:nth-child(2) { animation-delay: .15s; }
.chat-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .chat-dots i, .chat-step { animation: none; transition: none; } }
/* 승인 카드: AI 말풍선 아래 테두리 상자. 버튼은 공통 PIN 창(approval.mjs)을 연다 */
.chat-action { display: grid; gap: 10px; width: min(370px, calc(100% - 40px)); margin-left: 40px; padding: 16px; border: 1.5px solid var(--ui-blue); border-radius: 20px; background: var(--ui-white); }
.chat-action-kind { display: inline-flex; align-items: center; gap: 5px; justify-self: start; padding: 4px 10px; border-radius: 999px; background: var(--ui-blue-soft); color: var(--ui-blue-text); font-size: 12px; font-weight: 700; }
.chat-action-kind .ui-icon { width: 14px; height: 14px; flex-basis: 14px; }
.chat-action p { color: var(--ui-navy); font-size: 15px; font-weight: 600; line-height: 1.5; white-space: pre-line; }
.chat-action .ui-button { width: 100%; border-radius: 14px; }
.status { color: var(--muted); font-size: .88rem; }
.composer { position: sticky; bottom: var(--ui-tabs-height); z-index: 1; padding: 12px var(--ui-page-gutter); border-top: 1px solid var(--ui-line); background: var(--ui-white); }
.composer > div { display: flex; align-items: center; gap: 8px; }
.composer input { flex: 1; min-width: 0; min-height: 48px; padding: 12px 16px; border: 1.5px solid var(--ui-line); border-radius: 14px; background: var(--ui-surface); color: var(--ui-navy); font-size: 15px; font-weight: 400; }
.composer input:focus { border-color: var(--ui-blue); background: var(--ui-white); outline: none; }
.composer .primary { flex: 0 0 48px; width: 48px; min-width: 48px; min-height: 48px; padding: 0; border-radius: 14px; }
.composer .primary .ui-icon { width: 20px; height: 20px; }

.app[data-page="account"] h1, .app[data-page="manage"] h1, .transfer h1 { font-size: var(--ui-title-size); line-height: 1.35; word-break: keep-all; overflow-wrap: anywhere; }
.spread > div, .spread h1, .rows li > div, dd { min-width: 0; overflow-wrap: anywhere; }
.spread h1 { flex: 1; }
.spread .ui-button { padding-inline: 0; }
.rows li > strong { flex-shrink: 0; white-space: nowrap; }
.card h2:not(:first-child), .card dl + h2 { margin-block: var(--ui-space-md) var(--ui-space-sm); }
.transfer-summary { white-space: pre-line; overflow-wrap: anywhere; color: var(--ui-navy); }
.transfer .card .transfer-summary { color: var(--ui-navy); }
h1[tabindex="-1"]:focus { outline: none; }
.chips button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.transfer .card.spread > div { flex: 1; }
.transfer .card.spread .right { flex: 0 0 auto; }

@media (max-width: 350px) {
  .topbar { padding-inline: 12px; }
  .rows strong { font-size: .82rem; }
}

/* 계좌 상세 거래 목록: 날짜 줄은 점 없이 작은 회색 머리줄 */
.tx-list { margin: 0; padding: 0; list-style: none; }
.tx-date { margin-top: 12px; color: var(--ui-muted); font-size: 13px; font-weight: 700; }
