* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
body {
  background: #f5f3eb; color: #2f3e34; font-family: system-ui, sans-serif;
  display: flex; justify-content: center; align-items: center; min-height: 100vh;
}
.app { width: 100%; max-width: 420px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.top { display: flex; justify-content: space-between; font-size: 20px; font-weight: 700; }
canvas {
  width: 100%;  background: #fbfaf6; border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06); touch-action: manipulation; cursor: pointer;
}
.controls { display: flex; gap: 12px; }
button {
  flex: 1; padding: 14px; border: none; border-radius: 14px; background: #fff;
  color: #2f3e34; font-size: 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05); transition: transform 0.1s;
}
button:active { transform: scale(0.97); }
.right-top { display: flex; align-items: center; gap: 10px; }
.icon-btn { flex: none; padding: 6px 10px; font-size: 18px; border-radius: 10px; }
.panel { background: #fff; padding: 14px; border-radius: 16px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,0.06); }
.panel.hidden { display: none; }
.panel label { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel input[type=range] { width: 55%; accent-color: #2f3e34; }
.panel .chk { justify-content: flex-start; }
.row-btns { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.badge { background: #eef1ec; padding: 4px 10px; border-radius: 8px; font-weight: 700; font-size: 13px; }
button.primary { background: #2f3e34; color: #fff; }
.grid-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.grid-inputs label { font-size: 13px; color: #55635a; }
.grid-inputs input[type=number] {
  width: 64px; padding: 6px 8px; border: 1px solid #d5d0c3; border-radius: 8px;
  font-size: 14px; font-weight: 700; text-align: center; color: #2f3e34; background: #fbfaf6;
}
.app { position: relative; }
.splash {
  position: fixed; inset: 0; background: rgba(245, 243, 235, 0.85);
  backdrop-filter: blur(4px); z-index: 100; display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 14px; font-weight: 700; font-size: 18px;
}
.splash.hidden { display: none; }
.spinner {
  width: 38px; height: 38px; border: 4px solid #dcd8cc; border-top-color: #2f3e34;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.row-btns button.active-edit { background: #e65100; color: #fff; }
canvas.edit-mode { outline: 3px dashed #e65100; }
.full-badge { text-align: center; width: 100%; padding: 7px 10px; font-size: 13px; }
.row-btns button { padding: 11px 6px; font-size: 14px; white-space: nowrap; }
canvas { max-height: 62vh; width: auto; max-width: 100%; margin: 0 auto; }
.tool-btn { padding: 9px 6px; font-size: 13px; background: #fff; }
.tool-btn.active-tool { background: #e65100; color: #fff; }
canvas.edit-mode { outline: 3px dashed #e65100; touch-action: none; }
.res-title { font-size: 22px; font-weight: 800; color: #2f3e34; }
.res-sub { font-size: 16px; color: #55635a; background: #fff; padding: 10px 18px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.06); }

#editTools.hidden { display: none; }
.row-btns button { background: #fff; color: #2f3e34; border: 1px solid #dcd8cc; }
.row-btns button:active { background: #eef1ec; }
.lvl-box { display: flex; align-items: center; gap: 6px; }
.lvl-sel, .srv-sel { padding: 6px 10px; border-radius: 10px; border: 1px solid #dcd8cc; background: #fff; font-weight: 700; color: #2f3e34; font-size: 14px; }
.srv-sel { width: 100%; margin-top: 6px; }
.server-box { background: #fbfaf6; padding: 8px; border-radius: 12px; border: 1px solid #e6e2d6; }
.server-box.hidden { display: none; }
.workspace { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.side-col, .board-col { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.hidden { display: none !important; }
.lvl-sel, .srv-sel {
  appearance: none; -webkit-appearance: none; padding: 7px 28px 7px 12px; border-radius: 10px;
  border: 1px solid #d5d0c3; background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://w3.org' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232f3e34' stroke-width='3'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 10px center;
  font-weight: 700; color: #2f3e34; font-size: 13px; cursor: pointer;
}
.server-box label { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; color: #55635a; background: #fff; padding: 4px 10px; border-radius: 10px; border: 1px solid #d5d0c3; }
.server-box input[type=number] { border: none; background: transparent; font-weight: 800; font-size: 14px; color: #2f3e34; text-align: center; outline: none; }
@media (min-width: 860px) {
  body { align-items: center; }
  .app.editor-open { max-width: 980px; }
  .app.editor-open .workspace { flex-direction: row; align-items: flex-start; }
  .app.editor-open .side-col { flex: 0 0 410px; }
  .app.editor-open .board-col { flex: 1; position: sticky; top: 12px; }
  .app.editor-open canvas { max-height: 76vh; }
}
.preset-bar { display: flex; gap: 6px; align-items: center; padding-bottom: 6px; border-bottom: 1px solid #ece8dc; }
.txt-in { width: 105px; padding: 7px 8px; border-radius: 10px; border: 1px solid #d5d0c3; font-size: 13px; background: #fbfaf6; color: #2f3e34; }

.clear-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.clear-bar.hidden { display: none !important; }
.clear-bar .tool-btn { padding: 7px 4px; font-size: 12px; background: #fbfaf6; border: 1px solid #e6e2d6; }

.tools-wrap { display: flex; flex-direction: column; gap: 6px; }
.tools-wrap.hidden { display: none !important; }
.tool-group { display: grid; gap: 6px; }
.tool-group:first-child { grid-template-columns: repeat(3, 1fr); }
.tool-group:last-child { grid-template-columns: repeat(4, 1fr); }
.tool-group .tool-btn { padding: 8px 4px; font-size: 12px; min-width: 0; }
#editTools { display: flex; flex-direction: column; gap: 6px; width: 100%; }
#editTools.hidden { display: none !important; }
#editTools .tool-group:first-child { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#editTools .tool-group:last-child { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#editTools .tool-btn { padding: 9px 4px; font-size: 12px; width: 100%; min-width: 0; }

@media (min-width: 780px) {
  .app.editor-open { max-width: 1020px !important; width: 96vw !important; }
  .app.editor-open .workspace { display: flex !important; flex-direction: row !important; align-items: flex-start !important; gap: 16px !important; }
  .app.editor-open .side-col { flex: 0 0 420px !important; width: 420px !important; }
  .app.editor-open .board-col { flex: 1 1 auto !important; min-width: 0 !important; position: sticky; top: 12px; }
  .app.editor-open canvas { max-height: 78vh !important; }
}

.row-btns button.active-test { background: #1e88e5 !important; color: #fff !important; border-color: #1e88e5 !important; }

.test-bar { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.test-bar.hidden { display: none !important; }

.color-bar { display: flex; align-items: center; justify-content: space-between; gap: 5px; background: #fbfaf6; padding: 6px 8px; border-radius: 10px; border: 1px solid #e6e2d6; }
.color-bar.hidden { display: none !important; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; padding: 0; flex: none; cursor: pointer; transition: transform 0.1s; }
.swatch.active-swatch { border-color: #111; transform: scale(1.18); box-shadow: 0 0 0 2px #fff inset; }
.color-pick { width: 28px; height: 26px; border: none; background: transparent; padding: 0; cursor: pointer; }
.prog-wrap { width: 210px; height: 8px; background: #e6e2d6; border-radius: 6px; overflow: hidden; }
.prog-bar { width: 0%; height: 100%; background: #2f3e34; transition: width 0.08s linear; }
.quick-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.q-btn { padding: 6px 4px; font-size: 12px; border-radius: 10px; border: 1px solid #dcd8cc; background: #fbfaf6; color: #2f3e34; font-weight: 700; }
.q-btn:active { background: #e8e4d8; }
.cfg-section { background: #fbfaf6; border: 1px solid #ece8dc; border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cfg-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 800; color: #55635a; }
.cfg-badge { background: #eef1ec; padding: 2px 7px; border-radius: 8px; font-size: 11px; color: #2f3e34; }
.cfg-badge.warn { background: #ffebee; color: #c62828; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid-3 label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: #55635a; font-weight: 600; }
.grid-3 input { width: 100%; box-sizing: border-box; text-align: center; padding: 5px 2px; border-radius: 8px; border: 1px solid #d5d0c3; font-weight: 700; font-size: 13px; }
.cfg-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #55635a; font-weight: 600; padding: 2px 4px; }
.adv-box { margin-top: 2px; font-size: 12px; color: #2f3e34; }
.adv-box summary { cursor: pointer; font-weight: 700; color: #4a5550; user-select: none; padding: 2px 0; }
.adv-grid { display: grid; grid-template-columns: 1fr 48px 14px 48px; gap: 4px; align-items: center; margin-top: 6px; font-size: 12px; }
.adv-grid input { width: 100%; box-sizing: border-box; text-align: center; padding: 4px 2px; border-radius: 7px; border: 1px solid #d5d0c3; font-weight: 700; }
.info { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 8px 10px; line-height: 1.35; }
.info-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; }
.info-row.sub { font-size: 11px; color: #55635a; border-top: 1px solid #e6e2d6; padding-top: 4px; }
.st-ok { color: #2e7d32; font-weight: 800; }
.st-bad { color: #c62828; font-weight: 800; }

.d-ok { color: #2e7d32; font-weight: 700; }
.d-warn { color: #d84315; font-weight: 700; }
.cfg-foot-col { display: flex; flex-direction: column; gap: 6px; }
.seg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg-group { display: grid; grid-template-columns: 1fr 1fr; background: #ece8dc; padding: 3px; border-radius: 10px; gap: 2px; }
.seg-btn { border: none; background: transparent; padding: 6px 2px; font-size: 11px; font-weight: 700; color: #55635a; border-radius: 8px; cursor: pointer; }
.seg-btn.active { background: #2f3e34; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.start-row { display: flex; justify-content: space-between; align-items: center; background: #fbfaf6; border: 1px solid #ece8dc; border-radius: 10px; padding: 6px 10px; font-size: 12px; font-weight: 700; color: #55635a; }
.start-row input { width: 52px; text-align: center; padding: 4px; border-radius: 7px; border: 1px solid #d5d0c3; font-weight: 700; }
