:root {
  --bg: #1f2329; --panel: #2a2f37; --panel2: #323844; --line: #3d4451; --text: #e6e9ef; --muted: #9aa3b2;
  --accent: #4da3ff; --accent2: #2f6fb3; --on: #3fb37f; --warn: #e0a040;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo UI", "Segoe UI", Meiryo, sans-serif;
  --swl: 270px; --swr: 0px; --clwx: 0px; --clw: 380px;
  display: grid; grid-template-columns: var(--swl) minmax(0, 1fr) var(--swr) var(--clwx); grid-template-rows: 34px auto 1fr auto 26px;
  grid-template-areas: "top top top top" "ribbon ribbon ribbon ribbon" "sidel view sider claude" "cmd cmd cmd claude" "status status status status";
  user-select: none;
}
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 4px 9px; cursor: pointer; }
button:hover { background: #3b4352; }
button:active { background: var(--accent2); }
input, select, textarea { font: inherit; color: var(--text); background: #1a1d22; border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

#top { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 8px 0 0; background: #181b20; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .05em; color: var(--accent); }
.tb { display: flex; gap: 4px; }
.filename { margin-left: auto; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }

#tools { grid-area: tools; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; align-content: start; }
#tools .grp { grid-column: 1 / -1; color: var(--muted); font-size: 11px; margin: 6px 2px 1px; }
#tools button { display: flex; flex-direction: column; align-items: center; padding: 4px 2px; line-height: 1.15; }
#tools button b { font-weight: 500; font-size: 11.5px; white-space: nowrap; }
#tools button i { font-style: normal; color: var(--muted); font-size: 10px; }
#tools button.active { background: var(--accent2); border-color: var(--accent); }

#view { grid-area: view; position: relative; overflow: hidden; }
#view canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#over { cursor: none; }
#tip { position: absolute; pointer-events: none; background: rgba(20,24,30,.92); border: 1px solid var(--line); color: #ffd36a; font-size: 11px; padding: 1px 5px; border-radius: 3px; display: none; white-space: nowrap; }
#view.drop::after { content: "ここにDXF/DWGファイルをドロップ"; position: absolute; inset: 10px; border: 2px dashed var(--accent); display: grid; place-items: center; font-size: 18px; background: rgba(30,60,100,.25); pointer-events: none; }

#side, #side2 { background: var(--panel); overflow-y: auto; min-width: 0; display: flex; flex-direction: column; }
#side > section, #side2 > section { flex: 0 0 auto; }
#side { grid-area: sidel; border-right: 1px solid var(--line); }
#side2 { grid-area: sider; border-left: 1px solid var(--line); }
#side.empty, #side2.empty { display: none; }
#side section, #side2 section { border-bottom: 1px solid var(--line); padding: 8px; }
#side h3, #side2 h3 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.mini { padding: 1px 6px; font-size: 11px; }
/* 画層の欄 (laypanel.js) */
#layers { overflow-y: auto; outline: none; min-height: 60px; padding-right: 8px; scroll-padding-top: 22px; }
.laysec { display: flex; flex-direction: column; min-height: 0; }
#side > .laysec.fill, #side2 > .laysec.fill { flex: 1 1 260px; min-height: 180px; }
.laysec.fill #layers { flex: 1 1 0; }
.laysec h3 .laycur { flex: 1; margin-left: 8px; color: var(--fg, #ddd); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.laytools { display: flex; gap: 3px; margin-bottom: 4px; align-items: center; }
.laytools .mini { min-width: 22px; padding: 1px 4px; }
.laytools .layq { flex: 1; min-width: 40px; font-size: 11px; padding: 1px 4px; }
.lay { display: grid; grid-template-columns: 16px minmax(0, 1fr) 18px 18px 18px 16px 18px; gap: 3px; align-items: center; padding: 1px 3px; border-radius: 3px; cursor: default; user-select: none; }
.laysec.wide .lay { grid-template-columns: 16px minmax(90px, 1fr) 18px 18px 18px 16px 70px 46px 18px; min-width: 330px; }
.laysec.wide #layers { overflow-x: auto; }
.layhd { color: var(--muted); font-size: 10px; border-bottom: 1px solid var(--line); padding-bottom: 2px; margin-bottom: 2px; position: sticky; top: 0; z-index: 1; background: var(--panel); border-radius: 0; }
.layhd span { overflow: hidden; white-space: nowrap; text-align: center; }
.layhd span:nth-child(2) { text-align: left; }
.lay .st { text-align: center; color: #6fdc6f; font-weight: 700; cursor: pointer; align-self: stretch; min-height: 16px; line-height: 16px; }
.lay .st:hover { background: var(--panel2); }
.lay.cur .nm { font-weight: 700; }
.lay.noplot .nm { opacity: .75; }
.lay .nm.xr { font-style: italic; }
.lay .nmi { font-size: 12px; padding: 0 3px; min-width: 0; }
.lay .lt, .lay .lw { font-size: 10.5px; padding: 0 1px; min-width: 0; }
.lay .eye, .lay .frz, .lay .lck, .lay .plt { text-align: center; color: var(--muted); font-size: 12px; cursor: pointer; }
.lay .plt.off { opacity: 1; }
.lay .sw { cursor: pointer; }
.layrsz { height: 7px; margin: 3px -8px -8px; cursor: ns-resize; border-top: 1px solid var(--line); background: linear-gradient(var(--line), var(--line)) center / 28px 2px no-repeat; }
.layrsz:hover { background-color: var(--accent2); }
.ctxmenu .msep { height: 1px; background: #4a5260; margin: 3px 4px; }
/* 選択の循環 (重なった図形の一覧) */
.cycpop { z-index: 40; min-width: 240px; }
.cycpop .cyhd { color: #9aa3ad; font-size: 11px; padding: 2px 8px 4px; }
.cycpop .mi .sw { display: inline-block; width: 10px; height: 10px; border: 1px solid #000; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.cycpop .mi .nm { color: #9aa3ad; font-size: 11px; }
.cycpop .mi.on { background: #2f5b8a; }
/* 画層の結合 */
.mrgdlg { display: flex; flex-direction: column; gap: 6px; min-width: 380px; }
.mrglist { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; padding: 3px; }
.mrgrow { display: grid; grid-template-columns: 18px 18px 1fr auto; gap: 6px; align-items: center; padding: 1px 4px; font-size: 12px; }
.mrgrow .sw { width: 14px; height: 12px; border: 1px solid #000; border-radius: 2px; }
.mrgrow i { color: var(--muted); font-style: normal; font-size: 11px; }
.mrgrow[hidden] { display: none; }
/* 候補つき入力欄の一覧 (combo.js) */
.combopop { position: fixed; z-index: 1000; background: #2b3039; border: 1px solid #4a5260; border-radius: 5px; box-shadow: 0 8px 24px rgba(0,0,0,.45); overflow-y: auto; font-size: 12px; padding: 2px; }
.combopop .ci { display: flex; justify-content: space-between; gap: 14px; padding: 2px 8px; border-radius: 3px; cursor: pointer; white-space: nowrap; color: #e6e6e6; }
.combopop .ci i { font-style: normal; color: #9aa3ad; font-size: 11px; }
.combopop .ci:hover, .combopop .ci.hi { background: #2f5b8a; }
.combopop .ci.cur { font-weight: 700; }
.lay:hover { background: var(--panel2); }
.lay.cur { background: rgba(36, 71, 110, .45); }
.lay.sel, .lay.sel:hover { background: #2f5b8a; }
.layhd:hover { background: none; }
.lay .eye, .lay .frz, .lay .lck, .lay .del { text-align: center; color: var(--muted); font-size: 12px; }
.lay .frz.off, .lay .lck.off { opacity: .45; }
.lay .eye.off { opacity: .35; }
.lay .sw { width: 14px; height: 12px; border-radius: 2px; border: 1px solid #000; }
.lay .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lay .del { visibility: hidden; }
.lay:hover .del { visibility: visible; }
.prow { display: grid; grid-template-columns: 70px 1fr; gap: 6px; align-items: center; margin-bottom: 5px; }
.prow label { color: var(--muted); font-size: 12px; }
.prow input, .prow select, .prow textarea { width: 100%; }
.pinfo { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.swatch-sel { display: flex; gap: 4px; align-items: center; }
.swatch-sel .sw { width: 18px; height: 18px; border-radius: 3px; border: 1px solid #000; flex: none; }

#cmdarea { grid-area: cmd; background: #16191d; border-top: 1px solid var(--line); }
#hist { height: var(--histh, 66px); overflow-y: auto; padding: 3px 8px; color: var(--muted); font: 12px/1.4 Menlo, Consolas, "Hiragino Sans", "Yu Gothic UI", "MS Gothic", monospace; user-select: text; white-space: pre-wrap; }
.cmdline { display: flex; align-items: center; gap: 6px; padding: 3px 8px 5px; }
#prompt { color: #ffd36a; white-space: nowrap; font: 13px Menlo, Consolas, "Hiragino Sans", "Yu Gothic UI", "MS Gothic", monospace; }
#cmdin { flex: 1; background: transparent; border: none; outline: none; font: 13px Menlo, "Hiragino Sans", monospace; color: #fff; }

#status { grid-area: status; display: flex; align-items: center; gap: 6px; padding: 0 8px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; }
#coords { min-width: 210px; font-family: Menlo, Consolas, "MS Gothic", monospace; color: var(--muted); }
.tog { padding: 1px 8px; font-size: 12px; opacity: .6; }
.tog.on { opacity: 1; background: #2a5b45; border-color: var(--on); }
.sp { flex: 1; }
#dwgState { color: var(--muted); }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 10; }
#modal[hidden] { display: none; }
.dlg { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; min-width: 380px; max-width: 560px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.dlg h2 { margin: 0 0 10px; font-size: 15px; }
.dlg .body { margin-bottom: 14px; white-space: pre-wrap; user-select: text; }
.dlg .body label { display: block; padding: 4px 0; }
.dlg .body label.dis { opacity: .45; }
.dlg .btns { display: flex; justify-content: flex-end; gap: 8px; }
.dlg .btns .primary { background: var(--accent2); border-color: var(--accent); }
.dlg textarea { width: 100%; min-height: 90px; }
.note { color: var(--muted); font-size: 12px; }

#busy { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 20; }
#busy[hidden] { display: none; }
.spin { width: 34px; height: 34px; border: 3px solid #555; border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

#tabs { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; display: flex; gap: 2px; padding: 2px 6px 0; background: rgba(30,34,40,.92); border-top: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 1px 12px; font-size: 12px; border-radius: 5px 5px 0 0; border-bottom: none; background: var(--panel); white-space: nowrap; }
.tab.cur { background: var(--accent2); border-color: var(--accent); }
.tab.plus { padding: 1px 9px; }
.refrow { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.refrow b { font-weight: 500; font-size: 12px; }
.refrow .note { font-size: 11px; word-break: break-all; }
.brand .sub { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 4px; }

body.noside #side, body.noside #side2 { display: none; }
#appbtn { height: 34px; width: 48px; border-radius: 0; border: none; background: #b8262f; color: #fff; font-weight: 800; letter-spacing: .04em; }
#appbtn:hover { background: #d0333d; }
.qat { display: flex; gap: 2px; align-items: center; }
.qat button { padding: 2px 8px; font-size: 12px; background: transparent; border-color: transparent; }
.qat button:hover { background: var(--panel2); border-color: var(--line); }
.vsep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
#top .brand { margin-left: 8px; color: #e8555e; font-weight: 800; letter-spacing: .08em; }
#top .filename { margin-left: auto; }
#ribbon { grid-area: ribbon; background: var(--panel); border-bottom: 1px solid var(--line); }
#rtabs { display: flex; gap: 2px; padding: 3px 8px 0; background: #22262d; }
.rtab { border-radius: 5px 5px 0 0; border: 1px solid transparent; border-bottom: none; background: transparent; padding: 3px 14px; font-size: 12px; color: var(--muted); }
.rtab.cur { background: var(--panel); color: var(--text); border-color: var(--line); }
#rbody { display: flex; gap: 0; padding: 4px 4px 0; height: 92px; overflow-x: auto; overflow-y: hidden; }
.rgrp { display: flex; flex-direction: column; border-right: 1px solid var(--line); padding: 0 6px; flex: none; }
.ritems { display: flex; gap: 2px; flex: 1; align-items: flex-start; }
.rtitle { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0 3px; white-space: nowrap; }
.rbig { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; width: 66px; height: 68px; padding: 5px 2px; background: transparent; border-color: transparent; font-size: 11.5px; line-height: 1.15; }
.rbig .ic { width: 30px; height: 30px; }
.rcol { display: flex; flex-direction: column; gap: 1px; }
.rsmall { display: flex; align-items: center; gap: 4px; height: 22px; padding: 1px 5px 1px 3px; background: transparent; border-color: transparent; font-size: 12px; white-space: nowrap; min-width: 74px; }
.rsmall .ic { width: 17px; height: 17px; flex: none; }
.rbig:hover, .rsmall:hover { background: var(--panel2); border-color: var(--line); }
.rbig.active, .rsmall.active { background: var(--accent2); border-color: var(--accent); }
.ic { color: #cfe3ff; }
#dyn { position: absolute; pointer-events: none; display: none; font: 12px Menlo, "Hiragino Sans", monospace; z-index: 3; }
#dyn .dp { background: rgba(32,36,44,.95); border: 1px solid #56606e; color: #e6e9ef; padding: 2px 6px; border-radius: 3px; display: inline-block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dyn .dv { display: flex; gap: 3px; margin-top: 2px; }
#dyn .dv span { background: #fff; color: #000; border: 1px solid #3c7bd9; padding: 0 5px; border-radius: 2px; }
#dyn .di { background: #fff; color: #000; border: 1px solid #3c7bd9; padding: 1px 6px; margin-top: 2px; display: inline-block; min-width: 40px; }
.ctxmenu { position: fixed; z-index: 30; min-width: 220px; background: #2b3039; border: 1px solid #4a5260; border-radius: 6px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.45); font-size: 13px; }
.ctxmenu .mi { display: flex; justify-content: space-between; gap: 18px; padding: 4px 10px; border-radius: 4px; cursor: pointer; }
.ctxmenu .mi:hover { background: var(--accent2); }
.ctxmenu .mi i { font-style: normal; color: var(--muted); font-size: 11px; }
.ctxmenu .mi.dis { opacity: .4; cursor: default; }
.ctxmenu .mi.dis:hover { background: transparent; }
.ctxmenu .sep { height: 1px; background: #4a5260; margin: 3px 4px; }
#cmdarea { position: relative; }
#suggest { position: absolute; left: 70px; bottom: 34px; min-width: 320px; background: #2b3039; border: 1px solid #4a5260; border-radius: 5px; padding: 3px; z-index: 5; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
#suggest .sg { display: grid; grid-template-columns: 120px 90px 1fr; gap: 6px; padding: 2px 8px; border-radius: 3px; cursor: pointer; font-size: 12px; }
#suggest .sg b { font-weight: 600; font-family: Menlo, Consolas, "MS Gothic", monospace; }
#suggest .sg span { color: var(--muted); font-family: Menlo, Consolas, "MS Gothic", monospace; }
#suggest .sg.cur, #suggest .sg:hover { background: var(--accent2); }
.dlg.wide { max-width: 96vw; min-width: 900px; }
.laymgr .lmtools { display: flex; gap: 6px; margin-bottom: 8px; }
.laymgr .lmtools input { flex: 1; }
.lmtable { border-collapse: collapse; width: 100%; font-size: 12px; }
.lmtable th { text-align: left; color: var(--muted); font-weight: 500; padding: 3px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
.lmtable td { padding: 2px 4px; border-bottom: 1px solid #333943; white-space: nowrap; }
.lmtable tr.sel td { background: #24476e; }
.lmtable input, .lmtable select { font-size: 12px; padding: 1px 4px; }
.laymgr { max-height: 70vh; overflow: auto; }
.ib { background: transparent; border: none; padding: 0 4px; font-size: 14px; min-width: 24px; }
.ib.off { opacity: .45; }
.swb { display: flex; align-items: center; gap: 4px; padding: 1px 6px; font-size: 12px; }
.sw { display: inline-block; width: 14px; height: 12px; border: 1px solid #000; border-radius: 2px; vertical-align: middle; }
.lcombo, .pcombo { display: flex; flex-direction: column; gap: 3px; }
.lcbtn { display: flex; align-items: center; gap: 6px; width: 190px; height: 24px; padding: 1px 6px; font-size: 12px; text-align: left; background: #1a1d22; }
.lcbtn .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lcbtn .dd { color: var(--muted); }
.lcbtn .ic3 { letter-spacing: -1px; font-size: 11px; }
.pcsel { width: 172px; height: 23px; font-size: 12px; }
.rcol.wide { justify-content: flex-start; padding-top: 2px; }
.lbtns { display: flex; flex-wrap: wrap; gap: 1px; width: 206px; margin-top: 3px; }
.rtiny { width: 22px; height: 22px; padding: 1px; background: transparent; border-color: transparent; }
.rtiny .ic { width: 17px; height: 17px; }
.rtiny:hover { background: var(--panel2); border-color: var(--line); }
.laylist { max-height: 60vh; overflow-y: auto; min-width: 280px; }
.laylist .lrow { display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 4px; cursor: pointer; }
.laylist .lrow:hover { background: var(--accent2); }
.laylist .lrow.cur { background: #24476e; }
.laylist .li { font-size: 13px; width: 18px; text-align: center; }
.laylist .li.off { opacity: .45; }
.laylist .nm { flex: 1; }
#quad { position: absolute; z-index: 4; background: rgba(36,40,48,.97); border: 1px solid #56606e; border-radius: 8px; padding: 6px; box-shadow: 0 8px 20px rgba(0,0,0,.45); width: 220px; }
#quad .qh { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 4px; }
#quad .qg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
#quad .qg button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 1px; font-size: 10px; background: transparent; border-color: transparent; }
#quad .qg button:hover { background: var(--accent2); }
#quad .qg .ic { width: 18px; height: 18px; }
.purge { max-height: 60vh; overflow: auto; min-width: 360px; }
.purge .pgh { font-weight: 600; margin: 8px 0 2px; color: var(--muted); }

.pphead { display: flex; gap: 6px; margin-bottom: 6px; }
.ppfilter { flex: 1; }
.ppcat { margin-bottom: 4px; }
.pph { background: #343a45; padding: 3px 6px; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 3px; user-select: none; }
.pptable { width: 100%; border-collapse: collapse; table-layout: fixed; }
.pptable th { width: 44%; text-align: left; font-weight: 400; color: var(--muted); font-size: 12px; padding: 2px 6px; border-bottom: 1px solid #333943; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pptable td { padding: 1px 2px; border-bottom: 1px solid #333943; font-size: 12px; overflow: hidden; }
.pptable td input, .pptable td select, .pptable td textarea { width: 100%; font-size: 12px; padding: 1px 4px; background: transparent; border-color: transparent; }
.pptable td input:hover, .pptable td select:hover, .pptable td textarea:hover { border-color: var(--line); }
.pptable td input:focus, .pptable td select:focus, .pptable td textarea:focus { background: #1a1d22; }
.pptable .swatch-sel button { padding: 1px 6px; font-size: 12px; }
.stdlg { display: grid; grid-template-columns: 170px 1fr; gap: 14px; min-height: 300px; }
.stlist { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); padding-right: 8px; max-height: 60vh; overflow-y: auto; }
.stlist button { margin-top: 6px; }
.stitem { padding: 3px 6px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.stitem:hover { background: var(--panel2); }
.stitem.sel { background: #24476e; }
.stform .prow { grid-template-columns: 150px 1fr; }
.stform .pgh { font-weight: 600; margin: 8px 0 3px; color: var(--muted); font-size: 12px; }
.stprev { border: 1px solid var(--line); border-radius: 4px; margin-top: 8px; }
.dlg.wide2 { min-width: 640px; max-width: min(96vw, 900px); }
.ltdlg { max-height: 64vh; overflow-y: auto; min-width: 560px; }
.ltprev { vertical-align: middle; }
.coldlg { min-width: 560px; }
.ctabs { display: flex; gap: 4px; margin-bottom: 8px; }
.ctabs button.cur { background: var(--accent2); border-color: var(--accent); }
.cgrid { display: grid; grid-template-columns: repeat(24, 18px); gap: 1px; margin: 4px 0 8px; }
.cc { width: 18px; height: 18px; padding: 0; border: 1px solid #111; border-radius: 1px; }
.cc.big { width: 24px; height: 24px; }
.cc:hover { outline: 2px solid #fff; }
.crow { display: flex; gap: 3px; align-items: center; margin: 3px 0 8px; flex-wrap: wrap; }
.cinfo { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.cbig { width: 44px; height: 24px; border: 1px solid #000; border-radius: 3px; background-image: linear-gradient(45deg,#666 25%,transparent 25%,transparent 75%,#666 75%),linear-gradient(45deg,#666 25%,transparent 25%,transparent 75%,#666 75%); background-size: 8px 8px; background-position: 0 0,4px 4px; }
.cpick { width: 80px; height: 40px; padding: 0; border: none; }
.jdlg .jgrid { display: grid; grid-template-columns: repeat(4, minmax(70px, max-content) minmax(52px, 72px)); gap: 4px 8px; align-items: center; margin: 8px 0; font-size: 12px; }
.jdlg .jgrid label { color: var(--muted); text-align: right; }
.jdlg .jgrid input { width: 100%; min-width: 0; box-sizing: border-box; }
.jdlg .jgrid label { padding: 0; white-space: nowrap; }
.jdlg select { max-width: 100%; }
.jdlg .prow { grid-template-columns: auto 1fr; }
.jtbl .jtwrap { max-height: 56vh; overflow: auto; margin: 6px 0; }
.jtbl .lmtable input { font-size: 12px; padding: 1px 3px; }
#navbar { position: absolute; right: 10px; bottom: 36px; display: flex; flex-direction: column; gap: 2px; background: rgba(36,40,48,.9); border: 1px solid var(--line); border-radius: 8px; padding: 3px; z-index: 3; }
#navbar button { width: 32px; height: 30px; padding: 3px; background: transparent; border-color: transparent; }
#navbar button:hover { background: var(--accent2); }
#navbar .ic { width: 20px; height: 20px; }
#offscreen { position: absolute; z-index: 4; display: flex; align-items: center; gap: 6px; background: #f0b429; color: #1b1e23; border: none; border-radius: 18px; padding: 4px 12px 4px 8px; font-size: 12px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.45); text-align: left; line-height: 1.2; }
#offscreen:hover { background: #ffc94a; }
#offscreen .arw { display: inline-block; font-size: 18px; }
#offscreen small { font-weight: 400; }

.jdlg .jadjh { font-size: 12px; color: var(--muted); margin-top: 8px; }
.jdlg .jadj { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0; font-size: 12px; }
.jdlg .jag { display: inline-flex; align-items: center; gap: 4px; }
.jdlg .jag button.mini { min-width: 26px; font-size: 13px; }
.jdlg .jsum { white-space: pre-line; font-size: 12px; padding: 6px 8px; border: 1px solid var(--line, #444); border-radius: 4px; margin: 4px 0; }
.jdlg .jsum.chg { border-color: #ffb35c; color: #ffb35c; }
.stysec { margin: 8px 0; font-size: 12px; }
.stysec summary { cursor: pointer; color: var(--muted); }
.stygrid { display: grid; grid-template-columns: 110px 150px 140px 18px auto; gap: 4px 8px; align-items: center; margin-top: 6px; }
.stygrid label { color: var(--muted); text-align: right; }
.stygrid input { width: 150px; }
.stysw { width: 16px; height: 16px; border-radius: 3px; border: 1px solid #666; display: inline-block; }
.stynote { color: var(--muted); font-size: 11px; margin-left: 6px; }
.wrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; font-size: 12px; }
.wrow input { width: 64px; }
.wrow select { width: auto; }

/* ---- 画層・プロパティ欄を左に / Claude のチャット欄 (右端) */
#claude { grid-area: claude; display: none; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
body.claude-open #claude { display: flex; }
#clbtn { padding: 2px 10px; background: #2c3b52; border-color: #3d5a80; }
#clbtn:hover { background: #36507a; }
.clhead { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.clhead .sp, .clbtns .sp { flex: 1; }
.clstat { color: var(--muted); font-size: 11px; }
.clmsgs { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; user-select: text; }
.clm { padding: 6px 9px; border-radius: 8px; font-size: 12.5px; line-height: 1.55; word-break: break-word; }
.clm.user { align-self: flex-end; background: #2f4a6e; max-width: 88%; white-space: pre-wrap; }
.clm.assistant { background: var(--panel2); }
.clm.assistant pre { background: #16191d; padding: 6px; border-radius: 4px; overflow-x: auto; white-space: pre; font-size: 11.5px; }
.clm.assistant code { background: #16191d; padding: 0 3px; border-radius: 3px; font-size: 11.5px; }
.clm.tool { color: var(--muted); font-size: 11.5px; padding: 1px 9px; }
.clm.note { color: var(--muted); font-size: 11.5px; text-align: center; }
.clm.meta { color: var(--muted); font-size: 10.5px; text-align: right; padding: 0 9px; }
.clm.error { color: #ffb35c; font-size: 12px; background: #3a2c1c; }
#claude.busy .clmsgs::after { content: '考え中…'; color: var(--muted); font-size: 11.5px; padding: 2px 9px; }
.clin { border-top: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.clin textarea { width: 100%; height: 84px; resize: vertical; user-select: text; }
.clbtns { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.cledit { display: flex; align-items: center; gap: 4px; }

/* ---- 設定 */
.setdlg { display: grid; grid-template-columns: 150px 1fr; gap: 12px; min-height: 380px; }
.setnav { display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--line); padding-right: 10px; }
.setnav button { text-align: left; background: transparent; border-color: transparent; }
.setnav button.on { background: var(--accent2); }
.setbody { max-height: 62vh; overflow-y: auto; padding-right: 6px; }
.setbody h4 { margin: 4px 0 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.setrow { display: grid; grid-template-columns: 170px auto 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.setrow > label { color: var(--muted); text-align: right; }
.setrow select, .setrow input:not([type=checkbox]) { justify-self: start; }
.setnote { color: var(--muted); font-size: 11px; }
.setchk { display: block; margin: 4px 0 4px 20px; }
.setos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 8px; margin-left: 20px; }
.setalias { width: 100%; height: 180px; font-family: Menlo, Consolas, "MS Gothic", monospace; user-select: text; }
.setaliaslist { white-space: pre-wrap; font-size: 11px; color: var(--muted); max-height: 200px; overflow-y: auto; user-select: text; }
.panel-off { display: none !important; }

/* ---- Claude を左右の欄の中に置いたとき: 上の欄は必要な高さ (長ければその中でスクロール)、残りをチャット欄に */
#side.with-claude, #side2.with-claude { display: flex; flex-direction: column; overflow: hidden; }
#side.with-claude > section, #side2.with-claude > section { flex: 0 1 auto; overflow-y: auto; min-height: 48px; max-height: 45%; }
.with-claude .clstat { display: none; }
.with-claude .clhead .mini { white-space: nowrap; }
#side.with-claude > #claude, #side2.with-claude > #claude { flex: 1 1 0; min-height: 260px; border-left: none; border-top: 1px solid var(--line); }

/* ---- ▼ 付きの選択ボタン (寸法の種類など) */
.rsplit { display: flex; align-items: stretch; }
.rsplit .rsmall { min-width: 62px; padding-right: 2px; }
.rsplit .rdrop { background: transparent; border-color: transparent; padding: 0 3px; font-size: 11px; color: var(--muted); height: 22px; }
.rsplit:hover .rsmall, .rsplit:hover .rdrop { border-color: var(--line); }
.rsplit .rdrop:hover { background: var(--panel2); color: var(--text); }
/* 設定 → 標準の画層 */
.setpage .lmtools { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.laystdwrap { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 4px; margin: 4px 0 8px; }
.laystd td .stysw { vertical-align: middle; }

/* ---- 印刷スタイル テーブル エディタ・管理 */
.psed { width: min(880px, 86vw); }
.pstabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.pstabs button { border-bottom: none; border-radius: 5px 5px 0 0; background: transparent; }
.pstabs button.on { background: var(--panel2); border-color: var(--line); }
.pspage { min-height: 430px; }
.psform { display: grid; grid-template-columns: 170px 1fr; gap: 12px; }
.pslist { height: 400px; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; background: #1a1d22; }
.psitem { display: flex; align-items: center; gap: 6px; padding: 2px 6px; cursor: pointer; font-size: 12px; }
.psitem:hover { background: var(--panel2); }
.psitem.on { background: var(--accent2); }
.psitem .sw, .pstable .sw { width: 12px; height: 12px; display: inline-block; border: 1px solid #555; border-radius: 2px; }
.psmark { margin-left: auto; color: #ffb35c; font-style: normal; font-size: 10px; }
.psprops .setrow { grid-template-columns: 120px auto 1fr; margin-bottom: 5px; }
.psprops select, .psprops input:not([type=color]) { min-width: 230px; }
.pshead { font-weight: 600; margin-bottom: 8px; }
.pstable { max-height: 420px; overflow: auto; }
.pstable table { font-size: 11px; white-space: nowrap; }
.pstable th { position: sticky; top: 0; background: var(--panel); cursor: pointer; }
.pstable tbody th { position: sticky; left: 0; top: auto; background: var(--panel); text-align: right; }
.pstable td.chg, .pstable th.chg { color: #ffb35c; }
.psman { min-width: 520px; }
/* ---- ダイアログが画面より大きいときは中身をスクロール (枠から出さない) */
.dlg { max-height: 94vh; display: flex; flex-direction: column; box-sizing: border-box; }
.dlg .body { overflow: auto; min-height: 0; }
.dlg .btns { flex: none; }

/* リボンが画面の幅に収まらないときの送りボタン */
#ribbon { position: relative; }
.rscroll { position: absolute; z-index: 5; width: 20px; padding: 0; border: 0; border-radius: 0; font-size: 18px; line-height: 1; color: var(--fg, #ddd); background: var(--panel2, #333); opacity: .92; cursor: pointer; }
.rscroll.l { left: 0; border-right: 1px solid var(--line, #555); }
.rscroll.r { right: 0; border-left: 1px solid var(--line, #555); }
.rscroll:hover { opacity: 1; filter: brightness(1.25); }
