/* ============================================================
   온톤 — 앱 스타일 (반응형)

   시안 대조
   - PC 시안의 .d-* 조각을 그대로 계승하되 1280 고정폭 → 유동폭으로 바꿨습니다.
   - 모바일 시안의 셸(.a-bar / .a-tabbar / .a-dock)을 같은 파일에 흡수했습니다.

   화면 분기 (PC 우선)
   - 1080px 이상 : 사이드바 + 본문 + 우측 패널. 모든 작업 가능.
   - 720~1079px  : 사이드바가 드로어로 접힘. 우측 패널은 본문 아래로.
   - 719px 이하  : 모바일 셸(상단바 + 하단 탭바). 열람 전용 —
                   시안 선택 · 키트 다운로드 · 고도화 피드백은 잠기고
                   "PC에서 이어서 작업하기"로 넘깁니다.
   ============================================================ */

body.app-body {
  background: var(--surface-2);
  font-size: 14px;
  overflow: hidden;              /* 데스크톱: 셸 안쪽만 스크롤 */
}

/* ============================================================
   셸
   ============================================================ */

.d-app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ── 사이드바 ── */
.d-side {
  background: var(--surface);
  border-right: 1px solid var(--line-soft);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.d-logo { display: flex; align-items: center; gap: 9px; padding: 0 8px 2px; }
.d-logo .mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center;
  font-size: 14px; font-weight: 800; letter-spacing: -.03em; flex: none;
}
.d-logo .nm { font-size: 16px; font-weight: 800; letter-spacing: -.02em; }
.d-logo .env {
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px;
}

.d-navgrp { display: flex; flex-direction: column; gap: 2px; }
.d-navgrp .lb {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em;
  color: var(--faint); padding: 6px 9px 4px;
}
.d-nav {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  padding: 9px 10px; border-radius: 8px;
  color: var(--ink-2); font-size: 13.5px;
  transition: background .12s ease, color .12s ease;
}
.d-nav .ic { width: 16px; text-align: center; font-size: 13.5px; flex: none; }
.d-nav .tx { flex: 1; min-width: 0; }
.d-nav .tail { font-family: var(--mono); font-size: 10.5px; color: var(--faint); flex: none; }
.d-nav:hover { background: var(--surface-2); }
.d-nav.on { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.d-nav.on .tail { color: var(--brand-ink); opacity: .7; }
.d-nav.on:hover { background: var(--brand); }

.d-side-foot {
  margin-top: auto; border-top: 1px solid var(--line-soft);
  padding-top: 12px; display: flex; flex-direction: column; gap: 10px;
}
.d-user { display: flex; align-items: center; gap: 9px; padding: 0 4px; }
.d-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 800; flex: none;
}
.d-user .t { font-size: 13px; font-weight: 600; }
.d-user .s { font-size: 11.5px; color: var(--muted); }

/* ── 본문 ── */
.d-main { display: flex; flex-direction: column; min-width: 0; height: 100vh; height: 100dvh; }

.d-top {
  min-height: var(--topbar-h); flex: none;
  background: var(--surface); border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 24px;
}
.d-top-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.d-top-l > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.d-menu {
  display: none; width: 38px; height: 38px; flex: none;
  border: 1px solid var(--line); border-radius: 9px;
  place-items: center; font-size: 16px; color: var(--ink-2);
}
.d-menu:hover { border-color: var(--brand); color: var(--brand); }
.d-top-l h3 { font-size: 17px; font-weight: 700; letter-spacing: -.015em; }
.d-top-l .crumb { font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: .02em; }
.d-top-r { display: flex; align-items: center; gap: 8px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

.d-content {
  flex: 1; min-height: 0;
  padding: 20px 24px 28px;
  display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto; overscroll-behavior: contain;
}

/* 사이드바 드로어용 백드롭 */
.d-scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(22,19,31,.42);
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.d-scrim.on { opacity: 1; pointer-events: auto; }

/* ============================================================
   레이아웃 유틸 — 화면 렌더러가 인라인 스타일 없이 쓰는 조합자
   ============================================================ */

.d-split { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.d-split.wide  { grid-template-columns: minmax(0, 1fr) 348px; }
.d-split.slim  { grid-template-columns: minmax(0, 1fr) 300px; }
.d-split.docs  { grid-template-columns: 132px minmax(0, 1fr) 300px; }
.d-split > * { min-width: 0; }

.d-grid { display: grid; gap: 14px; }
.d-grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.d-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.d-grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.d-grid.c5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.d-grid.keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }  /* 좁은 화면에서도 2열을 지키는 비교용 */

.d-stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.d-stack.tight { gap: 9px; }
.d-stack.loose { gap: 18px; }
.d-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.d-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.d-push { margin-top: auto; }

/* ============================================================
   공통 조각
   ============================================================ */

.d-card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden;
  display: flex; flex-direction: column; min-width: 0;
}
.d-card.flat { box-shadow: none; }
.d-card.brandline { border-color: var(--brand-soft); }
.d-card.warnline { border-color: var(--warn); }
.d-card.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

.d-card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
}
.d-card-head h4 { font-size: 14px; font-weight: 700; }
.d-card-head .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.d-card-pad { padding: 16px; }
.d-card-foot {
  margin-top: auto; padding: 13px 16px;
  border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.d-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 15px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.d-btn:hover { border-color: var(--brand); color: var(--brand); }
.d-btn.pri { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.d-btn.pri:hover { filter: brightness(1.12); color: var(--brand-ink); }
.d-btn.acc { background: var(--accent); border-color: var(--accent); color: #fff; }
.d-btn.acc:hover { filter: brightness(1.08); color: #fff; }
.d-btn.gh { background: transparent; border-color: transparent; color: var(--brand); }
.d-btn.gh:hover { background: var(--brand-soft); }
.d-btn.mut { color: var(--muted); }
.d-btn.sm { min-height: 30px; padding: 0 11px; font-size: 12px; border-radius: 7px; }
.d-btn.lg { min-height: 42px; padding: 0 20px; font-size: 14px; }
.d-btn.block { width: 100%; }
.d-btn[disabled], .d-btn.off { opacity: .5; pointer-events: none; }

.d-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.d-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.p-ok    { background: var(--ok-bg);    color: var(--ok); }
.p-warn  { background: var(--warn-bg);  color: var(--warn); }
.p-crit  { background: var(--crit-bg);  color: var(--crit); }
.p-idle  { background: var(--idle-bg);  color: var(--muted); }
.p-run   { background: var(--run-bg);   color: var(--run); }
.p-brand { background: var(--brand-soft); color: var(--brand); }
.d-pill.fix { width: 76px; justify-content: center; }

.d-tag {
  display: inline-block;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .02em; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; white-space: nowrap;
}
.d-tag.eng { color: var(--brand); border-color: var(--brand-soft); background: var(--brand-soft); }
/* 세로 flex 안에서는 내용만큼만 차지하게 합니다 */
.d-tag { align-self: flex-start; }
.d-label .d-tag, .d-between .d-tag, .d-inline .d-tag, .d-card-head .d-tag { align-self: center; }

.d-num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; font-weight: 700; }
.d-num.xxl { font-size: 34px; line-height: 1.05; }
.d-num.xl  { font-size: 26px; line-height: 1.1; }
.d-num.lg  { font-size: 20px; }
.d-unit { font-size: .62em; font-weight: 500; color: var(--muted); margin-left: 2px; }
.d-stamp { font-family: var(--mono); font-size: 11px; color: var(--faint); }

.d-meter { height: 7px; border-radius: 4px; background: var(--ground-2); overflow: hidden; }
.d-meter i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.d-meter i.ok { background: var(--ok); }
.d-meter i.warn { background: var(--warn); }
.d-meter i.run { background: var(--run); }

.d-banner {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.55;
}
.d-banner .ic { flex: none; }
.d-banner strong { font-weight: 700; }
.b-info  { background: var(--surface); border: 1px solid var(--line-soft); color: var(--ink-2); }
.b-brand { background: var(--brand-soft); color: var(--brand); }
.b-warn  { background: var(--warn-bg); color: var(--warn); }
.b-ok    { background: var(--ok-bg); color: var(--ok); }

.d-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.d-table { width: 100%; font-size: 12.5px; }
.d-table th {
  text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em;
  color: var(--muted); font-weight: 500; padding: 10px 13px;
  border-bottom: 1px solid var(--line-soft); background: var(--surface-2); white-space: nowrap;
}
.d-table td { padding: 10px 13px; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); vertical-align: middle; }
.d-table tr:last-child td { border-bottom: 0; }
.d-table td.nm { color: var(--ink); font-weight: 600; }
.d-table td.mono { font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }

.d-kv { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 0; }
.d-kv + .d-kv { border-top: 1px solid var(--line-soft); }
.d-kv .k { font-size: 12.5px; color: var(--muted); flex: none; }
.d-kv .v { font-size: 13px; font-weight: 600; text-align: right; }
.d-kv .v.ok { color: var(--ok); }
.d-kv .v.warn { color: var(--warn); }
.d-kv .v.brand { color: var(--brand); }
.d-kv .v.none { color: var(--faint); font-weight: 400; }
.d-kv.dense { padding: 5px 0; }

.d-stat {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 13px 15px; display: flex; flex-direction: column; gap: 3px;
}
.d-stat .lb { font-size: 12px; color: var(--muted); }

/* 체크 · 경고 리스트 */
.d-checks { display: flex; flex-direction: column; gap: 11px; }
.d-check { display: flex; gap: 9px; align-items: flex-start; }
.d-check .mk { flex: none; font-size: 12.5px; line-height: 1.5; }
.d-check.ok   .mk { color: var(--ok); }
.d-check.warn .mk { color: var(--warn); }
.d-check.run  .mk { color: var(--run); }
.d-check.idle { opacity: .5; }
.d-check .t { font-size: 12.5px; font-weight: 600; }
.d-check .s { font-size: 11.5px; color: var(--muted); line-height: 1.55; }

/* 타임라인 */
.d-time { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.d-time:last-child { border-bottom: 0; }
.d-time .t { font-size: 13px; font-weight: 700; }
.d-time .t.warn { color: var(--warn); }
.d-time .t.ok { color: var(--ok); }
.d-time .s { font-size: 12px; color: var(--muted); }

/* 생성 단계 행 */
.d-stepline { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.d-stepline:last-child { border-bottom: 0; }
.d-stepline.idle { opacity: .62; }
.d-stepline .bd { flex: 1; min-width: 0; }
.d-stepline .t { font-size: 13.5px; font-weight: 700; }
.d-stepline .s { font-size: 12px; color: var(--muted); }
.d-stepline .rt { width: 56px; text-align: right; flex: none; }

/* ── 온보딩 스텝 레일 ── */
.d-steps { display: flex; flex-direction: column; gap: 2px; }
.d-step {
  display: grid; grid-template-columns: 22px 1fr; gap: 9px; align-items: center;
  padding: 8px 9px; border-radius: 7px; font-size: 13px; color: var(--muted);
}
.d-step .no {
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line);
  display: grid; place-items: center; font-family: var(--mono); font-size: 10px; color: var(--faint);
}
.d-step.done { color: var(--ink-2); }
.d-step.done .no { background: var(--ok-bg); border-color: var(--ok-bg); color: var(--ok); }
.d-step.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.d-step.on .no { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* 모바일용 가로 스텝 바 */
.d-steps-bar { display: flex; gap: 5px; }
.d-steps-bar i { flex: 1; height: 4px; border-radius: 2px; background: var(--ground-2); display: block; }
.d-steps-bar i.done { background: var(--ok); }
.d-steps-bar i.on { background: var(--brand); }

/* ── 폼 ── */
.d-field { display: flex; flex-direction: column; gap: 8px; }
.d-label { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.d-label .req { color: var(--accent); font-size: 11px; }
.d-help { font-size: 12px; color: var(--muted); line-height: 1.55; }
.d-input {
  width: 100%; min-height: 44px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  padding: 12px 13px; font-size: 14px; color: var(--ink);
  display: block; line-height: 1.6; resize: vertical;
}
.d-input::placeholder { color: var(--faint); }
.d-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.d-input.area { min-height: 92px; }

.d-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.d-chip {
  border: 1px solid var(--line); border-radius: 20px; padding: 6px 12px;
  font-size: 12.5px; color: var(--ink-2); background: var(--surface);
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.d-chip:hover { border-color: var(--brand); color: var(--brand); }
.d-chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }
.d-chip.ex { border-style: dashed; color: var(--muted); cursor: default; }
.d-chip.ex:hover { border-color: var(--line); color: var(--muted); }

/* 세그먼트 (PC / 모바일 전환 등) */
.d-seg { display: inline-flex; background: var(--ground-2); border-radius: 9px; padding: 3px; gap: 3px; }
.d-seg button {
  padding: 6px 14px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.d-seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ── 브랜드 토큰 ── */
.d-sw { display: flex; align-items: center; gap: 11px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.d-sw:last-child { border-bottom: 0; }
.d-sw .chip { width: 32px; height: 32px; border-radius: 8px; border: 1px solid rgba(0,0,0,.08); flex: none; }
.d-sw .nm { font-size: 12.5px; font-weight: 600; }
.d-sw .hx { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.d-sw .rl { margin-left: auto; font-size: 11px; color: var(--faint); font-family: var(--mono); text-align: right; }

.d-code {
  background: #16131F; color: #D8D2EC; border-radius: 9px;
  padding: 13px 14px; font-family: var(--mono); font-size: 11px; line-height: 1.7;
  overflow-x: auto; white-space: pre;
}
.d-code.plain { background: var(--surface-2); color: var(--ink-2); }
.d-code .k { color: #9C8CFF; }
.d-code .s { color: #7FD8A8; }
.d-code .n { color: #E2A76A; }

/* 톤 벡터 축 */
.d-axis { display: flex; flex-direction: column; gap: 4px; }
.d-axis .hd { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }

/* ── 산출물 타일 ── */
.d-tiles { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.d-tile {
  border: 1px solid var(--line-soft); border-radius: 11px; background: var(--surface);
  overflow: hidden; display: flex; flex-direction: column; text-align: left;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.d-tile:hover { border-color: var(--brand); }
.d-tile.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.d-tile .cv { flex: 1; display: grid; place-items: center; background: var(--surface); min-height: 148px; padding: 18px; }
.d-tile .ft {
  border-top: 1px solid var(--line-soft); padding: 9px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11.5px; color: var(--muted);
}
.d-tile .ft b { color: var(--ink); }

.d-mark { display: inline-flex; align-items: center; gap: 9px; }
.d-mark .gl {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.04em; flex: none;
}
.d-mark .wd { font-size: 19px; font-weight: 800; letter-spacing: -.03em; }
.d-mark .wd i { font-style: normal; font-weight: 500; }

/* 파생 포맷 4칸 */
.d-derived { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.d-derived > div {
  border-right: 1px solid var(--line-soft); padding: 16px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 9px;
}
.d-derived > div:last-child { border-right: 0; }

/* ── 명함 ── */
.d-bcard {
  width: 300px; max-width: 100%; aspect-ratio: 9 / 5; border-radius: 8px;
  position: relative; box-shadow: var(--shadow-md); overflow: hidden; flex: none;
}
.d-bcard .bleed { position: absolute; inset: 0; border: 1px dashed rgba(200,55,42,.55); border-radius: 8px; }
.d-bcard .safe { position: absolute; inset: 10px; border: 1px dashed rgba(28,111,184,.5); }
.d-bcard-face { position: absolute; inset: 0; padding: 24px 22px; display: flex; flex-direction: column; justify-content: space-between; }
.d-bcard-stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 24px; background: var(--surface-2); padding: 24px 18px;
}
.d-bcard-pair { display: flex; gap: 26px; flex-wrap: wrap; justify-content: center; }
.d-legend { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; font-size: 11.5px; color: var(--muted); }
.d-legend span { display: flex; align-items: center; gap: 6px; }
.d-legend i { width: 18px; height: 0; display: block; }

/* ── 문서 · 사이트 목업 ── */
.d-thumbs { display: flex; flex-direction: column; gap: 8px; }
.d-thumb {
  border: 1px solid var(--line-soft); border-radius: 6px; background: var(--surface);
  height: 58px; display: flex; align-items: center; gap: 8px; padding: 8px; flex: none; width: 100%;
}
.d-thumb.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.d-thumb .pg { font-family: var(--mono); font-size: 10px; color: var(--faint); flex: none; width: 18px; }
.d-thumb .bd { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.bar { border-radius: 3px; background: var(--ground-2); display: block; }

.d-page-stage {
  flex: 1; min-height: 320px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 18px;
}
.d-page {
  width: 100%; max-width: 460px; aspect-ratio: 1 / 1.414;
  background: #F6F4EF; border-radius: 4px; box-shadow: var(--shadow-md);
  padding: 38px 40px; display: flex; flex-direction: column;
}

.d-wire { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 8px; overflow: hidden; }
.d-wire .wnav { height: 38px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; }
.d-wire-stage { flex: 1; min-height: 300px; background: var(--surface-2); padding: 16px; display: grid; place-items: stretch; }

/* ── 요금제 ── */
.d-plan { display: flex; flex-direction: column; }
.d-plan.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.d-plan-ribbon {
  background: var(--brand); color: var(--brand-ink); padding: 7px 16px;
  font-size: 11.5px; font-weight: 700; display: flex; justify-content: space-between; gap: 8px;
}
.d-plan-feat { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.d-plan-feat .no { color: var(--faint); }

/* ============================================================
   PC 전용 잠금 — 모바일에서 작업형 액션을 막는 장치
   ============================================================ */

/* .d-lock 등 뒤에 정의된 규칙에 밀리지 않도록 우선순위를 고정합니다 */
.pc-only { display: inline-flex; }
.mo-only { display: none !important; }

/* 잠긴 영역 위에 덮이는 안내 */
.d-lock {
  border: 1px dashed var(--line); border-radius: 11px; background: var(--surface);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.d-lock .hd { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; }
.d-lock .s { font-size: 12.5px; color: var(--muted); line-height: 1.6; }

/* ============================================================
   모바일 셸 — 719px 이하에서만 나타납니다
   ============================================================ */

.a-bar {
  display: none;
  position: sticky; top: 0; z-index: 30;
  min-height: var(--mobar-h);
  background: var(--surface); border-bottom: 1px solid var(--line-soft);
  align-items: center; gap: 10px; padding: 10px 14px;
}
.a-back { font-size: 20px; color: var(--ink); width: 26px; flex: none; text-align: left; }
.a-bar-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.a-bar-title strong { font-size: 16.5px; font-weight: 700; letter-spacing: -.015em; }
.a-bar-title small { font-size: 12px; color: var(--muted); }
.a-bar-actions { display: flex; gap: 6px; align-items: center; flex: none; }
.a-icon { position: relative; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-size: 16px; }
.a-badge {
  position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 9.5px; font-weight: 800; display: grid; place-items: center;
}

.a-tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
  align-items: center; justify-content: space-around;
}
.a-tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--faint); flex: 1; }
.a-tabbar button.on { color: var(--brand); }
.a-tabbar .ic { font-size: 18px; line-height: 1; }
.a-tabbar .lb { font-size: 11px; font-weight: 700; }

/* 하단 고정 액션 (모바일) */
.a-dock {
  display: none;
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 29;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 12px 14px; flex-direction: column; gap: 9px;
}

/* 목록 행 (모바일에서 카드 내부 리스트로 씀) */
.a-row { display: flex; align-items: center; gap: 11px; padding: 13px 15px; border-bottom: 1px solid var(--line-soft); width: 100%; text-align: left; }
.a-row:last-child { border-bottom: 0; }
.a-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.a-row-main .t { font-size: 14px; font-weight: 600; }
.a-row-main .s { font-size: 12px; color: var(--muted); }
.a-row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }

.a-hero { display: flex; flex-direction: column; gap: 9px; padding: 24px 16px 20px; text-align: center; align-items: center; }
.a-hero .mark { font-size: 34px; line-height: 1; }
.a-hero .head { font-size: 21px; font-weight: 800; letter-spacing: -.025em; line-height: 1.35; text-wrap: balance; }
.a-hero .sub { font-size: 13px; color: var(--muted); }

/* ============================================================
   "PC에서 이어서 작업하기" 시트
   ============================================================ */

.bm-sheet {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(22,19,31,.45);
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.bm-sheet.on { opacity: 1; pointer-events: auto; }
.bm-sheet-inner {
  width: 100%; max-width: 520px;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
  transform: translateY(14px); transition: transform .2s ease;
  max-height: 88vh; overflow-y: auto;
}
.bm-sheet.on .bm-sheet-inner { transform: translateY(0); }
.bm-sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); align-self: center; }
.bm-sheet h4 { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.bm-sheet .lead { font-size: 13px; color: var(--muted); line-height: 1.6; }

@media (min-width: 720px) {
  .bm-sheet { align-items: center; }
  .bm-sheet-inner { border-radius: 16px; max-width: 460px; }
}

/* 토스트 */
.bm-toast-host {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 24px); z-index: 70;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(92vw, 460px);
}
.bm-toast {
  background: var(--ink); color: var(--surface);
  border-radius: 10px; padding: 12px 16px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: bmToastIn .22s ease;
}
@keyframes bmToastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 부팅 */
.bm-boot {
  position: fixed; inset: 0; z-index: 80;
  background: var(--surface); display: grid; place-items: center;
  transition: opacity .3s ease;
}
.bm-boot.off { opacity: 0; pointer-events: none; }
.bm-boot .in { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.bm-boot .mk {
  width: 46px; height: 46px; border-radius: 13px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-size: 22px; font-weight: 800;
}
.bm-boot p { font-size: 13px; color: var(--muted); }

/* ============================================================
   반응형 — 1080 / 720 두 지점에서 갈립니다
   ============================================================ */

/* ── 태블릿 : 사이드바를 드로어로 ── */
@media (max-width: 1079px) {
  .d-app { grid-template-columns: minmax(0, 1fr); }

  .d-side {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 45;
    width: 268px; max-width: 84vw;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .d-side.open { transform: none; }

  .d-split,
  .d-split.wide,
  .d-split.slim,
  .d-split.docs { grid-template-columns: minmax(0, 1fr); }

  .d-grid.c5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .d-grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .d-content { padding: 18px 20px 28px; }
  .d-top { padding: 10px 20px; }
  .d-menu { display: grid; }
}

/* ── 모바일 : 열람 전용 셸 ── */
@media (max-width: 719px) {
  body.app-body { overflow: auto; font-size: 14.5px; }

  .d-app { display: block; height: auto; }
  .d-main { height: auto; display: block; }

  /* 데스크톱 상단바 → 모바일 상단바로 교체 */
  .d-top { display: none; }
  .a-bar { display: flex; }
  .a-tabbar { display: flex; }

  .d-content {
    overflow: visible; padding: 14px 14px 0;
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
    gap: 14px;
  }
  .d-content.has-dock {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 116px);
  }
  .a-dock { display: flex; }

  .d-grid.c2, .d-grid.c3, .d-grid.c4, .d-grid.c5 { grid-template-columns: minmax(0, 1fr); }
  .d-grid.keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .d-tiles { grid-template-columns: minmax(0, 1fr); }
  .d-tile .cv { min-height: 118px; }
  .d-derived { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .d-derived > div:nth-child(2) { border-right: 0; }
  .d-derived > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }

  .d-card-head { padding: 12px 14px; }
  .d-card-pad { padding: 14px; }
  .d-card-head h4 { font-size: 14.5px; }
  .d-card-head .sub { display: none; }

  .d-page { max-width: 100%; padding: 26px 24px; }
  .d-bcard { width: 100%; max-width: 320px; }
  .d-bcard-pair { gap: 18px; }

  .d-time { grid-template-columns: 58px minmax(0, 1fr); gap: 10px; }
  .d-stepline .rt { display: none; }

  /* 작업형 조작은 모바일에서 감춥니다 */
  .pc-only { display: none !important; }
  .mo-only { display: flex !important; }
  span.mo-only { display: inline-flex !important; }

  .bm-toast-host { bottom: calc(var(--tabbar-h) + 20px); }
}

/* 아주 좁은 화면 */
@media (max-width: 380px) {
  .d-content { padding-left: 11px; padding-right: 11px; }
  .d-grid.keep2 { grid-template-columns: minmax(0, 1fr); }
}
