:root {
  --bg: #f4f1ea; --panel: #fffdf8; --line: #e2dccf; --ink: #26302a; --mute: #7a7f76;
  --accent: #1f7a4d; --accent-soft: #e3f2e9; --sel: #ff8a00;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 7px; padding: 5px 10px; cursor: pointer; }
button:hover { border-color: #c9c0ad; }
button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
input[type=number], input[type=search] { font: inherit; border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; background: #fff; }
input[type=number] { width: 70px; }

header { height: 52px; display: flex; align-items: center; gap: 16px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 700; font-size: 16px; }
.seg { display: flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 7px 0 0 7px; }
.seg button:last-child { border-radius: 0 7px 7px 0; }
.actions { margin-left: auto; display: flex; gap: 6px; }

main { display: grid; grid-template-columns: 250px 1fr 270px; height: calc(100% - 52px); }
aside { background: var(--panel); overflow: auto; }
#library { border-right: 1px solid var(--line); padding: 10px; }
#side { border-left: 1px solid var(--line); }
#search { width: 100%; margin-bottom: 8px; }

.card { display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.card:hover { background: var(--bg); }
.card.on { background: var(--accent-soft); border-color: var(--accent); }
.thumb { width: 48px; height: 48px; flex: none; border-radius: 6px; background: #eef3e8; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 44px; height: 44px; }
.card .nm { font-weight: 600; font-size: 13px; }
.card .sub { color: var(--mute); font-size: 11px; }

#center { display: flex; flex-direction: column; min-width: 0; }
#toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
#toolbar .sep { width: 1px; background: var(--line); margin: 0 4px; }
#toolbar .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.2); }
#stage { flex: 1; overflow: auto; position: relative; padding: 24px; }
#ground { position: relative; margin: 0 auto; }
#svg { display: block; box-shadow: 0 2px 12px rgba(0,0,0,.12); touch-action: none; }
#sprites { position: absolute; inset: 0; pointer-events: none; display: none; }
#hint { padding: 6px 12px; font-size: 12px; color: var(--mute); border-top: 1px solid var(--line); background: var(--panel); min-height: 30px; }

/* 3D */
body.v3d #stage { overflow: hidden; padding: 0; perspective: 1500px; cursor: grab;
  background: linear-gradient(#9fd3ef 0%, #d9eef7 45%, #eae4d2 46%, #d6cfb8 100%); }
body.v3d #ground { position: absolute; left: 50%; top: 60%; margin: 0; transform-style: preserve-3d; transform-origin: 50% 50%; }
body.v3d #svg { box-shadow: none; }
body.v3d #sprites { display: block; transform-style: preserve-3d; }
.sp { position: absolute; width: 0; height: 0; transform-style: preserve-3d; transform-origin: 0 0; }
.spi { position: absolute; }
.spi svg { display: block; width: 100%; height: 100%; overflow: visible; }

.panel { padding: 12px; border-bottom: 1px solid var(--line); }
.panel h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.row label { display: flex; gap: 6px; align-items: center; font-size: 12px; }
.big { font-size: 15px; font-weight: 700; }
.muted { color: var(--mute); font-size: 12px; }
.danger { color: #b3261e; }
#count .li { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
#count .li b { color: var(--accent); }
.zlabel { font: 700 1.2px -apple-system, sans-serif; fill: #666; letter-spacing: .1px; pointer-events: none; }
[hidden] { display: none !important; }
#lookQ { width: 100%; }
#jobSel { font: inherit; flex: 1; min-width: 0; padding: 5px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.links { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0; font-size: 12px; }
.links a { color: var(--accent); text-decoration: none; font-weight: 600; }
.links a:hover { text-decoration: underline; }
.lot { margin-top: 8px; padding: 8px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
