* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 12px "Segoe UI", Tahoma, Arial, sans-serif; color: #111; background: #a9a9a9; user-select: none; }
#app { display: flex; flex-direction: column; height: 100vh; }

/* menu bar */
#menubar { display: flex; background: #f0f0f0; border-bottom: 5px solid #1d3f73; padding: 0 2px; height: 24px; flex: none; position: relative; z-index: 50; }
.menu-top { padding: 3px 8px; cursor: default; }
.menu-top:hover, .menu-top.open { background: #fbd96b; }
.menu-top u { text-decoration: underline; }
.menu-pop { position: fixed; background: #f8f8f4; border: 1px solid #8a8a8a; box-shadow: 3px 3px 6px rgba(0,0,0,.3); padding: 2px; min-width: 210px; z-index: 1000; }
.menu-item { display: flex; align-items: center; padding: 3px 22px 3px 26px; position: relative; white-space: nowrap; cursor: default; }
.menu-item .key { margin-left: auto; padding-left: 28px; color: #444; }
.menu-item.arrow::after { content: "\25B8"; position: absolute; right: 7px; }
.menu-item:hover:not(.disabled) { background: #fbd96b; }
.menu-item.disabled { color: #9a9a9a; }
.menu-item .chk { position: absolute; left: 7px; }
.menu-sep { height: 1px; background: #c8c8c8; margin: 3px 2px 3px 24px; }

/* toolbars */
#stdbar, #optbar { display: flex; align-items: center; gap: 4px; padding: 2px 6px; background: #e8e8e8; flex: none; min-height: 28px; border-bottom: 1px solid #c4c4c4; }
#optbar { background: #efefef; }
.tb-btn { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 2px; background: none; padding: 0; cursor: default; }
.tb-btn:hover:not(:disabled) { border-color: #8aa6d6; background: #fdf2c8; }
.tb-btn:disabled { opacity: .35; }
.tb-btn svg { width: 18px; height: 18px; }
.tb-sep { width: 1px; align-self: stretch; background: #bdbdbd; margin: 2px 3px; }
.spacer { flex: 1; }
.mode-switch { display: inline-flex; border: 1px solid #888; border-radius: 12px; overflow: hidden; }
.mode-switch button { border: 0; background: #f4f4f4; padding: 2px 16px; font: inherit; }
.mode-switch button.on { background: #f5c518; font-weight: 600; }
select, input[type=number], input[type=text] { font: inherit; height: 21px; border: 1px solid #8f8f8f; background: #fff; padding: 0 3px; }
input[type=number] { width: 52px; }
label.opt { display: inline-flex; align-items: center; gap: 3px; }
.optgroup { display: inline-flex; align-items: center; gap: 4px; }
.sw { width: 18px; height: 18px; border: 1px solid #555; padding: 0; cursor: pointer; }
.tgl { min-width: 22px; height: 22px; border: 1px solid #9a9a9a; background: #f6f6f6; font: inherit; padding: 0 4px; }
.tgl.on { background: #fbd96b; border-color: #8a6d00; }

/* main area */
#main { flex: 1; display: flex; min-height: 0; }
#toolbox { width: 34px; background: #e8e8e8; border-right: 1px solid #b0b0b0; display: flex; flex-direction: column; align-items: center; padding: 4px 0; gap: 2px; flex: none; position: relative; }
.tool { position: relative; width: 28px; height: 26px; display: flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 2px; }
.tool:hover { border-color: #8aa6d6; background: #fdf2c8; }
.tool.active { background: #fbd96b; border-color: #8a6d00; }
.tool svg { width: 18px; height: 18px; pointer-events: none; }
.tool .fly { position: absolute; right: -1px; bottom: -1px; width: 8px; height: 8px; font-size: 7px; line-height: 8px; text-align: center; color: #333; cursor: pointer; }
.flyout { position: fixed; background: #fff; border: 1px solid #777; box-shadow: 3px 3px 6px rgba(0,0,0,.3); padding: 2px; z-index: 900; }
.flyout .fi { display: flex; align-items: center; gap: 6px; padding: 3px 14px 3px 6px; white-space: nowrap; }
.flyout .fi:hover { background: #fbd96b; }
.flyout .fi svg { width: 16px; height: 16px; }
.fgbg { position: relative; width: 28px; height: 30px; margin-top: 8px; }
.fgbg .fg, .fgbg .bg { position: absolute; width: 16px; height: 16px; border: 1px solid #333; cursor: pointer; }
.fgbg .fg { left: 0; top: 0; z-index: 2; }
.fgbg .bg { left: 8px; top: 8px; }
.fgbg .swap { position: absolute; right: -4px; top: -4px; font-size: 10px; cursor: pointer; }

/* workspace + document windows */
#workspace { flex: 1; position: relative; background: #a9a9a9; overflow: hidden; min-width: 0; }
.docwin { position: absolute; background: #fff; border: 1px solid #6a86b3; box-shadow: 2px 2px 8px rgba(0,0,0,.35); display: flex; flex-direction: column; min-width: 160px; min-height: 80px; overflow: hidden; }
.docwin.max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; resize: none; }
.docwin.min { height: auto !important; min-height: 0; resize: none; }
.docwin.min .dw-body { display: none; }
.docwin.active .dw-title { background: linear-gradient(#c4d8f4, #8fb1e4); }
.dw-title { display: flex; align-items: center; gap: 6px; padding: 2px 4px; background: linear-gradient(#e3e8f0, #cdd5e2); cursor: default; flex: none; }
.dw-title .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dw-title button { width: 20px; height: 16px; border: 1px solid #6a7a94; border-radius: 2px; background: #eef1f6; padding: 0; font-size: 10px; line-height: 12px; }
.dw-title button.x:hover { background: #e0614f; color: #fff; }
.dw-body { position: relative; flex: 1; min-height: 0; background: #a9a9a9; }
.dw-body canvas { position: absolute; left: 0; top: 0; z-index: 0; }
.dw-scroll { position: absolute; inset: 0; overflow: auto; z-index: 1; }

/* dock */
#dock { width: 230px; background: #e8e8e8; border-left: 1px solid #b0b0b0; display: flex; flex-direction: column; flex: none; }
.panel { display: flex; flex-direction: column; border-bottom: 1px solid #b0b0b0; min-height: 0; }
.panel.grow { flex: 1; }
.panel h4 { margin: 0; padding: 2px 6px; font-weight: 600; background: linear-gradient(#bcd0ee, #94b3e3); font-size: 11px; }
.panel .tabs { display: flex; background: #dcdcdc; }
.panel .tabs span { padding: 2px 8px; border-right: 1px solid #aaa; }
.panel .tabs span.on { background: #f8f8f8; font-weight: 600; }
.panel .plist { flex: 1; overflow: auto; background: #fff; min-height: 70px; }
.prow { display: flex; align-items: center; gap: 6px; padding: 2px 6px; border-bottom: 1px solid #eee; }
.prow.sel { background: #cfe0ff; }
.prow .eye { width: 14px; text-align: center; cursor: pointer; }

/* status bar */
#statusbar { display: flex; gap: 18px; background: #e8e8e8; border-top: 1px solid #b0b0b0; padding: 2px 8px; flex: none; height: 20px; }
#status-hint { flex: 1; }
.hidden { display: none !important; }

/* modal + toast */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.18); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.modal { background: #f6f6f2; border: 1px solid #5b6f94; box-shadow: 4px 4px 14px rgba(0,0,0,.4); }
.modal .mt { display: flex; justify-content: space-between; padding: 4px 8px; background: linear-gradient(#c4d8f4, #8fb1e4); font-weight: 600; }
.modal .mb { padding: 10px 12px; }
.modal .mf { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 12px 10px; }
.modal .mf button { min-width: 74px; height: 24px; font: inherit; border: 1px solid #6d7d99; background: #f0f0f0; border-radius: 2px; }
.modal .mf button.primary { border-color: #2a6ad6; box-shadow: inset 0 0 0 1px #6aa0f0; }
.frow { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.frow > label:first-child { width: 90px; }
.toast { position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 6px 14px; border-radius: 4px; z-index: 3000; opacity: .93; }

.text-edit { position: absolute; z-index: 3; margin: 0; padding: 0; border: 0; outline: 1px dashed #4a90e2; outline-offset: 2px; background: transparent; resize: none; overflow: hidden; white-space: pre; transform-origin: center; }
.layer-btns { display: flex; gap: 2px; padding: 2px 4px; background: #e8e8e8; border-bottom: 1px solid #c4c4c4; }
.layer-btns .tb-btn { width: 24px; height: 22px; font-size: 13px; }
.prow.dim { color: #999; }
.prow { cursor: default; }
.prow .ico { width: 14px; text-align: center; color: #365; }

/* M2 fixes: resizable dock */
#dock { position: relative; }
.panel.hist { flex: none; }
.panel.grow { min-height: 120px; overflow: hidden; }
.splitter-h { height: 5px; flex: none; cursor: ns-resize; background: #c4c4c4; border-top: 1px solid #aaa; }
.splitter-h:hover, .splitter-h.active { background: #94b3e3; }
.splitter-v { position: absolute; left: -3px; top: 0; bottom: 0; width: 6px; cursor: ew-resize; z-index: 5; }
.splitter-v:hover, .splitter-v.active { background: rgba(148,179,227,.6); }

.modal-back.floating { background: transparent; pointer-events: none; }
.modal-back.floating .modal { pointer-events: auto; }

/* Image Optimizer */
.opt-wrap { font-size: 12px; }
.opt-top { display: flex; align-items: center; margin-bottom: 6px; }
.opt-tabs { display: flex; background: #dcdcdc; }
.opt-tabs span { padding: 3px 18px; border-right: 1px solid #aaa; cursor: pointer; }
.opt-tabs span.on { background: #fff; font-weight: 600; }
.opt-panes { display: flex; gap: 10px; }
.opt-panes > div { flex: 1; min-width: 0; }
.opt-cap { font-weight: 600; margin-bottom: 2px; }
.opt-pane { width: 100%; height: 310px; overflow: auto; border: 1px solid #777; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0/12px 12px; }
.opt-pane canvas { display: block; }
.opt-info { margin-top: 4px; min-height: 30px; color: #333; }
.opt-bottom { display: flex; gap: 12px; margin-top: 8px; }
.opt-settings { flex: 1; border: 1px solid #bbb; padding: 6px 8px; background: #fafafa; }
.opt-settings .frow label { flex: none; }

.bm-list { max-height: 300px; overflow: auto; border: 1px solid #aaa; background: #fff; }
.bm-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-bottom: 1px solid #eee; cursor: pointer; }
.bm-item:hover { background: #eef3fb; }

/* context menus */
.ctxmenu { position: fixed; background: #fff; border: 1px solid #777; box-shadow: 3px 3px 7px rgba(0,0,0,.3); padding: 2px; min-width: 170px; font-size: 12px; user-select: none; }
.ctxmenu .cm-i { display: flex; align-items: center; gap: 4px; padding: 3px 6px; white-space: nowrap; cursor: default; }
.ctxmenu .cm-i:hover { background: #fbd96b; }
.ctxmenu .cm-i.dis { color: #999; }
.ctxmenu .cm-i.dis:hover { background: none; }
.ctxmenu .cm-chk { width: 12px; text-align: center; }
.ctxmenu .cm-l { flex: 1; }
.ctxmenu .cm-k { color: #666; padding-left: 18px; }
.ctxmenu .cm-sw { width: 14px; height: 14px; border: 1px solid #555; }
.ctxmenu .cm-sep { height: 1px; background: #ccc; margin: 3px 2px; }

.cbtn{width:26px;height:20px;border:1px solid #666;padding:0;cursor:pointer;border-radius:2px;vertical-align:middle}
.cbtn.fg,.cbtn.bg{width:26px;height:26px}
.colorpop{padding:6px;z-index:3100}
.cp-h{font-size:11px;color:#555;margin:4px 0 2px}
.cp-grid{display:grid;gap:2px}
.cp-c{width:16px;height:16px;border:1px solid #8884;cursor:pointer;box-sizing:border-box}
.cp-c:hover{outline:2px solid #1e6bff;z-index:1}
.cp-row{display:flex;gap:6px;margin-top:6px}
.cp-row button{flex:1;font-size:12px;padding:3px 6px}
.shp-btn{display:inline-flex;align-items:center;gap:5px;padding:1px 6px;height:22px;border:1px solid #888;background:#fff;cursor:pointer;font-size:12px}
.shp-btn svg,.cm-i svg{width:18px;height:18px;flex:none}

body.fs #stdbar, body.fs #optbar, body.fs #toolbox, body.fs #dock, body.fs #statusbar { display: none !important; }
#expresspanel { width: 190px; padding: 8px; background: #eef1f6; border-left: 1px solid #889; display: flex; flex-direction: column; gap: 4px; overflow: auto; }
#expresspanel.hidden { display: none; }
#expresspanel button { text-align: left; padding: 5px 8px; }
.ex-note { font-size: 11px; color: #555; margin-bottom: 4px; }

svg.wide{width:84px!important;height:16px!important}

.menu-strip { display: flex; align-items: stretch; gap: 2px; padding: 4px 8px; background: #f4f6fb; border-bottom: 1px solid #9aa4b5; overflow-x: auto; }
.ms-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 60px; max-width: 110px; padding: 4px 6px; border: 1px solid transparent; border-radius: 3px; background: none; font: inherit; font-size: 11px; cursor: pointer; }
.ms-btn:hover:not(.disabled), .ms-btn.open { background: #fbd96b; border-color: #d9b13c; }
.ms-btn.disabled { opacity: .4; cursor: default; }
.ms-ic svg { width: 28px; height: 28px; display: block; }
.ms-l { text-align: center; line-height: 1.15; }
.ms-sep { width: 1px; background: #b9c0cf; margin: 2px 4px; }
.mi-ic svg { width: 16px; height: 16px; margin-right: 6px; vertical-align: middle; }
.mi-ic { display: inline-flex; }


.pp-back { position: fixed; inset: 0; z-index: 4000; display: flex; flex-direction: column; background: #f0f0f0; }
.pp-title { height: 28px; background: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-size: 12px; border-bottom: 1px solid #ccc; }
.pp-title b { cursor: pointer; padding: 4px 10px; font-weight: 400; } .pp-title b:hover { background: #e81123; color: #fff; }
.pp-menubar { display: flex; gap: 14px; padding: 4px 8px; font-size: 12px; background: #fff; } .pp-menubar span { cursor: pointer; }
.pp-main { flex: 1; display: flex; min-height: 0; border-top: 1px solid #aaa; }
.pp-side { width: 215px; background: #f0f0f0; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; border-right: 1px solid #999; overflow: auto; }
.pp-side select { width: 100%; margin-bottom: 6px; } .pp-l { margin: 4px 0 2px; }
.pp-side fieldset { border: 1px solid #ccc; margin: 4px 0; padding: 2px 8px 8px; } .pp-side legend { padding: 0 3px; }
.pp-c { display: flex; align-items: center; gap: 5px; margin: 3px 0; } .pp-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.pp-row input[type=text] { width: 90px; } .pp-mg { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 6px; margin-top: 8px; font-size: 11px; }
.pp-m { display: flex; flex-direction: column; } .pp-m input { width: 100%; box-sizing: border-box; }
.pp-spacer { flex: 1; } .pp-btns { display: flex; gap: 8px; margin-top: 12px; } .pp-btns button { flex: 1; padding: 6px; }
.pp-right { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pp-toolbar { display: flex; gap: 4px; padding: 3px 6px; background: #f0f0f0; border-bottom: 1px solid #ccc; align-items: center; }
.pp-tb { min-width: 26px; height: 24px; padding: 0 5px; font-size: 12px; }
.pp-stage { flex: 1; overflow: auto; background: #f4f4f4; border-top: 1px solid #333; }
.pp-wrap { position: relative; margin: 6px auto; } .pp-page { position: absolute; background: #fff; box-shadow: 0 0 4px #0006; overflow: hidden; }
.pp-img { position: absolute; pointer-events: none; user-select: none; }
.pp-margin { position: absolute; border: 1px solid #e22; pointer-events: none; }
.pp-ml { position: absolute; z-index: 3; } .pp-ml.h { height: 6px; cursor: ns-resize; } .pp-ml.v { width: 6px; cursor: ew-resize; }
.pp-t { position: absolute; font-family: "Courier New", monospace; color: #000; white-space: nowrap; overflow: hidden; pointer-events: none; }
.pp-guide { position: absolute; pointer-events: none; z-index: 2; } .pp-guide.v { top: 0; bottom: 0; border-left: 1px dashed #000; } .pp-guide.h { left: 0; right: 0; border-top: 1px dashed #000; }
.pp-frame { position: absolute; border: 1px solid #000; cursor: move; z-index: 4; }
.pp-h { position: absolute; width: 7px; height: 7px; margin: -4px 0 0 -4px; background: #000; }
.pp-ruler { position: absolute; background: #fff; border: 1px solid #333; overflow: hidden; font-size: 10px; color: #000; }
.pp-ruler.h { top: 0; height: 20px; } .pp-ruler.v { left: 0; width: 20px; }
.pp-ruler i { position: absolute; background: #000; } .pp-ruler.h i { bottom: 0; width: 1px; } .pp-ruler.v i { right: 0; height: 1px; }
.pp-ruler u { position: absolute; text-decoration: none; font-weight: 700; } .pp-ruler.h u { top: 0; } .pp-ruler.v u { writing-mode: vertical-rl; left: 2px; }
.pp-corner { position: absolute; left: 0; top: 0; width: 20px; height: 20px; border: 1px solid #333; background: #fff; font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; z-index: 2; }

.dw-rs { position: absolute; z-index: 20; }
.dw-rs.n { top: 0; left: 8px; right: 8px; height: 6px; cursor: ns-resize; } .dw-rs.s { bottom: 0; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.dw-rs.e { right: 0; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; } .dw-rs.w { left: 0; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.dw-rs.ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; } .dw-rs.sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.dw-rs.nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; } .dw-rs.se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.docwin.max .dw-rs, .docwin.min .dw-rs { display: none; }

.docwin.dw-drop { outline: 3px solid #2a7fff; outline-offset: -3px; }

.help-back { position: fixed; inset: 0; z-index: 4500; background: #f5f6f8; display: flex; flex-direction: column; }
.hl-head { display: flex; align-items: center; gap: 14px; padding: 8px 12px; background: #243b66; color: #fff; }
.hl-head b { white-space: nowrap; } .hl-search { flex: 1; padding: 6px 10px; font-size: 14px; border-radius: 4px; border: 0; }
.hl-main { flex: 1; display: flex; min-height: 0; } .hl-list { width: 300px; overflow: auto; border-right: 1px solid #bbb; background: #fff; }
.hl-group { padding: 8px 12px 3px; font-weight: 700; color: #243b66; font-size: 12px; text-transform: uppercase; }
.hl-item { padding: 6px 14px; cursor: pointer; font-size: 13px; } .hl-item:hover { background: #eef3fb; } .hl-item.on { background: #cfe0fb; }
.hl-item small { color: #666; display: block; font-size: 11px; margin-top: 2px; } .hl-none { padding: 14px; color: #666; }
.hl-view { flex: 1; overflow: auto; padding: 18px 28px 40px; max-width: 980px; } .hl-view h2 { margin: 0 0 10px; color: #243b66; }
.hl-view figure { margin: 8px 0 16px; } .hl-view img { max-width: 100%; max-height: 360px; border: 1px solid #aaa; border-radius: 4px; cursor: zoom-in; background: #fff; }
.hl-view img.big { max-height: none; cursor: zoom-out; } .hl-view figcaption { color: #555; font-size: 12px; margin-top: 4px; font-style: italic; }
.hl-body { font-size: 14px; line-height: 1.5; } .hl-body kbd { background: #eee; border: 1px solid #bbb; border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; font-size: 12px; }
.hl-body a { color: #1a5fd0; } mark { background: #ffe58a; }
.hl-table { border-collapse: collapse; width: 100%; font-size: 13px; } .hl-table td, .hl-table th { border-bottom: 1px solid #ddd; padding: 3px 8px; text-align: left; }
