* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #2b2925; background: #f4f3f0; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

.top { display: flex; align-items: center; gap: 14px; padding: 8px 12px; background: #fff; border-bottom: 1px solid #e2dfd9; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 15px; color: #8a5a22; letter-spacing: .2px; }
.grp { display: flex; align-items: center; gap: 8px; }
.grp.right { margin-left: auto; }
.seg { display: inline-flex; border: 1px solid #d6d2cb; border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 5px 11px; color: #4b4741; }
.seg button + button { border-left: 1px solid #d6d2cb; }
.seg button.on { background: #8a5a22; color: #fff; }
.inl { display: inline-flex; align-items: center; gap: 5px; color: #4b4741; white-space: nowrap; }
.inl input[type=number] { width: 72px; padding: 3px 5px; border: 1px solid #d6d2cb; border-radius: 5px; }
.muted { color: #8f8a82; }
.btn { border: 1px solid #d6d2cb; background: #fff; border-radius: 6px; padding: 5px 10px; color: #2b2925; }
.btn:hover { background: #f6f4f0; }
.btn.sm { padding: 3px 8px; }
.btn.pri { background: #8a5a22; border-color: #8a5a22; color: #fff; }
.btn.pri:hover { background: #75491a; }
.seg.lang button { padding: 3px 8px; font-size: 12px; }
.proj { display: flex; align-items: center; gap: 6px; }
.proj input { width: 190px; padding: 4px 7px; border: 1px solid #d6d2cb; border-radius: 6px; font-weight: 600; }
.dirty { width: 8px; height: 8px; border-radius: 50%; background: #e37400; display: none; }
.dirty.on { display: inline-block; }

/* окно проектов */
.modal-bg { position: fixed; inset: 0; background: rgba(40,30,20,.35); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding-top: 70px; }
.modal { background: #fff; border-radius: 10px; box-shadow: 0 12px 40px rgba(40,30,20,.3); width: min(640px, 94vw); max-height: 80vh; display: flex; flex-direction: column; }
.modal header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #ebe8e3; }
.modal header h3 { margin: 0; font-size: 15px; flex: 1; }
.modal .body { overflow-y: auto; padding: 6px 8px 10px; }
.modal .note { color: #8f8a82; font-size: 12px; padding: 6px 8px; }
.plist { width: 100%; border-collapse: collapse; }
.plist td { padding: 7px 6px; border-bottom: 1px solid #f0eeea; vertical-align: middle; }
.plist tr.cur td { background: #fff8ec; }
.plist .nm { font-weight: 600; }
.plist .dt { color: #8f8a82; font-size: 12px; white-space: nowrap; }
.plist .ac { text-align: right; white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2b2925; color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 70; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: #c5221f; }
.btn:disabled { opacity: .4; cursor: default; background: #fff; }
#undo, #redo { font-size: 15px; line-height: 1; padding: 3px 9px; }
.lnk { border: 0; background: none; color: #1a73e8; padding: 2px 4px; }
.lnk.red { color: #c5221f; }

body[data-mode="sketch"] .only-3d { display: none !important; }
body[data-mode="3d"] .only-sketch { display: none !important; }

.main { flex: 1; display: flex; min-height: 0; }
aside { width: 440px; min-width: 360px; background: #fff; border-right: 1px solid #e2dfd9; overflow-y: auto; }
.work { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tools { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: #fff; border-bottom: 1px solid #e2dfd9; flex-wrap: wrap; }
.tools [data-tool] { border: 1px solid #d6d2cb; background: #fff; border-radius: 6px; padding: 4px 9px; }
.tools [data-tool].on { background: #e8f0fe; border-color: #1a73e8; color: #1a56b8; }
.gcol { display: inline-flex; align-items: center; gap: 3px; color: #4b4741; margin-left: 4px; }
.gcol button { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #d6d2cb; padding: 0; }
.gcol button.on { box-shadow: 0 0 0 2px #2b2925; }
.gcol input { width: 24px; height: 20px; padding: 0; border: 0; background: none; cursor: pointer; }
.gname { width: 140px; padding: 3px 6px; border: 1px solid #d6d2cb; border-radius: 5px; }
.gname:disabled { background: #f6f4f0; }
.canvasbox > .hint { position: absolute; left: 56px; top: 8px; right: 10px; margin: 0; pointer-events: none; color: #6b665e; font-size: 12px; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.canvasbox { flex: 1; position: relative; min-height: 0; }
#sketch, #view3d { position: absolute; inset: 0; width: 100%; height: 100%; }
#sketch { cursor: grab; touch-action: none; }
.cursor { position: absolute; right: 10px; bottom: 8px; background: rgba(255,255,255,.9); border: 1px solid #e2dfd9; border-radius: 5px; padding: 2px 8px; font-variant-numeric: tabular-nums; color: #4b4741; pointer-events: none; }
.cursor:empty { display: none; }

/* боковая панель */
.tabs { display: flex; border-bottom: 1px solid #e2dfd9; position: sticky; top: 0; background: #fff; z-index: 2; }
.tabs button { flex: 1; border: 0; background: none; padding: 9px 4px; color: #6b665e; border-bottom: 2px solid transparent; }
.tabs button.on { color: #8a5a22; border-bottom-color: #8a5a22; font-weight: 600; }
.warn { color: #fff; background: #d93025; border-radius: 8px; padding: 0 5px; font-size: 11px; }
.sec { padding: 10px 12px; border-bottom: 1px solid #efede9; }
.sec h3 { margin: 0 0 8px; font-size: 13px; }
.sec h3 small { font-weight: 400; color: #8f8a82; }
.hdr { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hdr h3 { margin: 0; }
.hdr .f.wide { flex: 1; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.f { display: flex; flex-direction: column; gap: 2px; }
.f.wide { grid-column: 1 / -1; }
.f span { color: #6b665e; font-size: 11.5px; }
.f span:empty { display: none; }
.f input, .f select, .hdr select { padding: 4px 6px; border: 1px solid #d6d2cb; border-radius: 5px; width: 100%; background: #fff; }
.hint { color: #8f8a82; font-size: 12px; margin: 0 0 8px; }
.empty { color: #a9a49c; margin: 4px 0; }
.item { border: 1px solid #ebe8e3; border-radius: 8px; padding: 8px; margin-bottom: 8px; }
.item.bad { border-color: #f1a7a1; background: #fff6f5; }
.item.sel { border-color: #e0b26f; background: #fff8ec; box-shadow: 0 0 0 2px #f3d3a3; }
.item.sel .hdr input { font-weight: 600; }
.warnline { color: #c5221f; margin: 0 0 6px; }

.lib { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.card { display: flex; align-items: center; gap: 7px; text-align: left; border: 1px solid #e2dfd9; background: #fdfcfa; border-radius: 7px; padding: 6px 7px; }
.card:hover { border-color: #c79a5e; background: #fff8ee; }
.card span { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.card small { color: #8f8a82; font-size: 11px; }
.card em { font-style: normal; color: #8a5a22; font-weight: 700; }
.sw { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.sw.liner { background: #e6c48b; border: 1px solid #8a6a35; }
.sw.shell { background: #bfc3c8; border: 1px solid #5f6368; }
.fill { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; color: #4b4741; }
.fill input { width: 70px; padding: 3px 5px; border: 1px solid #d6d2cb; border-radius: 5px; }

.stacks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stacks h4 { margin: 0 0 4px; font-size: 12px; color: #6b665e; font-weight: 600; }
.row { display: flex; align-items: center; gap: 3px; padding: 2px 3px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.row:hover { background: #f6f4f0; }
.row.sel { background: #fff1dc; outline: 1px solid #e0b26f; }
.row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .z { color: #8f8a82; font-size: 11px; font-variant-numeric: tabular-nums; }
.row button { border: 0; background: none; padding: 0 3px; color: #6b665e; font-size: 12px; }
.row button:hover { color: #1a73e8; }
.row .sp { width: 0; }
.row button.rot { background: #eef3fd; color: #1a56b8; border: 1px solid #c6d6f5; border-radius: 10px; padding: 0 6px; font-size: 11px; white-space: nowrap; }
.row button.rot:hover { background: #dfe9fc; }
.allrot { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; font-size: 11px; color: #6b665e; margin-bottom: 4px; }
.allrot button { border: 1px solid #c6d6f5; background: #eef3fd; color: #1a56b8; border-radius: 10px; padding: 0 6px; font-size: 11px; }
.f.chk { flex-direction: row; align-items: center; gap: 6px; padding-top: 14px; }
.f.chk input { width: auto; }
.f.chk span { font-size: 12.5px; color: #2b2925; }
.tag { font-size: 11px; color: #8a5a22; background: #fff1dc; border-radius: 8px; padding: 1px 7px; white-space: nowrap; }
.acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; align-items: center; }
.fill select { padding: 3px 5px; border: 1px solid #d6d2cb; border-radius: 5px; max-width: 170px; }
.tabs button { font-size: 12.5px; }

/* контекстное меню */
.ctx { position: fixed; z-index: 50; min-width: 200px; background: #fff; border: 1px solid #d6d2cb; border-radius: 8px; box-shadow: 0 6px 24px rgba(40,30,20,.18); padding: 4px; font-size: 13px; }
.ctx-title { padding: 5px 10px 4px; color: #8f8a82; font-size: 11.5px; font-weight: 600; }
.ctx-sep { height: 1px; background: #ebe8e3; margin: 4px 2px; }
.ctx-item { position: relative; padding: 6px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.ctx-item:hover { background: #fff1dc; }
.ctx-item.danger { color: #c5221f; }
.ctx-item.has-sub::after { content: '▸'; position: absolute; right: 8px; color: #8f8a82; }
.ctx-item.has-sub { padding-right: 24px; }
.ctx-sub { display: none; position: absolute; left: 100%; top: -5px; }
.ctx.flip .ctx-sub { left: auto; right: 100%; }
.ctx-item.has-sub:hover > .ctx-sub { display: block; }
.dragging, .dragging * { cursor: move !important; }

.spec { width: 100%; border-collapse: collapse; }
.spec td { padding: 3px 0; border-bottom: 1px solid #f0eeea; }
.spec td:last-child { text-align: right; color: #4b4741; }
