/* 드롭빈 웹 /w — 기준 brand/DESIGN.md(투빈). 앱 색 드롭빈 #1E88C7, 글자·버튼은 진한 #14659A. */
:root {
  color-scheme: light dark;
  --bg: #FBFAF7;
  --panel: #F4F1EA;
  --card: #FFFFFF;
  --ink: #1D1F24;
  --muted: #5B5F66;
  --line: #E6E1D6;
  --line-strong: #D9D2C3;
  --accent: #14659A;
  --accent-ink: #FFFFFF;
  --accent-mark: #1E88C7;
  --tint: #DCEDF8;
  --tint-ink: #0F4E78;
  --focus: #1F6E8C;
  --warn-bg: #F8EDC2; --warn: #5B4A00;
  --ok-bg: #DCEFE3; --ok: #1D5733;
  --bad-bg: #F9DEDE; --bad: #8A2424;
  --info-bg: #DCEBF4; --info: #134F66;
  --shadow: 0 30px 60px -28px rgba(29, 31, 36, 0.5);
  --r-sm: 14px; --r: 20px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316; --panel: #17191C; --card: #1B1D21; --ink: #ECEAE4; --muted: #A9ABB0; --line: #2F3238; --line-strong: #3A3E45;
    --accent: #6CB8E6; --accent-ink: #0B2233; --accent-mark: #6CB8E6; --tint: #1A2C38; --tint-ink: #9CD0EF; --focus: #7CBBD6;
    --warn-bg: #3F3714; --warn: #F2DD8A; --ok-bg: #1E3A2A; --ok: #8FD9AE; --bad-bg: #472327; --bad: #F2A3A3; --info-bg: #1F3544; --info: #9CD0E8;
    --shadow: 0 30px 60px -28px rgba(0, 0, 0, 0.8);
  }
}
:root[data-theme="dark"] {
  --bg: #121316; --panel: #17191C; --card: #1B1D21; --ink: #ECEAE4; --muted: #A9ABB0; --line: #2F3238; --line-strong: #3A3E45;
  --accent: #6CB8E6; --accent-ink: #0B2233; --accent-mark: #6CB8E6; --tint: #1A2C38; --tint-ink: #9CD0EF; --focus: #7CBBD6;
  --warn-bg: #3F3714; --warn: #F2DD8A; --ok-bg: #1E3A2A; --ok: #8FD9AE; --bad-bg: #472327; --bad: #F2A3A3; --info-bg: #1F3544; --info: #9CD0E8;
  --shadow: 0 30px 60px -28px rgba(0, 0, 0, 0.8);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.6 var(--font); word-break: keep-all; overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--tint); color: var(--tint-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.3; font-weight: 800; letter-spacing: -0.03em; text-wrap: balance; }
h2 { font-size: 1.125rem; line-height: 1.4; font-weight: 700; }
code, .pair-code, .big-code, .add-code { font-variant-numeric: tabular-nums; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.875em; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(72rem, 100% - 2.5rem); margin-inline: auto; }
[hidden] { display: none !important; }

.i { width: 1.25rem; height: 1.25rem; flex: none; }
.i.sm { width: 1.125rem; height: 1.125rem; }
.i.xs { width: 0.95rem; height: 0.95rem; }

/* ── 상단 바 ── */
.bar { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.bar-in { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.125rem; letter-spacing: -0.02em; }
.brand img { border-radius: 22%; box-shadow: 0 0 0 2px var(--card); }
.bar-right { display: flex; align-items: center; gap: 0.75rem; }
.count { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; padding: 0 0.35rem; border-radius: 999px; background: var(--tint); color: var(--tint-ink); font-size: 0.8125rem; font-weight: 700; }
.offline { font-size: 0.875rem; color: var(--warn); background: var(--warn-bg); padding: 0.3rem 0.75rem; border-radius: 999px; }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 44px; padding: 0.6rem 1.25rem; border-radius: 999px; border: 1px solid transparent;
  font: 700 0.9375rem/1.2 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.btn, .target, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover:not(:disabled) { border-color: var(--ink); }
.btn.ghost.danger { color: var(--bad); }
.btn.ghost.danger:hover { border-color: var(--bad); background: var(--bad-bg); }
.btn.sm { min-height: 36px; padding: 0.4rem 0.85rem; font-size: 0.875rem; }
.btn.lg { min-height: 52px; padding: 0.85rem 1.6rem; font-size: 1rem; }
kbd { font: 600 0.75rem/1 var(--font); padding: 0.15rem 0.4rem; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--card); }

/* ── 짝맺기 ── */
.pair { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: clamp(2rem, 6vw, 5rem); align-items: start; padding-block: clamp(2.5rem, 7vw, 5rem); }
.lead { margin-top: 0.75rem; color: var(--muted); font-size: 1.0625rem; line-height: 1.7; max-width: 34em; }
.notice { margin-top: 1.25rem; padding: 0.75rem 1rem; border-radius: var(--r-sm); background: var(--info-bg); color: var(--info); font-size: 0.9375rem; max-width: 34em; }
.steps { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 1.1rem; max-width: 34em; }
.steps li { display: grid; grid-template-columns: 2rem 1fr; gap: 0.9rem; align-items: start; }
.steps strong { display: block; font-weight: 700; }
.steps span:not(.num) { display: block; color: var(--muted); font-size: 0.9375rem; margin-top: 0.1rem; }
.num { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 0.875rem; }
.num.last { background: var(--accent); color: var(--accent-ink); }
.have-app { margin-top: 2.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); max-width: 34em; }
.have-app summary { cursor: pointer; font-weight: 600; color: var(--accent); min-height: 44px; display: flex; align-items: center; list-style: none; gap: 0.5rem; }
.have-app summary::-webkit-details-marker { display: none; }
.have-app summary::before { content: ""; width: 0.5rem; height: 0.5rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.2s ease; flex: none; }
.have-app[open] summary::before { transform: rotate(45deg); }
.code-form { margin-top: 0.75rem; }
.code-form label { display: block; font-size: 0.875rem; color: var(--muted); margin-bottom: 0.4rem; }
.code-row { display: flex; gap: 0.6rem; }
input[inputmode="numeric"] {
  width: 10rem; min-height: 44px; padding: 0.5rem 1rem; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); font: 700 1.125rem/1 var(--font); letter-spacing: 0.2em; font-variant-numeric: tabular-nums;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.75; }
.field-error { margin-top: 0.5rem; color: var(--bad); font-size: 0.875rem; }

.qr-card { background: var(--card); border: 1px solid var(--line); border-radius: 28px; padding: 1.75rem; text-align: center; box-shadow: var(--shadow); }
.qr { aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: #FFFFFF; display: grid; place-items: center; }
.qr svg { width: 100%; height: 100%; display: block; }
.qr-skeleton { width: 100%; height: 100%; background: linear-gradient(100deg, #F1EEE8 30%, #F8F6F2 50%, #F1EEE8 70%); background-size: 300% 100%; animation: shimmer 1.4s ease-in-out infinite; }
.qr-fail { padding: 1.5rem; color: #8A2424; font-size: 0.9375rem; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.pair-code { margin-top: 1.25rem; font-size: 2rem; font-weight: 800; letter-spacing: 0.08em; }
.lock-line { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 0.4rem; font-size: 0.8125rem; color: var(--muted); }

/* ── 확인 코드 ── */
.confirm { display: grid; place-items: center; padding-block: clamp(3rem, 9vw, 6rem); }
.confirm-card { width: min(30rem, 100%); text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 28px; padding: 2.5rem 2rem; box-shadow: var(--shadow); }
.confirm-card .lead { margin-inline: auto; }
.big-code { margin: 1.75rem 0 0.5rem; font-size: clamp(2.75rem, 9vw, 3.5rem); font-weight: 800; letter-spacing: 0.08em; color: var(--accent); }
.confirm-actions { margin-top: 2rem; display: grid; gap: 0.6rem; }

/* ── 주 화면 ── */
.main { display: grid; grid-template-columns: 23rem minmax(0, 1fr); gap: 2.5rem; align-items: start; padding-block: 2rem 4rem; }
.composer { position: sticky; top: calc(64px + 1.5rem); display: grid; gap: 0.9rem; }
textarea {
  width: 100%; min-height: 8.5rem; resize: none; padding: 0.9rem 1rem; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); font: 400 1rem/1.6 var(--font);
  transition: border-color 0.2s ease;
}
textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--tint); }
.compose-row { display: flex; justify-content: space-between; gap: 0.6rem; }
.compose-row .primary { flex: 1; }
.hint { font-size: 0.8125rem; color: var(--muted); line-height: 1.7; }
.targets-box { border: 0; padding: 0.9rem 0 0; margin: 0; border-top: 1px solid var(--line); min-width: 0; }
.targets-box legend { padding: 0; font-size: 0.8125rem; font-weight: 600; color: var(--muted); margin-bottom: 0.5rem; float: left; width: 100%; }
.targets { display: flex; flex-wrap: wrap; gap: 0.5rem; clear: both; }
.target { position: relative; display: inline-flex; align-items: center; gap: 0.4rem; min-height: 36px; padding: 0.35rem 0.85rem 0.35rem 0.65rem; border-radius: 999px; border: 1px solid var(--line-strong); font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: background-color 0.2s ease, border-color 0.2s ease; }
.target input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.target:has(input:checked) { background: var(--tint); border-color: transparent; color: var(--tint-ink); }
.target:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
.target .i { width: 1rem; height: 1rem; }

.fresh { display: grid; gap: 0.6rem; }
.fresh-row { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 0.6rem; align-items: start; padding: 0.85rem 1rem; border-radius: var(--r-sm); background: var(--warn-bg); color: var(--warn); }
.fresh-row .i { margin-top: 0.15rem; }
.fresh-text { display: grid; gap: 0.15rem; font-size: 0.875rem; }
.fresh-row .btn { grid-column: 2; justify-self: start; color: var(--warn); border-color: currentColor; }
.fresh-row .btn + .btn { margin-top: -0.2rem; }

.history-box { min-width: 0; }
.history-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.search-row input {
  width: min(18rem, 100%); min-height: 40px; padding: 0.45rem 1rem; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); font: 400 0.9375rem/1.2 var(--font);
}
.search-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--tint); }
.no-match { padding: 2rem 0; color: var(--muted); font-size: 0.9375rem; }
.history { list-style: none; margin: 0; padding: 0; }
.day h3 { font-size: 0.8125rem; font-weight: 600; color: var(--muted); padding: 1.25rem 0 0.5rem; }
.day:first-child h3 { padding-top: 0.25rem; }
.entry { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto; gap: 0.9rem; align-items: start; padding: 1rem 0; border-top: 1px solid var(--line); }
.day + .entry { border-top: 0; }
.kind { width: 2.5rem; height: 2.5rem; border-radius: 12px; display: grid; place-items: center; background: var(--tint); color: var(--accent); }
.entry.out .kind { background: var(--panel); color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 0.6rem; font-size: 0.8125rem; color: var(--muted); }
.meta .who { font-weight: 700; color: var(--ink); }
.state { display: inline-flex; align-items: center; gap: 0.2rem; }
.state.ok { color: var(--ok); }
.state.bad { color: var(--bad); font-weight: 600; }
.body > p, .body > img, .body > div { margin-top: 0.3rem; }
.link { color: var(--accent); font-weight: 600; overflow-wrap: anywhere; word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link.blocked { color: var(--muted); font-weight: 400; }
.text { white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; max-width: 46em; }
.text.masked { color: var(--muted); font-style: normal; letter-spacing: 0; }
.thumb { display: block; max-width: min(100%, 22rem); max-height: 15rem; width: auto; height: auto; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); object-fit: contain; }
.file { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; }
.file strong { overflow-wrap: anywhere; word-break: break-all; }
.file span { font-size: 0.875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.note { font-size: 0.875rem; color: var(--muted); display: flex; align-items: center; gap: 0.35rem; }
.note.warn { color: var(--warn); background: var(--warn-bg); padding: 0.45rem 0.75rem; border-radius: 10px; display: inline-flex; }
.note.bad { color: var(--bad); }
.progress { position: relative; height: 1.75rem; border-radius: 999px; background: var(--panel); overflow: hidden; max-width: 22rem; }
.progress span { position: absolute; inset: 0 auto 0 0; background: var(--tint); transition: width 0.25s ease; }
.progress em { position: relative; display: block; font-style: normal; font-size: 0.8125rem; font-weight: 600; line-height: 1.75rem; padding-inline: 0.75rem; color: var(--tint-ink); font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.4rem; padding-top: 0.15rem; }
.entry.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--tint); } to { background: transparent; } }

.empty { text-align: center; padding: 3rem 1.5rem; border: 1px dashed var(--line-strong); border-radius: var(--r); display: grid; justify-items: center; gap: 0.4rem; }
.empty img { width: 112px; height: 112px; margin-bottom: 0.5rem; }
.empty .muted { max-width: 24em; font-size: 0.9375rem; }

/* ── 기기 메뉴(popover) ── */
.menu {
  position: fixed; inset: 72px 1.25rem auto auto; margin: 0; width: min(24rem, calc(100vw - 2.5rem)); max-height: calc(100vh - 96px); overflow: auto;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); padding: 1.25rem; box-shadow: var(--shadow); overscroll-behavior: contain;
}
.menu h2 { margin-bottom: 0.75rem; }
.device-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; }
.device-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 0.75rem; align-items: center; padding: 0.75rem 0; border-top: 1px solid var(--line); }
.device-list li:first-child { border-top: 0; padding-top: 0; }
.device-list .i { color: var(--muted); }
.dev-text { display: grid; min-width: 0; }
.dev-text span { font-size: 0.8125rem; color: var(--muted); }
.menu .add { width: 100%; }
.add-box { margin-top: 0.75rem; padding: 1rem; border-radius: var(--r-sm); background: var(--panel); text-align: center; display: grid; gap: 0.5rem; }
.add-code { font-size: 1.75rem; font-weight: 800; letter-spacing: 0.08em; color: var(--accent); }
.add-confirm { display: flex; justify-content: center; gap: 0.5rem; }
.menu-actions { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: space-between; }

/* ── 끌어다 놓기·알림 ── */
.drop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 82%, transparent); pointer-events: none; }
.drop::before { content: ""; position: absolute; inset: 1rem; border: 2px dashed var(--accent-mark); border-radius: 28px; }
.drop p { font-size: 1.375rem; font-weight: 800; color: var(--accent); background: var(--card); padding: 0.9rem 1.5rem; border-radius: 999px; box-shadow: var(--shadow); }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 30; max-width: min(32rem, calc(100vw - 2.5rem)); padding: 0.75rem 1.25rem; border-radius: var(--r-sm); background: var(--ink); color: var(--bg); font-size: 0.9375rem; font-weight: 600; box-shadow: var(--shadow); animation: up 0.2s ease-out; }
.toast[data-tone="error"] { background: var(--bad-bg); color: var(--bad); }
.toast[data-tone="success"] { background: var(--ok-bg); color: var(--ok); }
@keyframes up { from { transform: translate(-50%, 0.5rem); opacity: 0; } }

/* ── 좁은 화면 ── */
@media (max-width: 60rem) {
  .main { grid-template-columns: 1fr; gap: 2rem; }
  .composer { position: static; }
}
@media (max-width: 52rem) {
  .pair { grid-template-columns: 1fr; }
  .qr-card { max-width: 22rem; width: 100%; justify-self: center; order: -1; }
}
@media (max-width: 36rem) {
  .search-row, .search-row input { width: 100%; }
  .entry { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .actions { grid-column: 2; justify-content: flex-start; }
  .code-row { flex-direction: column; }
  input[inputmode="numeric"] { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
