/* beQR 메인 화면 — docs/spec/screens/main.md 「시각 토큰」(모노크롬, decisions/0006). 색은 회색조만. */
:root {
  --paper: #EFEFEF; --ink: #000000; --muted: #666666; --line: #C4C4C4;
  --accent: #000000; --accent-ink: #FFFFFF; --sticker: #FFFFFF;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161616; --ink: #FFFFFF; --muted: #A3A3A3; --line: #3D3D3D;
    --accent: #FFFFFF; --accent-ink: #000000; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #161616; --ink: #FFFFFF; --muted: #A3A3A3; --line: #3D3D3D;
  --accent: #FFFFFF; --accent-ink: #000000; color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased; accent-color: var(--ink); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 화면 높이를 채운다 — 내용이 짧으면 하단 안내가 화면 바닥에 붙는다 */
body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.top, .stage, .note { width: 100%; }

/* 머리글: 로고 | 도구(기록·언어 — 아이콘만). 입력 방식 전환은 입력칸 바로 위(.compose 맨 위) */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px;
  max-width: 1120px; margin: 0 auto; padding: 20px clamp(16px, 4vw, 48px) 0; }
.tools { display: inline-flex; align-items: center; gap: 2px; margin-right: -10px; }
.tool { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 999px; background: none; color: var(--ink); cursor: pointer; }
.tool:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.globe .t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.compose > .modes { margin-bottom: 28px; }
@media (max-width: 559px) {
  .compose > .modes { display: flex; margin-bottom: 24px; }
  .compose > .modes button { flex: 1 1 auto; padding: 7px 6px; } /* 탭 넷(0017) — 글자 길이만큼 나눠 한 줄에 */
}
@media (max-width: 359px) { .compose > .modes button { padding: 7px 3px; font-size: 13px; letter-spacing: -0.02em; } }
.brand { display: inline-flex; align-items: center; gap: 9px; color: inherit; text-decoration: none;
  font-weight: 800; font-size: 19px; letter-spacing: -0.01em; }
.modes { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.modes button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600;
  padding: 7px 15px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.modes button[aria-selected="true"] { background: var(--ink); color: var(--paper); }

/* 칸은 minmax(0, …): 처음부터 긴 내용이 든 입력칸이 칸을 밀어내 가로 스크롤이 생기지 않게 */
.stage { flex: 1 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 36px; align-content: start; max-width: 1120px; margin: 0 auto; padding: 36px clamp(16px, 4vw, 48px) 40px; }
@media (min-width: 880px) {
  .stage { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 64px; padding-top: 72px; align-items: start; }
}

/* 주소가 곧 입력칸 — 이 화면의 중심 */
.address { display: flex; flex-wrap: wrap; align-items: baseline; cursor: text;
  font-size: clamp(28px, 4.4vw, 46px); font-weight: 750; line-height: 1.16; letter-spacing: -0.025em;
  padding-bottom: 12px; border-bottom: 3px solid var(--ink); }
.address:focus-within { box-shadow: 0 3px 0 var(--ink); }
.host { color: var(--muted); font-weight: 600; }
.address textarea { flex: 0 0 auto; max-width: 100%; padding: 0; border: 0; outline: none; resize: none; overflow: hidden;
  background: none; color: var(--ink); font: inherit; letter-spacing: inherit; line-height: inherit; overflow-wrap: anywhere; }
.address textarea::placeholder { color: var(--muted); opacity: 0.45; }
.measure { position: absolute; visibility: hidden; white-space: pre; pointer-events: none; }
.address { position: relative; overflow: clip; } /* 측정용 요소가 페이지 폭을 늘리지 않게 */
.reallink { margin: 12px 0 0; color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.reallink strong { color: var(--ink); font-weight: 650; }
.caution { margin: 0; color: var(--muted); font-size: 14px; }
.hint { margin: 16px 0 0; color: var(--muted); font-size: 17px; }

.form { display: grid; gap: 18px; max-width: 520px; }
.form .field > span, .form legend { display: block; margin-bottom: 2px; color: var(--muted); font-size: 14px; font-weight: 600; }
.form input[type="text"], .form input[type="tel"], .form input[type="email"], .form input[type="password"] { width: 100%; padding: 8px 0; border: 0;
  border-bottom: 2px solid var(--line); background: none; color: var(--ink); font: inherit; font-size: 22px; font-weight: 650; outline: none; }
.form input:focus { border-bottom-color: var(--ink); }
.form .field > .pw { display: flex; align-items: center; gap: 14px; margin: 0; color: inherit; font-size: inherit; font-weight: inherit; }
.pw input { flex: 1; min-width: 0; }
.form fieldset { margin: 0; padding: 0; border: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.choices label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 15px; cursor: pointer; }
.choices label:has(input:checked) { border-color: var(--ink); font-weight: 650; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; cursor: pointer; }

/* 읽기(0017): QR 스티커 자리에 카메라 — 스티커 안 정사각 검은 상자, 영상은 회색조(색을 쓰지 않는다, 0006), 가운데 조준 귀퉁이 넷.
   읽으면 같은 자리에 그 QR. 입력칸 자리에는 안내·이미지에서 읽기. 모양 전환·버튼은 읽는 동안 숨긴다 */
.vf { display: none; position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 12px; background: #000000; color: #FFFFFF; }
body.scanning .vf { display: block; }
body.scanning :is(#qr, #link, .shape, .actions, .output > .error) { display: none; }
body.scanning .sticker { padding-bottom: 10px; }
.vf video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1);
  border-radius: inherit; } /* 영상 층은 상자의 둥근 자르기를 벗어난다(크롬) — 영상에도 같은 둥근 모서리 */
.aim { position: absolute; inset: 16%; display: none;
  --c: linear-gradient(rgba(255, 255, 255, 0.92) 0 0);
  background: var(--c) 0 0 / 30px 4px, var(--c) 0 0 / 4px 30px, var(--c) 100% 0 / 30px 4px, var(--c) 100% 0 / 4px 30px,
    var(--c) 0 100% / 30px 4px, var(--c) 0 100% / 4px 30px, var(--c) 100% 100% / 30px 4px, var(--c) 100% 100% / 4px 30px;
  background-repeat: no-repeat; }
.vf.on .aim { display: block; }
.vfmsg { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 24px;
  text-align: center; font-size: 16px; }
.vfmsg p { margin: 0; max-width: 30ch; }
.vf.on .vfmsg { display: none; }
.vf .act { min-height: 44px; color: #FFFFFF; }
/* 실시간 읽기(0019): 읽히는 QR 테두리(QR을 따라 움직임) + 결과 카드(종류·요약·동작·이 QR 열기) */
.hit { position: absolute; inset: 0; width: 100%; height: 100%; display: none; overflow: visible; pointer-events: none; }
.hit.on { display: block; }
.hit polygon { fill: none; stroke-linejoin: round; }
.hit .halo { stroke: #FFFFFF; stroke-width: 9; }
.hit .line { stroke: #000000; stroke-width: 3.5; }
.scard { width: 100%; padding: 14px 16px 12px; border: 1.5px solid var(--ink); border-radius: 14px; }
.sline { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin: 0; font-size: 17px; }
.sline .content { min-width: 0; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* 카드: 「이 QR 열기」는 왼쪽 글자 링크, 종류별 동작은 오른쪽 끝 주 버튼(ink 바탕, 0021) */
.sacts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 10px; }
.sacts .primary { display: inline-flex; align-items: center; min-height: 44px; margin-left: auto; padding: 10px 18px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer; }
.sacts .act { min-height: 44px; font-size: 15px; }
@media (prefers-reduced-motion: no-preference) { .scard.pop { animation: card-pop 220ms ease-out; } }
@keyframes card-pop { 40% { transform: scale(1.015); } }
.scan { display: grid; gap: 16px; justify-items: start; }
.scan .hint { margin: 0; }
.scan > button { min-height: 46px; padding: 11px 18px; border: 1.5px solid var(--ink); border-radius: 12px; background: none;
  color: var(--ink); font: inherit; font-size: 16px; font-weight: 650; cursor: pointer; }
.scan > button:disabled { opacity: 0.5; cursor: progress; }
.scan .error { width: 100%; }
:lang(ko) .vfmsg p { word-break: keep-all; }

.reading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-top: 24px; font-size: 17px; }
.kind { padding: 2px 8px; border-radius: 4px; background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 700; }
.content { overflow-wrap: anywhere; }
.act { padding: 0; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.act:hover { text-decoration-thickness: 3px; }
.literal { margin-top: 10px; }

.output { display: grid; justify-items: center; gap: 20px; }
.sticker { width: min(100%, 380px); margin: 0; padding: 10px 10px 16px; border-radius: 22px; background: var(--sticker); color: #000000;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10), 0 18px 40px -18px rgba(0, 0, 0, 0.35); }
.qr svg { display: block; width: 100%; height: auto; }
.qr.empty { display: grid; place-items: center; aspect-ratio: 1; border: 2px dashed #C4C4C4; border-radius: 12px;
  color: #8A8A8A; font-size: 15px; text-align: center; padding: 24px; }
.sticker figcaption { margin: 2px 12px 0; text-align: center; font-size: 15px; font-weight: 650; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* 모양 전환(0009·0015): 알약 안에 모양 그림 버튼. 라디오는 투명하게 덮어 둔다(누름·화살표 키는 라디오가 받는다) */
.shape { display: inline-flex; margin: 0; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.shape label { position: relative; display: block; }
.shape input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.shape input + span { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-height: 38px; border-radius: 999px;
  color: var(--muted); }
.shape .t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* 이름은 읽기 도구·마우스 올림(title) */
.shape input:checked + span { background: var(--ink); color: var(--paper); }
.shape input:focus-visible + span { outline: 3px solid var(--ink); outline-offset: 2px; }
.shape label:hover input:not(:checked) + span { color: var(--ink); }
.error { width: min(100%, 380px); margin: 0; padding-left: 12px; border-left: 4px solid var(--ink); color: var(--ink); font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.actions button { min-height: 46px; padding: 11px 18px; border: 1.5px solid var(--ink); border-radius: 12px; background: none;
  color: var(--ink); font: inherit; font-size: 16px; font-weight: 650; cursor: pointer; }
.actions .quiet { min-height: auto; padding: 8px 6px; border: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.actions .quiet:hover:not(:disabled) { color: var(--ink); text-decoration: underline; }
.actions .primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.actions button:disabled { opacity: 0.35; cursor: not-allowed; }
.quiet { color: var(--muted); font-size: 14px; }
.note { max-width: 1120px; margin: 0 auto; padding: 8px 16px 24px; color: var(--muted); font-size: 14px; text-align: center; }
.note p { margin: 0; }
/* 한국어 안내 문장은 어절 단위로 줄바꿈(음절 중간에서 끊기지 않게) */
:lang(ko) :is(.note p, .hint, .caution, .hempty, .error) { word-break: keep-all; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  .sticker { transition: transform 160ms ease-out; }
  .sticker.pop { transform: scale(1.015); }
}

/* 기록 서랍(0010): 왼쪽에서 나오는 판 + 뒤 막. 목록은 화면 JS가 채운다 */
body.drawer-open { overflow: hidden; }
.scrim { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, 0.4); }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 11; display: none; flex-direction: column; width: min(380px, 92vw);
  background: var(--paper); border-right: 1px solid var(--line); box-shadow: 18px 0 40px -24px rgba(0, 0, 0, 0.5); }
.dhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 4px; }
.dhead h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.015em; }
.dhead .act { min-height: 44px; font-size: 15px; }
.dtabs { display: flex; margin: 10px 20px 0; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.dtabs button { flex: 1; min-height: 38px; border: 0; border-radius: 999px; background: none; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.dtabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.dtabs .count { font-weight: 500; }
.hlist:empty { display: none; } /* 빈 목록이면 안내 문장이 위에 온다 */
.hlist { flex: 1; min-height: 0; overflow-y: auto; margin: 12px 0 0; padding: 0 10px; list-style: none; }
.hitem { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.hopen { flex: 1; min-width: 0; display: grid; gap: 3px; padding: 12px 10px; border: 0; border-radius: 8px; background: none;
  color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.hopen:hover, .hdel:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.hline { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hline .kind { flex: none; }
.hsum, .hmeta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hsum { font-size: 15px; font-weight: 650; }
.hmeta { color: var(--muted); font-size: 13px; }
.hdel { flex: none; width: 44px; border: 0; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 22px; line-height: 1; cursor: pointer; }
.hdel:hover { color: var(--ink); }
.hempty { margin: 20px; color: var(--muted); font-size: 15px; }
.hclear { align-self: flex-start; min-height: 44px; margin: 4px 20px 16px; padding: 0; border: 0; background: none; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.hclear[data-armed] { color: var(--ink); font-weight: 750; text-decoration-thickness: 2px; }
/* 좁은 화면: 서랍(모달) — .open. 넓은 화면(1440px 이상): html.dock이면 늘 펼친 왼쪽 칸(0014), 본문은 그만큼 오른쪽으로 */
.drawer.open { display: flex; }
@media (min-width: 1440px) {
  html.dock body { padding-left: 320px; }
  html.dock .drawer { display: flex; width: 320px; box-shadow: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .drawer.open { animation: drawer-in 180ms ease-out; }
  .scrim { animation: scrim-in 180ms ease-out; }
}
@keyframes drawer-in { from { transform: translateX(-100%); } }
@keyframes scrim-in { from { opacity: 0; } }

/* 휴대폰(880px 미만, 0018): 아래 메뉴 — 만들기 · 읽기 · 기록. JS가 붙으면(body.bnav-on) 보인다. 880px 이상은 그대로.
   아이폰 홈 표시줄·노치: viewport-fit=cover + safe-area 여백 */
.bnav { display: none; }
@media (max-width: 879px) {
  body.bnav-on { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  body.bnav-on .bnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; display: flex;
    padding: 2px max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
    background: var(--paper); border-top: 1px solid var(--line); }
  .bnav button { flex: 1; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 60px; padding: 4px 0;
    border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
  .bnav .ic { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px; }
  .bnav button[aria-current] { color: var(--ink); font-weight: 750; }
  .bnav button[aria-current] .ic { background: var(--ink); color: var(--paper); }
  .bnav button:focus-visible { outline: none; }
  .bnav button:focus-visible .ic { outline: 3px solid var(--ink); outline-offset: 2px; }
  body.bnav-on #histOpen { display: none; }                         /* 기록은 아래 메뉴로 */
  body.bnav-on .modes [data-mode="scan"] { display: none; }         /* 읽기도 아래 메뉴로 */
  body.bnav-on.scanning .compose > .modes { display: none; }        /* 읽기에는 입력 방식이 없다 */
  body.scanning .output { order: -1; }                              /* 읽기: 카메라(스티커 자리)가 맨 위 */
  /* 기록: 머리글·아래 메뉴 사이가 기록 화면(막·닫기 없음) */
  body.hist-full :is(.stage, .note) { display: none; }
  .drawer.full { position: static; display: flex; flex: 1 0 auto; width: 100%; max-width: 640px; margin: 0 auto; border-right: 0; box-shadow: none; background: none; }
  .drawer.full #histClose { display: none; }
  .drawer.full .dhead { padding-top: 28px; }
  .drawer.full .hlist { overflow: visible; }
}
@supports (padding: max(0px)) {
  .top { padding-top: max(20px, env(safe-area-inset-top, 0px)); }
  .top, .stage { padding-left: max(clamp(16px, 4vw, 48px), env(safe-area-inset-left, 0px)); padding-right: max(clamp(16px, 4vw, 48px), env(safe-area-inset-right, 0px)); }
}
