/* Handwriting Simulator Styles */
.statmat-tool.handwriting-sim {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-width: 1000px;
  margin: 0 auto;
  color: #333;
  background-color: #f4f4f5;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.05);
  border: 1px solid #e4e4e7;
  overflow: hidden;
}

.statmat-tool.handwriting-sim * {
  box-sizing: border-box;
}

.statmat-tool.handwriting-sim .hw-header {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: #fff;
  padding: 30px 24px;
  text-align: center;
}

.statmat-tool.handwriting-sim .hw-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.statmat-tool.handwriting-sim .hw-header h2 {
  margin: 0 0 8px 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.statmat-tool.handwriting-sim .hw-header p {
  margin: 0;
  color: #bfdbfe;
  font-size: 16px;
}

.statmat-tool.handwriting-sim .hw-container {
  padding: 30px;
}

.statmat-tool.handwriting-sim .workspace {
  display: flex;
  gap: 30px;
}

/* Input Panel */
.statmat-tool.handwriting-sim .input-panel {
  width: 340px;
  flex-shrink: 0;
  background-color: #fff;
  padding: 24px;
  border-radius: 8px;
  border: 1px solid #e4e4e7;
  display: flex;
  flex-direction: column;
}

.statmat-tool.handwriting-sim .control-group {
  margin-bottom: 20px;
}

.statmat-tool.handwriting-sim .row-group {
  display: flex;
  gap: 16px;
}

.statmat-tool.handwriting-sim .row-group .control-group {
  flex: 1;
}

.statmat-tool.handwriting-sim label {
  display: block;
  font-weight: 700;
  color: #52525b;
  margin-bottom: 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.statmat-tool.handwriting-sim textarea,
.statmat-tool.handwriting-sim select {
  width: 100%;
  padding: 12px;
  border: 2px solid #d4d4d8;
  border-radius: 6px;
  font-size: 15px;
  background-color: #fff;
  transition: all 0.2s;
  font-family: inherit;
}

.statmat-tool.handwriting-sim textarea {
  resize: vertical;
  line-height: 1.5;
}

.statmat-tool.handwriting-sim textarea:focus,
.statmat-tool.handwriting-sim select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.statmat-tool.handwriting-sim input[type="range"] {
  width: 100%;
  margin-top: 10px;
}

.statmat-tool.handwriting-sim .action-row {
  margin-top: auto;
  padding-top: 16px;
}

.statmat-tool.handwriting-sim .btn {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.statmat-tool.handwriting-sim .btn-primary {
  background-color: #2563eb;
  color: white;
}

.statmat-tool.handwriting-sim .btn-primary:hover {
  background-color: #1d4ed8;
}

/* Canvas Panel */
.statmat-tool.handwriting-sim .canvas-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.statmat-tool.handwriting-sim .canvas-wrapper {
  background-color: #e5e5e5;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: hidden;
  height: 100%;
  padding: 20px;
}

.statmat-tool.handwriting-sim canvas {
  max-width: 100%;
  height: auto;
  display: block;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* Paper shadow */
  background-color: #fff;
}

@media (max-width: 850px) {
  .statmat-tool.handwriting-sim .workspace {
    flex-direction: column;
  }
  .statmat-tool.handwriting-sim .input-panel {
    width: 100%;
  }
}

/* Global override for mobile scrolling on long results */
.statmat-tool [class*="result"], 
.statmat-tool [class*="output"],
.statmat-tool [class*="preview"],
.statmat-tool [class*="display"] {
  overflow-x: auto;
  max-width: 100%;
}

/* Global safeguard: ensure main wrapper never exceeds mobile viewport */
.statmat-tool {
  width: 100% !important;
  box-sizing: border-box;
}
