/* 발췌기 — responsive standalone */
:root {
  --line: #dcdcda;
  --line-soft: #e8e8e6;
  --muted: #9a9a98;
  --side: 380px;
  --mono: 'JetBrains Mono', 'Noto Sans KR', monospace;
  /* dvh 는 주소창이 숨을 때마다 값이 바뀌어 패널·카드가 들썩인다.
   svh 는 주소창이 보이는 상태 기준으로 고정이라 흔들리지 않는다. */
  --panel-h: clamp(200px, 33svh, 330px);
}
* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; padding: 0;
  position: fixed; top: 0; left: 0; right: 0;
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100dvh);
  background: #ededeb;
  color: #111;
  font-family: 'Archivo', 'Noto Sans KR', system-ui, sans-serif;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font-family: inherit; color: inherit; }
button { touch-action: manipulation; }
[contenteditable]:focus { outline: none; }
::selection { background: #111; color: #fff; }

/* ---------- app shell ---------- */
.screen {
  width: 100%; height: 100%;
  min-width: 0; min-height: 0;
  background: #fff;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ---------- common controls ---------- */
.mono { font-family: var(--mono); }
.topbar {
  flex: none; height: 50px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .title { font-size: 13px; font-weight: 500; letter-spacing: 0.01em; }
.link { font-size: 13.5px; color: #9a9a9a; cursor: pointer; background: none; border: none; padding: 6px 2px; }
.link.strong { color: #111; font-weight: 600; }

.btn {
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 11.5px; line-height: 1; padding: 0 8px; height: 32px;
  white-space: nowrap; /* line-height 1이라 두 줄이 되는 순간 무조건 깨져 보인다 */
  transition: background 0.12s ease;
}
.btn.on { border-color: #111; }
.btn.fill { background: #111; border-color: #111; color: #fff; }
.btn.danger { color: #a03030; }
.btn.fill.danger { background: #a03030; border-color: #a03030; color: #fff; }
.btn.wide { flex: 1; min-width: 0; }
.btn.tall { height: 40px; font-size: 12.5px; }
@media (hover: hover) {
  .btn:hover { background: #f2f2f0; }
  .btn.fill:hover { background: #000; }
  .btn.danger:hover { background: #f7eded; }
  .btn.fill.danger:hover { background: #8a2828; }
}

/* 서식 도구줄: 낱개 버튼을 흩어 놓으면 어수선해서 한 줄로 이어 붙인다 */
.fmtbar { display: flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.fmtbar .btn {
  flex: 1; min-width: 0; height: 42px; padding: 0 4px;
  border: none; border-right: 1px solid var(--line-soft); border-radius: 0;
  white-space: nowrap;
}
.fmtbar .btn:last-child { border-right: none; }
.fmtbar .btn:active { transform: none; background: #eaeae8; }

.lbl {
  font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.04em; color: var(--muted); flex: none;
}
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid8 { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.seg button {
  flex: 1; min-width: 0; height: 32px; border: none; border-right: 1px solid var(--line);
  background: #fff; color: #6a6a68; font-size: 11.5px; cursor: pointer;
  padding: 0 2px; white-space: nowrap; /* 좁아져도 "손글씨"가 두 줄로 터지지 않게 */
}
.seg button:last-child { border-right: none; }
.seg button.on { background: #111; color: #fff; }
.fontgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fontchip {
  height: 42px; font-size: 15px; line-height: 1.15; padding: 0 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 일본어 지원 표시. 채워진 것은 한자까지, 빈 것은 가나까지. */
.fontchip .jb {
  font-family: var(--mono); font-style: normal;
  font-size: 7.5px; line-height: 1; margin-left: 4px; padding: 2px 3px;
  vertical-align: 2px; border: 1px solid currentColor; border-radius: 2px; opacity: 0.45;
}
.fontchip .jb.full { background: currentColor; color: #fff; opacity: 0.72; }
.fontchip.fill .jb.full { background: #fff; color: #111; opacity: 1; }
/* ---------- 프리셋 칩 (이름 붙여 저장한 설정 묶음) ---------- */
.chips {
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto; overflow-y: hidden; padding: 1px 0 3px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 10px; max-width: 150px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 11.5px; line-height: 1;
}
.chip .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .dot {
  position: relative; flex: none; width: 15px; height: 15px;
  border: 1px solid rgba(0,0,0,0.14);
}
.chip .dot i { position: absolute; right: -1px; bottom: -1px; width: 7px; height: 7px; }
/* 앱이 들고 있는 조합은 지울 수 없어 테두리를 점선으로 구분한다 */
.chip.built { border-style: dashed; color: #5a5a58; }
.chip .x {
  flex: none; width: 16px; height: 16px; margin-right: -3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: #9a9a98; border: 1px solid var(--line-soft); border-radius: 50%;
}
.chip .pen { flex: none; font-size: 10px; color: #9a9a98; }
/* 내 프리셋과 기본 제공 사이의 칸막이 */
.chip-sep { flex: none; width: 1px; height: 18px; background: var(--line); margin: 0 1px; }
/* 줄이 잘려 있을 때만 뜨는 '더 있음' 힌트. 흐림 + 화살표. */
.chipwrap { position: relative; min-width: 0; }
.chipwrap .cfade {
  position: absolute; top: 1px; bottom: 3px; width: 30px;
  display: none; align-items: center; pointer-events: none;
  font-style: normal; font-size: 13px; color: #8f8f8d;
}
.chipwrap .cfade.r { right: 0; justify-content: flex-end; background: linear-gradient(270deg, #fff 30%, rgba(255,255,255,0)); }
.chipwrap .cfade.l { left: 0; justify-content: flex-start; background: linear-gradient(90deg, #fff 30%, rgba(255,255,255,0)); }
.chipwrap.can-r .cfade.r { display: flex; }
.chipwrap.can-l .cfade.l { display: flex; }
@media (hover: hover) {
  .chip:hover { background: #f2f2f0; }
  .chip .x:hover { color: #a03030; border-color: #a03030; }
}
@media (pointer: coarse) {
  .chip { min-height: 36px; }
  .chip .x { width: 20px; height: 20px; font-size: 10px; }
}

/* 테마 색 견본: 줄마다 높이가 달라 옹색해 보이던 것을 38px로 통일한다.
   .on 은 색 위에서도 보이게 안쪽 이중 테두리(흰 띠 + 검은 띠)로 표시 — .thumb.on 과 같은 문법.
   컬러피커도 견본 줄의 한 칸이므로 고정폭을 풀고 같이 늘어난다 */
.tsw { height: 38px; }
/* 빈 색 버튼의 좌우 패딩이 flex 분배에 끼어 피커만 좁아진다 — 견본은 패딩 0 */
.btn.wide.tsw { padding: 0; }
input[type="color"].tsw { flex: 1; min-width: 0; width: auto; height: 38px; }
.btn.tsw.on { border-color: #111; box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px #111; }

.swatch { height: 28px; border: 1px solid rgba(0,0,0,0.12); cursor: pointer; padding: 0; }
.swatch.small { height: 24px; }
.swatch.light { border-color: var(--line); }

/* ---------- 컬러피커 (팔레트 옆에서 아무 색이나) ---------- */
input[type="color"] {
  -webkit-appearance: none; appearance: none;
  flex: none; width: 36px; height: 28px; padding: 0;
  border: 1px solid var(--line); background: #fff; border-radius: 0; cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(0,0,0,0.08); }
input[type="color"]::-moz-color-swatch { border: 1px solid rgba(0,0,0,0.08); }
input[type="color"].tall { height: 34px; }
input[type="color"]:focus { border-color: #111; }

/* ---------- 이미지 보관함 (한 번 넣은 이미지 다시 쓰기) ---------- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 7px; }
.thumb {
  height: 34px; padding: 0; cursor: pointer;
  border: 1px solid var(--line); background-color: #f2f2f0;
  background-size: cover; background-position: center;
}
.thumb.on { border-color: #111; box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 3px #111; }
.note {
  font-size: 10.5px; line-height: 1.65; color: var(--muted); letter-spacing: 0;
}
input[type="range"] { flex: 1; min-width: 0; height: 26px; accent-color: #111; cursor: pointer; }
.fld {
  height: 34px; min-width: 0; padding: 0 10px;
  border: 1px solid var(--line); background: #fff; border-radius: 0;
  font-size: 12.5px; outline: none; -webkit-appearance: none;
}
.fld:focus { border-color: #111; }
.fld::placeholder { color: #b8b8b6; }

/* ---------- input screen ---------- */
.input-screen {
  flex: 1; min-height: 0; width: 100%; max-width: 620px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 10px 20px 24px;
}
.step {
  display: flex; align-items: baseline; gap: 9px;
  font-size: 11.5px; letter-spacing: 0.01em; color: #8f8f8d;
}
.step .n {
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.16em; color: #b4b4b2;
}
.raw {
  flex: 1; min-height: 0; width: 100%; border: 1px solid var(--line); padding: 14px;
  font-size: 12.5px; line-height: 1.8; resize: none; outline: none;
  border-radius: 0; -webkit-appearance: none;
}
.hint { display: flex; flex-direction: column; gap: 5px; font-size: 10.5px; line-height: 1.7; color: var(--muted); }
.hint b { font-weight: 400; color: #111; }

/* ---------- stage ---------- */
.stage {
  flex: 1; min-height: 0; min-width: 0; position: relative;
  display: grid; place-items: center;
  background: #f5f5f4;
  border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
  overflow: hidden;
  /* 무대 위 핀치는 카드 배율 조절로 쓴다 — 브라우저 페이지 확대에 뺏기지 않게 */
  touch-action: pan-x pan-y;
}
/* 핀치 중에는 크기 전환 애니메이션을 끈다 — 손을 따라와야 한다 */
.screen.pinching .card-fit,
.screen.pinching .card-scale { transition: none; }
/* 카드가 실제로 굴러가는 층. 스크롤을 여기서 맡아, 무대에 앵커된
   떠 있는 조작(kbfit·zoomctl)이 카드와 함께 밀려나지 않게 한다.
   grid 트랙 안에서 height:100% 는 무시되고 내용 높이를 갖게 되므로
   absolute 로 무대 크기에 정확히 고정한다 — fitCard 가 이 크기를 잰다. */
.stage-scroll {
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
/* 키보드가 뜨고 지거나 주소창이 오르내려 배율이 바뀔 때, 툭 튀지 않고 넘어가게.
   다시 그릴 때는 요소가 새로 생기므로 애니메이션이 걸리지 않는다(깜빡임 없음). */
.card-fit {
  position: relative; flex: none;
  transition: width 0.16s ease, height 0.16s ease;
}
.card-scale {
  position: absolute; top: 0; left: 0; transform-origin: 0 0;
  transition: transform 0.16s ease;
}
@media (prefers-reduced-motion: reduce) {
  .card-fit, .card-scale { transition: none; }
}
.card {
  position: relative; overflow: hidden;
  box-shadow: 0 1px 0 rgba(0,0,0,0.08), 0 12px 28px rgba(0,0,0,0.1);
}
.card-bg { position: absolute; inset: 0; overflow: hidden; }
.card-bg .pic { position: absolute; background-size: cover; background-position: center; background-color: #d8d8d6; }
.card-bg .pick {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; letter-spacing: 0.1em; color: rgba(255,255,255,0.8); cursor: pointer;
}
.card-bg .veil { position: absolute; inset: 0; pointer-events: none; }
.card-stage { position: relative; z-index: 1; height: 100%; overflow: hidden; }
.card-fitwrap { width: 100%; height: 100%; transform-origin: 0 0; }
.card-flow { height: 100%; display: flex; flex-direction: column; }
/* 자동 비율: 카드 높이가 내용을 따라간다 */
.card.is-auto .card-stage,
.card.is-auto .card-fitwrap,
.card.is-auto .card-flow { height: auto; }
.guide { position: absolute; z-index: 2; border: 1px dashed rgba(120,120,255,0.5); pointer-events: none; }

.blk { position: relative; break-inside: avoid; }
.blk .grip {
  position: absolute; left: -21px; top: 0; width: 16px; height: 100%;
  cursor: grab; display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.blk .grip::after { content: ""; position: absolute; inset: -8px -12px -8px -14px; }
.blk .grip i { width: 4px; height: 100%; max-height: 15px; border-left: 1px solid; border-right: 1px solid; }
.blk .dropline { position: absolute; left: 0; right: 0; height: 2px; pointer-events: none; }
.blk .dropline.before { top: -6px; }
.blk .dropline.after { bottom: -6px; }

.b-col { display: flex; flex-direction: column; }
.b-line { display: flex; align-items: center; gap: 10px; }
.b-rule { height: 1px; flex: 1; }
.b-photo { width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background-size: cover; background-position: center; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 7px; letter-spacing: 0.1em; }
.b-divider { display: flex; justify-content: center; padding: 5px 0; }
.b-divider span { width: 46%; height: 1px; }
.b-bullet { display: flex; gap: 9px; align-items: baseline; }
.b-bullet .dash { width: 10px; flex: none; height: 1px; position: relative; top: -3px; }
.b-avatar { display: flex; gap: 10px; align-items: flex-start; }
.b-avatar .face {
  width: 26px; height: 26px; flex: none; border-radius: 50%; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px;
}
.b-avatar .face[data-act] { cursor: pointer; }
.b-avatar .face .h { width: 8px; height: 8px; border-radius: 50%; }
.b-avatar .face .s { width: 15px; height: 7px; border-radius: 8px 8px 0 0; }
.bubble { max-width: 76%; padding: 7px 12px; border-radius: 14px; text-wrap: pretty; }

/* ---------- status + tabs ---------- */
.statusbar {
  flex: none; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border-bottom: 1px solid var(--line-soft); background: #f5f5f4;
  font-family: var(--mono); font-size: 10px;
}
.statusbar .sep { width: 1px; height: 12px; background: var(--line); flex: none; }
.statusbar button { width: 26px; height: 24px; flex: none; border: 1px solid var(--line); background: #fff; font-size: 11px; cursor: pointer; }
.statusbar button:disabled { color: #c8c8c6; cursor: default; }

.panel { flex: none; background: #fff; min-height: 0; }
.tabs { display: flex; flex: none; }
.tabs button {
  flex: 1; min-width: 0; height: 44px; border: none; border-bottom: 2px solid transparent;
  background: none; font-size: 12.5px; font-weight: 500; color: #9a9a9a; cursor: pointer;
}
.tabs button.on { border-bottom-color: #111; color: #111; }
.panel-body {
  padding: 16px 16px 14px;
  height: var(--panel-h);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
/* 활성 탭 재탭 또는 오른쪽 손잡이로 패널 본체를 접어 무대에 높이를 몰아준다 (사이드바 레이아웃 제외) */
.screen.fold > .panel > .panel-body { display: none; }
.tabs .tabfold { flex: none; width: 44px; font-size: 10px; color: #9a9a9a; }
/* 상태줄의 '크게' 토글 — 켜져 있는 동안 채워서 표시 */
.statusbar button.on { background: #111; border-color: #111; color: #fff; }
/* 카드에 타이핑하는 동안(키보드 올라옴)에는 아래 패널을 접고
   남는 높이를 전부 미리보기에 준다. 키보드를 내리면 되돌아온다. */
.screen.kb-edit > .panel { display: none; }
/* 상단바까지 접어 보이는 영역을 넓힌다 (키보드 내리면 돌아온다) */
.screen.kb-edit > .topbar { display: none; }
/* 카드가 무대보다 커지면 — 이유가 무엇이든(모바일 70% 바닥, '크게' 토글,
   수동 배율, 타이핑 중 가로 맞춤) — fitCard 가 실제 크기를 재서 .over 를 단다.
   그때만 양방향 스크롤로 전환한다. grid 가운데 정렬은 넘칠 때 왼쪽·위가 잘려
   닿을 수 없으므로 flex + margin:auto 로 — 카드가 들어가면 가운데,
   넘치면 여백이 0으로 접혀 가장자리까지 스크롤된다. */
.stage-scroll.over {
  display: flex;
  overflow: auto;
  overscroll-behavior: contain;
}
.stage-scroll.over > .card-fit { margin: auto; }

/* 배율 조절 위젯: 무대 오른쪽 아래에 떠 있다. 타이핑 중에는 kbfit 이 그 자리를 쓴다 */
.zoomctl {
  position: absolute; right: 10px; bottom: 10px; z-index: 3;
  display: flex; box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}
.zoomctl button {
  min-width: 28px; height: 26px; padding: 0;
  border: 1px solid var(--line); background: rgba(255,255,255,0.92);
  font-family: var(--mono); font-size: 11px; cursor: pointer;
}
.zoomctl button + button { border-left: none; }
.zoomctl button:disabled { color: #c8c8c6; cursor: default; }
.screen.kb-edit .zoomctl { display: none; }

/* 타이핑 중에만 뜨는 전체/크게 전환 */
.kbfit { display: none; }
.screen.kb-edit .kbfit {
  display: block; position: absolute; top: 8px; right: 8px; z-index: 3;
  height: 26px; padding: 0 10px;
  border: 1px solid rgba(0,0,0,0.14); border-radius: 13px;
  background: rgba(255,255,255,0.9);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-size: 10px; letter-spacing: 0.04em; color: #4a4a48;
  cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* 좁은 화면: 탭으로 한 묶음씩 */
.pane { display: none; }
.pane.on { display: block; }
.pane-h { display: none; }
.blockname { font-size: 12.5px; font-weight: 600; flex: 1; min-width: 0; }
.blockname span { font-weight: 400; color: #a0a09e; }

/* ---------- 미리보기 ---------- */
.preview {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: #1c1c1a; color: #fff;
  padding-bottom: env(safe-area-inset-bottom);
}
.preview-bar {
  flex: none; height: 50px; padding: 0 14px; gap: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.preview-bar .link { color: rgba(255,255,255,0.6); }
.preview-bar .link.strong { color: #fff; }
.preview-meta {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(255,255,255,0.45); white-space: nowrap;
}
.preview-body {
  flex: 1; min-height: 0; min-width: 0;
  display: grid; place-items: center; overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.preview-nav {
  flex: none; min-height: 54px; gap: 12px;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 14px 10px;
}
.preview-nav button {
  width: 44px; height: 38px; flex: none;
  border: 1px solid rgba(255,255,255,0.22); background: none; color: #fff;
  font-size: 15px; cursor: pointer;
}
.preview-nav button:disabled { color: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.09); cursor: default; }
.preview-nav .count {
  font-family: var(--mono); font-size: 11px;
  color: rgba(255,255,255,0.72); min-width: 46px; text-align: center;
}
.preview-hint { font-size: 11px; color: rgba(255,255,255,0.38); }
@media (max-width: 400px) {
  .preview-nav .preview-hint { display: none; }
}

/* ---------- sheet + toast ---------- */
.sheet {
  position: absolute; inset: 0; z-index: 40; background: rgba(0,0,0,0.38);
  display: flex; flex-direction: column; justify-content: flex-end;
}
.sheet-card {
  background: #fff; width: 100%; max-width: 520px; margin: 0 auto;
  padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  max-height: 88%; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.sheet-card h2 {
  margin: 0 0 14px; font-family: var(--mono); font-size: 10.5px;
  font-weight: 400; letter-spacing: 0.05em; color: #9a9a9a; text-transform: uppercase;
}
/* 확인 모달: 내보내기 시트와 달리 질문 한 줄이 주인공이라 제목을 본문 크기로 키운다 */
.sheet-card.dlg { gap: 0; }
.dlg-q { margin: 2px 0 0; font-size: 15.5px; font-weight: 600; line-height: 1.55; letter-spacing: -0.01em; }
.sheet-card.dlg .btn { height: 46px; font-size: 13px; }
.sheet-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 0; border-top: 1px solid #ececea; cursor: pointer; font-size: 15px;
}
.sheet-row .with-icon { display: flex; align-items: center; gap: 9px; }
.sheet-row .meta { font-family: var(--mono); font-size: 10.5px; color: #9a9a9a; }
.sheet-close { margin-top: 16px; height: 50px; flex: none; border: 1px solid #111; background: #111; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }

.toast {
  position: absolute; left: 20px; right: 20px; z-index: 50;
  bottom: calc(40px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; pointer-events: none;
}
.toast div {
  background: #111; color: #fff; font-size: 13px; letter-spacing: -0.01em;
  padding: 12px 18px; display: flex; align-items: center; gap: 9px; max-width: 100%;
}

/* ---------- 상호작용 애니메이션 ----------
   다시 그릴 때마다 요소가 새로 생기므로, 등장 계열(keyframes)은 app.js의
   markEntrances()가 "이번에 새로 나타난 것"에만 .anim-in / .anim-screen 을 붙여 건다.
   CSS만으로 걸면 버튼 하나 누를 때마다 시트·토스트가 다시 미끄러져 들어온다.
   누름 피드백(:active)은 요소 수명과 무관해서 그냥 CSS로 건다. */
.btn, .seg button, .chip, .thumb, .swatch, .tabs button,
.statusbar button, .preview-nav button, input[type="color"] {
  transition: transform 0.1s ease, background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn:active, .seg button:active, .chip:active, .thumb:active, .swatch:active,
input[type="color"]:active,
.statusbar button:not(:disabled):active,
.preview-nav button:not(:disabled):active { transform: scale(0.95); }
.tabs button:active { transform: scale(0.97); }
.link { transition: opacity 0.12s ease; }
.link:active { opacity: 0.5; }
.sheet-row:active { background: #f6f6f4; }
.sheet-close:active { transform: scale(0.98); }

/* 화면(입력↔편집↔미리보기) 전환: 부드럽게 나타난다 */
@keyframes screen-in { from { opacity: 0; } }
.screen.anim-screen { animation: screen-in 0.22s ease; }

/* 탭 전환: 내용이 살짝 떠오르며 바뀐다 */
@keyframes pane-in { from { opacity: 0; transform: translateY(5px); } }
.panel-body.anim-in { animation: pane-in 0.16s ease; }

/* 시트: 어둠은 스르르, 카드는 아래에서 미끄러져 올라온다 */
@keyframes veil-in { from { background: rgba(0,0,0,0); } }
@keyframes sheet-up { from { opacity: 0; transform: translateY(28px); } }
.sheet.anim-in { animation: veil-in 0.22s ease; }
.sheet.anim-in .sheet-card { animation: sheet-up 0.26s cubic-bezier(0.2, 0.75, 0.25, 1); }

/* 토스트: 아래에서 살짝 떠오른다 */
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast.anim-in div { animation: toast-in 0.2s ease; }

/* 위의 .card-fit 블록과 별개로 두는 이유: keyframe 규칙보다 뒤에 와야 이긴다 */
@media (prefers-reduced-motion: reduce) {
  .screen.anim-screen, .panel-body.anim-in,
  .sheet.anim-in, .sheet.anim-in .sheet-card, .toast.anim-in div { animation: none; }
}

/* ---------- touch tuning ---------- */
@media (pointer: coarse) {
  .btn, .seg button, .swatch { min-height: 38px; }
  input[type="color"] { min-height: 38px; }
  .thumb { height: 42px; }
  .tabs button { height: 50px; }
  .statusbar { height: 44px; }
  .statusbar button { min-width: 32px; min-height: 30px; }
  .link { padding: 10px 4px; }
  .raw { font-size: 16px; line-height: 1.7; }
  .fld { min-height: 40px; font-size: 16px; }
  .hint { font-size: 11.5px; }
  .sheet-row { padding: 17px 0; }
}

/* ---------- tablet / desktop: floating app card ---------- */
@media (min-width: 560px) {
  body { padding: clamp(12px, 3vh, 30px); }
  .screen {
    max-width: 470px; max-height: 940px;
    border: 1px solid #e2e2e0; border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.16);
  }
}

/* ---------- wide: stage + side panel ---------- */
/* 가로 모드 폰 조건에 min-width 를 반드시 함께 건다.
   CSS의 orientation 은 기기 방향이 아니라 뷰포트 비율이라, 안드로이드에서
   키보드가 올라오면 세로 폰도 landscape 로 잡혀 2단이 켜져 버린다. */
@media (min-width: 820px), (orientation: landscape) and (max-height: 560px) and (min-width: 640px) {
  .screen { max-width: 1280px; max-height: none; }
  .screen.is-edit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--side);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top side" "stage side" "status side";
  }
  .screen.is-edit > .topbar { grid-area: top; }
  .screen.is-edit > .stage { grid-area: stage; border-right: 1px solid var(--line-soft); }
  .screen.is-edit > .statusbar { grid-area: status; border-bottom: none; border-top: 1px solid var(--line-soft); }
  .screen.is-edit > .panel { grid-area: side; min-height: 0; display: flex; flex-direction: column; }
  /* 넓은 화면인데 모바일용 여백을 그대로 쓰면 조밀하다 — 사이드바는 더 숨 쉬게 */
  .screen.is-edit > .panel > .panel-body { flex: 1; height: auto; padding: 18px 20px; }
  /* 사이드바 레이아웃에서는 접기가 무의미하다 — 모바일에서 접은 채 넘어와도 펼쳐 둔다 */
  .screen.fold > .panel > .panel-body { display: block; }
  .tabs .tabfold { display: none; }
  .sheet { align-items: center; justify-content: center; }
  .sheet-card { border-radius: 16px; max-width: 460px; padding-bottom: 28px; }
}

/* ---------- PC: 탭 없이 설정을 한 화면에 모두 펼친다 ---------- */
@media (min-width: 1100px) and (min-height: 760px) {
  :root { --side: 412px; }
  .screen.is-edit > .panel > .tabs { display: none; }
  .screen.is-edit > .panel > .panel-body { padding: 20px 22px 26px; }
  .screen.is-edit .pane { display: block; }
  /* 네 묶음이 한 덩어리로 붙어 보이지 않게 사이를 넉넉히 띄운다 */
  .screen.is-edit .pane + .pane {
    margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft);
  }
  /* 비율 버튼은 세로로 클 이유가 없어 데스크톱에서는 낮춘다 */
  .screen.is-edit .pane [data-act="ratio"] { height: 46px !important; }
  .screen.is-edit .pane-h {
    display: block; margin: 0 0 13px;
    font-family: var(--mono); font-size: 9.5px; font-weight: 400;
    letter-spacing: 0.05em; color: var(--muted); text-transform: uppercase;
  }
}

/* ---------- landscape phones: no chrome, tighter side panel ---------- */
@media (orientation: landscape) and (max-height: 560px) and (min-width: 640px) {
  :root { --side: 320px; }
  body { padding: 0; }
  .screen { max-width: none; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
  .topbar { height: 42px; }
  .tabs button { height: 40px; }
}
