:root {
  /* 회색 흑연 계열 한 줄기 + 초록 강조 하나. 색은 내용(아바타·배터리·인증번호)에만 */
  --bg: #f5f5f4;
  --surface: #ffffff;
  --surface-2: #efefed;
  --line: rgba(20, 20, 22, 0.09);
  --text: #18181a;
  --text-2: #5c5c62;
  --text-3: #8a8a90;
  --accent: #14855c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ea;
  --danger: #d1343a;
  --warn: #a8670f;
  --info: #2f6fd6;
  --raised: #ffffff;
  --bubble-in: #ffffff;
  --bubble-out: #14855c;
  --bubble-out-ink: #ffffff;
  --shadow: 0 1px 2px rgba(16, 20, 30, 0.06), 0 1px 1px rgba(16, 20, 30, 0.04);
  --radius: 14px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-pill: 999px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --fs-large: 34px;
  --fs-title: 17px;
  --fs-body: 16px;
  --fs-sub: 13px;
  --fs-cap: 12px;
  --hair: 0.5px;
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-1: 0.16s;
  --dur-2: 0.32s;
  --nav-h: 44px;
  --tab-h: 50px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

/* 다크: 테마가 '자동'이면 아이폰 설정을 따르고, 설정 화면에서 고정하면 data-theme 이 이긴다 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113;
    --surface: #1a1a1c;
    --surface-2: #252527;
    --line: rgba(237, 237, 237, 0.09);
    --text: #ededed;
    --text-2: #a1a1a6;
    --text-3: #6f6f75;
    --accent: #3cc48c;
    --accent-ink: #062016;
    --accent-soft: rgba(60, 196, 140, 0.14);
    --danger: #e5484d;
    --warn: #d9a04a;
    --info: #5b93ec;
    --raised: #3a3a3d;
    --bubble-in: #252527;
    --bubble-out: #1f8a61;
    --bubble-out-ink: #ffffff;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111113;
  --surface: #1a1a1c;
  --surface-2: #252527;
  --line: rgba(237, 237, 237, 0.09);
  --text: #ededed;
  --text-2: #a1a1a6;
  --text-3: #6f6f75;
  --accent: #3cc48c;
  --accent-ink: #062016;
  --accent-soft: rgba(60, 196, 140, 0.14);
  --danger: #e5484d;
  --warn: #d9a04a;
  --info: #5b93ec;
  --raised: #3a3a3d;
  --bubble-in: #252527;
  --bubble-out: #1f8a61;
  --bubble-out-ink: #ffffff;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.app { min-height: 100%; display: flex; flex-direction: column; }
.boot { margin: auto; color: var(--text-3); padding: 40px; }

/* ── 상단 바 ───────────────────────────── */
/* 왼쪽 버튼 · 가운데 제목 · 오른쪽 버튼. 제목이 길면 가운데 칸만 줄고 말줄임. */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: minmax(40px, 1fr) minmax(0, auto) minmax(40px, 1fr); align-items: center; gap: var(--sp-2);
  min-height: calc(var(--safe-t) + var(--nav-h));
  padding: var(--safe-t) var(--sp-4) 0;
  background: transparent;
  box-shadow: 0 var(--hair) 0 transparent;
  transition: background-color var(--dur-1), box-shadow var(--dur-1);
}
.topbar.scrolled {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.8) blur(20px);
  -webkit-backdrop-filter: saturate(1.8) blur(20px);
  box-shadow: 0 var(--hair) 0 var(--line);
}
.topbar > :first-child { justify-self: start; }
.topbar > :last-child { justify-self: end; }
.topbar h1 { font-size: var(--fs-title); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.topbar .sub { display: block; font-size: var(--fs-cap); font-weight: 500; color: var(--text-3); }
.topbar .title-wrap { min-width: 0; text-align: center; }
.topbar .title-wrap h1, .topbar .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-side.end { display: flex; justify-content: flex-end; align-items: center; gap: var(--sp-2); }
.nav-title {
  font-size: var(--fs-title); font-weight: 600; white-space: nowrap;
  opacity: 0; transform: translateY(4px); transition: opacity var(--dur-1), transform var(--dur-1) var(--ease-out);
}
.topbar.collapsed .nav-title { opacity: 1; transform: none; }
.large-title {
  font-size: var(--fs-large); line-height: 1.15; font-weight: 700; letter-spacing: -0.02em;
  margin: 0 4px var(--sp-3);
}
.icon-btn {
  border: 0; background: transparent; padding: 8px; margin: -8px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--accent);
  min-width: 40px; min-height: 40px;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
  white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.on { background: var(--accent); }
.dot.off { background: var(--danger); }

/* ── 본문 ─────────────────────────────── */
.view { flex: 1; padding: 4px 16px calc(var(--tab-h) + var(--safe-b) + 20px); }
.view.chat { padding: 0; display: flex; flex-direction: column; }
.section-title { font-size: var(--fs-sub); font-weight: 500; color: var(--text-3); margin: 24px 4px 8px; }

.chips { display: flex; gap: 8px; margin: 4px 0 12px; overflow-x: auto; scrollbar-width: none; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list { list-style: none; margin: 0; padding: 0; }

/* iOS 식 안쪽 들여쓴 머리카락 구분선: 아바타 오른쪽(글자 시작)부터 */
.conv {
  position: relative;
  display: flex; gap: 12px; align-items: center; padding: 12px 16px; text-decoration: none; color: inherit;
}
.conv::after, .row::after, .log li::after, .audit::after {
  content: ""; position: absolute; right: 0; bottom: 0; left: 16px; height: var(--hair); background: var(--line);
}
.conv::after { left: 72px; }
.list > li:last-child .conv::after, .row:last-child::after, .log li:last-child::after, .audit:last-child::after { display: none; }
.conv:active { background: var(--surface-2); }
.avatar {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 17px; color: #fff;
}
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 8px; }
.conv-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.conv-time { font-size: 12px; color: var(--text-3); flex: none; font-variant-numeric: tabular-nums; }
.conv-bottom { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.conv-text { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.conv-app { font-size: 12px; color: var(--text-3); }
.badge {
  font-variant-numeric: tabular-nums;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600;
  min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.muted-mark { font-size: 12px; color: var(--text-3); flex: none; }

.empty { text-align: center; color: var(--text-3); padding: 48px 20px; font-size: 15px; }
.empty strong { display: block; color: var(--text-2); font-size: 17px; margin-bottom: 6px; }

/* ── 대화 화면 ────────────────────────── */
.messages { flex: 1; padding: 12px 16px 8px; display: flex; flex-direction: column; gap: 4px; }
.older { align-self: center; margin: 12px auto 0; padding: 8px 16px; border: 0; border-radius: 999px; background: var(--surface-2); color: var(--accent); font: inherit; font-size: 14px; }
.older[hidden] { display: none; }
.older:disabled { opacity: .5; }
.day { align-self: center; font-size: 12px; font-weight: 500; color: var(--text-3); margin: 12px 0 8px; }
.msg { max-width: 82%; display: flex; flex-direction: column; align-items: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg .who { font-size: 12px; color: var(--text-3); margin: 6px 4px 2px; }
.bubble {
  background: var(--bubble-in); padding: 8px 12px; border-radius: 18px; border-top-left-radius: 6px;
  white-space: pre-wrap; word-break: break-word; box-shadow: 0 0 0 var(--hair) var(--line);
}
.msg.out .bubble { background: var(--bubble-out); color: var(--bubble-out-ink); border-radius: 18px; border-top-right-radius: 6px; box-shadow: none; }
.messages.feed { gap: 8px; }
.noti {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 16px; display: flex; flex-direction: column; gap: 4px;
}
.noti-top { display: flex; align-items: baseline; gap: 8px; }
.noti-title { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noti-top time { flex: none; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.noti-text { font-size: 15px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }
.noti .otp { align-self: flex-start; margin-top: 4px; }
.msg .meta { font-size: 11px; color: var(--text-3); margin: 4px 8px 8px; font-variant-numeric: tabular-nums; }
.msg.pending .bubble { opacity: 0.6; }
.msg.failed .meta { color: var(--danger); }
.otp {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 12px;
  background: var(--surface); color: var(--text); border: 0; border-radius: 12px;
  box-shadow: inset 3px 0 0 var(--accent), 0 0 0 var(--hair) var(--line);
  padding: 8px 12px 8px 16px; text-align: left;
}
.otp-code {
  font: 600 22px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
}
.otp-act { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; color: var(--accent); }
.otp-act svg { width: 16px; height: 16px; }
.otp.copied .otp-act { color: var(--text-3); }

.composer {
  position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 12px calc(var(--safe-b) + 8px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); background: var(--surface);
  border-radius: 20px; padding: 9px 14px; max-height: 140px; min-height: 40px; outline: none; line-height: 1.35;
}
.composer textarea:focus { border-color: var(--accent); }
.send {
  border: 0; background: var(--accent); color: var(--accent-ink); width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.send:disabled { background: var(--surface-2); color: var(--text-3); }
.send svg { width: 20px; height: 20px; }
.notice {
  margin: 8px 12px calc(var(--safe-b) + 10px); padding: 10px 12px; border-radius: 12px;
  background: var(--surface-2); color: var(--text-2); font-size: 14px;
}

/* ── 제어 화면 ────────────────────────── */
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.status-cell:last-child:nth-child(odd) { grid-column: 1 / -1; }
.status-cell { background: var(--surface); padding: 12px 16px; min-width: 0; }
.status-cell .k { font-size: 12px; color: var(--text-3); }
.status-cell .v { font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-cell .sub { font-size: 12px; color: var(--text-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-body { padding: 16px; display: grid; gap: 12px; }
.loc-head { display: flex; gap: 10px; align-items: flex-start; }
.loc-head svg { width: 22px; height: 22px; color: var(--accent); flex: none; margin-top: 1px; }
.loc-text { min-width: 0; }
.loc-text b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.loc-text span { font-size: 13px; color: var(--text-3); }
.loc-empty { color: var(--text-2); font-size: 14px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.device-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 0; }
.device-head .name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-head .seen { font-size: 12px; color: var(--text-3); flex: none; }
.dot.on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.power { padding: 12px 16px 16px; border-bottom: var(--hair) solid var(--line); }
.power-fig { display: flex; align-items: baseline; gap: 8px; }
.power-fig b { font-size: 40px; line-height: 1; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.power-fig b small { font-size: 20px; font-weight: 500; color: var(--text-2); margin-left: 2px; letter-spacing: 0; }
.power-fig span { font-size: var(--fs-sub); color: var(--text-3); }
.meter {
  position: relative; height: 12px; margin-top: 12px; border-radius: 4px; overflow: hidden;
  background: var(--surface-2); box-shadow: inset 0 0 0 var(--hair) var(--line);
}
.meter i {
  position: absolute; inset: 0 auto 0 0; border-radius: 4px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 86%, #fff), var(--accent));
  transition: width var(--dur-2) var(--ease-out);
}
.meter.low i { background: var(--danger); }
.meter.charging i { background-image: repeating-linear-gradient(-45deg, transparent 0 6px, rgba(255, 255, 255, 0.18) 6px 12px), linear-gradient(180deg, color-mix(in srgb, var(--accent) 86%, #fff), var(--accent)); }
.meter::after { /* 20% 눈금: 휴대폰 배터리 칸처럼 */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(20% - 1px), var(--surface) calc(20% - 1px) 20%);
}

.controls { display: grid; gap: 8px; }
.control {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.control .label { flex: 1; min-width: 0; }
.control .label b { display: block; font-weight: 600; }
.control .label span { font-size: 13px; color: var(--text-3); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; flex: none; }
.seg button {
  border: 0; background: transparent; border-radius: 8px; padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--text-2);
}
.seg button:active { background: var(--surface); }
.seg button.primary { background: var(--accent); color: var(--accent-ink); }

.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; background: var(--accent); color: var(--accent-ink);
  width: 100%;
}
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; }
.btn, .chip, .seg button, .send, .otp { transition: transform var(--dur-1) var(--ease-out), opacity var(--dur-1); }
.btn:active:not(:disabled), .chip:active, .seg button:active, .send:active:not(:disabled), .otp:active { transform: scale(0.97); }
.btn-row { display: flex; gap: 8px; }

.log { font-size: 13px; }
.log li { position: relative; display: flex; gap: 12px; padding: 12px 16px; align-items: baseline; }
.log .what { flex: 1; min-width: 0; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log .st { font-weight: 600; flex: none; }
.st-done { color: var(--accent); }
.st-failed, .st-expired { color: var(--danger); }
.st-pending, .st-sent { color: var(--warn); }
.log time { color: var(--text-3); flex: none; font-size: 12px; font-variant-numeric: tabular-nums; }

/* ── 설정 ─────────────────────────────── */
.row { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 52px; }
.row .label { flex: 1; min-width: 0; }
.row .label span { display: block; font-size: 13px; color: var(--text-3); }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; background: var(--surface-2); border-radius: 16px; transition: background 0.2s; border: 1px solid var(--line); }
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 25px; height: 25px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.row .seg button { padding: 6px 12px; }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.help { font-size: 13px; color: var(--text-3); margin: 8px 4px 0; }
.steps { margin: 0; padding: 12px 16px 12px 36px; font-size: 14px; color: var(--text-2); }
.steps li { margin: 4px 0; }
.stack { display: grid; gap: 12px; padding: 16px; }

/* ── 로그인 ───────────────────────────── */
.login { margin: auto; width: min(360px, 100%); padding: 24px 16px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 16px; }
.login h1 { font-size: 24px; font-weight: 600; margin: 16px 0 4px; }
.login p { color: var(--text-3); margin: 0 0 24px; }
.login input {
  width: 100%; border: 0; background: var(--surface); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 12px; outline: none; box-shadow: inset 0 0 0 var(--hair) var(--line);
}
.login input:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
/* iOS 식 묶음 칸: 이름·비밀번호를 한 카드에, 사이는 머리카락 선 */
.field-group { background: var(--surface); border-radius: 12px; overflow: hidden; margin-bottom: 16px; box-shadow: 0 0 0 var(--hair) var(--line); }
.field-group input { margin: 0; border-radius: 0; box-shadow: none; min-height: 48px; }
.field-group input + input { border-top: var(--hair) solid var(--line); }
.field-group input:focus { box-shadow: inset 3px 0 0 var(--accent); }
.login .code-input {
  text-align: center; font: 600 28px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.3em;
  font-variant-numeric: tabular-nums; padding: 12px 16px 12px calc(16px + 0.3em);
}
.login .code-input::placeholder { font: 400 16px/1.2 -apple-system, system-ui, sans-serif; letter-spacing: 0; }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* ── 하단 탭 ──────────────────────────── */
.tabbar {
  box-shadow: 0 calc(-1 * var(--hair)) 0 var(--line);
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding-bottom: var(--safe-b); height: calc(var(--tab-h) + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--text-3); font-size: 10px; font-weight: 500; position: relative;
}
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar svg { width: 25px; height: 25px; }
.tabbar .badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 11px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; max-width: calc(100% - 32px); text-align: center;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── 보안 화면 ─────────────────────────── */
.view.sub-view { padding-bottom: calc(var(--safe-b) + 28px); }
.nav-row { text-decoration: none; color: inherit; }
.nav-row svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.nav-row:active { background: var(--surface-2); }
.field {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px;
  padding: 12px 14px; outline: none;
}
.field:focus { border-color: var(--accent); }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 14px; font-weight: 600; padding: 8px 4px; }
.btn-row.center { justify-content: center; gap: 16px; }
.btn.danger-fill { background: var(--danger); color: #fff; }
.help.flush, .steps.flush { margin: 0; padding-top: 0; padding-bottom: 0; }
.qr-link { justify-self: center; display: block; }
.qr { width: 200px; height: 200px; border-radius: 10px; display: block; image-rendering: pixelated; }
.secret { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--text-3); }
.secret code { color: var(--text); font-size: 14px; letter-spacing: 0.04em; word-break: break-all; flex: 1 1 100%; }
.codes { list-style: none; margin: 0; padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; background: var(--bg); border-radius: 12px; }
.codes code { font-size: 15px; letter-spacing: 0.02em; }
.tag { font-style: normal; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.row .label .tag { display: inline; }
.audit { position: relative; padding: 12px 16px; font-size: 14px; }
.audit span { display: block; font-size: 12px; color: var(--text-3); }
.audit.fail > div { color: var(--danger); }

/* ── 상태: 자리표시·신호 막대·연결 띠 ───── */
.sk { background: var(--surface-2); border-radius: 6px; animation: sk-pulse 1.4s ease-in-out infinite; }
.avatar.sk { border-radius: 13px; }
.sk-line { height: 12px; margin: 6px 0; }
.sk-line.w60 { width: 60%; }
.sk-line.w90 { width: 90%; }
.skeleton .conv { pointer-events: none; }
@keyframes sk-pulse { 50% { opacity: 0.45; } }
.signal { display: inline-flex; align-items: center; gap: 8px; }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.bars i { width: 4px; border-radius: 1px; background: var(--line); }
.bars i.on { background: currentColor; }
.link-banner {
  position: fixed; left: 50%; top: calc(var(--safe-t) + var(--nav-h) + 6px); transform: translateX(-50%); z-index: 15;
  max-width: calc(100% - 32px); padding: 7px 14px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg);
  font-size: var(--fs-sub); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: banner-in var(--dur-2) var(--ease-ios);
}
@keyframes banner-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ── 행 밀기 동작 ─────────────────────── */
.swipe { position: relative; overflow: hidden; }
.swipe > .conv { background: var(--surface); will-change: transform; }
.swipe-tray { position: absolute; top: 0; right: 0; bottom: 0; display: flex; }
.swipe:not(.open):not(.dragging) .swipe-tray { visibility: hidden; } /* 닫혀 있을 때 경계에서 색이 비치지 않게 */
.swipe > .conv { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; }
.swipe-act {
  border: 0; min-width: 76px; padding: 0 14px; color: #fff; font-size: 15px; font-weight: 600;
}
.swipe-act.read { background: var(--info); }
.swipe-act.delete { background: var(--danger); }

/* ── 당겨서 새로 고침 ──────────────────── */
.view { position: relative; }
.ptr {
  position: absolute; top: 0; left: 50%; z-index: 4; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
  background: var(--surface); color: var(--text-3); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.ptr svg { width: 18px; height: 18px; }
.ptr.ready { color: var(--accent); }
.ptr.spin { color: var(--accent); opacity: 1 !important; }
.ptr.spin svg { animation: ptr-spin 0.8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ── 동작 시트 ─────────────────────────── */
.sheet {
  position: fixed; inset: auto 0 0; margin: 0 auto; width: min(100%, 480px); max-width: none; max-height: none;
  border: 0; padding: 0 8px calc(var(--safe-b) + 8px); background: transparent; color: var(--text);
  display: grid; gap: 8px;
  animation: sheet-in var(--dur-2) var(--ease-ios);
}
.sheet:not([open]) { display: none; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.36); animation: fade-in var(--dur-2) var(--ease-out); }
.sheet.closing { animation: sheet-out 0.18s var(--ease-out) forwards; }
.sheet.closing::backdrop { animation: fade-out 0.18s var(--ease-out) forwards; }
.sheet-group {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
  border-radius: var(--radius); overflow: hidden;
}
.sheet-head { padding: 16px 16px 12px; text-align: center; border-bottom: var(--hair) solid var(--line); }
.sheet-head b { display: block; font-size: var(--fs-sub); font-weight: 600; color: var(--text-2); }
.sheet-head p { margin: 4px 0 0; font-size: var(--fs-sub); color: var(--text-3); }
.sheet-btn {
  display: block; width: 100%; min-height: 56px; border: 0; background: transparent;
  font-size: 18px; color: var(--accent); transition: background-color var(--dur-1);
}
.sheet-btn:active { background: var(--surface-2); }
.sheet-btn.danger { color: var(--danger); }
.sheet-btn.cancel { font-weight: 600; color: var(--text); }
.sheet-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* 원격 제어: 갤럭시 응답 대기 */
.control.waiting .label span { color: var(--accent); }
.seg button:disabled { opacity: 0.45; }
.seg button.busy { opacity: 1; position: relative; color: transparent; }
.seg button.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--accent-ink) var(--accent-ink) transparent transparent;
  animation: ptr-spin 0.8s linear infinite;
}
.seg button.busy:not(.primary)::after { border-color: var(--text-2) var(--text-2) transparent transparent; }

/* ── 화면 전환 ─────────────────────────── */
/* push 는 header·main 에만 transform(앱 전체에 걸면 고정 위치 탭바가 따라 움직인다), pop 은 투명도만. */
.app.nav-push > header, .app.nav-push > main { animation: nav-push var(--dur-2) var(--ease-ios) both; }
.app.nav-pop > header, .app.nav-pop > main { animation: nav-pop var(--dur-1) var(--ease-out) both; }
@keyframes nav-push { from { transform: translateX(28%); opacity: 0; } }
@keyframes nav-pop { from { opacity: 0.4; } }

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