/* CSS Grid 생성기 전용 CSS (2026-10-21). 격자 도면판: 예시 9 → [위 줄 · 열 자 | 행 자 + 실제 grid 무대 · 풀이 문장] → [격자 | 영역·고른 것] → 코드. 공용 부품은 assets/v2.css
   영역 색은 색상 8개를 종이(--paper)·글자(--ink) 색과 섞어 라이트·다크 모두에서 맞춘다 */
.grd{container:grd / inline-size;--grd-h0:#c2410c;--grd-h1:#0f766e;--grd-h2:#6d28d9;--grd-h3:#a16207;--grd-h4:#1d4ed8;--grd-h5:#be185d;--grd-h6:#4d7c0f;--grd-h7:#475569;--grd-rw:58px}
.grd [data-h="0"]{--h:var(--grd-h0)}.grd [data-h="1"]{--h:var(--grd-h1)}.grd [data-h="2"]{--h:var(--grd-h2)}.grd [data-h="3"]{--h:var(--grd-h3)}
.grd [data-h="4"]{--h:var(--grd-h4)}.grd [data-h="5"]{--h:var(--grd-h5)}.grd [data-h="6"]{--h:var(--grd-h6)}.grd [data-h="7"]{--h:var(--grd-h7)}
.grd svg{flex:0 0 auto}
.grd-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.grd :focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* 예시 배치 */
.grd-exw{padding:12px 14px;border-bottom:1px solid var(--soft)}
.grd-ex{display:grid;grid-template-columns:repeat(var(--cols,9),minmax(0,1fr));gap:6px}
.grd-tile{display:grid;align-content:start;gap:5px;min-width:0;padding:5px 5px 6px;border:1px solid var(--soft);border-radius:var(--radius);background:var(--paper);color:var(--ink);text-align:left;cursor:pointer;transition:border-color var(--ease)}
.grd-tile:hover{border-color:var(--line)}
.grd-tv{position:relative;display:block;height:46px;overflow:hidden;background:var(--wash);border-radius:var(--radius)}
.grd-mini{position:absolute;left:0;top:0;display:grid;box-sizing:border-box;transform-origin:0 0;pointer-events:none}
.grd-mini i:only-child{width:40%}
.grd-mini i{display:block;min-width:0;min-height:40px;background:color-mix(in oklab, var(--h) 30%, var(--paper));border:6px solid color-mix(in oklab, var(--h) 70%, var(--ink));border-radius:10px}
.grd-tile b{padding:0 1px;font-family:var(--sans);font-size:11.5px;font-weight:700;line-height:1.3;overflow-wrap:break-word;hyphens:auto}
:lang(ko) .grd-tile b{word-break:keep-all}

/* 도면: 위 줄 */
.grd-board{border-bottom:1px solid var(--soft)}
.grd-bar{display:flex;align-items:center;flex-wrap:wrap;gap:8px 14px;padding:12px 16px 10px}
.grd-step{display:inline-flex;align-items:center;gap:5px}
.grd-step .v2-label{margin-right:2px}
.grd-ib{width:30px;height:30px;padding:0;justify-content:center}
.grd-ib svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round}
.grd-n{min-width:20px;text-align:center;font-family:var(--sans);font-size:15px;font-weight:800;font-variant-numeric:tabular-nums lining-nums}
.grd-step + .grd-step + .grd-ws{margin-left:auto}
.grd-ws button{height:30px;padding:0 9px;font-family:var(--mono);font-size:11.5px}
.grd-ws button:disabled{opacity:.4;cursor:not-allowed}
.grd-rs svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}

/* 도면: 자 + 무대 */
.grd-stage{display:grid;grid-template-columns:var(--grd-rw) minmax(0,1fr);grid-template-rows:44px auto;padding:8px 30px 30px 6px;margin:0 16px;border-radius:var(--radius);background:radial-gradient(var(--dot) 1px,transparent 1.3px) 0 0 / 14px 14px,var(--wash);overflow-x:auto;overscroll-behavior-x:contain}
.grd-cr,.grd-rr{position:relative;min-width:0;min-height:0}
.grd-corner{display:grid;align-content:end;justify-items:end;gap:1px;padding:0 6px 6px 0;font-family:var(--mono);font-size:10px;line-height:1.15;color:var(--muted);white-space:nowrap;font-variant-numeric:tabular-nums}
.grd-corner b{font-size:11px;color:var(--ink)}
.grd-tk{position:absolute;box-sizing:border-box;display:grid;align-content:center;justify-items:center;gap:0;min-width:0;padding:0 2px;border:1px solid var(--soft);border-radius:var(--radius);background:var(--paper);color:var(--ink);font-family:var(--mono);line-height:1.2;overflow:hidden;cursor:pointer;transition:background var(--ease),border-color var(--ease)}
.grd-tk b{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:700}
.grd-tk small{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:9.5px;color:var(--muted)}
.grd-tk:hover{border-color:var(--line)}
.grd-tk[aria-pressed="true"]{background:var(--fill);border-color:var(--fill);color:var(--on-fill)}
.grd-tk[aria-pressed="true"] small{color:inherit;opacity:.8}
.grd-tk.is-imp{border-style:dashed;background:transparent;color:var(--muted)}
.grd-tk.is-tiny small,.grd-tk.is-min b{display:none}
.grd-cr .grd-tk{bottom:4px;height:30px}
.grd-rr .grd-tk{right:5px;width:calc(100% - 20px)}
.grd-ln{position:absolute;font-family:var(--mono);font-size:9.5px;font-weight:700;line-height:12px;color:var(--muted);pointer-events:none;white-space:nowrap}
.grd-cr .grd-ln{top:0;transform:translateX(-50%)}
.grd-rr .grd-ln{left:1px;transform:translateY(-50%)}
.grd-ln.is-imp{opacity:.55}
.grd-bw{position:relative;min-width:0}
.grd-box{position:relative;box-sizing:border-box;display:grid;border:1px dashed var(--line);background:var(--paper)}
.grd[data-mode="t"] .grd-box{cursor:crosshair;touch-action:none}
.grd-cells{position:absolute;inset:0;pointer-events:none}
.grd-c{position:absolute;box-sizing:border-box;border:1px dashed color-mix(in srgb, var(--line) 80%, transparent);border-radius:2px}
.grd-c.is-imp{border-style:dotted;border-color:color-mix(in srgb, var(--line) 55%, transparent)}
.grd-draw{position:absolute;z-index:3;box-sizing:border-box;display:grid;place-items:center;border:2px solid var(--ink);border-radius:3px;background:color-mix(in srgb, var(--ink) 9%, transparent);font-family:var(--mono);font-size:12px;font-weight:700;color:var(--ink)}
/* 영역 크기 규칙(최소 폭 0·넘침 숨김·안쪽 여백 4px 6px·테두리 1px·글자 12.5px/1.3)은 '꾸밈 포함' 코드(tool.js DECO)와 같다 */
.grd-it{position:relative;z-index:1;box-sizing:border-box;display:grid;place-items:center;min-width:0;min-height:0;padding:4px 6px;font:700 12.5px/1.3 var(--mono);border:1px solid color-mix(in oklab, var(--h) 62%, var(--ink));border-radius:3px;background:color-mix(in oklab, var(--h) 17%, var(--paper));color:var(--ink);overflow:hidden;cursor:grab;transition:background var(--ease)}
.grd[data-mode="a"] .grd-it{cursor:pointer}
.grd-it b{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:inherit;color:color-mix(in oklab, var(--h) 70%, var(--ink))}
.grd-it:hover{background:color-mix(in oklab, var(--h) 26%, var(--paper))}
.grd-it.is-cur{background:color-mix(in oklab, var(--h) 30%, var(--paper));box-shadow:inset 0 0 0 2px color-mix(in oklab, var(--h) 75%, var(--ink))}
.grd-it.is-auto{border-style:dashed}
.grd-rz{position:absolute;z-index:3;width:14px;height:14px;margin:-17px 0 0 -17px;box-sizing:border-box;border:2px solid var(--paper);border-radius:3px;background:var(--ink);cursor:nwse-resize;touch-action:none}
.grd-grip{position:absolute;z-index:4;display:grid;place-items:center;width:26px;height:26px;margin:-1px 0 0 -1px;padding:0;border:1px solid var(--line);border-radius:50%;background:var(--paper);color:var(--ink);box-shadow:0 1px 3px rgba(0,0,0,.2);cursor:nwse-resize;touch-action:none}
.grd-grip svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round}
.grd.is-drag,.grd.is-drag *{user-select:none}
.grd.is-mv,.grd.is-mv *{cursor:grabbing!important}
.grd.is-rz,.grd.is-rz *,.grd.is-gp,.grd.is-gp *{cursor:nwse-resize!important}
.grd.is-dr,.grd.is-dr *{cursor:crosshair!important}
.grd-say{min-height:1.55em;margin:10px 16px 0;font-size:13.5px;line-height:1.55;color:var(--ink);font-variant-numeric:tabular-nums lining-nums}
.grd-hint{margin:4px 16px 0;font-size:12px;line-height:1.5;color:var(--muted)}
.grd-status{display:block;min-height:1.5em;margin:2px 16px 10px;line-height:1.5}

/* 조작판: 격자 | 영역·고른 것 */
.grd-panels{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
.grd-par,.grd-sel{min-width:0;padding:14px 16px 4px}
.grd-par{border-right:1px solid var(--soft)}
.grd-ph{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px 10px;min-height:30px;margin:0 0 10px}
.grd-ph b{font-family:var(--serif);font-size:15px;font-weight:800;letter-spacing:-.01em}
.grd-ph code{font-family:var(--mono);font-size:12px;color:var(--muted)}
.grd-g{margin:0 0 12px}
.grd-g .v2-label{display:block;margin:0 0 5px}
.grd-two{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px;margin:0 0 12px}
.grd-two[hidden]{display:none}
.grd-four{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin:0 0 12px}
.grd-f > span.v2-label{display:block;margin:0 0 5px}
.grd-f .v2-label code{font-family:var(--mono);font-size:10.5px;font-weight:400;color:var(--muted);white-space:nowrap}
.grd-seg{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:4px;width:100%}
.grd-seg button{display:grid;place-items:center;min-width:0;padding:0 6px;line-height:1.2}
.grd-seg button:disabled{opacity:.4;cursor:not-allowed}
.grd-tall button{height:var(--v2-ctl)}
.grd-ico svg{width:24px;height:16px;fill:currentColor}
.grd-ico svg .fr{fill:none;stroke:currentColor;stroke-width:1;opacity:.5}
.grd-tin input{text-align:left;font-family:var(--mono);font-size:14px}
.grd-sw{display:flex!important;align-items:center;height:var(--v2-ctl);font-family:var(--mono);font-size:12.5px}
.grd-list{display:flex;flex-wrap:wrap;gap:5px;margin:0 0 12px}
.grd-list button{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 9px;border:1px solid var(--soft);border-radius:var(--radius);background:var(--paper);font-family:var(--mono);font-size:12px;font-weight:600;color:var(--ink)}
.grd-list button i{width:9px;height:9px;border-radius:2px}
.grd-list button[aria-pressed="true"]{border-color:var(--ink);background:var(--btn)}
.grd-empty{font-size:12.5px;color:var(--muted);line-height:28px}
.grd-eds{display:grid}
.grd-ed{grid-area:1 / 1;min-width:0;padding:12px 0 0;border-top:1px solid var(--soft)}
.grd-stack{display:grid}
.grd-stack > *{grid-area:1 / 1}
.grd .is-off{visibility:hidden}
.grd-eh{display:flex;align-items:baseline;justify-content:space-between;gap:8px;min-height:20px;margin:0 0 8px}
.grd-eh code{font-family:var(--mono);font-size:12px;font-weight:700;color:var(--ink)}
.grd-it-note{display:flex;flex-wrap:wrap;justify-content:space-between;gap:2px 10px;min-height:1.5em;margin:0 0 10px;font-size:12px;line-height:1.5;color:var(--muted)}
.grd-it-note code{font-family:var(--mono);font-size:11.5px;color:var(--ink);overflow-wrap:anywhere}
.grd-acts{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;margin:0 0 12px}
.grd-qk{display:flex;flex-wrap:wrap;gap:4px;margin:10px 0}
.grd-qk button{height:28px;padding:0 8px;font-family:var(--mono);font-size:11.5px}
.grd-tr-note{min-height:3em;margin:0 0 10px;font-size:12.5px;line-height:1.5;color:var(--ink)}

/* 코드 */
.grd-code{padding:14px 16px 16px}
.grd-chead{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 10px}
.grd-chead .grd-acts{margin:0 0 0 auto}
.grd-tabs button{min-width:56px}
.grd-names button:disabled{opacity:.4;cursor:not-allowed}
.grd-why{margin:0 0 8px;font-size:12.5px;line-height:1.5;color:var(--muted)}
.grd-why.is-warn{color:var(--accent)}
.grd-why:empty{display:none}
.grd-pre{margin:0;padding:12px 14px;background:var(--wash);border:1px solid var(--soft);border-radius:var(--radius);font-family:var(--mono);font-size:12.5px;line-height:1.6;color:var(--ink);white-space:pre;overflow-x:auto;tab-size:2}
.grd-k{font-weight:700;color:color-mix(in oklab, var(--h) 78%, var(--ink))}

@container grd (max-width: 639px){
  .grd-panels{grid-template-columns:minmax(0,1fr)}
  .grd-par{border-right:0;border-bottom:1px solid var(--soft)}
  .grd-ed.is-off{display:none}
}
@container grd (max-width: 479px){
  .grd{--grd-rw:50px}
  .grd-exw,.grd-bar{padding-left:12px;padding-right:12px}
  .grd-stage{margin:0 10px;padding:8px 28px 30px 4px}
  .grd-par,.grd-sel,.grd-code{padding-left:12px;padding-right:12px}
  .grd-say,.grd-hint,.grd-status{margin-left:12px;margin-right:12px}
  .grd-rs{width:30px;padding:0;justify-content:center}
  .grd-rs span{display:none}
  .grd-chead .grd-acts{margin-left:0}
}
@media (prefers-reduced-motion: reduce){
  .grd-tile,.grd-it,.grd-tk{transition:none}
}
.v2-article pre.grd-code{margin:10px 0 16px;padding:12px 14px;overflow-x:auto;border:1px solid var(--soft);border-radius:var(--radius);background:var(--card);font-family:var(--mono);font-size:13px;line-height:1.6;color:var(--ink)}
.v2-article pre.grd-code code{font-size:inherit;font-weight:500;overflow-wrap:normal;white-space:pre}
