/* PixelStudio — Photoshop 风格深色界面 */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #1b1b1b; color: #d7d7d7; overflow: hidden; user-select: none;
  font: 12px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; }
#app { display: grid; grid-template-rows: 34px 40px 1fr 26px; height: 100vh; }

/* ---------------- 菜单栏 ---------------- */
#menubar {
  display: flex; align-items: center; gap: 16px; padding: 0 10px;
  background: #262626; border-bottom: 1px solid #101010; position: relative; z-index: 60;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #efefef; letter-spacing: .2px; }
.logo {
  width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center;
  background: linear-gradient(135deg, #4bb4ff, #0b6fd0); color: #032338;
  font: 700 11px/1 system-ui; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}
#menus { display: flex; gap: 1px; flex: 1; }
.menu { position: relative; padding: 5px 9px; border-radius: 4px; color: #cfcfcf; cursor: default; }
.menu:hover, .menu.open { background: #3a3a3a; color: #fff; }
.menu-panel {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 232px; display: none;
  background: #2f2f2f; border: 1px solid #4a4a4a; border-radius: 6px; padding: 5px;
  box-shadow: 0 14px 34px rgba(0,0,0,.6); z-index: 70;
}
.menu.open .menu-panel { display: block; }
.menu-item { display: flex; justify-content: space-between; gap: 26px; padding: 5px 9px; border-radius: 4px; white-space: nowrap; cursor: default; }
.menu-item:hover { background: #2a7fff; color: #fff; }
.menu-item.disabled { opacity: .35; pointer-events: none; }
.menu-item .key { color: #8f8f8f; font-size: 11px; }
.menu-item:hover .key { color: #dbe9ff; }
.menu-sep { height: 1px; background: #444; margin: 4px 6px; }
.doc-title { color: #8d8d8d; font-size: 11px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 选项栏 ---------------- */
.optionsbar {
  display: flex; align-items: center; gap: 16px; padding: 0 12px;
  background: #2d2d2d; border-bottom: 1px solid #101010; overflow-x: auto; white-space: nowrap;
}
.optionsbar::-webkit-scrollbar { height: 0; }
.opt { display: flex; align-items: center; gap: 6px; color: #bdbdbd; }
.opt > label { color: #a5a5a5; }
.opt .sep { width: 1px; height: 20px; background: #444; }
.opt input[type=range] { width: 88px; }
.opt input[type=number], .opt input[type=text] {
  width: 54px; background: #1f1f1f; border: 1px solid #4a4a4a; color: #e0e0e0;
  border-radius: 4px; padding: 3px 5px; outline: none;
}
.opt select { background: #1f1f1f; border: 1px solid #4a4a4a; color: #e0e0e0; border-radius: 4px; padding: 3px 5px; outline: none; }
.tool-label { color: #eaeaea; font-weight: 600; }
.swatch { width: 22px; height: 22px; border-radius: 4px; border: 1px solid #555; box-shadow: inset 0 0 0 1px rgba(0,0,0,.4); }
.btn-sm {
  padding: 4px 10px; border-radius: 4px; background: #3b3b3b; border: 1px solid #4d4d4d; color: #dcdcdc;
}
.btn-sm:hover { background: #484848; }
.btn-sm.primary { background: #2a7fff; border-color: #2a7fff; color: #fff; }
.btn-sm.primary:hover { background: #3b8cff; }
.btn-sm.danger { background: #4a2626; border-color: #6a3535; }

/* ---------------- 工作区 ---------------- */
#workspace { display: grid; grid-template-columns: 50px 1fr 272px; min-height: 0; }
#toolbar {
  background: #242424; border-right: 1px solid #101010; display: flex; flex-direction: column;
  align-items: center; gap: 2px; padding: 6px 0; overflow-y: auto;
}
#toolbar::-webkit-scrollbar { width: 0; }
.tool {
  width: 38px; height: 34px; display: grid; place-items: center; border-radius: 5px;
  color: #c7c7c7; position: relative;
}
.tool:hover { background: #363636; color: #fff; }
.tool.active { background: #2a7fff; color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool-sep { width: 26px; height: 1px; background: #3a3a3a; margin: 4px 0; }
.tool .badge {
  position: absolute; right: 3px; bottom: 1px; font-size: 8px; color: #8d8d8d; letter-spacing: 0;
}
.tool.active .badge { color: #e6f0ff; }

#viewport { position: relative; overflow: hidden; background: #161616; min-width: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#viewport.panning #view { cursor: grabbing !important; }

/* 欢迎页 */
#welcome { position: absolute; inset: 0; display: grid; place-items: center; background: #191919; }
#welcome.hidden { display: none; }
.w-card { text-align: center; padding: 34px 40px; border-radius: 14px; background: #212121; border: 1px solid #313131; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.w-logo {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, #4bb4ff, #0b6fd0); color: #032338; font: 700 24px/1 system-ui;
}
.w-card h1 { margin: 0 0 6px; font-size: 18px; color: #f0f0f0; letter-spacing: .3px; }
.w-sub { margin: 0 0 20px; color: #8e8e8e; }
.w-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.w-tip { margin: 16px 0 0; color: #6e6e6e; font-size: 11px; }

.btn { padding: 7px 14px; border-radius: 6px; background: #333; border: 1px solid #474747; color: #dcdcdc; }
.btn:hover { background: #3f3f3f; }
.btn.primary { background: #2a7fff; border-color: #2a7fff; color: #fff; }
.btn.primary:hover { background: #3c8bff; }
.btn.ghost { background: transparent; color: #9c9c9c; }
.btn.ghost:hover { background: #2c2c2c; }

/* ---------------- 侧栏 ---------------- */
#sidepanel { background: #242424; border-left: 1px solid #101010; display: flex; flex-direction: column; min-height: 0; }
.panel { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.panel.quick { flex: 0 0 auto; max-height: 40%; overflow: auto; }
.panel > header {
  height: 28px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px;
  background: #2d2d2d; border-bottom: 1px solid #1a1a1a; font-weight: 600; color: #c9c9c9; font-size: 11.5px;
}
.panel-head-right { color: #7d7d7d; font-weight: 400; }
.layer-controls { padding: 7px 8px; display: flex; flex-direction: column; gap: 6px; border-bottom: 1px solid #1a1a1a; }
.layer-controls select {
  width: 100%; background: #1f1f1f; border: 1px solid #454545; color: #dcdcdc; border-radius: 4px; padding: 3px 5px; outline: none;
}
.opacity-box { display: flex; align-items: center; gap: 6px; color: #9e9e9e; padding-right: 2px; }
.opacity-box input[type=range] { flex: 1; min-width: 0; width: 60px; }
.opacity-box input[type=number] {
  width: 38px; background: #1f1f1f; border: 1px solid #454545; color: #e0e0e0; border-radius: 4px; padding: 2px 2px; text-align: right; outline: none;
}
.opacity-box .unit { color: #7e7e7e; }

.layer-list { flex: 1; overflow-y: auto; min-height: 60px; }
.layer-list::-webkit-scrollbar { width: 9px; }
.layer-list::-webkit-scrollbar-thumb { background: #454545; border-radius: 5px; }
.layer-item {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-bottom: 1px solid #1c1c1c;
  position: relative; cursor: default;
}
.layer-item:hover { background: #2b2b2b; }
.layer-item.active { background: #35455c; }
.layer-item.active::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: #4aa3ff; }
.eye { width: 16px; flex: 0 0 16px; color: #b9b9b9; opacity: .95; display: grid; place-items: center; }
.eye.off { opacity: .28; }
.eye svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.l-thumb {
  width: 38px; height: 34px; flex: 0 0 auto; border: 1px solid #4d4d4d; border-radius: 3px; overflow: hidden;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Crect width='6' height='6' fill='%23cfcfcf'/%3E%3Crect x='6' y='6' width='6' height='6' fill='%23cfcfcf'/%3E%3C/svg%3E");
  display: grid; place-items: center;
}
.l-thumb canvas { max-width: 100%; max-height: 100%; display: block; }
.l-thumb.mask { border-style: dashed; background: #000; }
.l-meta { flex: 1; min-width: 0; }
.l-name { color: #dcdcdc; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item.active .l-name { color: #fff; }
.l-sub { color: #7b7b7b; font-size: 10px; }
.l-name-input {
  width: 100%; background: #121212; border: 1px solid #2a7fff; color: #fff; border-radius: 3px; padding: 1px 3px; outline: none; font-size: 11.5px;
}
.layer-actions { display: flex; gap: 2px; padding: 5px 6px; border-top: 1px solid #1a1a1a; background: #262626; }
.layer-actions button {
  flex: 1; height: 24px; border-radius: 4px; color: #b9b9b9; font-size: 13px; display: grid; place-items: center;
}
.layer-actions button:hover { background: #383838; color: #fff; }

.align-bar { display: flex; gap: 2px; padding: 4px 6px; border-top: 1px solid #1a1a1a; background: #262626; }
.align-bar button { flex: 1; height: 22px; border-radius: 4px; color: #b9b9b9; display: grid; place-items: center; }
.align-bar button:hover { background: #383838; color: #fff; }
.align-bar svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.align-bar svg rect { fill: rgba(255,255,255,.18); stroke: currentColor; }
.layer-item.multi { background: #2f3d4f; }
.layer-item.multi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: #6f8bb3; }

.quick-body { padding: 8px; display: flex; flex-direction: column; gap: 7px; }
.quick-row { display: flex; align-items: center; gap: 7px; color: #9e9e9e; }
.quick-row label { width: 62px; flex: 0 0 62px; }
.quick-row input[type=range] { flex: 1; min-width: 0; }
.quick-row .val { width: 30px; text-align: right; color: #cfcfcf; font-variant-numeric: tabular-nums; }

/* ---------------- 状态栏 ---------------- */
#statusbar {
  display: flex; align-items: center; gap: 18px; padding: 0 12px; background: #262626;
  border-top: 1px solid #101010; color: #949494; font-size: 11px;
}
#statusbar .grow { flex: 1; }
.zoomctl { display: flex; align-items: center; gap: 2px; }
.zoomctl button { width: 20px; height: 18px; border-radius: 3px; color: #b5b5b5; }
.zoomctl button:hover { background: #3a3a3a; color: #fff; }
#zoomInput {
  width: 48px; text-align: center; background: #1f1f1f; border: 1px solid #404040; border-radius: 3px;
  color: #dcdcdc; padding: 1px 2px; outline: none; font-size: 11px;
}
#zoomFit { width: auto; padding: 0 6px; }

/* ---------------- 滚动条 ---------------- */
input[type=range] {
  -webkit-appearance: none; appearance: none; height: 16px; background: transparent; outline: none;
}
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: #4a4a4a; border-radius: 2px; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%;
  background: #d0d0d0; border: 1px solid #6d6d6d; box-shadow: 0 1px 2px rgba(0,0,0,.5);
}
input[type=range]:hover::-webkit-slider-thumb { background: #fff; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 200;
  backdrop-filter: blur(1.5px);
}
.modal {
  background: #2b2b2b; border: 1px solid #4a4a4a; border-radius: 9px; min-width: 340px; max-width: 92vw;
  box-shadow: 0 26px 70px rgba(0,0,0,.7); color: #dcdcdc; overflow: hidden;
}
.modal-title {
  padding: 10px 14px; background: #333; border-bottom: 1px solid #1c1c1c; font-weight: 600; font-size: 12.5px; color: #eee;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-close { color: #999; font-size: 16px; line-height: 1; padding: 0 2px; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 14px; display: flex; flex-direction: column; gap: 11px; max-height: 66vh; overflow: auto; }
.modal-foot { padding: 10px 14px; display: flex; justify-content: flex-end; gap: 8px; background: #262626; border-top: 1px solid #1c1c1c; }
.field { display: flex; align-items: center; gap: 10px; }
.field > label { flex: 0 0 92px; color: #a9a9a9; }
.field input[type=text], .field input[type=number], .field select {
  flex: 1; min-width: 0; background: #1d1d1d; border: 1px solid #4a4a4a; color: #e3e3e3; border-radius: 4px;
  padding: 5px 7px; outline: none;
}
.field input[type=text]:focus, .field input[type=number]:focus, .field select:focus { border-color: #2a7fff; }
.field input[type=range] { flex: 1; }
.field input.num { width: 58px; flex: 0 0 58px; padding: 5px 6px; text-align: right; }
.modal .hint { color: #868686; font-size: 11px; line-height: 1.6; }
.kbd-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 11.5px; }
.kbd-list b { color: #cfcfcf; font-weight: 500; }
.kbd-list span { color: #949494; }
.slider-row { display: flex; align-items: center; gap: 8px; }
.slider-row .val { width: 42px; text-align: right; color: #e0e0e0; font-variant-numeric: tabular-nums; }
.group-title { color: #8b8b8b; font-size: 11px; letter-spacing: .5px; text-transform: uppercase; margin-top: 2px; }

/* ---------------- 工具栏颜色色块 ---------------- */
.tool-colors {
  margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 0 6px; border-top: 1px solid #333; width: 100%; flex: 0 0 auto;
}
.tool-colors { position: relative; height: 44px; }
.tool-color {
  width: 22px; height: 22px; padding: 0; border: 1px solid #6f6f6f; border-radius: 4px;
  background: transparent; cursor: pointer; position: absolute; left: 9px;
}
#fgSwatch { top: 8px; z-index: 2; }
#bgSwatch { top: 18px; left: 19px; z-index: 1; }
.tool-color::-webkit-color-swatch-wrapper { padding: 2px; }
.tool-color::-webkit-color-swatch { border: none; border-radius: 2px; }
.swap-btn { position: absolute; right: 1px; top: 2px; font-size: 10px; color: #9a9a9a; line-height: 1; }
.swap-btn:hover { color: #fff; }

/* Tab 隐藏面板 */
body.panels-hidden #sidepanel,
body.panels-hidden #toolbar,
body.panels-hidden #optionsbar { display: none; }
body.panels-hidden #workspace { grid-template-columns: 0 1fr 0; }

/* 形状几何编辑输入框 */
.geom-field { display: inline-flex; align-items: center; gap: 3px; margin-right: 6px; }
.geom-field i { font-style: normal; color: #7f7f7f; font-size: 10px; }
.geom-field input.num { width: 56px; }
