/* ==========================================================================
   Create mode — design toolbar, tool palette, canvas, side panels
   ========================================================================== */
.page--create { max-width: 1560px; }
.h3 { font-size: var(--fs-md); }
.cbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-bottom: var(--s-4); }
.cbar__name { flex: 1 1 200px; min-width: 0; max-width: 340px; font-weight: 600; }
.cbar__group { display: flex; flex-wrap: wrap; gap: var(--s-1); align-items: center; }

.create { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s-4); align-items: start; }
.create__stage { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; position: sticky; top: calc(var(--topbar-h) + var(--s-4)); overflow: hidden; }
.create__side { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.create__go { position: sticky; bottom: 0; z-index: 5; padding: var(--s-2) 0 var(--s-3); background: linear-gradient(180deg, transparent, var(--bg) 35%); }
.create__out { margin-top: var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); scroll-margin-top: calc(var(--topbar-h) + var(--s-4)); }
#results { display: flex; flex-direction: column; gap: var(--s-4); }

.tools { grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 2px; padding: var(--s-2); border-right: 1px solid var(--border); background: var(--surface); }
.tools button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid transparent; border-radius: var(--r-1); background: none; color: var(--text-2); cursor: pointer; }
.tools button:hover { background: var(--surface-2); color: var(--text); }
.tools button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.tools button svg { width: 22px; height: 22px; }
.tools hr { width: 100%; border: 0; border-top: 1px solid var(--border); margin: var(--s-1) 0; }

.dc { position: relative; height: min(62vh, 640px); min-height: 320px; background: var(--bg-2); touch-action: none; overflow: hidden; }
.dc__svg { position: absolute; inset: 0; width: 100%; height: 100%; outline-offset: -2px; user-select: none; -webkit-user-select: none; }
.dc__svg[data-tool="pan"] { cursor: grab; }
.dc__svg:not([data-tool="select"]):not([data-tool="pan"]) { cursor: crosshair; }
.dc__travel { fill: none; stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; opacity: .55; }
.dc__stock { fill: var(--dc-stock, #c9a56b); fill-opacity: .16; stroke: var(--dc-stock-line, #c9a56b); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.dc__stock--over { stroke: var(--bad); }
.dc__grid { fill: none; stroke: var(--text-3); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .16; }
.dc__shape { fill: none; stroke: var(--text-2); stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.dc__hit { fill: none; stroke: transparent; stroke-width: 14; vector-effect: non-scaling-stroke; pointer-events: stroke; cursor: move; }
.dc__hit--closed { fill: transparent; pointer-events: all; }
.dc__svg:not([data-tool="select"]) .dc__hit { pointer-events: none; }
.dc__g--none .dc__shape { stroke-dasharray: 5 4; }
.dc__g--profile-outside .dc__shape { stroke: var(--accent-text); stroke-width: 2.2; }
.dc__g--profile-inside .dc__shape { stroke: var(--bad-text); stroke-width: 2.2; }
.dc__g--pocket .dc__shape { stroke: var(--ok-text); fill: var(--ok-soft); }
.dc__g--follow .dc__shape { stroke: var(--warn-text); }
.dc__g--drill .dc__shape { stroke: var(--bad-text); stroke-dasharray: 2 3; }
.dc__g.is-selected .dc__shape { stroke-width: 2.8; filter: drop-shadow(0 0 2px var(--focus)); }
.dc__draft path { fill: none; stroke: var(--focus); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; }
.dc__start { fill: var(--focus); }
.dc__box { fill: none; stroke: var(--focus); stroke-width: 1; stroke-dasharray: 4 3; pointer-events: none; }
.dc__marquee { fill: var(--accent-soft); stroke: var(--focus); stroke-width: 1; pointer-events: none; }
.dc__handle { fill: var(--surface); stroke: var(--focus); stroke-width: 1.5; }
.dc__handle--rot { cursor: grab; }
.dc__axis { fill: none; stroke: var(--bad-text); stroke-width: 2; pointer-events: none; }
.dc__label { fill: var(--text-3); font: 11px var(--font-sans); pointer-events: none; user-select: none; }
.dc__foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); padding: var(--s-2) var(--s-3); border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.dc__gridsize { display: inline-flex; align-items: center; gap: var(--s-2); }
.dc__gridsize .input { width: 72px; }
.dc__readout { margin-left: auto; color: var(--text-3); font-family: var(--font-mono); font-size: var(--fs-xs); min-width: 13ch; text-align: right; }
.dc__legend { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); font-size: var(--fs-xs); color: var(--text-3); }

/* side panels */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2) var(--s-3); }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s-2) var(--s-3); }
.mini { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mini > span:first-child { font-size: var(--fs-xs); color: var(--text-3); }
.mini .input, .mini .select { width: 100%; min-width: 0; }
.mini .unit-wrap { width: 100%; }
.mini .unit-wrap .input { width: 100%; }
.btnrow { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.hint { color: var(--text-2); font-size: var(--fs-sm); }
textarea.input { width: 100%; min-height: 64px; resize: vertical; padding: var(--s-2) var(--s-3); line-height: 1.35; }
.shapelist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 180px; overflow: auto; }
.shapelist button { width: 100%; text-align: left; background: none; border: 0; padding: 5px var(--s-2); border-radius: var(--r-1); cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); display: flex; gap: var(--s-2); justify-content: space-between; }
.shapelist button:hover { background: var(--surface-2); color: var(--text); }
.shapelist .tag { color: var(--text-3); font-size: var(--fs-xs); }

.op { border: 1px solid var(--border); border-radius: var(--r-2); background: var(--surface); }
.op + .op { margin-top: var(--s-2); }
.op > summary { list-style: none; cursor: pointer; padding: var(--s-2) var(--s-3); display: flex; align-items: center; gap: var(--s-2); }
.op > summary::-webkit-details-marker { display: none; }
.op > summary::before { content: '▸'; color: var(--text-3); width: 1em; }
.op[open] > summary::before { content: '▾'; }
.op__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--text-3); }
.op__dot--profile-outside { background: var(--accent-text); } .op__dot--profile-inside { background: var(--bad-text); } .op__dot--pocket { background: var(--ok-text); } .op__dot--follow { background: var(--warn-text); } .op__dot--drill { background: var(--bad-text); } .op__dot--face { background: var(--text-2); }
.op__title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op__sub { margin-left: auto; color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }
.op__body { padding: var(--s-2) var(--s-3) var(--s-3); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--s-3); }
.op__feeds { color: var(--text-2); font-size: var(--fs-sm); background: var(--surface-2); border-radius: var(--r-1); padding: var(--s-2) var(--s-3); }

.files { display: flex; flex-direction: column; gap: var(--s-2); }
.file { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-2) var(--s-3); border: 1px solid var(--border); border-radius: var(--r-2); }
.file__name { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: 600; word-break: break-all; }
.file__meta { color: var(--text-2); font-size: var(--fs-sm); flex: 1 1 220px; min-width: 0; }
.file--frame { border-style: dashed; }
.imgdlg__preview { width: 100%; max-height: 300px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: var(--r-1); image-rendering: pixelated; }
.tpl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-2); }
.tpl button { text-align: left; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-2); background: var(--surface); cursor: pointer; }
.tpl button:hover { border-color: var(--accent); }
.tpl strong { display: block; margin-bottom: 2px; } .tpl span { color: var(--text-2); font-size: var(--fs-sm); }

:root[data-theme="light"] { --dc-stock: #b98a45; --dc-stock-line: #9a7030; }

@media (max-width: 1100px) {
  .create { grid-template-columns: minmax(0, 1fr); }
  .create__stage { position: static; }
  .dc { height: min(56vh, 520px); }
}
@media (max-width: 600px) {
  .create__stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .tools { grid-row: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .tools button { flex: none; }
  .tools hr { width: 1px; height: auto; border-top: 0; border-left: 1px solid var(--border); margin: 0 var(--s-1); }
  .dc { height: 52vh; min-height: 280px; }
  .cbar__name { max-width: none; flex-basis: 100%; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .dc__readout { display: none; }
}
