/* チラシメーカー：デジタル庁デザインシステム準拠（業務の道具）。主色は緑（--g800）。書体は Noto Sans JP。 */
@font-face { font-family: 'Noto Sans JP'; src: url('../fonts/NotoSansJP-VF.ttf') format('truetype'); font-weight: 100 900; font-display: block; }
@font-face { font-family: 'Zen Kaku Gothic New'; src: url('../fonts/ZenKakuGothicNew-Bold.ttf') format('truetype'); font-weight: 700; font-display: block; }
@font-face { font-family: 'Zen Kaku Gothic New'; src: url('../fonts/ZenKakuGothicNew-Black.ttf') format('truetype'); font-weight: 900; font-display: block; }
@font-face { font-family: 'Dela Gothic One'; src: url('../fonts/DelaGothicOne-Regular.ttf') format('truetype'); font-weight: 400; font-display: block; }

:root {
  --g50: #e6f5ec; --g100: #c2e5d1; --g700: #1d8b56; --g800: #197a4b; --g900: #115a36; --g1000: #0c472a;
  --k0: #fff; --k50: #f2f2f2; --k100: #e6e6e6; --k200: #ccc; --k536: #767676; --k700: #4d4d4d; --k900: #1a1a1a;
  --focus: #ffd43d; --err: #ec0000; --r: 6px; --h: 36px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { font: 400 14px/1.5 'Noto Sans JP', system-ui, sans-serif; color: var(--k900); background: var(--k50); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; box-shadow: 0 0 0 1px var(--k900); }
.ic { display: block; flex: none; }

.app { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; height: 100dvh; min-width: 0; }
/* 上の帯：用紙・表示・保存 */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 10px; background: var(--k0); border-bottom: 1px solid var(--k200); min-width: 0; }
.bar .grp { display: flex; align-items: center; gap: 4px; min-width: 0; }
.bar .sep { width: 1px; height: 24px; background: var(--k200); margin: 0 2px; }
.bar .gap { flex: 1 1 0; min-width: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: var(--h); height: var(--h); padding: 0 8px; border: 1px solid transparent; border-radius: var(--r); background: transparent; color: var(--k900); }
.btn:hover { background: var(--k100); }
.btn[aria-pressed="true"], .btn.on { background: var(--g800); color: #fff; }
.btn[aria-pressed="true"]:hover, .btn.on:hover { background: var(--g900); }
.btn:disabled { color: var(--k536); cursor: default; background: transparent; }
.btn.line { border-color: var(--k536); background: var(--k0); }
.btn.line:hover { background: var(--k100); }
.btn.pri { background: var(--g800); color: #fff; }
.btn.pri:hover { background: var(--g900); }
.btn.pri:disabled { background: var(--k200); color: var(--k536); }
.btn span { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* 入力欄は 1 つの部品（.fld）に統一：名前＋入力＋単位。数値は上下のレバー */
.fld { display: flex; align-items: center; gap: 6px; height: var(--h); min-width: 0; padding: 0 6px 0 8px; border: 1px solid var(--k536); border-radius: var(--r); background: var(--k0); }
.fld:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; box-shadow: 0 0 0 1px var(--k900); }
.fld > span { flex: none; font-size: 12px; color: var(--k700); white-space: nowrap; }
.fld > i { flex: none; font-style: normal; font-size: 12px; color: var(--k700); }
.fld input, .fld select, .fld textarea { flex: 1 1 0; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; height: 100%; padding: 0; text-align: right; font-variant-numeric: tabular-nums; appearance: none; -moz-appearance: textfield; }
.fld input::-webkit-outer-spin-button, .fld input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fld select { text-align: left; text-align-last: left; cursor: pointer; }
.fld input[type="text"].l, .fld input.l { text-align: left; }
.fld.area { height: auto; align-items: flex-start; padding: 6px 8px; }
.fld.area > span { padding-top: 2px; }
.fld.area textarea { height: 72px; resize: none; text-align: left; line-height: 1.4; }
.lv { display: flex; flex-direction: column; flex: none; width: 18px; height: 28px; }
.lv button { flex: 1 1 0; display: flex; align-items: center; justify-content: center; border: 0; background: transparent; padding: 0; color: var(--k700); border-radius: 3px; }
.lv button:hover { background: var(--k100); color: var(--k900); }
.lv .ic { width: 14px; height: 14px; }
.fld.sw { padding-right: 4px; }
.fld.on { background: var(--g50); border-color: var(--g800); }

/* 3 列：左（パネル）・中（紙面）・右（値） */
.main { display: grid; grid-template-columns: 276px minmax(0, 1fr) 292px; min-height: 0; min-width: 0; }
.side { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--k0); }
.side.left { border-right: 1px solid var(--k200); }
.side.right { border-left: 1px solid var(--k200); }
.tabs { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--k200); flex: none; }
.tabs button { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0; height: 48px; padding: 4px 0 2px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--k700); border-radius: var(--r) var(--r) 0 0; font-size: 12px; line-height: 1.2; }
.tabs button:hover { background: var(--k50); }
.tabs button[aria-selected="true"] { color: var(--g800); border-bottom-color: var(--g800); font-weight: 700; }
.tabs button span { max-width: 100%; overflow: hidden; text-overflow: clip; white-space: nowrap; }
.tabs button[data-tab="insp"] { display: none; }
.head { flex: none; display: flex; align-items: center; gap: 6px; min-height: 49px; padding: 6px 10px; border-bottom: 1px solid var(--k200); font-weight: 700; min-width: 0; }
.head .t { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.body { flex: 1 1 0; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.sec { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sec > h3 { margin: 0; font-size: 12px; font-weight: 700; color: var(--k700); display: flex; align-items: center; gap: 6px; }
.sec > h3 .n { margin-left: auto; font-weight: 400; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; min-width: 0; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; min-width: 0; }
.row4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; min-width: 0; }
.seg { display: flex; border: 1px solid var(--k536); border-radius: var(--r); overflow: hidden; min-width: 0; }
.seg button { flex: 1 1 0; min-width: 0; height: calc(var(--h) - 2px); border: 0; border-left: 1px solid var(--k200); background: var(--k0); padding: 0 4px; white-space: nowrap; overflow: hidden; }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--k100); }
.seg button[aria-pressed="true"] { background: var(--g800); color: #fff; font-weight: 700; }

/* 型（テンプレ）の一覧：絵＋名前 */
.tpls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tpl { display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 6px; border: 1px solid var(--k200); border-radius: var(--r); background: var(--k0); text-align: center; min-width: 0; }
.tpl:hover { background: var(--k50); }
.tpl[aria-pressed="true"] { border: 2px solid var(--g800); padding: 5px; background: var(--g50); }
.tpl .th { height: 84px; display: flex; align-items: center; justify-content: center; background: var(--k100); border-radius: 3px; overflow: hidden; }
.tpl .th svg { max-width: 100%; max-height: 100%; display: block; }
.tpl .nm { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 層・木の行 */
.lrow { display: flex; align-items: center; gap: 2px; min-height: 44px; padding: 2px 4px 2px 8px; border: 1px solid var(--k200); border-radius: var(--r); min-width: 0; }
.lrow .nm { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .n { flex: none; min-width: 2.2em; text-align: right; color: var(--k700); font-variant-numeric: tabular-nums; }
.lrow.off .nm { color: var(--k536); }
.trow { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 32px; padding: 2px 6px; border: 0; border-radius: 4px; background: transparent; text-align: left; min-width: 0; }
.trow:hover { background: var(--k50); }
.trow.sel { background: var(--g100); font-weight: 700; }
.trow .nm { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .n { flex: none; color: var(--k700); font-variant-numeric: tabular-nums; font-size: 12px; }
.trow.lk { color: var(--k536); }

.kv { display: flex; align-items: baseline; gap: 6px; font-size: 13px; min-width: 0; }
.kv b { font-variant-numeric: tabular-nums; }
.kv .k { color: var(--k700); font-size: 12px; }
.msg { padding: 6px 8px; border-radius: var(--r); background: var(--k50); font-size: 13px; overflow-wrap: anywhere; }
.msg.err { background: #fde8e8; color: #7c0000; }
.list { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.list li { padding: 4px 8px; border-radius: 4px; background: var(--k50); font-size: 13px; overflow-wrap: anywhere; }
.swatch { flex: none; width: 22px; height: 22px; border: 1px solid var(--k536); border-radius: 4px; }

/* 中央：紙面 */
.stage { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; min-width: 0; background: var(--k200); }
.canvas { min-height: 0; min-width: 0; overflow: auto; display: flex; padding: 14px; }
.canvas > .wrap { margin: auto; flex: none; }
.canvas svg.paper { display: block; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .35); }
.canvas svg.paper [data-node] { cursor: pointer; }
.canvas svg.paper [data-locked="1"] [data-node] { cursor: default; }
.status { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 12px; background: var(--k0); border-top: 1px solid var(--k200); font-size: 12px; color: var(--k700); min-width: 0; }
.status b { color: var(--k900); font-variant-numeric: tabular-nums; font-weight: 700; }
.status .bad b { color: #a80000; }

/* PDF 書き出しの欄：紙面（.stage）の右上に重ねる。ほかの欄の位置は動かさない */
.pop { position: absolute; z-index: 6; top: 8px; right: 8px; width: 320px; max-width: calc(100% - 16px); max-height: calc(100% - 52px); display: flex; flex-direction: column; min-height: 0; background: var(--k0); border: 1px solid var(--k536); border-radius: var(--r); box-shadow: 0 4px 18px rgba(0, 0, 0, .28); }
.pop[hidden] { display: none; }
.pop > .body { flex: 0 1 auto; min-height: 0; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.acts .btn { flex: 1 1 auto; }
.chks { display: flex; flex-direction: column; gap: 4px; }
.chk { display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 2px 8px; border: 1px solid var(--k200); border-radius: var(--r); font-size: 13px; }
.chk .nm { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chk .n { flex: none; font-variant-numeric: tabular-nums; font-weight: 700; }
.chk.bad { background: #fde8e8; border-color: #a80000; color: #7c0000; }
.chk.warn { background: #fff4d6; border-color: #8a5a00; color: #5c3b00; }   /* 警告：数えて見せるだけ。書き出しは止めない */

/* 狭い画面：紙面の下にパネルを置く（ページ全体はスクロールさせない） */
@media (max-width: 900px) {
  .main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 46%); }
  .side.left { grid-row: 2; border-right: 0; border-top: 1px solid var(--k200); }
  .side.right { display: none; }
  .stage { grid-row: 1; }
  .tabs button[data-tab="insp"] { display: flex; }
  .tabs button { height: 44px; }
  .tpls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tpl .th { height: 56px; }
  .canvas { padding: 8px; }
}
@media (max-width: 520px) {
  .tpls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar { padding: 4px 6px; gap: 4px 4px; }
  .bar .sep { display: none; }
  .btn { min-width: 34px; }
  .main { grid-template-rows: minmax(0, 1fr) minmax(0, 50%); }
}

/* 層の編集（文字スタイルの装飾・図形）：1 層 = 1 枚。上が重なりの上。開いたままで、ほかの位置を動かさない */
.lys { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ly { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 6px; border: 1px solid var(--k200); border-radius: var(--r); }
.ly.off { background: var(--k50); }
.ly.off .swatch { opacity: .45; }
.ly .lh { display: flex; align-items: center; gap: 2px; min-width: 0; }
.ly .lh .ti { flex: none; display: flex; align-items: center; justify-content: center; width: 28px; color: var(--g800); }
.ly .lh .nm { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 13px; }
.ly .lh .swatch { margin: 0 4px; }
.ly .lh .btn { min-width: 30px; height: 32px; padding: 0 3px; }
