:root {
  --bg: #f4f3f1; --panel: #ffffff; --ink: #222; --sub: #6b6b6b; --line: #dcdad6;
  --accent: #b5462f; --accent-ink: #fff; --seam: #c0392b; --sel: #1f6feb;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", sans-serif; color: var(--ink); background: var(--bg); font-size: 13px; }
header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
header .logo { height: 34px; width: auto; }
header h1 { font-size: 16px; margin: 0 8px 0 0; white-space: nowrap; }
header input { width: 280px; }
.spacer { flex: 1; }
button { font: inherit; padding: 6px 12px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
button:hover { border-color: #999; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.active { background: #222; color: #fff; border-color: #222; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea { font: inherit; padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
main { display: grid; grid-template-columns: 270px 1fr 330px; height: calc(100vh - 51px); }
aside { overflow-y: auto; background: var(--panel); padding: 4px 12px 20px; }
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); }
section { margin: 10px 0 14px; }
h2 { font-size: 13px; margin: 0 0 6px; padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.reco { margin-top: 8px; padding: 8px; border: 1px dashed var(--line); border-radius: 6px; }
.reco-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.reco-row label { display: flex; gap: 3px; align-items: center; }
.reco-row input { width: 62px; }
#recoOut { font-size: 12px; line-height: 1.6; }
#recoOut b { font-size: 15px; color: var(--accent); }
#recoOut button { margin-top: 4px; padding: 3px 10px; }
.guide { margin-top: 8px; padding: 6px 8px; background: #f6f4f0; border-radius: 6px; line-height: 1.6; font-size: 12px; }
.guide small { color: var(--sub); }
details.hint summary { cursor: pointer; }
.hint { color: var(--sub); font-size: 11.5px; line-height: 1.5; margin: 6px 0 0; }
.list { padding-left: 16px; }
.row { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.check { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
.tpl-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tpl-buttons .wide { grid-column: 1 / 3; }
#tplParams label, #right label { display: block; margin: 8px 0 2px; color: #444; }
#right label input, #right label select, #right label textarea { width: 100%; margin-top: 2px; }
#tplParams input[type=range] { width: 100%; }
#tplParams .val { float: right; color: var(--sub); }
#tplParams .seg { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
#tplParams .seg button { padding: 4px 8px; font-size: 12px; }
#center { position: relative; display: flex; flex-direction: column; min-width: 0; }
#toolbarMsg { min-height: 28px; padding: 5px 12px; color: var(--sub); }
#toolbarMsg.mode { color: var(--sel); font-weight: bold; }
#canvas { flex: 1; width: 100%; height: 100%; touch-action: none; user-select: none; }
.fab { display: grid; grid-template-columns: 22px 28px 1fr 24px; gap: 6px; align-items: center; padding: 4px; border-radius: 6px; border: 2px solid transparent; cursor: pointer; margin-bottom: 4px; }
.fab.on { border-color: var(--sel); background: #eef4ff; }
.fab .id { font-weight: bold; text-align: center; }
.fab input[type=color] { width: 28px; height: 24px; padding: 0; border: 1px solid var(--line); }
.fab input[type=text] { width: 100%; }
.fab .memo { grid-column: 2 / 5; font-size: 11.5px; padding: 3px 6px; }
.fab .del { padding: 0; width: 24px; height: 24px; color: #999; }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 3px 4px; border-bottom: 1px solid #eee; text-align: left; vertical-align: middle; }
td select { width: 100%; padding: 2px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 1px solid #0003; vertical-align: -1px; margin-right: 4px; }
#seamList { padding-left: 20px; margin: 0; line-height: 1.6; }
#warnBox { background: #fff6e5; border: 1px solid #f0c36d; border-radius: 6px; padding: 6px 8px; }
#warnList { margin: 0; padding-left: 16px; color: #8a5a00; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; min-width: 420px; }
dialog::backdrop { background: #0004; }
.size-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0; }
.size-grid label { display: flex; gap: 4px; align-items: center; }
#exportResult { margin: 10px 0; max-height: 300px; overflow: auto; }
#exportResult a { color: var(--sel); margin-right: 10px; }
#designList { padding-left: 0; list-style: none; max-height: 360px; overflow: auto; }
#designList li { padding: 6px; border-bottom: 1px solid #eee; cursor: pointer; }
#designList li:hover { background: #f5f5f5; }
#designList small { color: var(--sub); margin-left: 8px; }

/* SVG */
.outline { fill: none; stroke: #111; stroke-width: 2.2; vector-effect: non-scaling-stroke; }
.piece { stroke: #0006; stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; }
.piece:hover { filter: brightness(1.08); }
.seamline { fill: none; stroke: #0000; stroke-width: 14; vector-effect: non-scaling-stroke; cursor: pointer; }
.seamvis { fill: none; stroke: var(--seam); stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
.seamvis.sel { stroke: var(--sel); stroke-width: 3; }
.handle { fill: #fff; stroke: var(--seam); stroke-width: 2; vector-effect: non-scaling-stroke; cursor: grab; }
.handle.end { fill: var(--seam); }
.handle.sel { stroke: var(--sel); }
.plabel { font-weight: bold; fill: #fff; paint-order: stroke; stroke: #000a; stroke-width: 3px; vector-effect: non-scaling-stroke; pointer-events: none; text-anchor: middle; }
.slabel { font-weight: bold; fill: var(--seam); paint-order: stroke; stroke: #fff; stroke-width: 4px; vector-effect: non-scaling-stroke; pointer-events: none; text-anchor: middle; }
.ghost { fill: none; stroke: var(--sel); stroke-dasharray: 6 4; stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
.notch { stroke: #333; stroke-width: 1.5; vector-effect: non-scaling-stroke; pointer-events: none; }
.cl { stroke: #0003; stroke-dasharray: 4 4; stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }

/* 狭い画面: 図を上に大きく、左右のパネルはその下に並べる */
@media (max-width: 1100px) {
  header { flex-wrap: wrap; }
  header input { flex: 1; min-width: 160px; width: auto; }
  main { grid-template-columns: 1fr 1fr; grid-template-rows: 62vh auto; height: auto; }
  #center { grid-column: 1 / 3; grid-row: 1; border-bottom: 1px solid var(--line); }
  #left { grid-column: 1; grid-row: 2; border-right: 1px solid var(--line); }
  #right { grid-column: 2; grid-row: 2; border-left: none; }
  aside { overflow: visible; }
}
@media (max-width: 640px) {
  main { grid-template-columns: 1fr; }
  #center { grid-column: 1; }
  #left, #right { grid-column: 1; grid-row: auto; border: none; }
}

/* 公開版 */
.viewbar { display: flex; gap: 6px; align-items: center; padding: 6px 10px 0; }
.viewbar button { padding: 4px 10px; font-size: 12px; }
.viewbar .logo-opt { font-size: 12px; display: flex; gap: 4px; align-items: center; }
.viewbar .logo-opt select { padding: 2px 4px; font-size: 12px; }
#photoView { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px; min-height: 0; }
#photoView canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
#imageView { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; min-height: 0; }
#imageView svg { width: 100%; height: 100%; }
.garment .vtitle { font-size: 40px; font-weight: bold; text-anchor: middle; fill: #333; }
#designList li { display: flex; align-items: center; gap: 8px; }
#designList li small { flex: 1; }
#designList li .del { padding: 2px 8px; font-size: 11px; color: #a33; }
.site-foot { text-align: center; color: var(--sub); font-size: 11px; padding: 6px; background: var(--panel); border-top: 1px solid var(--line); }
