:root {
  /* plan B Home 컬러: 오트 아이보리(배경) · 딥 세이지(글자·주요 버튼) · 테라코타(선택 포인트) */
  --bg: #F7F5EF; --panel: #fffdf9; --line: #e8e3d8; --line2: #d9d2c3;
  --ink: #2b2925; --ink2: #6a655c; --ink3: #9b958a; --sage: #315648;
  --pri: #315648; --pri-ink: #F7F5EF; --pri-soft: #e4ece7; --accent: #B85F42; --accent-soft: #f4e4dd; --danger: #e5484d; --ok: #16a34a;
  --radius: 12px; --shadow: 0 6px 24px rgba(20, 28, 48, 0.08);
  --top: 56px; --side: 340px; --insp: 300px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 14px/1.45 Pretendard, -apple-system, 'Noto Sans KR', system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top { position: fixed; inset: 0 0 auto 0; height: var(--top); display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; white-space: nowrap; }
.logo { width: 30px; height: 30px; display: block; background: none; }
.pname { width: 180px; padding: 6px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; font-weight: 600; }
.pname:hover, .pname:focus { border-color: var(--line2); background: #fff; outline: none; }
.save-state { color: var(--ink3); font-size: 12px; white-space: nowrap; }
.grow { flex: 1; }
.seg { display: inline-flex; background: #ece8de; border-radius: 10px; padding: 3px; }
.seg button { padding: 6px 14px; border-radius: 8px; color: var(--ink2); font-weight: 600; white-space: nowrap; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.btn { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #f3f0e8; }
.btn.pri { background: var(--pri); color: var(--pri-ink); border-color: var(--pri); }
.btn.pri:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.ic-btn { width: 36px; height: 36px; border-radius: 9px; font-size: 18px; color: var(--ink2); }
.ic-btn:hover { background: #f1f3f6; }

.layout { position: fixed; inset: var(--top) 0 0 0; display: flex; }
.side { width: var(--side); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 6px; }
.tabs button { flex: 1; padding: 12px 4px; color: var(--ink3); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--pri); }
.side-body { flex: 1; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.stage { position: relative; flex: 1; min-width: 0; }
.view { position: absolute; inset: 0; }
.view canvas { display: block; touch-action: none; }
.insp { width: var(--insp); background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; }

.toolbar { position: absolute; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 2px; padding: 5px; background: #fff; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); z-index: 5; }
.toolbar button { min-width: 48px; padding: 6px 8px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 17px; color: var(--ink2); }
.toolbar button span { font-size: 11px; font-weight: 600; }
.toolbar button:hover { background: #f3f0e8; }
.toolbar button.on { background: var(--pri-soft); color: var(--pri); }
.toolbar i { width: 1px; background: var(--line); margin: 4px 4px; }
.walk-help { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); padding: 6px 14px; background: rgba(20,24,32,0.7); color: #fff; border-radius: 20px; font-size: 13px; z-index: 5; pointer-events: none; }
.orbit-help { position: absolute; left: 12px; top: 12px; padding: 6px 10px; background: rgba(255,255,255,0.88); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; color: var(--ink2); z-index: 4; pointer-events: none; max-width: calc(100% - 24px); }
@media (max-width: 900px), (pointer: coarse) { .orbit-help { display: none; } }
.hint { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); max-width: min(560px, 90%); padding: 9px 14px; background: #1d2129; color: #fff; border-radius: 12px; font-size: 13px; z-index: 6; box-shadow: var(--shadow); }
.joy { position: absolute; left: 24px; bottom: calc(24px + var(--safe-b)); width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,0.35); border: 2px solid rgba(255,255,255,0.7); z-index: 5; touch-action: none; }
.joy .knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,0.9); transform: translate(-50%, -50%); box-shadow: var(--shadow); }

/* 사이드 콘텐츠 */
h3.sec { margin: 4px 0 10px; font-size: 13px; color: var(--ink2); font-weight: 700; }
.sec + .sec, .block + h3.sec { margin-top: 20px; }
.addmine { width: 100%; justify-content: flex-start; margin-bottom: 10px; padding: 10px 12px; border-style: dashed; color: var(--pri); }
.addmine .muted { margin-left: 6px; font-weight: 500; }
.field textarea { padding: 8px 10px; border: 1px solid var(--line2); border-radius: 9px; font: inherit; resize: vertical; }
.swatches input[type=color] { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; overflow: hidden; background: none; cursor: pointer; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { padding: 5px 11px; border-radius: 20px; background: #f1f3f6; color: var(--ink2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; }
.search { width: 100%; padding: 9px 12px; border: 1px solid var(--line2); border-radius: 10px; margin-bottom: 10px; background: #fff; }
.search:focus, .field input:focus, .field select:focus { outline: 2px solid var(--pri-soft); border-color: var(--pri); }
.plist { display: grid; gap: 8px; }
.pgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pgrid .pcard { flex-direction: column; align-items: stretch; gap: 3px; padding: 6px 6px 8px; text-align: left; }
.pgrid .pcard .thumb { position: relative; width: 100%; height: auto; aspect-ratio: 1; border-radius: 10px; background: linear-gradient(#faf8f3, #efebe2); }
.pgrid .pcard .thumb canvas { width: 100%; height: 100%; }
.pgrid .pcard .badge { position: absolute; left: 6px; top: 6px; padding: 1px 6px; border-radius: 6px; background: rgba(255,255,255,0.92); font-size: 10px; font-weight: 800; color: var(--pri); }
.pgrid .pcard .name { font-size: 12.5px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; padding: 0 2px; }
.pgrid .pcard .dim { font-size: 11px; color: var(--ink3); padding: 0 2px; }
.pgrid .pcard .dots { padding: 0 2px; }
.pcard { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; text-align: left; width: 100%; }
.pcard.armed { border-color: var(--pri); background: var(--pri-soft); }
.pcard:hover { border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft); }
.pcard .thumb { width: 56px; height: 56px; flex: none; border-radius: 10px; background: #f3f4f6; display: grid; place-items: center; overflow: hidden; }
.pcard .thumb canvas { width: 56px; height: 56px; }
.pcard .t { flex: 1; min-width: 0; }
.pcard .brand { font-size: 11px; font-weight: 700; color: var(--pri); }
.pcard .name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.pcard .dim { font-size: 12px; color: var(--ink3); }
.dots { display: flex; gap: 3px; margin-top: 3px; }
.dots i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.12); }
.mgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mcard { border: 2px solid transparent; border-radius: 12px; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px var(--line); text-align: center; padding: 0 0 6px; }
.mcard img { width: 100%; aspect-ratio: 1; display: block; object-fit: cover; }
.mcard span { display: block; font-size: 11.5px; font-weight: 600; padding: 4px 4px 0; line-height: 1.25; }
.mcard.on { border-color: var(--pri); }
.target { padding: 10px 12px; background: var(--pri-soft); border-radius: 10px; font-size: 13px; margin-bottom: 12px; color: #2a3f8f; }
.block { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.muted { color: var(--ink3); font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 8px; }
.row + .row { margin-top: 8px; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list-item .t { flex: 1; min-width: 0; }
.list-item .t b { display: block; font-size: 13px; }
.list-item a { color: var(--pri); font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }

/* 인스펙터 */
.insp h2 { margin: 0 0 2px; font-size: 16px; }
.insp .sub { color: var(--ink3); font-size: 12.5px; margin-bottom: 14px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--ink2); font-weight: 600; }
.field input, .field select { padding: 8px 10px; border: 1px solid var(--line2); border-radius: 9px; background: #fff; width: 100%; }
.dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dims input { text-align: right; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); }
.swatches button.on { outline: 2px solid var(--pri); outline-offset: 2px; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.close-insp { float: right; width: 30px; height: 30px; border-radius: 8px; color: var(--ink3); font-size: 18px; }

/* 모달 */
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 30, 0.45); display: grid; place-items: center; padding: 16px; }
.mbox { width: min(880px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; overflow: hidden; background: var(--panel); border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); padding: 0; }
.mscroll { overflow-y: auto; overscroll-behavior: contain; padding: 24px; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.mscroll::-webkit-scrollbar { width: 8px; } .mscroll::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; border: 2px solid var(--panel); } .mscroll::-webkit-scrollbar-track { background: transparent; margin: 14px 0; }
.mbox.narrow { width: min(460px, 100%); }
.mbox { position: relative; }
.mclose { position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; border-radius: 10px; background: #f1f3f6; font-size: 17px; color: var(--ink2); }
.mclose:hover { background: #e6e9ee; }
.mback { margin: -4px 0 8px; padding: 4px 8px 4px 2px; color: var(--pri); font-weight: 600; font-size: 13px; }
.tabs-seg { margin-bottom: 14px; }
.tpl em { display: block; font-style: normal; font-size: 11.5px; color: var(--ink2); font-weight: 600; margin-top: 2px; }
.mbox h1 { margin: 0 0 4px; font-size: 22px; }
.mbox h2 { margin: 18px 0 10px; font-size: 15px; }
.mbox .lead { margin: 0 0 18px; color: var(--ink2); }
.start-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.start-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; text-align: left; background: #fff; display: flex; flex-direction: column; gap: 6px; }
.start-card:hover { border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft); }
.start-card .big { font-size: 26px; }
.start-card b { font-size: 15px; }
.start-card span { color: var(--ink3); font-size: 12.5px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tpl { border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: #fff; text-align: left; }
.tpl:hover { border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft); }
.tpl canvas { width: 100%; aspect-ratio: 4 / 3; display: block; background: #faf8f3; border-radius: 8px; }
.tpl b { display: block; margin-top: 6px; font-size: 14px; }
.tpl span { color: var(--ink3); font-size: 11.5px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.proj { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; text-align: left; display: flex; flex-direction: column; }
.proj.cur { border-color: var(--pri); box-shadow: 0 0 0 3px var(--pri-soft); }
.proj .open { display: block; padding: 0; }
.proj .pmeta { padding: 8px 10px; }
.pact { display: flex; gap: 4px; margin-top: 6px; }
.pact button { flex: 1; padding: 4px 0; border-radius: 7px; background: #f1f3f6; font-size: 12px; font-weight: 600; color: var(--ink2); }
.pact button:hover { background: #e7eaef; }
.pact .del { color: var(--danger); }
.proj img, .proj .noimg { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; display: block; background: #eef1f4; }

.proj b { display: block; font-size: 13px; }
.proj span { font-size: 11.5px; color: var(--ink3); }
.calib canvas { width: 100%; max-height: 46vh; object-fit: contain; background: #faf8f3; border-radius: 10px; display: block; }
.calsum { margin-top: 10px; padding: 10px 12px; background: #f6f8fb; border-radius: 10px; font-size: 13px; line-height: 1.6; }
.calwarn { margin-top: 6px; color: var(--danger); font-weight: 600; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--pri-soft); border-top-color: var(--pri); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

#toasts { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); display: grid; gap: 6px; z-index: 60; pointer-events: none; }
.toast { padding: 10px 16px; background: #1d2129; color: #fff; border-radius: 12px; box-shadow: var(--shadow); font-size: 13.5px; animation: tin 3.2s forwards; text-align: center; }
@keyframes tin { 0% { opacity: 0; transform: translateY(6px); } 8% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

body.readonly .side, body.readonly #tb2d [data-tool]:not([data-tool="select"]), body.readonly #btnUndo, body.readonly #btnRedo, body.readonly #btnShare { display: none !important; }

/* ---------- 모바일 */
@media (max-width: 900px) {
  :root { --top: 52px; }
  .top { padding: 0 8px; gap: 4px; }
  .brand b, .save-state, .ic-btn { display: none; }
  .pname { width: 96px; padding: 5px 6px; }
  .seg button { padding: 6px 9px; font-size: 13px; }
  .btn { padding: 7px 10px; font-size: 13px; }
  #btnShare { display: none; }
  .layout { flex-direction: column; }
  .stage { flex: 1; }
  .side { position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 44vh; border: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,0.12); z-index: 15; transition: transform .2s; padding-bottom: var(--safe-b); }
  .side.collapsed { transform: translateY(calc(100% - 46px)); }
  .side::before { content: ''; position: absolute; left: 50%; top: 5px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: #d3d7de; }
  .tabs { padding-top: 6px; }
  .pgrid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .pgrid .pcard .name { font-size: 11.5px; }
  #tb3d #b3dRotL, #tb3d #b3dRotR, #tb3d #b3dIn, #tb3d #b3dOut, #tb3d i { display: none; }
  .insp .dims input { padding: 7px 6px; }
  .tabs button { padding: 12px 2px; font-size: 13px; }
  .insp { position: fixed; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); width: auto; max-height: 52vh; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); z-index: 16; }
  .toolbar { bottom: calc(44vh + 10px); max-width: calc(100vw - 16px); overflow-x: auto; }
  body.side-collapsed .toolbar { bottom: calc(56px + var(--safe-b)); }
  .toolbar button { min-width: 42px; padding: 5px 4px; }
  .start-grid { grid-template-columns: 1fr; }
  .mscroll { padding: 18px; }
  .joy { bottom: calc(60px + var(--safe-b)); }
  #toasts { bottom: calc(46vh + var(--safe-b)); }
}

/* 목록에서 끌어오기 */
.pgrid .pcard { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: pan-y; }
.dragchip { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.22); font-size: 12.5px; font-weight: 700; max-width: 240px; opacity: .92; }
.dragchip canvas { width: 40px; height: 40px; border-radius: 8px; background: #f2f3f5; }
.dragchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dragchip.over { opacity: .55; }
body.cdragging, body.cdragging * { cursor: grabbing !important; }

.chk { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 8px 0; line-height: 1.4; }
.row.wrap { flex-wrap: wrap; gap: 6px; }
.btn.sm small { font-weight: 500; opacity: .7; font-size: 10.5px; }
.btn.sm.on { border-color: var(--pri); color: var(--pri); background: var(--pri-soft); }

/* 3D 나침반 */
.compass { position: absolute; right: 14px; top: 14px; width: 48px; height: 48px; padding: 0; border: 0; background: none; border-radius: 50%; box-shadow: var(--shadow); cursor: grab; z-index: 4; touch-action: none; }
.compass:active { cursor: grabbing; }
.compass svg { width: 100%; height: 100%; transform: rotate(var(--rot, 0deg)); }
.compass .cmpN { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) translateY(-27px); font-size: 9px; font-weight: 800; color: #e5484d; pointer-events: none; }

/* 문 · 몰딩 색상 견본 */
.swrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); padding: 0; cursor: pointer; position: relative; }
.sw.on { box-shadow: 0 0 0 2px var(--pri); }
.sw.custom { display: inline-flex; align-items: center; justify-content: center; background: conic-gradient(#f66, #fc6, #6c6, #6cf, #96f, #f6c, #f66); overflow: hidden; }
.sw.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sw.custom span { color: #fff; font-weight: 800; font-size: 14px; text-shadow: 0 0 2px rgba(0,0,0,.5); pointer-events: none; }
.chip.sm { padding: 4px 9px; font-size: 11.5px; }

/* 둘러보기 조작 패드 */
.walk-pad { position: absolute; right: 16px; bottom: calc(18px + var(--safe-b)); display: flex; gap: 10px; align-items: flex-end; z-index: 6; user-select: none; -webkit-user-select: none; }
.wp-grid { display: grid; grid-template-columns: repeat(3, 50px); gap: 6px; padding: 8px; background: rgba(255,255,255,0.86); border-radius: 18px; box-shadow: var(--shadow); }
.wp-grid button, .wp-side button { height: 46px; border-radius: 12px; background: #fff; border: 1px solid var(--line); font-size: 19px; color: var(--ink); touch-action: none; }
.wp-grid button:active, .wp-grid button.on { background: var(--pri-soft); color: var(--pri); border-color: var(--pri); }
.wp-side { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: rgba(255,255,255,0.86); border-radius: 18px; box-shadow: var(--shadow); }
.wp-side button { width: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-size: 15px; height: 38px; }
.wp-side button span { font-size: 10.5px; font-weight: 700; }
@media (max-width: 900px), (pointer: coarse) {
  .walk-pad { right: 12px; bottom: calc(60px + var(--safe-b)); }
  .wp-grid { display: none; } /* 모바일은 왼쪽 조이스틱으로 이동·회전 */
}

/* 내 제품 추가: 미리보기 */
.cp-grid { display: flex; gap: 12px; align-items: flex-start; }
.cp-prev { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 0 0 auto; }
.cp-prev canvas { width: 150px; height: 123px; border-radius: 12px; background: linear-gradient(#faf8f3, #efebe2); }
@media (max-width: 480px) { .cp-prev canvas { width: 120px; height: 98px; } }
.swatches .sw.custom { width: 26px; height: 26px; }

/* plan B Home 컬러 보정 */
.seg button.on { background: var(--pri); color: var(--pri-ink); }
.chip.on { background: var(--pri); color: var(--pri-ink); border-color: var(--pri); }
.pcard.armed { outline: 2px solid var(--accent); }
.sw.on { box-shadow: 0 0 0 2px var(--accent); }
.mcard.on { outline: 2px solid var(--accent); }
.chips.sub { margin-top: -4px; }
.chips.sub .chip { padding: 4px 10px; font-size: 12px; background: transparent; border: 1px solid var(--line2); }
.chips.sub .chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.jump { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.jump button { padding: 5px 12px; border-radius: 16px; background: var(--pri-soft); color: var(--pri); font-weight: 700; font-size: 12.5px; }

/* 도구 막대 글자가 한 글자씩 세로로 꺾이지 않게 */
.toolbar button { flex-shrink: 0; }
.toolbar button span, .wp-side button span, .tabs button, .chip, .btn { white-space: nowrap; }
.btns { margin-bottom: 6px; }
.guide { font-size: 12.5px; color: var(--ink2); line-height: 1.6; }
.guide > b { display: block; color: var(--ink); margin-top: 6px; }
.guide > b:first-child { margin-top: 0; }
.guide ul { margin: 2px 0 4px; padding-left: 16px; }
.guide .dot.acc { display: inline-block; width: 9px; height: 9px; border: 2px solid var(--accent); background: #fff; vertical-align: -1px; }

/* 로고 · 계정 */
.brand .logo { width: 30px; height: 30px; display: block; background: none; border-radius: 0; }
.wordmark { display: inline-flex; align-items: baseline; gap: 3px; font-size: 17px; letter-spacing: -0.02em; color: var(--ink); line-height: 1; }
.wm-plan { font-weight: 500; } .wm-b { font-weight: 800; color: var(--accent); font-size: 1.12em; } .wm-home { font-weight: 700; }
.acct { min-width: 36px; height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line2); background: var(--panel); font-weight: 700; color: var(--ink); white-space: nowrap; }
.acct.in { width: 36px; padding: 0; background: var(--accent); color: #fff; border-color: var(--accent); font-size: 15px; }
.acct-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin: 0 0 16px; border-radius: 12px; background: var(--pri-soft); color: var(--ink); font-size: 13px; }
.acct-banner:empty { display: none; }
.auth .auth-head { display: flex; align-items: center; gap: 10px; } .auth .auth-head .logo { width: 34px; height: 34px; } .auth .auth-head h1 { margin: 0; }
.btn.wide { width: 100%; padding: 11px; }
.btn.ghost { background: transparent; }
.mclose, .mback { z-index: 2; }
@media (max-width: 700px) { .wordmark { display: none; } .acct:not(.in) { padding: 0 10px; font-size: 13px; } }

.help-btn { padding: 7px 12px; }
.guide.help { font-size: 14px; line-height: 1.75; } .guide.help > b { font-size: 15px; margin-top: 12px; }
@media (max-width: 900px) { .help-btn span { display: none; } .help-btn { padding: 7px 10px; } }

/* 모바일 상단: 로고 · 보기 전환 · 되돌리기 · ☰ 메뉴 */
.menu-btn { display: none; }
.mmenu { position: fixed; top: calc(var(--top) + 6px); right: 10px; z-index: 40; display: flex; flex-direction: column; min-width: 200px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.mmenu button { text-align: left; padding: 11px 12px; border-radius: 10px; font-weight: 600; color: var(--ink); }
.mmenu button:active { background: var(--pri-soft); }
@media (max-width: 700px) {
  .top { gap: 6px; padding: 0 10px; }
  .menu-btn { display: grid; place-items: center; }
  #projName, #saveState, #btnShare, #btnProjects, #btnAccount, #btnRedo, .help-btn, .top .grow:first-of-type { display: none !important; }
  .seg button { padding: 6px 10px; font-size: 13px; }
  .top .grow { flex: 1; }
  .ic-btn { width: 36px; height: 36px; }
  /* 손가락으로 누르기 쉬운 크기 */
  .chip { padding: 7px 12px; } .btn.sm { padding: 7px 11px; }
  .sw { width: 32px; height: 32px; }
  .mscroll { padding: 18px 16px; }
  .mbox { max-height: calc(100dvh - 20px); border-radius: 16px; }
  #modal { padding: 10px; }
  .compass { width: 42px; height: 42px; right: 10px; top: 10px; }
}

.sw-sep { width: 1px; height: 22px; background: var(--line2); margin: 0 2px; }
.sw.mine { box-shadow: 0 0 0 1px var(--line2), inset 0 0 0 2px #fff; }
.sw.mine.on { box-shadow: 0 0 0 2px var(--accent), inset 0 0 0 2px #fff; }

/* 약관·방침 링크, 탈퇴 */
.legal { margin: 18px 0 0; font-size: 12px; color: var(--ink3); text-align: center; } .legal a, .auth a, .mm-legal { color: var(--ink2); }
.mm-legal { padding: 8px 12px; font-size: 12.5px; text-decoration: none; }
.danger-zone { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; } .danger-zone summary { cursor: pointer; color: var(--ink3); }
.danger-zone input { padding: 8px 10px; border: 1px solid var(--line2); border-radius: 9px; }

.btn.kakao { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; background: #FEE500; border-color: #FEE500; color: #191600; text-decoration: none; }
.btn.kakao:hover { background: #f5dc00; }

.iq-rep { white-space: pre-wrap; margin-top: 8px; padding: 8px 12px; background: var(--pri-soft); border-radius: 10px; }

/* ---------- 디자인 다듬기: 글자는 따뜻한 먹색, 초록은 주요 버튼·선택 표시에만, 제목은 명조(고운바탕) ---------- */
:root { --serif: 'Gowun Batang', 'Noto Serif KR', 'Apple SD Gothic Neo', serif; --line: #e9e4d9; --line2: #d8d1c2; }
.mbox h1, .insp h2, .start-card b, .tpl b, .auth .auth-head h1 { font-family: var(--serif); font-weight: 700; letter-spacing: -0.02em; }
.mbox h1 { font-size: 25px; margin-bottom: 8px; }
.insp h2 { font-size: 18px; }
.mbox h2, h3.sec { font-size: 12px; letter-spacing: 0.06em; color: var(--ink3); font-weight: 700; }
.mbox h2::before, h3.sec::before { content: ''; display: inline-block; width: 14px; height: 2px; background: var(--accent); vertical-align: middle; margin-right: 8px; border-radius: 2px; }
.wordmark { color: var(--ink); } .wm-plan, .wm-home { color: var(--sage); }
.top { background: var(--bg); border-bottom-color: var(--line); }
.seg { background: #ebe6da; border-radius: 12px; }
.seg button { color: var(--ink2); border-radius: 9px; }
.seg button.on { background: var(--ink); color: #F7F5EF; box-shadow: none; }
.tabs button { color: var(--ink3); }
.tabs button.on { color: var(--ink); border-color: var(--accent); }
.chip { background: #efeadf; color: var(--ink2); }
.chip.on { background: var(--ink); color: #F7F5EF; border-color: var(--ink); }
.chips.sub .chip.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn { border-color: var(--line2); color: var(--ink); background: var(--panel); }
.btn.pri { background: var(--sage); border-color: var(--sage); color: #F7F5EF; }
.pcard, .start-card, .tpl, .block, .proj { border-color: var(--line); background: #fffdf9; }
.pcard:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pcard.armed { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.pgrid .pcard .badge { color: var(--accent); }
.pgrid .pcard .name { color: var(--ink); } 
.start-card { transition: transform .12s, box-shadow .12s, border-color .12s; }
.start-card:hover, .tpl:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(60, 40, 20, 0.08); }
.start-card b { font-size: 17px; }
.acct-banner { background: #f1ece1; }
.toolbar { border-color: var(--line); border-radius: 16px; }
.toolbar button { color: var(--ink2); }
.toolbar button.on { background: var(--accent-soft); color: var(--accent); }
.jump button { background: #efeadf; color: var(--ink); }
.addmine { color: var(--accent); border-color: var(--line2); }
.search:focus, .field input:focus, .field select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.legal a, .auth a { color: var(--accent); }
.help-btn { color: var(--ink2); }
.mmenu button { color: var(--ink); }
.walk-help, .hint { background: rgba(43, 41, 37, 0.82); }
.wp-grid button:active, .wp-grid button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* 비밀번호 보기 버튼 · 조건 */
.pw-wrap { position: relative; display: flex; } .pw-wrap input { flex: 1; min-width: 0; padding-right: 44px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px; min-height: 0 !important; display: grid; place-items: center; border-radius: 8px; color: var(--ink3); background: none; }
.pw-eye:hover { background: #efeadf; color: var(--ink); } .pw-eye.on { color: var(--accent); } .pw-eye .ic { width: 20px; height: 20px; }
.pw-rules { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; } .pw-rules span { font-size: 11.5px; padding: 2px 9px; border-radius: 10px; background: #efeadf; color: var(--ink3); }
.pw-rules span.ok { background: var(--pri-soft); color: var(--sage, #315648); font-weight: 700; } .pw-rules span.ok::before { content: '✓ '; }

/* ---------- 아이콘 컴포넌트 ---------- */
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.toolbar button .ic, .wp-side button .ic { width: 20px; height: 20px; }
.wp-grid button .ic { width: 22px; height: 22px; }
.ic-btn .ic { width: 20px; height: 20px; }
.btn .ic { margin-right: 2px; }
.mmenu button { display: flex; align-items: center; gap: 10px; } .mmenu button .ic { width: 18px; height: 18px; color: var(--ink2); }
.mclose, .close-insp { display: grid; place-items: center; } .mclose .ic, .close-insp .ic { width: 18px; height: 18px; }
.start-card .big { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-size: 0; margin-bottom: 4px; }
.start-card .big .ic { width: 24px; height: 24px; }
.start-card:nth-child(2) .big { background: var(--pri-soft); color: var(--sage); }
.start-card:nth-child(3) .big { background: #efeadf; color: var(--ink2); }
.help-btn { display: inline-flex; align-items: center; gap: 4px; }
.addmine { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
/* ---------- 모든 기기에서 컴포넌트가 깨지지 않게 ---------- */
.btn, .chip, .toolbar button, .tabs button, .seg button { min-height: 34px; }
.btn.sm, .chip { min-height: 30px; }
.btns, .row.wrap, .chips, .swrow { row-gap: 6px; }
.mfoot { flex-wrap: wrap; }
.dims { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } .dims .field, .dims input { min-width: 0; width: 100%; }
.cp-grid { flex-wrap: wrap; }
img, canvas, svg { max-width: 100%; }
@media (pointer: coarse) { .btn, .chip, .toolbar button, .tabs button, .seg button, .ic-btn, .pw-eye { min-height: 40px; } .btn.sm, .chip { min-height: 36px; } .sw { width: 34px; height: 34px; } input, select, textarea { font-size: 16px; } /* iOS 입력 시 자동 확대 방지 */ }
@media (max-width: 700px) {
  .start-grid { grid-template-columns: 1fr; gap: 8px; }
  .start-card { display: grid; grid-template-columns: 46px 1fr; column-gap: 12px; align-items: center; text-align: left; padding: 14px; }
  .start-card .big { grid-row: span 2; margin: 0; }
  .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .proj-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mbox h1 { font-size: 21px; padding-right: 40px; }
  .acct-banner { flex-direction: column; align-items: flex-start; }
  .toolbar button span { font-size: 10px; }
  .pw-rules span { font-size: 11px; }
}
@media (min-width: 701px) and (max-width: 1100px) { :root { --side: 300px; --insp: 280px; } .help-btn span { display: none; } .pname { width: 120px; } }
@media (min-width: 1600px) { :root { --side: 380px; } .pgrid { grid-template-columns: repeat(3, 1fr); } }

/* ---------- 글 줄바꿈: 한글은 단어 단위로, 제목·안내문은 줄 길이를 고르게 ---------- */
body { word-break: keep-all; overflow-wrap: anywhere; line-break: strict; }
.mbox h1, .insp h2, .start-card b { text-wrap: balance; }
.lead, .muted, .guide li, .target, .acct-banner span, .toast, .hint, .walk-help, .orbit-help, .chk span, .legal { text-wrap: pretty; }
.mbox .lead { max-width: 62ch; line-height: 1.65; }
.muted { line-height: 1.55; }
.orbit-help, .walk-help { line-height: 1.5; max-width: min(720px, calc(100% - 90px)); }
.toast { max-width: min(520px, calc(100vw - 32px)); line-height: 1.5; }
.chk { align-items: flex-start; } .chk input { margin-top: 3px; flex: none; }
.guide li + li { margin-top: 2px; }
.pgrid .pcard .name, .list-item .t b { word-break: keep-all; overflow-wrap: anywhere; }

.btn.naver { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; background: #03C75A; border-color: #03C75A; color: #fff; text-decoration: none; }
.btn.naver:hover { background: #02b351; }

.btn.google { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; background: #fff; border-color: #dadce0; color: #3c4043; text-decoration: none; }
.btn.google:hover { background: #f8f9fa; }

/* ---------- 로그인 · 가입 팝업 ---------- */
.auth .mscroll { padding: 28px 26px 22px; }
.auth-hero { text-align: center; padding: 6px 0 4px; } .auth-hero .logo { width: 52px; height: 52px; margin: 0 auto 10px; } .auth-hero h1 { font-size: 26px; margin: 0 0 6px; } .auth-hero .lead { margin: 0 auto 18px; }
.auth-sec { display: grid; gap: 8px; } .auth-cap { font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--ink3); margin-bottom: 2px; }
.btn.sns { display: grid; grid-template-columns: 24px 1fr 24px; align-items: center; margin: 0; padding: 13px 16px; border-radius: 12px; font-size: 15px; font-weight: 700; text-decoration: none; text-align: center; min-height: 50px; }
.btn.sns svg { justify-self: center; } .btn.sns span { grid-column: 2; }
.btn.sns.kakao { background: #FEE500; border-color: #FEE500; color: #191600; } .btn.sns.naver { background: #03C75A; border-color: #03C75A; color: #fff; } .btn.sns.google { background: #fff; border-color: #dadce0; color: #3c4043; }
.btn.sns:hover { filter: brightness(0.97); transform: translateY(-1px); }
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--ink3); font-size: 12px; font-weight: 600; } .or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line2); }
.auth-two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .auth-two .btn { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 8px; }
.auth-guest { display: block; width: 100%; margin-top: 16px; padding: 8px; color: var(--ink2); font-weight: 600; font-size: 13.5px; text-align: center; } .auth-guest:hover { color: var(--accent); }
.auth-legal { text-align: center; font-size: 11.5px; margin: 10px 0 0; }
.auth-switch { text-align: center; margin: 14px 0 0; font-size: 13.5px; color: var(--ink2); } .auth-switch a { font-weight: 700; }
.sns-row { display: flex; justify-content: center; gap: 14px; } .sns-dot { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: 1px solid transparent; }
.sns-dot.kakao { background: #FEE500; } .sns-dot.naver { background: #03C75A; } .sns-dot.google { background: #fff; border-color: #dadce0; } .sns-dot:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,.12); }
.auth .mback { position: static; display: inline-block; margin: 0 0 12px; padding: 0; background: none; color: var(--ink2); font-size: 13px; font-weight: 600; }
.auth .auth-head { margin-bottom: 4px; } .auth .lead { margin-bottom: 14px; }
@media (max-width: 480px) { .auth .mscroll { padding: 22px 18px 18px; } .auth-two { grid-template-columns: 1fr; } .auth-hero h1 { font-size: 23px; } }
